diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..c96b1a34 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,111 @@ +name: Publish Docker Image + +on: + push: + branches: + - main + - dev + workflow_dispatch: + inputs: + image_repository: + description: "Docker image repository to publish to" + required: false + default: "pymcdev/pymc-repeater" + +jobs: + docker: + if: | + github.event_name == 'workflow_dispatch' || + github.repository == 'pyMC-dev/pyMC_Repeater' || + github.repository == 'yellowcooln/pyMC_Repeater' + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Compute package version + id: package_version + run: | + python -m pip install --disable-pip-version-check setuptools_scm + version="$(python -m setuptools_scm)" + echo "version=${version}" >> "$GITHUB_OUTPUT" + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Determine image repository + id: image_repo + shell: bash + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.image_repository }}" ]; then + image_repository="${{ inputs.image_repository }}" + elif [ "${{ github.repository }}" = "yellowcooln/pyMC_Repeater" ]; then + image_repository="yellowcooln/pymc-repeater" + else + image_repository="pymcdev/pymc-repeater" + fi + + echo "Using image repository: ${image_repository}" + echo "image_repository=${image_repository}" >> "$GITHUB_OUTPUT" + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image_repo.outputs.image_repository }} + tags: | + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} + type=sha,format=short + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./dockerfile + platforms: linux/amd64,linux/arm64 + push: true + build-args: | + PACKAGE_VERSION=${{ steps.package_version.outputs.version }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Home Assistant add-on repository + if: github.repository == 'pyMC-dev/pyMC_Repeater' + env: + DISPATCH_TOKEN: ${{ secrets.HA_ADDON_REPO_DISPATCH_TOKEN }} + CHANNEL: ${{ github.ref_name }} + REVISION: ${{ github.sha }} + run: | + if [ -z "${DISPATCH_TOKEN}" ]; then + echo "HA_ADDON_REPO_DISPATCH_TOKEN is not set" >&2 + exit 1 + fi + + curl -fsSL \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${DISPATCH_TOKEN}" \ + https://api.github.com/repos/pyMC-dev/pyMC-HA-Add-on/dispatches \ + -d "{\"event_type\":\"sync-upstream-channel\",\"client_payload\":{\"channel\":\"${CHANNEL}\",\"revision\":\"${REVISION}\"}}" diff --git a/README.md b/README.md index a3c2852b..fc174cdc 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Frequency Labs meshadv GPIO Pins: CS=21, Reset=18, Busy=20, IRQ=16, TXEN=13, RXEN=12, use_dio3_tcxo=True HT-RA62 module - + Hardware: Heltec HT-RA62 LoRa module Platform: Raspberry Pi (or compatible single-board computer) Frequency: 868MHz (EU) or 915MHz (US) @@ -92,7 +92,7 @@ HT-RA62 module SPI Bus: SPI0 GPIO Pins: CS=21, Reset=18, Busy=20, IRQ=16, use_dio3_tcxo=True, use_dio2_rf=True -Zindello Industries UltraPeater +Zindello Industries UltraPeater Hardware: EBYTE E22/P 1W Module Platform: Luckfox Pico Ultra/W (NOT A PI DEVICE) @@ -113,16 +113,6 @@ Waveshare LoRaWAN/GNSS HAT (SPI Version Only) GPIO Pins: CS=21, Reset=18, Busy=20, IRQ=16 Note: Only the SPI version is supported. The UART version will not work. -RAK Wireless RAK6421 with RAK1330x - - Hardware: RAK1330x LoRa module - Platform: Raspberry Pi (or compatible single-board computer) - Frequency: 868MHz (EU) or 915MHz (US) - TX Power: 22dBm on RAK13300, 30dBm on RAK13302 - SPI Bus: SPI0 - GPIO Pins(IO Slot 1): Reset=16, Busy=24, IRQ=22, use_dio3_tcxo=True, use_dio2_rf=True - GPIO Pins(IO Slot 2): Reset=24, Busy=19, IRQ=18, use_dio3_tcxo=True, use_dio2_rf=True - ... ## Screenshots @@ -141,7 +131,7 @@ Before You Begin Make sure SPI is switched on using raspi-config: -```bash +```bash sudo raspi-config ``` @@ -155,12 +145,12 @@ sudo reboot ``` After reboot, you can confirm SPI is active: -```bash +```bash ls /dev/spi* ``` You should see something like: -```bash +```bash /dev/spidev0.0 /dev/spidev0.1 ``` diff --git a/buildroot-manage.sh b/buildroot-manage.sh index 6a0aa683..26b4cea8 100644 --- a/buildroot-manage.sh +++ b/buildroot-manage.sh @@ -21,8 +21,11 @@ SILENT_MODE="${PYMC_SILENT:-${SILENT:-}}" R2_BASE_URL="https://wheel.pymc.dev/pymc_build_deps" PIWHEELS_INDEX_URL="https://www.piwheels.org/simple" R2_ENABLED=1 +YQ_VERSION="${YQ_VERSION:-v4.44.3}" PYMC_CORE_REPO="${PYMC_CORE_REPO:-https://github.com/rightup/pyMC_core.git}" PYMC_CORE_REF="${PYMC_CORE_REF:-}" +PYMC_CORE_LOCAL_DIR="${PYMC_CORE_LOCAL_DIR:-}" +PYMC_SKIP_BUILDROOT_DEP_INSTALL="${PYMC_SKIP_BUILDROOT_DEP_INSTALL:-0}" RADIO_SETTINGS_JSON="$SCRIPT_DIR/radio-settings.json" RADIO_PRESETS_JSON="$SCRIPT_DIR/radio-presets.json" BUILDROOT_RADIO_SETTINGS_JSON="$SCRIPT_DIR/radio-settings-buildroot.json" @@ -61,6 +64,41 @@ fail() { exit 1 } +run_with_spinner() { + local message="$1" + shift + + if [ ! -t 1 ] || [ "${SILENT_MODE:-}" = "1" ] || [ "${SILENT_MODE:-}" = "true" ]; then + "$@" + return $? + fi + + local log_file pid spinner_index status + local spinner='|/-\' + + log_file=$(mktemp) + "$@" >"$log_file" 2>&1 & + pid=$! + spinner_index=0 + + while kill -0 "$pid" 2>/dev/null; do + printf '\r - %s... %s' "$message" "${spinner:$spinner_index:1}" + spinner_index=$(( (spinner_index + 1) % 4 )) + sleep 0.15 + done + + wait "$pid" + status=$? + printf '\r\033[K' + + if [ "$status" -ne 0 ]; then + cat "$log_file" >&2 + fi + + rm -f "$log_file" + return "$status" +} + detect_local_git_ref() { local branch tag @@ -113,6 +151,16 @@ need_cmd() { command -v "$1" >/dev/null 2>&1 || fail "Missing required command: $1" } +normalize_interactive_tty() { + [ -t 0 ] || return 0 + [ -r /dev/tty ] || return 0 + + # Buildroot shells sometimes end up with a bad erase character, which + # makes backspace print ^H during interactive prompts. + stty sane < /dev/tty >/dev/null 2>&1 || true + stty erase '^H' < /dev/tty >/dev/null 2>&1 || true +} + is_buildroot() { [ -f /etc/pymc-image-build-id ] && return 0 [ -f /etc/os-release ] && grep -q '^ID=buildroot$' /etc/os-release 2>/dev/null && return 0 @@ -129,6 +177,8 @@ prompt_value() { return 0 fi + normalize_interactive_tty + if [ -n "$default_value" ]; then printf '%s [%s]: ' "$prompt" "$default_value" >&2 else @@ -142,6 +192,8 @@ prompt_value() { prompt_secret() { local prompt="$1" + normalize_interactive_tty + python3 - "$prompt" <<'PY' import os import sys @@ -315,6 +367,59 @@ install_system_packages() { libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev } +get_yq_cmd() { + local candidate + + for candidate in /usr/local/bin/yq /usr/bin/yq; do + if [ -x "$candidate" ] && "$candidate" --version 2>&1 | grep -q "mikefarah/yq"; then + printf '%s\n' "$candidate" + return 0 + fi + done + + return 1 +} + +ensure_yq() { + local yq_cmd yq_binary + + yq_cmd=$(get_yq_cmd 2>/dev/null || true) + if [ -n "$yq_cmd" ]; then + printf '%s\n' "$yq_cmd" + return 0 + fi + + need_cmd wget + + case "$(uname -m)" in + aarch64|arm64) yq_binary="yq_linux_arm64" ;; + x86_64|amd64) yq_binary="yq_linux_amd64" ;; + armv7l|armv7) yq_binary="yq_linux_arm" ;; + *) + warn "Unable to install yq automatically on unsupported architecture: $(uname -m)" + return 1 + ;; + esac + + printf '\n==> Installing yq\n' >&2 + printf ' - Fetching mikefarah/yq %s\n' "$YQ_VERSION" >&2 + wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${yq_binary}" || { + warn "Failed to download yq; config updates will keep working but comments will not be preserved." + rm -f /usr/local/bin/yq + return 1 + } + chmod +x /usr/local/bin/yq + + yq_cmd=$(get_yq_cmd 2>/dev/null || true) + if [ -n "$yq_cmd" ]; then + printf '%s\n' "$yq_cmd" + return 0 + fi + + warn "Installed yq is not the expected mikefarah/yq binary." + return 1 +} + ensure_venv() { local recreate=0 @@ -332,9 +437,10 @@ ensure_venv() { stage "Creating virtual environment" info "Creating $VENV_DIR" info "This can take a minute on Buildroot flash storage." - python3 -m venv "$VENV_DIR" - info "Bootstrapping pip, setuptools, and wheel" - "$VENV_PIP" install --upgrade --no-cache-dir pip setuptools wheel + run_with_spinner "Creating virtual environment" python3 -m venv "$VENV_DIR" + info "Bootstrapping pip, setuptools, wheel, and setuptools_scm" + run_with_spinner "Bootstrapping Python build tools" \ + "$VENV_PIP" install --upgrade --no-cache-dir pip setuptools wheel setuptools_scm info "Virtual environment is ready" else info "Using existing virtual environment at $VENV_DIR" @@ -345,6 +451,7 @@ ensure_venv_build_backend() { if "$VENV_PYTHON" - <<'PY' import setuptools import setuptools.build_meta +import setuptools_scm import wheel PY then @@ -353,14 +460,16 @@ PY fi stage "Rebuilding virtual environment" - warn "Existing venv is contaminated or incomplete; recreating it cleanly." + warn "Existing venv is missing required Python build packages or has incompatible leftovers; recreating it cleanly. This can take a minute on Buildroot flash storage." rm -rf "$VENV_DIR" - python3 -m venv "$VENV_DIR" - "$VENV_PIP" install --upgrade --no-cache-dir pip setuptools wheel + run_with_spinner "Recreating virtual environment" python3 -m venv "$VENV_DIR" + run_with_spinner "Reinstalling Python build tools" \ + "$VENV_PIP" install --upgrade --no-cache-dir pip setuptools wheel setuptools_scm if "$VENV_PYTHON" - <<'PY' import setuptools import setuptools.build_meta +import setuptools_scm import wheel PY then @@ -426,6 +535,15 @@ install_buildroot_dependencies() { local wheel_base local deps + if [ "${PYMC_SKIP_BUILDROOT_DEP_INSTALL}" = "1" ]; then + stage "Checking embedded Python dependency baseline" + if check_buildroot_dependencies_installed >/dev/null 2>&1; then + info "Image-provided Python dependency wheels already satisfy Buildroot requirements" + return 0 + fi + fail "Embedded/offline install requested, but the required Python dependency wheels are not already present in the image." + fi + wheel_base=$(get_r2_wheel_base 2>/dev/null || true) deps=$(set_wheel_dependencies) stage "Installing Python dependency wheels" @@ -448,6 +566,34 @@ install_buildroot_dependencies() { fi } +check_buildroot_dependencies_installed() { + local deps + + deps=$(set_wheel_dependencies) + "$VENV_PYTHON" - $deps <<'PY' +import sys +from importlib import metadata +from packaging.requirements import Requirement +from packaging.version import Version + +failed = [] +for raw in sys.argv[1:]: + req = Requirement(raw) + try: + installed = metadata.version(req.name) + except metadata.PackageNotFoundError: + failed.append(f"{req.name} (missing)") + continue + if req.specifier and Version(installed) not in req.specifier: + failed.append(f"{req.name} {installed} (! {req.specifier})") + +if failed: + for item in failed: + print(item) + raise SystemExit(1) +PY +} + link_system_site_packages() { local venv_site_dir pth_file system_paths @@ -476,9 +622,32 @@ PY info "Linked image-provided Python runtime into the venv" } +remove_shadowing_buildroot_native_packages() { + local removed=0 + + if "$VENV_PIP" show python-periphery >/dev/null 2>&1; then + stage "Restoring Buildroot GPIO runtime" + info "Removing venv-installed python-periphery so the image-provided package is used" + "$VENV_PIP" uninstall -y python-periphery >/dev/null 2>&1 || true + removed=1 + fi + + if [ "$removed" -eq 0 ]; then + info "No shadowing Buildroot native GPIO wheels found in the venv" + fi +} + install_core_into_venv() { local core_repo core_ref core_spec + if [ -n "$PYMC_CORE_LOCAL_DIR" ]; then + [ -d "$PYMC_CORE_LOCAL_DIR" ] || fail "Missing local pyMC_core checkout: $PYMC_CORE_LOCAL_DIR" + stage "Installing pyMC_core" + info "Local dir: ${PYMC_CORE_LOCAL_DIR}" + "$VENV_PIP" install --upgrade --no-cache-dir --no-deps --no-build-isolation "$PYMC_CORE_LOCAL_DIR" + return 0 + fi + core_repo="$PYMC_CORE_REPO" case "$core_repo" in *.git) ;; @@ -492,6 +661,37 @@ install_core_into_venv() { "$VENV_PIP" install --upgrade --no-cache-dir --no-deps --no-build-isolation "$core_spec" } +get_installed_core_commit() { + "$VENV_PYTHON" - <<'PY' +import glob +import json +import os + +matches = glob.glob("/opt/pymc_repeater/venv/lib/python*/site-packages/pymc_core-*.dist-info/direct_url.json") +for path in matches: + try: + with open(path, "r", encoding="utf-8") as fh: + data = json.load(fh) + print(data.get("vcs_info", {}).get("commit_id", "")) + raise SystemExit(0) + except Exception: + pass +print("") +PY +} + +resolve_core_commit() { + local core_repo core_ref + + core_repo="$PYMC_CORE_REPO" + case "$core_repo" in + *.git) ;; + *) core_repo="${core_repo}.git" ;; + esac + core_ref=$(resolve_core_ref) + git ls-remote "$core_repo" "$core_ref" 2>/dev/null | awk 'NR==1 {print $1}' +} + install_repeater_package() { stage "Installing pyMC Repeater into venv" info "Installing checked-out repo without re-resolving dependencies" @@ -839,13 +1039,22 @@ write_repeater_config() { local tx_power="$8" local board_key="$9" - python3 - "$CONFIG_DIR/config.yaml" "$RADIO_SETTINGS_JSON" "$BUILDROOT_RADIO_SETTINGS_JSON" "$node_name" "$admin_password" "$jwt_secret" "$freq_mhz" "$sf" "$bw_khz" "$coding_rate" "$tx_power" "$board_key" <<'PY' + local config_path temp_config example_config yq_cmd stripped_user temp_merged + + config_path="$CONFIG_DIR/config.yaml" + example_config="$CONFIG_DIR/config.yaml.example" + temp_config=$(mktemp) + stripped_user=$(mktemp) + temp_merged=$(mktemp) + + python3 - "$config_path" "$temp_config" "$RADIO_SETTINGS_JSON" "$BUILDROOT_RADIO_SETTINGS_JSON" "$node_name" "$admin_password" "$jwt_secret" "$freq_mhz" "$sf" "$bw_khz" "$coding_rate" "$tx_power" "$board_key" <<'PY' import json import sys import yaml ( config_path, + output_path, radio_settings_path, buildroot_settings_path, node_name, @@ -857,7 +1066,7 @@ import yaml coding_rate, tx_power, board_key, -) = sys.argv[1:13] +) = sys.argv[1:14] with open(config_path, "r", encoding="utf-8") as fh: data = yaml.safe_load(fh) or {} @@ -904,9 +1113,25 @@ if data["radio_type"] == "sx1262_ch341": if "pid" in hardware: ch341["pid"] = hardware["pid"] -with open(config_path, "w", encoding="utf-8") as fh: +with open(output_path, "w", encoding="utf-8") as fh: yaml.safe_dump(data, fh, sort_keys=False) PY + + yq_cmd=$(ensure_yq 2>/dev/null || true) + if [ -n "$yq_cmd" ] && [ -f "$example_config" ]; then + "$yq_cmd" eval '... comments=""' "$temp_config" > "$stripped_user" 2>/dev/null || cp "$temp_config" "$stripped_user" + if "$yq_cmd" eval-all '. as $item ireduce ({}; . * $item)' "$example_config" "$stripped_user" > "$temp_merged" 2>/dev/null \ + && "$yq_cmd" eval '.' "$temp_merged" >/dev/null 2>&1; then + mv "$temp_merged" "$config_path" + else + warn "yq merge failed; writing config without preserving comments." + cp "$temp_config" "$config_path" + fi + else + cp "$temp_config" "$config_path" + fi + + rm -f "$temp_config" "$stripped_user" "$temp_merged" } seed_repeater_config() { @@ -997,6 +1222,14 @@ is_running() { [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null } +start_or_restart_service() { + if is_running; then + "$INIT_SCRIPT" restart + else + "$INIT_SCRIPT" start + fi +} + get_version() { if [ -x "$VENV_PYTHON" ]; then "$VENV_PYTHON" -c "from importlib.metadata import version; print(version('pymc_repeater'))" 2>/dev/null || echo "not installed" @@ -1005,6 +1238,27 @@ get_version() { fi } +prepare_git_version() { + local git_version + + if [ -d "$SCRIPT_DIR/.git" ]; then + stage "Inspecting checked-out repo version" + info "Fetching tags for setuptools_scm version detection" + git -C "$SCRIPT_DIR" fetch --tags 2>/dev/null || true + git_version=$(python3 -m setuptools_scm 2>/dev/null || echo "1.0.5") + export SETUPTOOLS_SCM_PRETEND_VERSION="$git_version" + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER="$git_version" + info "Using version: $git_version" + else + git_version="1.0.5" + export SETUPTOOLS_SCM_PRETEND_VERSION="$git_version" + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER="$git_version" + info "Using fallback version: $git_version" + fi + + printf '%s\n' "$git_version" +} + doctor() { stage "Checking Buildroot image baseline" @@ -1094,6 +1348,7 @@ install_repeater() { ensure_root stage "Preparing Buildroot installation" install_system_packages + ensure_yq >/dev/null 2>&1 || true ensure_service_user stage "Preparing directories and config" @@ -1115,22 +1370,13 @@ install_repeater() { stage "Cleaning legacy install state" cleanup_legacy_install_state - if [ -d "$SCRIPT_DIR/.git" ]; then - stage "Inspecting checked-out repo version" - info "Fetching tags for setuptools_scm version detection" - git -C "$SCRIPT_DIR" fetch --tags 2>/dev/null || true - git_version=$(python3 -m setuptools_scm 2>/dev/null || echo "1.0.5") - export SETUPTOOLS_SCM_PRETEND_VERSION="$git_version" - info "Using version: $git_version" - else - export SETUPTOOLS_SCM_PRETEND_VERSION="1.0.5" - info "Using fallback version: 1.0.5" - fi + git_version=$(prepare_git_version) preinstall_r2_wheels install_buildroot_dependencies install_core_into_venv install_repeater_package + remove_shadowing_buildroot_native_packages link_system_site_packages stage "Validating installed runtime" @@ -1146,7 +1392,7 @@ install_repeater() { create_init_script stage "Starting service" - "$INIT_SCRIPT" restart + start_or_restart_service ip_address=$(get_primary_ip) if is_running; then @@ -1157,19 +1403,46 @@ install_repeater() { } upgrade_repeater() { + local current_version new_version ip_address git_version + local target_core_commit installed_core_commit + ensure_root is_installed || fail "Service is not installed." + current_version=$(get_version) ensure_venv ensure_venv_build_backend stage "Cleaning legacy install state" cleanup_legacy_install_state + git_version=$(prepare_git_version) preinstall_r2_wheels stage "Upgrading pyMC Repeater" - install_buildroot_dependencies - install_core_into_venv - install_repeater_package + if [ "${PYMC_FORCE_DEPS:-0}" = "1" ]; then + info "Forcing dependency reinstall" + install_buildroot_dependencies + elif check_buildroot_dependencies_installed >/dev/null 2>&1; then + info "Python dependency wheels already satisfy Buildroot requirements; skipping reinstall" + else + info "One or more Python dependency wheels are missing or out of range; reinstalling" + install_buildroot_dependencies + fi + + target_core_commit=$(resolve_core_commit) + installed_core_commit=$(get_installed_core_commit) + if [ -n "$target_core_commit" ] && [ "$installed_core_commit" = "$target_core_commit" ] && [ "${PYMC_FORCE_CORE:-0}" != "1" ]; then + info "pyMC_core is already at ${target_core_commit}; skipping reinstall" + else + install_core_into_venv + fi + + if [ "$current_version" = "$git_version" ] && [ "${PYMC_FORCE_REPEATER:-0}" != "1" ]; then + info "pyMC Repeater is already at ${git_version}; skipping reinstall" + else + ensure_yq >/dev/null 2>&1 || true + install_repeater_package + fi + remove_shadowing_buildroot_native_packages link_system_site_packages stage "Validating installed runtime" if check_venv_runtime; then @@ -1177,7 +1450,20 @@ upgrade_repeater() { else fail "Installed packages are present but one or more native modules are unusable on this image." fi + + stage "Restarting service" "$INIT_SCRIPT" restart + + new_version=$(get_version) + ip_address=$(get_primary_ip) + + if is_running; then + printf '\nUpgrade complete.\n' + printf 'Version: %s -> %s\n' "$current_version" "$new_version" + printf 'Service is running on: http://%s:8000\n' "${ip_address}" + else + fail "Upgrade completed but the service failed to start. Check: sh $0 logs" + fi } uninstall_repeater() { diff --git a/config.yaml.example b/config.yaml.example index 1060e7b2..e7888ec2 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -1,7 +1,3 @@ -# Default Repeater Configuration -# radio_type: sx1262 | kiss (use kiss for serial KISS TNC modem) -radio_type: sx1262 - repeater: # Node name for logging and identification node_name: "mesh-repeater-01" @@ -126,6 +122,157 @@ repeater: # Controls how long users stay logged in before needing to re-authenticate jwt_expiry_minutes: 60 +# Local GPS receiver. When enabled, the daemon reads NMEA sentences from the +# configured source and exposes parsed data at /api/gps. +gps: + enabled: false + + # --------------------------------------------------------------------------- + # Source + # --------------------------------------------------------------------------- + + # Source type: + # serial = read directly from an attached GPS module + # file = read NMEA lines from source_path (useful for gpsd/sidecar bridges) + source: serial + + # Serial source settings (used when source: serial) + device: "/dev/serial0" + baud_rate: 9600 + read_timeout_seconds: 1.0 + reconnect_interval_seconds: 5.0 + + # File source settings (used when source: file) + # The file may contain raw NMEA lines or JSON with a "sentences" list / + # "last_sentence" field. + source_path: "/var/lib/pymc_repeater/gps_nmea.txt" + poll_interval_seconds: 2.0 + + # --------------------------------------------------------------------------- + # Location behaviour + # Three independent controls — read the comments carefully, they do + # different things: + # + # api_fallback_to_config_location — what the API *displays* before a fix + # advertise_gps_location — what the mesh *advertises* in adverts + # persist_gps_fix_to_config — whether the fix is *written* to config + # --------------------------------------------------------------------------- + + # API display: while GPS has no valid fix, show repeater.latitude/longitude + # from config in the /api/gps effective position instead of null/0,0. + # The default 0,0 repeater location is treated as unset (no fallback shown). + # Has no effect on mesh adverts or config persistence. + api_fallback_to_config_location: true + + # Mesh adverts: use GPS coordinates in repeater-originated location fields + # (flood adverts, etc.). When false, repeater.latitude/longitude from config + # are always used for outgoing mesh packets. + advertise_gps_location: false + + # Config persistence: write a valid GPS fix back into repeater.latitude/ + # repeater.longitude so adverts location details follow the + # receiver across restarts. Updates are throttled to avoid rewriting config + # on every NMEA sentence. location_precision_digits is applied before saving. + persist_gps_fix_to_config: false + persist_gps_fix_interval_seconds: 600.0 + + # Optional privacy/obfuscation: round coordinates to this many decimal places + # before they are used for advertising or persisted to config (0–8). + # Leave null for full precision. Affects both advertise_gps_location and + # persist_gps_fix_to_config. + location_precision_digits: null + + # --------------------------------------------------------------------------- + # Diagnostics + # --------------------------------------------------------------------------- + + stale_after_seconds: 10.0 + retain_sentences: 25 + validate_checksum: true + require_checksum: false + + # --------------------------------------------------------------------------- + # Time sync + # --------------------------------------------------------------------------- + + # Automatically set the Linux system clock from GPS UTC time once the + # receiver has a valid non-stale fix. The systemd service grants + # CAP_SYS_TIME for this. + time_sync_enabled: true + time_sync_interval_seconds: 3600.0 + time_sync_min_offset_seconds: 1.0 + time_sync_min_valid_year: 2020 + +# Sensor plug-ins (polled in background and exposed under /api/stats -> sensors) +sensors: + # Master switch for sensor subsystem + enabled: true + + # Poll interval for all configured sensors + poll_interval_seconds: 10.0 + + # If true, missing Python packages for a sensor may be installed at runtime + # using "python -m pip install ...". + auto_install_packages: true + + # Sensor definitions. Add one item per sensor instance. + definitions: + # Built-in sensor: host CPU/memory/disk/network stats + - type: hardware_stats + name: system-health + enabled: true + + # Example INA219 sensor (commented out by default) + # - type: ina219 + # name: power-monitor + # enabled: true + # auto_install_packages: true + # settings: + # i2c_address: 64 # 0x40 in decimal + # bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + # max_expected_amps: 2.0 + # shunt_ohms: 0.1 + + # Example ENS210 temperature/humidity sensor (commented out by default) + # - type: ens210 + # name: ambient + # enabled: true + # auto_install_packages: true + # settings: + # i2c_address: 0x43 # Default ENS210 address + # bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + # read_timeout_seconds: 1.0 # Max seconds to wait for valid data (polls every 50 ms) + + # Example SHTC3 Ambient + # - type: shtc3 + # name: ambient + # enabled: true + # auto_install_packages: false + # settings: + # i2c_address: 0x70 + # bus_number: 1 + + # Example Waveshare UPS D Hat + # - type: waveshare_ups_d + # name: battery + # enabled: true + # auto_install_packages: false + # settings: + # i2c_address: 0x43 + # bus_number: 1 + + # Example Waveshare UPS E Hat + # - type: waveshare_ups_e + # name: "battery" + # enabled: true + # auto_install_packages: false + # settings: + # i2c_address: 0x2D # Waveshare UPS HAT (E) fixed address + # bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + # low_cell_mv: 3150 # Per-cell warning threshold in mV + + + # Mesh Network Configuration mesh: # Unscoped flood policy - controls whether the repeater allows or denies unscoped flooding @@ -193,7 +340,11 @@ identities: # Supported: # - sx1262 (Linux spidev + system GPIO) # - sx1262_ch341 (CH341 USB-to-SPI + CH341 GPIO 0-7) -radio_type: sx1262 +# - kiss (KISS-modem over a serial port; alias: kiss-modem) +# - pymc_tcp (pymc_usb firmware modem over Wi-Fi/TCP) +# - pymc_usb (pymc_usb firmware modem over USB-CDC) +# - null/none (disable radio hardware; daemon starts without RF I/O) +radio_type: null # CH341 USB-to-SPI adapter settings (only used when radio_type: sx1262_ch341) # NOTE: VID/PID are integers. Hex is also accepted in YAML, e.g. 0x1A86. @@ -220,9 +371,6 @@ radio: # Preamble length in symbols preamble_length: 17 - # Sync word (LoRa network ID) - sync_word: 13380 - # Use implicit header mode implicit_header: false @@ -231,6 +379,24 @@ radio: # port: "/dev/ttyUSB0" # baud_rate: 9600 +# pymc_usb firmware modem over Wi-Fi/TCP (when radio_type: pymc_tcp). +# Requires pyMC_core with the TCPLoRaRadio driver +# pymc_tcp: +# host: "pymc-3e2834.local" # modem hostname / mDNS name / LAN IP +# port: 5055 # firmware default +# token: "" # empty = no auth; set to match firmware NVS token +# connect_timeout: 5.0 # seconds; deferred-connect retries with backoff on failure +# lbt_enabled: true # Listen-Before-Talk via firmware CAD +# lbt_max_attempts: 5 + +# pymc_usb firmware modem over USB-CDC (when radio_type: pymc_usb). +# Requires pyMC_core with the USBLoRaRadio driver +# pymc_usb: +# port: "/dev/ttyACM0" # USB-CDC device; udev rule may symlink to /dev/lora-modem +# baudrate: 921600 # must match firmware monitor_speed +# lbt_enabled: true +# lbt_max_attempts: 5 + # SX1262 Hardware Configuration # NOTE: # - When radio_type: sx1262, these pins are BCM GPIO numbers. @@ -251,6 +417,10 @@ sx1262: txen_pin: -1 rxen_pin: -1 + # Optional radio power-enable pin(s) driven HIGH during init + en_pin: -1 + # en_pins: [26, 23] + # LED pins for TX/RX indication (-1 to disable) txled_pin: -1 rxled_pin: -1 @@ -294,7 +464,7 @@ storage: # - 1 hour resolution for 1 year -mqtt: +mqtt_brokers: iata_code: "Test" # e.g., "SFO", "LHR", "Test" status_interval: 300 # How often a status message is sent (in seconds) owner: "" @@ -308,11 +478,17 @@ mqtt: # port: # Typically 443 for websocket endpoints or 1883 for tcp # transport: "tcp" or "websockets" # audience: "" # For JWT auth'd endpoints, this is usually the host unless always stated by endpoint owners - # use_jwt_auth: true|false # Does this endpoint require JWT auth + # use_jwt_auth: true|false # Does this endpoint require JWT auth. Mutually Exclusive with Username & Password fields # username: "" # Username for basic auth. If empty or missing, uses anonymous access # password: "" # Password for basic auth. Required if username is set - # format: letsmesh|mqtt + # format: meshcoretomqtt|letsmesh|waev|mqtt + # meshcoretomqtt - canonical open-source MC2MQTT topic structure + # letsmesh, waev - MC2MQTT family flavors (same topic structure, network-specific identity) + # mqtt - legacy pyMC_Repeater local-broker convention (custom topic, singular 'packet') # retain_status: true|false # Sets MQTT "retain" on status messages so they remain on the broker when disconnected. Also enforces a QOS of 1 (guaranteed delivery) + # tls: + # enabled: true|false # Enable TLS. If the endpoint's certificate is self-signed, the Root CA should be added to the OS's certificate store. + # insecure: true|false # Validate TLS certificates # Block specific packet types from being published to the MQTT endpoint # If not specified or empty list, all types are published @@ -331,21 +507,34 @@ mqtt: # - TRACE # Don't publish trace packets # - RAW_CUSTOM # Don't publish custom raw packets - # Example of using the US and EU LetsMesh endpoints + # Bundled network presets (recommended). Endpoints ship with the package, + # so URL/audience updates arrive via `pip install -U`. Available presets: + # waev, letsmesh. + # + # brokers: + # - preset: waev + # - preset: letsmesh + # + # Override a preset broker by listing it again with the same name AFTER + # the preset entry. Later entries win on name collision. + # # brokers: - # - name: US West (LetsMesh v1) - # host: mqtt-us-v1.letsmesh.net - # port: 443 - # audience: mqtt-us-v1.letsmesh.net - # use_jwt_auth: true + # - preset: waev + # - name: waev-b + # enabled: false + # + # Mix presets with fully custom brokers in the same list: + # + # brokers: + # - preset: waev + # - name: my-lan-mqtt # enabled: true - - # - name: Europe (LetsMesh v1) - # host: mqtt-eu-v1.letsmesh.net - # port: 443 - # audience: mqtt-eu-v1.letsmesh.net - # use_jwt_auth: true - # enabled: true + # host: mqtt.lan + # port: 1883 + # transport: tcp + # format: mqtt + # username: repeater + # password: secret # pyMC_Glass control-plane integration (optional) glass: diff --git a/debian/changelog b/debian/changelog index 35085272..8fbe9bb7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,4 +3,4 @@ pymc-repeater (1.0.5~dev0) unstable; urgency=medium * Development build from git commit 7112da9 * Version: 1.0.5.post0 - -- Lloyd Tue, 30 Dec 2025 12:55:47 +0000 + -- Rightup Tue, 30 Dec 2025 12:55:47 +0000 diff --git a/debian/control b/debian/control index 83a70d0c..acaafd98 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: pymc-repeater Section: net Priority: optional -Maintainer: Lloyd +Maintainer: Rightup Build-Depends: debhelper-compat (= 13), dh-python, python3-all, diff --git a/debian/pymc-repeater.service b/debian/pymc-repeater.service index b2a9893f..5ed72528 100644 --- a/debian/pymc-repeater.service +++ b/debian/pymc-repeater.service @@ -11,5 +11,9 @@ ExecStart=/usr/bin/pymc-repeater Restart=always RestartSec=10 +# Allow GPS time sync to update CLOCK_REALTIME without running as root +CapabilityBoundingSet=CAP_SYS_TIME +AmbientCapabilities=CAP_SYS_TIME + [Install] WantedBy=multi-user.target diff --git a/docker-compose.yml b/docker-compose.yml index 10489938..647db595 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,10 @@ services: pymc-repeater: - build: . + build: + context: . + args: + PUID: ${PUID:-1000} + PGID: ${PGID:-1000} container_name: pymc-repeater restart: unless-stopped ports: @@ -18,5 +22,5 @@ services: group_add: - plugdev volumes: - - ./config.yaml:/etc/pymc_repeater/config.yaml + - ./config:/etc/pymc_repeater - ./data:/var/lib/pymc_repeater diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..16788ac5 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,87 @@ +#!/bin/sh +set -eu + +INSTALL_DIR="${INSTALL_DIR:-/opt/pymc_repeater}" +CONFIG_DIR="${CONFIG_DIR:-/etc/pymc_repeater}" +CONFIG_PATH="${PYMC_REPEATER_CONFIG:-${CONFIG_DIR}/config.yaml}" +EXAMPLE_PATH="${CONFIG_DIR}/config.yaml.example" +BUNDLED_EXAMPLE_PATH="${INSTALL_DIR}/config.yaml.example" +RUNTIME_USER="${USER:-repeater}" +RUNTIME_UID="${PUID:-unknown}" +RUNTIME_GID="${PGID:-unknown}" +YQ_CMD="${YQ_CMD:-/usr/local/bin/yq}" + +mkdir -p "${CONFIG_DIR}" + +copy_or_die() { + src="$1" + dest="$2" + if ! cp "${src}" "${dest}"; then + echo "Failed to initialize ${dest} from ${src}." >&2 + echo "If you are bind-mounting ./config.yaml, ensure the host path is writable by ${RUNTIME_USER} (${RUNTIME_UID}:${RUNTIME_GID})." >&2 + exit 1 + fi +} + +merge_config_from_example() { + config_path="$1" + + if [ ! -f "${config_path}" ] || [ ! -f "${EXAMPLE_PATH}" ]; then + return 0 + fi + + if [ ! -x "${YQ_CMD}" ] || ! "${YQ_CMD}" --version 2>&1 | grep -q "mikefarah/yq"; then + echo "Skipping config merge: mikefarah yq is not available at ${YQ_CMD}." >&2 + return 0 + fi + + tmpdir="$(mktemp -d)" + stripped_user="${tmpdir}/config.stripped.yaml" + merged_config="${tmpdir}/config.merged.yaml" + + cleanup_merge() { + rm -rf "${tmpdir}" + } + trap cleanup_merge EXIT HUP INT TERM + + # Keep only the example's comments to avoid comment duplication across upgrades. + "${YQ_CMD}" eval '... comments=""' "${config_path}" > "${stripped_user}" 2>/dev/null || cp "${config_path}" "${stripped_user}" + + if ! "${YQ_CMD}" eval-all '. as $item ireduce ({}; . * $item)' "${EXAMPLE_PATH}" "${stripped_user}" > "${merged_config}" 2>/dev/null; then + echo "Failed to merge ${config_path} with ${EXAMPLE_PATH}; keeping the existing config." >&2 + cleanup_merge + trap - EXIT HUP INT TERM + return 0 + fi + + if ! "${YQ_CMD}" eval '.' "${merged_config}" >/dev/null 2>&1; then + echo "Merged config for ${config_path} is invalid; keeping the existing config." >&2 + cleanup_merge + trap - EXIT HUP INT TERM + return 0 + fi + + if ! cmp -s "${config_path}" "${merged_config}"; then + copy_or_die "${merged_config}" "${config_path}" + fi + + cleanup_merge + trap - EXIT HUP INT TERM +} + +if [ ! -f "${EXAMPLE_PATH}" ] && [ -f "${BUNDLED_EXAMPLE_PATH}" ]; then + copy_or_die "${BUNDLED_EXAMPLE_PATH}" "${EXAMPLE_PATH}" +fi + +if [ -d "${CONFIG_PATH}" ]; then + if [ ! -s "${CONFIG_PATH}/config.yaml" ] && [ -f "${EXAMPLE_PATH}" ]; then + copy_or_die "${EXAMPLE_PATH}" "${CONFIG_PATH}/config.yaml" + fi + CONFIG_PATH="${CONFIG_PATH}/config.yaml" +elif [ ! -s "${CONFIG_PATH}" ] && [ -f "${EXAMPLE_PATH}" ]; then + copy_or_die "${EXAMPLE_PATH}" "${CONFIG_PATH}" +fi + +merge_config_from_example "${CONFIG_PATH}" + +exec python3 -m repeater.main --config "${CONFIG_PATH}" diff --git a/dockerfile b/dockerfile index 2dfee916..f0b56d6a 100644 --- a/dockerfile +++ b/dockerfile @@ -1,13 +1,25 @@ FROM python:3.12-slim-bookworm +ARG PACKAGE_VERSION=1.0.5 +ARG USER=repeater +ARG GROUP=repeater +ARG PUID=15888 +ARG PGID=15888 +ARG TARGETARCH +ARG YQ_VERSION=v4.40.5 + ENV INSTALL_DIR=/opt/pymc_repeater \ CONFIG_DIR=/etc/pymc_repeater \ DATA_DIR=/var/lib/pymc_repeater \ + HOME_DIR=/home/${USER} \ + PATH=/home/${USER}/.local/bin:${PATH} \ PYTHONUNBUFFERED=1 \ - SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=1.0.5 + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=${PACKAGE_VERSION} \ + PUID=${PUID} \ + PGID=${PGID} # Install runtime dependencies only -RUN apt-get update && apt-get install -y \ +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ libffi-dev \ python3-rrdtool \ jq \ @@ -19,20 +31,47 @@ RUN apt-get update && apt-get install -y \ python3-dev \ && rm -rf /var/lib/apt/lists/* +RUN arch="${TARGETARCH:-}" \ + && if [ -z "${arch}" ]; then arch="$(uname -m)"; fi \ + && case "${arch}" in \ + amd64|x86_64) YQ_BINARY="yq_linux_amd64" ;; \ + arm64|aarch64) YQ_BINARY="yq_linux_arm64" ;; \ + arm|armv7|armv7l) YQ_BINARY="yq_linux_arm" ;; \ + *) echo "Unsupported architecture for yq: ${arch}" >&2; exit 1 ;; \ + esac \ + && wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}" \ + && chmod +x /usr/local/bin/yq + +# Create the group and user in order to run without root privileges +RUN groupadd --gid "$PGID" "$GROUP" \ + && useradd --uid "$PUID" --gid "$PGID" --home-dir "$HOME_DIR" --create-home --shell /usr/bin/bash "$USER" + # Create runtime directories -RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} +RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} \ + && chown -R "$USER":"$GROUP" ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} ${HOME_DIR} WORKDIR ${INSTALL_DIR} # Copy source COPY repeater ./repeater COPY pyproject.toml . +COPY config.yaml.example . COPY radio-presets.json . COPY radio-settings.json . +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh + +# Switch to the unprivileged runtime user +USER ${USER} # Install package RUN pip install --no-cache-dir . +USER root + +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +USER ${USER} + EXPOSE 8000 -ENTRYPOINT ["python3", "-m", "repeater.main", "--config", "/etc/pymc_repeater/config.yaml"] +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/docs/adding_sensors.md b/docs/adding_sensors.md new file mode 100644 index 00000000..28e672e1 --- /dev/null +++ b/docs/adding_sensors.md @@ -0,0 +1,171 @@ +# Adding a New Sensor Plug-in + +Sensors in pyMC_Repeater are self-contained modules that live in `repeater/sensors/`. The subsystem is plug-in based: adding a new sensor requires only one new file. The manager discovers and loads it automatically at runtime by importing the module named after the sensor type. + +--- + +## How the sensor subsystem works + +| Component | File | Role | +|-----------|------|------| +| `SensorBase` | `repeater/sensors/base.py` | Abstract base class all sensors inherit from | +| `SensorRegistry` | `repeater/sensors/registry.py` | Maps type strings → sensor classes via `@SensorRegistry.register` | +| `SensorManager` | `repeater/sensors/manager.py` | Reads config, imports sensor modules, polls sensors in background | + +When `SensorManager` loads a sensor of type `"foo"`, it calls `importlib.import_module("repeater.sensors.foo")`. That import runs the `@SensorRegistry.register("foo")` decorator on your class, making it available. No changes to `__init__.py` or the manager are needed. + +--- + +## Step-by-step guide + +### 1. Create `repeater/sensors/.py` + +Name the file after the sensor type string (lowercase, underscores for hyphens). The type string is what operators write in `config.yaml`. + +Minimal template: + +```python +""" + sensor plug-in. + +Requires: pip install + +Config example: + - type: + name: "my-sensor" + enabled: true + auto_install_packages: false + settings: + some_option: value +""" + +from __future__ import annotations + +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + + +@SensorRegistry.register("") +class MySensor(SensorBase): + sensor_type = "" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + # Read settings with safe defaults + self.some_option = self.settings.get("some_option", "default") + + self.available = False + if not self.ensure_python_modules( + [ + ("import_name", "pip-package-name"), + ] + ): + return # logs a warning; sensor will report unavailable + + try: + import import_name # type: ignore[import-not-found] + # Initialise hardware here + self.device = import_name.Device(...) + self.available = True + self.log.info("MySensor initialized") + except Exception as exc: + self.log.warning("MySensor init failed: %s", exc) + self.available = False + + def _read(self) -> Dict[str, Any]: + if not self.available: + raise RuntimeError("device not available") + try: + return { + "field_one": ..., + "field_two": ..., + } + except Exception as exc: + raise RuntimeError(f"read failed: {exc}") from exc +``` + +Key rules: + +- **`sensor_type`** class attribute must match the string passed to `@SensorRegistry.register`. +- **`self.settings`** is the `settings:` block from the sensor's config entry (a plain dict). +- **`ensure_python_modules`** handles missing dependencies gracefully. Pass a multi-line list of `(import_name, pip_package)` tuples. Returns `False` and logs a warning if any are missing and `auto_install_packages` is `false`; installs them via pip if `true`. Sensor-specific packages belong here — do **not** add them to `pyproject.toml`. +- **`_read`** must return a flat `dict[str, Any]`. The base class wraps it in a standard envelope (`name`, `type`, `ok`, `timestamp`, `data`, optional `error`). +- **`_read`** must raise `RuntimeError` on failure — the base class catches it, marks `ok=False`, and logs it without crashing the polling loop. +- All hardware initialisation belongs in `__init__`, not in `_read`. Keep `_read` fast. +- Lazy-import third-party packages inside `__init__` (after `ensure_python_modules` returns `True`) so the module can be imported on hosts that don't have the package installed. + +### 2. Add a commented example to `config.yaml.example` + +Find the `sensors.definitions` block and add your sensor alongside the existing examples: + +```yaml + # Example MySensor (commented out by default) + # - type: + # name: my-sensor + # enabled: true + # auto_install_packages: true + # settings: + # some_option: value +``` + +Use hex notation for I2C addresses (e.g. `0x43`) as this matches how addresses are listed in datasheets and tools like `i2cdetect`. + +### 3. Test locally + +Add a test to `tests/test_sensors.py` that: + +1. Registers a lightweight mock of your sensor (or stubs the hardware import). +2. Verifies that `SensorManager` loads it and `read_all()` returns the expected structure. +3. Verifies that a hardware failure in `_read` produces an `ok=False` result rather than raising. + +Example pattern from the existing test suite: + +```python +class _MockMySensor(SensorBase): + sensor_type = "" + + def _read(self): + return {"field_one": 42.0, "field_two": 55.0} + +SensorRegistry.register("", _MockMySensor) + +def test_my_sensor_loads_and_reads(): + config = { + "sensors": { + "enabled": True, + "definitions": [ + {"name": "test-sensor", "type": "", "settings": {}}, + ], + } + } + manager = SensorManager(config) + readings = manager.read_all() + assert readings[0]["ok"] is True + assert readings[0]["data"]["field_one"] == 42.0 +``` + +--- + +## Checklist + +- [ ] `repeater/sensors/.py` created +- [ ] `sensor_type` class attribute matches the `@SensorRegistry.register` key +- [ ] All settings read from `self.settings` with sensible defaults +- [ ] `ensure_python_modules` called before any third-party import +- [ ] Hardware initialised in `__init__`, not `_read` +- [ ] `_read` raises `RuntimeError` on failure (never returns `None` or partial data silently) +- [ ] Commented example added to `config.yaml.example` +- [ ] Unit test added to `tests/test_sensors.py` + +--- + +## Existing sensors + +| Type | File | Hardware | +|------|------|----------| +| `hardware_stats` | `repeater/sensors/hardware_stats.py` | Host CPU / memory / disk / network (via `psutil`) | +| `ina219` | `repeater/sensors/ina219.py` | INA219 I²C current/voltage/power monitor | +| `ens210` | `repeater/sensors/ens210.py` | ENS210 I²C relative humidity and temperature sensor | diff --git a/docs/pr_hash_once.md b/docs/pr_hash_once.md deleted file mode 100644 index d8e7cef6..00000000 --- a/docs/pr_hash_once.md +++ /dev/null @@ -1,346 +0,0 @@ -# PR: Compute Packet Hash Once Per Forwarded Packet - -**Branch:** `perf/hash-once` -**Base:** `rightup/fix-perfom-speed` -**Files changed:** `repeater/engine.py` (1 file, ~51 lines net) - ---- - -## Problem - -`packet.calculate_packet_hash()` runs a SHA-256 digest over the full serialised -packet bytes, converts the result to a hex string, and uppercases it. Before -this change the hot forwarding path triggered this computation **three times per -packet**: - -| Call site | Where | When | -|-----------|-------|------| -| `__call__` line 162 | `pkt_hash_full = packet.calculate_packet_hash()...` | Every received packet | -| `flood_forward` / `direct_forward` via `is_duplicate` | `pkt_hash = packet.calculate_packet_hash()...` | Every packet that reaches the forward check | -| `flood_forward` / `direct_forward` via `mark_seen` | `pkt_hash = packet_hash or packet.calculate_packet_hash()...` | Every packet that passes the duplicate check | - -And on the drop path, a fourth computation: - -| Call site | Where | When | -|-----------|-------|------| -| `_get_drop_reason` → `is_duplicate` | `pkt_hash = packet.calculate_packet_hash()...` | Every dropped packet | - -The hash computed in `__call__` was already available as `pkt_hash_full` but was -never passed into `process_packet`, `flood_forward`, `direct_forward`, -`is_duplicate`, `mark_seen`, or `_get_drop_reason`. Each of those methods -recomputed it independently. - ---- - -## Root Cause - -The `packet_hash` optional parameter existed on `mark_seen` but not on -`is_duplicate`, `flood_forward`, `direct_forward`, `process_packet`, or -`_get_drop_reason`. The call chain therefore had no way to propagate the -already-computed hash. - ---- - -## Solution - -Thread the pre-computed `pkt_hash_full` from `__call__` down through the call -chain as an optional `packet_hash: Optional[str] = None` parameter. Each method -uses the provided hash if present, or falls back to computing it — preserving -backward compatibility for any caller that doesn't have a pre-computed hash. - -``` -Before: - __call__ → calculate_packet_hash() #1 - → process_packet - → flood_forward - → is_duplicate → calculate_packet_hash() #2 - → mark_seen → calculate_packet_hash() #3 - (drop path) - → _get_drop_reason - → is_duplicate → calculate_packet_hash() #4 - -After: - __call__ → calculate_packet_hash() #1 (only computation) - → process_packet(packet_hash=pkt_hash_full) - → flood_forward(packet_hash=pkt_hash_full) - → is_duplicate(packet_hash=pkt_hash_full) uses provided hash ✓ - → mark_seen(packet_hash=pkt_hash_full) uses provided hash ✓ - (drop path) - → _get_drop_reason(packet_hash=pkt_hash_full) - → is_duplicate(packet_hash=pkt_hash_full) uses provided hash ✓ -``` - ---- - -## Methods Changed - -### `is_duplicate(packet, packet_hash=None)` - -```python -# Before -def is_duplicate(self, packet: Packet) -> bool: - pkt_hash = packet.calculate_packet_hash().hex().upper() # always recomputed - if pkt_hash in self.seen_packets: - return True - return False - -# After -def is_duplicate(self, packet: Packet, packet_hash: Optional[str] = None) -> bool: - """... - INVARIANT: purely synchronous — no await points. The caller relies on - is_duplicate + mark_seen being atomic within the asyncio event loop. - Do NOT add any await here without revisiting that invariant. - """ - pkt_hash = packet_hash or packet.calculate_packet_hash().hex().upper() - return pkt_hash in self.seen_packets -``` - -### `_get_drop_reason(packet, packet_hash=None)` - -```python -# Before -def _get_drop_reason(self, packet: Packet) -> str: - if self.is_duplicate(packet): ... # recomputes hash - -# After -def _get_drop_reason(self, packet: Packet, packet_hash: Optional[str] = None) -> str: - if self.is_duplicate(packet, packet_hash=packet_hash): ... # propagates hash -``` - -### `flood_forward(packet, packet_hash=None)` - -```python -# Before -def flood_forward(self, packet: Packet) -> Optional[Packet]: - ... - if self.is_duplicate(packet): ... # recomputes - self.mark_seen(packet) # recomputes - -# After -def flood_forward(self, packet: Packet, packet_hash: Optional[str] = None) -> Optional[Packet]: - """... - INVARIANT: purely synchronous — no await points. - """ - ... - if self.is_duplicate(packet, packet_hash=packet_hash): ... # propagates - self.mark_seen(packet, packet_hash=packet_hash) # propagates -``` - -### `direct_forward(packet, packet_hash=None)` — same pattern as `flood_forward` - -### `process_packet(packet, snr=0.0, packet_hash=None)` - -```python -# Before -def process_packet(self, packet, snr=0.0): - fwd_pkt = self.flood_forward(packet) # no hash - -# After -def process_packet(self, packet, snr=0.0, packet_hash=None): - """... - packet_hash: pre-computed SHA-256 hex from __call__; eliminates 2 SHA-256 - calls per forwarded packet by propagating the hash through the call chain. - """ - fwd_pkt = self.flood_forward(packet, packet_hash=packet_hash) -``` - -### `__call__` — two call-site changes - -```python -# Before -result = (None if ... else self.process_packet(processed_packet, snr)) -... -drop_reason = processed_packet.drop_reason or self._get_drop_reason(processed_packet) - -# After -result = (None if ... else self.process_packet(processed_packet, snr, packet_hash=pkt_hash_full)) -... -drop_reason = processed_packet.drop_reason or self._get_drop_reason( - processed_packet, packet_hash=pkt_hash_full -) -``` - ---- - -## What Was Not Changed - -`record_packet_only` (line 446) and `record_duplicate` (line 486) each compute -the hash independently. These are separate recording paths (called from the -inject path and from the raw-packet subscriber, respectively) that have no -`pkt_hash_full` from `__call__` in scope. Changing them would require a larger -refactor with no benefit to the forwarding hot path, so they are left unchanged. - -The fallback `packet_hash or packet.calculate_packet_hash()...` pattern in -`is_duplicate`, `mark_seen`, and `_build_packet_record` ensures external callers -(e.g. `TraceHelper.is_duplicate(packet)` from trace processing) continue to work -without any change. - ---- - -## Invariant Comments Added - -`flood_forward`, `direct_forward`, and `is_duplicate` now carry explicit docstring -invariants: - -> **INVARIANT:** purely synchronous — no await points. The is_duplicate + -> mark_seen pair is atomic within the asyncio event loop. Do NOT add any await -> here without revisiting that invariant in `__call__` / `process_packet`. - -These invariants were implicit before. Making them explicit means a future -contributor adding an `await` inside these methods will see the warning and -understand the consequence: the duplicate-check and mark-seen can no longer be -guaranteed atomic, allowing the same packet to be forwarded twice under concurrent -task dispatch. - ---- - -## Quantification - -On a Raspberry Pi running CPython 3.13, `hashlib.sha256` on a 50–200 byte -LoRa payload takes approximately 1–3 µs. The `.hex().upper()` string conversion -adds another ~0.5 µs. Savings per forwarded packet: ~3–8 µs. - -At 3 packets/second sustained forwarding rate this saves ~10–25 µs/second, which -is negligible in absolute terms. The more significant benefit is correctness and -clarity: - -- One canonical hash value per packet in the forwarding path. -- No possibility of the hash changing between the `is_duplicate` check and the - `mark_seen` call if `calculate_packet_hash` had any mutable state (it doesn't, - but the pattern is now provably correct). -- Explicit invariant documentation closes a latent trap for future contributors. - ---- - -## Test Plan - -### Unit tests (no hardware) - -**T1 — Hash computed exactly once per forwarded packet** - -```python -async def test_hash_computed_once_for_flood(): - call_count = 0 - original = Packet.calculate_packet_hash - - def counting_hash(self): - nonlocal call_count - call_count += 1 - return original(self) - - with patch.object(Packet, "calculate_packet_hash", counting_hash): - await engine(flood_packet, metadata={}) - - assert call_count == 1, f"Expected 1 hash computation, got {call_count}" -``` - -**T2 — Hash computed exactly once per dropped (duplicate) packet** - -```python -async def test_hash_computed_once_for_duplicate(): - # Mark packet seen first - engine.seen_packets[packet.calculate_packet_hash().hex().upper()] = time.time() - - call_count = 0 - original = Packet.calculate_packet_hash - def counting_hash(self): - nonlocal call_count; call_count += 1; return original(self) - - with patch.object(Packet, "calculate_packet_hash", counting_hash): - await engine(packet, metadata={}) - - # One computation in __call__ for pkt_hash_full; should not trigger again - # in process_packet → flood_forward → is_duplicate (drop path via _get_drop_reason) - assert call_count == 1 -``` - -**T3 — External callers of `is_duplicate` without hash still work** - -```python -def test_is_duplicate_without_hash(): - """TraceHelper and other external callers pass no hash — must still work.""" - pkt = make_test_packet() - engine.seen_packets[pkt.calculate_packet_hash().hex().upper()] = time.time() - - assert engine.is_duplicate(pkt) is True # no packet_hash arg - assert engine.is_duplicate(pkt, packet_hash="WRONGHASH") is False -``` - -**T4 — mark_seen / is_duplicate agree on the same hash** - -```python -def test_mark_then_is_duplicate_consistent(): - pkt = make_test_packet() - pkt_hash = pkt.calculate_packet_hash().hex().upper() - - assert engine.is_duplicate(pkt, packet_hash=pkt_hash) is False - engine.mark_seen(pkt, packet_hash=pkt_hash) - assert engine.is_duplicate(pkt, packet_hash=pkt_hash) is True - # Same result without the pre-computed hash (fallback path) - assert engine.is_duplicate(pkt) is True -``` - -**T5 — flood_forward / direct_forward signatures are backward compatible** - -```python -def test_flood_forward_no_hash_arg(): - """Callers that don't pass packet_hash must still work (fallback compute).""" - pkt = make_flood_packet() - result = engine.flood_forward(pkt) # no packet_hash — must not raise - assert result is not None or pkt.drop_reason is not None -``` - -### Integration / field tests (with hardware) - -**T6 — Forwarding throughput unchanged** - -1. Forward 100 packets at maximum duty-cycle budget. -2. Verify all eligible packets are forwarded (same count as before change). -3. Verify no `Duplicate` drops that were not present before. - -**T7 — Duplicate detection unchanged** - -1. Send the same packet twice within 1 second. -2. Verify the first is forwarded and the second is logged as `"Duplicate"`. - -**T8 — CPU profile shows reduced `calculate_packet_hash` calls** - -1. Enable Python profiling (`cProfile`) on the repeater for 60 seconds. -2. Compare `calculate_packet_hash` call count before and after. - -**Expected:** call count approximately halved for workloads where most packets -are forwarded (≤ 1 call per forwarded packet vs ≥ 3 before). - ---- - -## Proof of Correctness - -### Why the fallback `packet_hash or packet.calculate_packet_hash()` is safe - -`packet_hash` is either the correct hash (passed from `__call__`) or `None`. -If it is `None`, the fallback computes the hash fresh — identical to the old -behaviour. There is no case where a wrong hash is used: the only source of a -non-None `packet_hash` is `pkt_hash_full = packet.calculate_packet_hash()...` -in `__call__`, computed over the same `processed_packet` (a deep copy of the -received packet, unchanged between hash computation and the call to -`process_packet`). - -### Why passing the hash through a deep-copied packet is correct - -`processed_packet = copy.deepcopy(packet)` (line 178) happens before -`pkt_hash_full` is passed to `process_packet`. The deep copy does not change -the packet's wire representation — `calculate_packet_hash()` calls -`packet.write_to()` which serialises the packet's fields. The copy has the -same fields, so `deepcopy(packet).calculate_packet_hash() == packet.calculate_packet_hash()`. -Passing the hash computed from the original to the copy is correct. - -### Why the invariant is critical - -asyncio only yields execution at `await` points. `flood_forward` and -`direct_forward` have no `await`, so they run atomically from the event loop's -perspective. The `is_duplicate` check and the `mark_seen` call inside them -cannot be interleaved with another coroutine. If a future change added an -`await` between them, two concurrent `_route_packet` tasks could both pass the -duplicate check for the same packet before either marked it seen — sending the -same packet twice. The invariant comment documents this so the risk is visible -at the point where it could be broken. diff --git a/docs/pr_in_flight_cap.md b/docs/pr_in_flight_cap.md deleted file mode 100644 index df6cbc91..00000000 --- a/docs/pr_in_flight_cap.md +++ /dev/null @@ -1,349 +0,0 @@ -# PR: Bounded In-Flight Task Counter + Simplified Route Task Management - -**Branch:** `perf/in-flight-cap` -**Base:** `rightup/fix-perfom-speed` -**Files changed:** `repeater/packet_router.py` (1 file, ~33 lines net) - ---- - -## Background - -The queue loop dispatches each incoming packet as an `asyncio.create_task` so TX -delay timers run concurrently — this is correct behaviour. The previous -implementation tracked these tasks in a `set[asyncio.Task]` (`_route_tasks`) for -two reasons: - -1. **Error surfacing** — the done-callback read `task.result()` to log exceptions. -2. **Shutdown cancellation** — `stop()` cancelled and awaited all tasks in the set. - -This PR replaces the set with a simple integer counter and tightens the companion -deduplication prune threshold. - ---- - -## Problems - -### Problem 1 — Unbounded task accumulation - -LoRa airtime naturally limits steady-state throughput to a handful of in-flight -tasks at any time. But burst arrivals can spike the count temporarily: - -- **Multi-hop flood amplification**: a single source packet is forwarded by every - repeater in range, each of which re-broadcasts it. A node at a mesh junction - may receive 5–10 copies within 100 ms, each scheduling a separate `delayed_send` - task. -- **Collision retries**: hardware-level collisions produce duplicate RF bursts that - all arrive within the same RX window. -- **Bridge nodes**: high-traffic gateway nodes connect multiple mesh segments and - forward both directions simultaneously. - -Under these conditions `_route_tasks` can accumulate dozens of sleeping tasks. -Each holds a reference to the packet, the forwarded packet copy, a closure over -`delayed_send`, and associated asyncio task overhead. There is no cap; the set -grows until the duty-cycle gate finally fires for each task. - -### Problem 2 — `_route_tasks` set adds O(1) cost on every packet but O(n) cost on shutdown - -Every packet adds one entry to `_route_tasks` and removes it in the done-callback. -This is O(1) per operation, but the `stop()` shutdown path iterates the entire set -to cancel and gather all tasks — O(n) where n is however many tasks happen to be -in-flight at shutdown time. On a busy node this could delay clean shutdown. - -### Problem 3 — `_COMPANION_DEDUPE_PRUNE_THRESHOLD = 1000` is too high - -The companion delivery deduplication dict prunes itself only when it exceeds 1000 -entries. With a 60-second TTL, each PATH/protocol-response packet adds one entry. -On a busy mesh with 50+ nodes sending adverts and PATH packets, the dict can grow -to hundreds of entries before a prune is triggered — keeping stale entries in -memory for up to 60 seconds × 1000/rate entries worth of time. - ---- - -## Solution - -### Replace `_route_tasks` set with `_in_flight` counter - -An integer counter provides the same protection (tasks complete; done-callback -fires) without holding strong references to each task object: - -```python -# __init__ -self._in_flight: int = 0 -self._max_in_flight: int = 30 - -# _process_queue — drop early if cap reached -if self._in_flight >= self._max_in_flight: - logger.warning("In-flight task cap reached (%d/%d), dropping packet", ...) - continue -self._in_flight += 1 -task = asyncio.create_task(self._route_packet(packet)) -task.add_done_callback(self._on_route_done) - -# done-callback -def _on_route_done(self, task): - self._in_flight -= 1 - if not task.cancelled() and task.exception(): - logger.error("_route_packet raised: %s", task.exception(), ...) -``` - -### Cap at 30 concurrent in-flight tasks - -30 is chosen as a ceiling that is: -- **Never reached in normal operation**: LoRa airtime at SF8/125 kHz limits - throughput to ~2–3 packets per second; with delays of 0.5–5 s each, the - steady-state in-flight count is at most 5–15 tasks. -- **High enough not to drop legitimate traffic**: a burst of 30 nearly-simultaneous - packets would require every node in a large mesh to transmit within 1 second. -- **Low enough to protect against pathological scenarios**: a misconfigured node - flooding the channel or a software bug causing infinite re-queuing. - -### Tighten companion dedup prune threshold to 200 - -200 entries at 60 s TTL means a sweep is triggered after ~200 unique PATH/response -packets arrive without any expiry. This is far more than a typical companion -session (which sees a handful of active connections) but prevents multi-hour -accumulation on a busy mesh. - ---- - -## Trade-off: Shutdown Cancellation - -The previous `_route_tasks` set allowed `stop()` to explicitly cancel and await -all in-flight tasks on shutdown. The counter approach does not. - -**Why this is acceptable:** - -1. In-flight `_route_packet` tasks are sleeping inside `delayed_send` (waiting for - their TX delay timer). When the event loop is shut down — whether via - `asyncio.run()` completing, `loop.stop()`, or `SIGTERM` handling — Python - cancels all pending tasks automatically. - -2. Even under the old approach, cancelling a sleeping `delayed_send` means the - packet is not transmitted. The result is the same whether cancellation happens - explicitly in `stop()` or implicitly when the event loop closes. - -3. For a graceful shutdown where we want to *wait* for in-flight packets to - complete transmission, the right mechanism is `stop()` awaiting the queue to - drain *before* cancelling the router task — not cancelling sleeping tasks. - Neither the old code nor this PR implements that, so no regression. - ---- - -## Why This Is the Right Approach - -### Alternative A — Keep `_route_tasks` set, add a size cap - -```python -if len(self._route_tasks) >= 30: - logger.warning(...) - continue -``` - -Works, but the set still holds a strong reference to every Task object for the -duration of its sleep. The counter holds an integer. Task objects in Python 3.12+ -are already strongly referenced by the event loop scheduler; the set reference is -redundant for preventing GC cancellation. - -### Alternative B — `asyncio.Semaphore` - -```python -self._sem = asyncio.Semaphore(30) -async with self._sem: - await self._route_packet(packet) -``` - -Correct but changes the queue loop from fire-and-forget to blocking: the loop -would wait at `async with self._sem` for a slot to open, stalling packet reads -while a slot is occupied. That reintroduces the queue freeze the concurrent -dispatch was designed to prevent. A semaphore is the right tool for *rate- -limiting* producers; a counter cap at the dispatch site is the right tool for -bounding *background* tasks. - -### Alternative C — Integer counter (this PR) - -- O(1) increment and decrement. -- No strong reference to task objects beyond the event loop's own reference. -- Drop decision is synchronous and immediate — no sleeping on semaphore. -- Error logging preserved in `_on_route_done`. -- Simpler code, easier to reason about. - ---- - -## Changes — `repeater/packet_router.py` only - -| Location | Change | Reason | -|----------|--------|--------| -| Module level | Remove `_COMPANION_DEDUPE_PRUNE_THRESHOLD = 1000` | Replaced with inline literal `200`; no need for a named constant for a single usage site | -| `__init__` | Remove `self._route_tasks = set()`; add `self._in_flight = 0`, `self._max_in_flight = 30` | Replace set-based tracking with counter | -| `stop()` | Remove `_route_tasks` cancellation block | Tasks complete or are cancelled by event loop shutdown; explicit cancellation not needed | -| `_on_route_task_done` → `_on_route_done` | Simpler done-callback: decrement counter + log exceptions | Error logging preserved; set management removed | -| `_should_deliver_path_to_companions` | `> _COMPANION_DEDUPE_PRUNE_THRESHOLD` → `> 200` with explanatory comment | Lower threshold; comment explains the sizing rationale | -| `_process_queue` | Check `_in_flight >= _max_in_flight` before `create_task`; increment `_in_flight`; use `_on_route_done` | Cap accumulation; counter tracks live task count | - ---- - -## Test Plan - -### Unit tests (no hardware) - -**T1 — Counter increments and decrements correctly** - -```python -async def test_in_flight_counter(): - router = PacketRouter(mock_daemon) - await router.start() - - assert router._in_flight == 0 - - # Enqueue a packet that takes time to process - async def slow_route(pkt): - await asyncio.sleep(0.1) - - router._route_packet = slow_route - await router.enqueue(make_test_packet()) - await asyncio.sleep(0.01) # let queue loop run - - assert router._in_flight == 1 # task is sleeping - - await asyncio.sleep(0.15) # task finishes - assert router._in_flight == 0 # counter decremented by done-callback -``` - -**T2 — Cap enforced: packet dropped when at limit** - -```python -async def test_cap_drops_packet_at_limit(): - router = PacketRouter(mock_daemon) - router._max_in_flight = 2 - router._in_flight = 2 # simulate cap reached - - dropped = [] - original_create_task = asyncio.create_task - asyncio.create_task = lambda coro: dropped.append(coro) - - await router._process_queue_once(make_test_packet()) - - assert dropped == [], "create_task must not be called when cap is reached" - asyncio.create_task = original_create_task -``` - -**T3 — Exceptions in `_route_packet` are logged, not swallowed** - -```python -async def test_exception_logged(): - router = PacketRouter(mock_daemon) - - async def failing_route(pkt): - raise ValueError("simulated error") - - router._route_packet = failing_route - with patch("repeater.packet_router.logger") as mock_log: - task = asyncio.create_task(failing_route(make_test_packet())) - router._in_flight = 1 - task.add_done_callback(router._on_route_done) - await asyncio.gather(task, return_exceptions=True) - mock_log.error.assert_called_once() - - assert router._in_flight == 0 -``` - -**T4 — Companion dedup dict pruned at 200, not 1000** - -```python -def test_companion_dedup_prune_threshold(): - router = PacketRouter(mock_daemon) - future_time = time.time() + 999 - - # Fill with 199 entries (all unexpired) — no prune - router._companion_delivered = {f"key{i}": future_time for i in range(199)} - pkt = make_path_packet() - router._should_deliver_path_to_companions(pkt) - assert len(router._companion_delivered) == 200 # added one, no prune yet - - # 201st entry triggers prune — all unexpired so count stays at 201 - router._companion_delivered[f"key_extra"] = future_time - assert len(router._companion_delivered) == 201 - - # Force prune by making all existing entries expired - past_time = time.time() - 1 - router._companion_delivered = {f"key{i}": past_time for i in range(201)} - router._should_deliver_path_to_companions(pkt) - # All expired entries pruned; only the new entry remains - assert len(router._companion_delivered) == 1 -``` - -### Integration / field tests (with hardware) - -**T5 — Burst flood: verify cap fires under pathological load** - -1. Configure a test mesh with 4+ nodes all in range of the repeater. -2. Have all nodes send a flood packet simultaneously. -3. Observe repeater logs. - -**Expected:** `_in_flight` peaks in low single digits (LoRa airtime prevents -large bursts); no `"In-flight task cap reached"` warning fires under normal -conditions, confirming the cap is never a bottleneck in practice. - -**T6 — Counter reaches zero after all packets processed** - -1. Send a burst of 10 packets. -2. Wait 10 seconds (longer than max TX delay of 5 s). -3. Query `router._in_flight` from a debug endpoint or log. - -**Expected:** `_in_flight == 0` after all delays expire and packets transmit. - -**T7 — Error in `_route_packet` is logged and counter is decremented** - -1. Temporarily introduce a deliberate exception in `_route_packet`. -2. Send a packet. -3. Check logs for the error message and verify the repeater continues operating - (counter decremented, queue still draining). - -**T8 — Normal forwarding throughput unchanged** - -1. Send packets at a steady rate of 1 every 10 seconds for 5 minutes. -2. Verify all packets are forwarded with no warnings or errors. -3. Confirm `_in_flight` never exceeds 3–4 during normal operation. - ---- - -## Proof of Correctness - -### Counter vs set: why the counter is sufficient - -The `_route_tasks` set solved two problems: - -1. **GC protection**: In Python < 3.12, a task with no strong references other - than the event loop's internal weakref could be garbage collected before - completing. Python 3.12+ strengthened task references in the event loop. - However, even in earlier versions, the set was unnecessary once `create_task` - returns — the caller holds the reference, and the done-callback fires reliably - because the event loop holds the task alive until completion. - -2. **Explicit shutdown cancellation**: The counter loses this. As argued above, - the outcome is identical — sleeping tasks are cancelled either explicitly by - `stop()` or implicitly by the event loop at shutdown — and no packet that - hasn't been transmitted yet can complete its send after the radio is shut down - anyway. - -### Why `_on_route_done` is a done-callback and not a `try/finally` inside `_route_packet` - -A `try/finally` block inside `_route_packet` would also decrement the counter. -Done-callbacks are preferable because: - -- They fire even if the task is externally cancelled (e.g. by event loop shutdown), - whereas `finally` may not run if `CancelledError` is not caught. -- They decouple counter management from `_route_packet` logic — `_route_packet` - has no knowledge of or dependency on the cap mechanism. -- They keep the pattern consistent with the rest of the codebase's use of - `add_done_callback` for task lifecycle management. - -### Why 30 and not a smaller number like 10 - -At SF8, 125 kHz bandwidth, a 30-byte payload takes ~111 ms airtime and produces -a TX delay of roughly 0.5–3 s. With a 60-second duty-cycle window and 3.6 s -max airtime, the node can forward at most ~32 packets per minute at full budget. -If all 32 arrive within one second (they cannot physically, but as an upper -bound), 32 tasks would be in-flight simultaneously. A cap of 30 is aggressive -enough to protect against unbounded growth but not so low that it would drop -legitimate traffic under any realistic burst scenario. diff --git a/docs/pr_tx_serialization.md b/docs/pr_tx_serialization.md deleted file mode 100644 index b9e84d08..00000000 --- a/docs/pr_tx_serialization.md +++ /dev/null @@ -1,395 +0,0 @@ -# PR: Serialise Radio TX and Close Duty-Cycle TOCTOU Race - -**Branch:** `fix/tx-serialization` -**Base:** `rightup/fix-perfom-speed` -**Files changed:** `repeater/engine.py` (1 file, ~30 lines net) - ---- - -## Problem - -Two separate bugs share the same root cause: concurrent `delayed_send` coroutines -racing each other at transmission time. - -### Bug 1 — Interleaved SPI/serial commands to the radio - -The queue loop (added in an earlier commit) dispatches each incoming packet as an -`asyncio.create_task`, so multiple `delayed_send` coroutines can have their sleep -timers running concurrently. That is correct and intentional — it mirrors how -firmware nodes use a hardware timer so the radio keeps listening during a TX delay. - -However the LoRa radio is **half-duplex**: it can only transmit one packet at a -time. When two delay timers expire at nearly the same moment both coroutines call -`dispatcher.send_packet` simultaneously. `send_packet` issues a sequence of -SPI/serial register writes to the radio; two tasks interleaving these writes -produces undefined radio state and the transmission of neither packet is reliable. - -### Bug 2 — TOCTOU gap in duty-cycle enforcement - -`__call__` calls `can_transmit()` before scheduling a task: - -```python -# __call__ (before this fix) -can_tx, wait_time = self.airtime_mgr.can_transmit(airtime_ms) -if not can_tx: - ... # drop or defer -tx_task = await self.schedule_retransmit(fwd_pkt, delay, airtime_ms, ...) -``` - -`record_tx()` is only called later, inside `delayed_send`, after the sleep -completes. Between the check and the debit there is a window that spans the -entire TX delay (up to several seconds). Two packets that both pass the check -before either has slept and recorded its airtime will **both** be transmitted even -if transmitting both would exceed the duty-cycle budget. - -Under normal single-packet conditions this window is harmless. Under burst -conditions — multi-hop amplification, collision retries, or a busy mesh segment -where several packets arrive within the same delay window — multiple tasks pass -the advisory check simultaneously, and the duty-cycle limit is exceeded. - ---- - -## Root Cause - -There is no mutual exclusion around the radio send path. Each `delayed_send` -coroutine independently checks duty-cycle, sleeps, and transmits without -coordinating with any other concurrent coroutine doing the same thing. - ---- - -## Solution - -Add `self._tx_lock = asyncio.Lock()` (initialised in `__init__`) and acquire it -inside `delayed_send` **after** the sleep completes: - -``` -Delay timers run concurrently (unchanged): - Task A: sleep(1.2s) ──────────────────► acquire _tx_lock → check → TX A → release - Task B: sleep(0.9s) ──────────────────► acquire _tx_lock (waits) ──────────► check → TX B → release - Task C: sleep(2.1s) ────────────────────────────────────────────────────────────────► ... - -Radio: one packet at a time, duty-cycle state always stable inside the lock. -``` - -Inside the lock, a **second** `can_transmit()` call is made immediately before -sending. Because only one task holds the lock at a time, airtime state is stable -at this point and `record_tx()` follows on success — check and debit are -effectively atomic. This closes the TOCTOU window completely. - -The upfront `can_transmit()` in `__call__` is retained as an **advisory** fast -path: it still drops or defers packets that are obviously over budget before a -delay task is even scheduled, avoiding unnecessary sleep timers. It is no longer -the enforcement point. - ---- - -## Why This Is the Right Approach - -### Alternative A — Move `record_tx()` before the sleep - -```python -# hypothetical -self.airtime_mgr.record_tx(airtime_ms) # reserve before sleeping -await asyncio.sleep(delay) -await self.dispatcher.send_packet(...) # actual TX -``` - -Records airtime even if the send fails (exception, LBT busy, radio error) — -the budget is debited for a packet that was never transmitted. Over time this -inflates the apparent airtime, causing the node to throttle legitimate traffic -it actually has budget for. Requires a compensating `release_airtime()` on -every failure path, creating new complexity and failure modes. - -### Alternative B — A single global advisory check (status quo before this PR) - -Already demonstrated to fail under burst conditions (two tasks both pass before -either records its airtime). - -### Alternative C — asyncio.Lock (this PR) - -- Delay timers remain concurrent — no regression on the primary non-blocking TX - improvement. -- The check-and-debit pair is atomic within the lock — no TOCTOU window. -- No phantom airtime on send failure — `record_tx()` is only called on success. -- One `asyncio.Lock` object, no new state machines or compensating paths. -- The lock is `async`, so it only blocks other TX tasks, not the event loop or - the packet RX queue. - -### Why `asyncio.Lock` rather than `threading.Lock` - -The entire repeater runs on a single asyncio event loop. `asyncio.Lock` only -yields at `await` points; it does not involve OS threads or context switches. -A `threading.Lock` would work but is semantically wrong here (this is not a -thread-safety problem) and would block the event loop thread if held across an -`await`. - ---- - -## Changes - -### `repeater/engine.py` - -**1. Move `import random` to module level** - -```python -# before (inside _calculate_tx_delay): -def _calculate_tx_delay(self, packet, snr=0.0): - import random - ... - -# after (top of file, with other stdlib imports): -import random -``` - -This is a housekeeping fix bundled with this PR because `random` is a stdlib -module that should never be imported inside a hot-path function — Python caches -the import after the first call, but the attribute lookup and cache check still -run on every call. Moving it to module level is the standard pattern. - -**2. Add `self._tx_lock` to `__init__`** - -```python -# Serialise all radio TX calls. -# -# Background: since the queue loop dispatches each packet as an -# asyncio.create_task, multiple _route_packet coroutines can have their -# TX delay timers running concurrently — which is the intended behaviour -# (firmware nodes do the same with a hardware timer). However, the -# LoRa radio is half-duplex: it can only transmit one packet at a time. -# Without serialisation, two tasks whose delay timers expire near- -# simultaneously both call dispatcher.send_packet, interleaving SPI/serial -# commands to the radio and both passing the LBT check before either has -# actually transmitted. -# -# _tx_lock is acquired after each delay sleep and held for the entire -# send_packet call. Delays still run concurrently; only the radio -# access is serialised. This also eliminates the TOCTOU gap in duty-cycle -# enforcement — see schedule_retransmit / delayed_send for details. -self._tx_lock = asyncio.Lock() -``` - -**3. Acquire lock inside `delayed_send`, add authoritative duty-cycle gate** - -```python -async def delayed_send(): - await asyncio.sleep(delay) - - # Acquire the TX lock *after* the delay so that delay timers for - # multiple packets still run concurrently (matching firmware). Only - # one coroutine enters the radio send path at a time. - async with self._tx_lock: - # ── Authoritative duty-cycle gate ───────────────────────────── - # The upfront can_transmit() call in __call__ is advisory: it - # avoids scheduling packets that are obviously over budget, but - # it cannot prevent a race between two tasks whose delay timers - # expire at almost the same moment. Both tasks pass the advisory - # check before either has recorded its airtime, then both try to - # transmit. - # - # Inside _tx_lock only one task runs at a time, so airtime state - # is stable here. The check and the subsequent record_tx() are - # effectively atomic — no TOCTOU window. - if airtime_ms > 0: - can_tx_now, _ = self.airtime_mgr.can_transmit(airtime_ms) - if not can_tx_now: - logger.warning( - "Packet dropped at TX time: duty-cycle exceeded " - "(airtime=%.1fms)", airtime_ms, - ) - return - - last_error = None - for attempt in range(2 if local_transmission else 1): - try: - await self.dispatcher.send_packet(fwd_pkt, wait_for_ack=False) - self._record_packet_sent(fwd_pkt) - if airtime_ms > 0: - self.airtime_mgr.record_tx(airtime_ms) - ... -``` - ---- - -## Invariants Maintained - -| Property | Before | After | -|----------|--------|-------| -| Delay timers run concurrently | ✅ | ✅ | -| Radio accessed by one task at a time | ❌ | ✅ | -| Duty-cycle check and debit atomic | ❌ | ✅ | -| Airtime recorded only on TX success | ✅ | ✅ | -| Event loop not blocked by lock | ✅ | ✅ (asyncio.Lock) | - ---- - -## Test Plan - -### Unit tests (can run without hardware) - -**T1 — Serial TX ordering** - -```python -import asyncio -from unittest.mock import AsyncMock, MagicMock, patch - -async def test_tx_serialized(): - """Two tasks whose delays expire simultaneously must not interleave.""" - send_order = [] - send_lock = asyncio.Lock() - - async def mock_send(pkt, **kw): - # Confirm the _tx_lock is already held when we enter send_packet - assert send_lock.locked(), "send_packet called without _tx_lock held" - send_order.append(pkt) - await asyncio.sleep(0) # yield; a second task must not enter here - - engine._tx_lock = send_lock # replace with the mock lock reference - engine.dispatcher.send_packet = mock_send - - t1 = asyncio.create_task(engine.schedule_retransmit(pkt_a, delay=0.01, airtime_ms=100)) - t2 = asyncio.create_task(engine.schedule_retransmit(pkt_b, delay=0.01, airtime_ms=100)) - await asyncio.gather(t1, t2) - - assert len(send_order) == 2 # both transmitted - assert send_order[0] is not send_order[1] # different packets -``` - -**T2 — Authoritative duty-cycle gate blocks over-budget second packet** - -```python -async def test_second_packet_dropped_when_over_budget(): - """When first TX fills the budget, second task must be dropped inside the lock.""" - # Set a tiny budget: 50ms per minute - engine.airtime_mgr.max_airtime_per_minute = 50 - - sent = [] - async def mock_send(pkt, **kw): - sent.append(pkt) - - engine.dispatcher.send_packet = mock_send - - # Each packet costs ~111ms (SF8, BW125, 30-byte payload) — first passes, second must not - t1 = asyncio.create_task(engine.schedule_retransmit(pkt_a, delay=0.01, airtime_ms=111)) - t2 = asyncio.create_task(engine.schedule_retransmit(pkt_b, delay=0.01, airtime_ms=111)) - await asyncio.gather(t1, t2) - - assert len(sent) == 1, f"Expected 1 TX, got {len(sent)}" -``` - -**T3 — Airtime not debited on TX failure** - -```python -async def test_airtime_not_recorded_on_send_failure(): - before = engine.airtime_mgr.total_airtime_ms - - async def failing_send(pkt, **kw): - raise RuntimeError("radio error") - - engine.dispatcher.send_packet = failing_send - - with pytest.raises(RuntimeError): - await engine.schedule_retransmit(pkt, delay=0, airtime_ms=100) - - assert engine.airtime_mgr.total_airtime_ms == before, \ - "Airtime must not be recorded when send raises" -``` - -**T4 — Advisory check still drops before scheduling (fast path not regressed)** - -```python -async def test_advisory_check_still_drops_obvious_overage(): - """__call__ should not even schedule a task when clearly over budget.""" - engine.airtime_mgr.max_airtime_per_minute = 0 # budget exhausted - - tasks_created = [] - original = asyncio.create_task - asyncio.create_task = lambda coro: tasks_created.append(coro) or original(coro) - - await engine(over_budget_packet, metadata={}) - - assert not tasks_created, "No task should be created when advisory check fails" -``` - -### Integration / field tests (with hardware) - -**T5 — Burst scenario: 5 packets arrive within the same delay window** - -1. Connect the repeater to a radio. -2. Using a second node, send 5 FLOOD packets in quick succession (< 100 ms apart) - with a low RSSI score so the repeater's delay is ~1–2 s for all of them. -3. Monitor the radio with a spectrum analyser or a third node running in monitor - mode. - -**Expected (after this fix):** -- Transmissions are sequential — no overlapping on-air signals. -- `Retransmitted packet` log lines appear one after another, each with a non-zero - airtime value. -- No `Retransmit failed` errors in the log. -- Duty-cycle log shows airtime accumulating correctly. - -**Expected (before this fix, to confirm the bug existed):** -- Occasional `Retransmit failed` errors under burst load. -- Airtime tracking diverging from actual on-air time (double-counted or missed). - -**T6 — Duty-cycle enforcement under burst** - -1. Set `max_airtime_per_minute` to a low value (e.g. 500 ms) in config. -2. Send 10 packets rapidly so the repeater tries to forward all 10. -3. Observe logs. - -**Expected:** -- First N packets transmitted (total airtime ≤ 500 ms). -- Subsequent packets log `"Packet dropped at TX time: duty-cycle exceeded"` from - inside `delayed_send` (not just the advisory drop). -- `airtime_mgr.get_stats()["utilization_percent"]` reads ≤ 100%. - -**T7 — Normal single-packet forwarding not regressed** - -1. Send one packet every 5 seconds (well within duty-cycle budget). -2. Verify each packet is forwarded with correct airtime logged. -3. Verify no lock contention warnings in the log. - -**T8 — Local TX retry path (local_transmission=True) still works** - -1. Send a command that triggers a local transmission (e.g. a ping reply). -2. Briefly block the radio (simulate with a mock) so the first attempt fails. -3. Verify the retry fires after 1 s and the packet is eventually transmitted. - ---- - -## Proof of Correctness - -### Why `asyncio.Lock` is sufficient (no OS-level synchronisation needed) - -Python's asyncio event loop is **single-threaded**. All coroutines share one -thread and only yield execution at `await` points. Between two consecutive -`await` calls in a coroutine, the event loop does not switch to another coroutine. - -`asyncio.Lock.acquire()` suspends the current coroutine if the lock is held, -returning control to the event loop. `asyncio.Lock.release()` wakes the next -waiter. Because `send_packet` is awaited inside the lock, no other TX task can -run until the current one releases the lock and the event loop gets a chance to -schedule the next waiter. - -There is no possibility of the race seen with `threading.Lock` where an OS thread -can be preempted mid-instruction. - -### Why the advisory check in `__call__` cannot be removed - -The advisory check is still necessary as a fast path. If it were removed, every -incoming packet — even when the node is clearly at 100% duty-cycle — would -schedule a `delayed_send` task that would sleep for the full TX delay (up to -several seconds) before the lock drops it. Under a sustained flood of incoming -packets this wastes memory and CPU. The advisory check prunes the queue early at -negligible cost. - -### Why `record_tx()` must be inside the lock (not before or after) - -- **Before the send:** records airtime for a packet that may never be transmitted - (send could fail, LBT could reject it). Budget is overcounted. -- **After releasing the lock:** a second task could pass the authoritative - `can_transmit()` check between `send_packet` returning and `record_tx()` being - called — the TOCTOU window reopens at a smaller scale. -- **Inside the lock, after a successful send:** the budget is debited exactly once - for exactly the packets that were actually transmitted. The lock ensures no - other task reads airtime state between the check and the debit. diff --git a/manage.sh b/manage.sh index aa8dcde7..7d5b2fa4 100755 --- a/manage.sh +++ b/manage.sh @@ -341,7 +341,7 @@ install_repeater() { echo "25"; echo "# Installing system dependencies..." apt-get update -qq - DEBIAN_FRONTEND=noninteractive apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev + DEBIAN_FRONTEND=noninteractive apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev i2c-tools # Install polkit (package name varies by distro version) DEBIAN_FRONTEND=noninteractive apt-get install -y policykit-1 2>/dev/null \ || DEBIAN_FRONTEND=noninteractive apt-get install -y polkitd pkexec 2>/dev/null \ @@ -746,7 +746,7 @@ upgrade_repeater() { echo "[3/9] Updating system dependencies..." apt-get update -qq - apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev + apt-get install -y libffi-dev libusb-1.0-0 sudo jq pip python3-venv python3-rrdtool wget swig build-essential python3-dev i2c-tools # Install polkit (package name varies by distro version) apt-get install -y policykit-1 2>/dev/null \ || apt-get install -y polkitd pkexec 2>/dev/null \ diff --git a/pymc-repeater.service b/pymc-repeater.service index 72c7eba3..cc7715d5 100644 --- a/pymc-repeater.service +++ b/pymc-repeater.service @@ -3,8 +3,9 @@ [Unit] Description=pyMC Repeater Daemon -After=network-online.target +After=network-online.target dbus.socket Wants=network-online.target +Requires=dbus.socket [Service] Type=simple @@ -34,5 +35,9 @@ SyslogIdentifier=pymc-repeater ReadWritePaths=/var/log/pymc_repeater /var/lib/pymc_repeater /etc/pymc_repeater SupplementaryGroups=plugdev dialout +# Allow GPS time sync to update CLOCK_REALTIME without running as root, also allow changing user via polkit or sudo +CapabilityBoundingSet=CAP_SYS_TIME CAP_SETUID CAP_SETGID +AmbientCapabilities=CAP_SYS_TIME + [Install] WantedBy=multi-user.target diff --git a/pyproject.toml b/pyproject.toml index 98d02a47..137a957c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "pymc_repeater" dynamic = ["version"] authors = [ - {name = "Lloyd", email = "lloyd@rightup.co.uk"}, + {name = "Rightup", email = "rightup@pymc.dev"}, ] description = "PyMC Repeater Daemon" readme = "README.md" @@ -30,12 +30,13 @@ keywords = ["mesh", "networking", "lora", "repeater", "daemon", "iot"] dependencies = [ - "pymc_core[hardware]==1.0.10", + "pymc_core[hardware] @ git+https://github.com/rightup/pyMC_core.git@dev", "pyyaml>=6.0.0", "cherrypy>=18.0.0", "paho-mqtt>=1.6.0", "cherrypy-cors==1.7.0", "psutil>=5.9.0", + "pyserial>=3.5", "pyjwt>=2.8.0", "ws4py>=0.6.0", ] @@ -45,7 +46,7 @@ dependencies = [ [project.optional-dependencies] # SX1262/SPI support (Linux only; required for Raspberry Pi HATs) hardware = [ - "pymc_core[hardware]", + "pymc_core[hardware] @ git+https://github.com/rightup/pyMC_core.git@dev", ] # RRD metrics (Performance Metrics chart); system librrd required (e.g. apt install rrdtool) rrd = [ @@ -74,6 +75,7 @@ repeater = [ "web/html/assets/**/*", "web/*.yaml", "web/*.html", + "presets/*.yaml", ] [tool.black] diff --git a/radio-presets.json b/radio-presets.json index d173566a..94c4eb07 100644 --- a/radio-presets.json +++ b/radio-presets.json @@ -144,6 +144,14 @@ "spreading_factor": "11", "bandwidth": "250", "coding_rate": "5" + }, + { + "title": "USA (Southern California)", + "description": "927.875MHz / SF7 / BW62.5 / CR7", + "frequency": "927.875", + "spreading_factor": "7", + "bandwidth": "62.5", + "coding_rate": "7" }, { "title": "Vietnam", @@ -156,4 +164,4 @@ ] } } -} \ No newline at end of file +} diff --git a/radio-settings-buildroot.json b/radio-settings-buildroot.json index 16e14942..6093c4c7 100644 --- a/radio-settings-buildroot.json +++ b/radio-settings-buildroot.json @@ -18,6 +18,7 @@ "reset_pin": 54, "busy_pin": 122, "irq_pin": 121, + "radio_timing_delay": 0.012, "en_pin": 0, "txen_pin": -1, "rxen_pin": -1, @@ -42,6 +43,7 @@ "reset_pin": 54, "busy_pin": 123, "irq_pin": 55, + "radio_timing_delay": 0.012, "en_pin": -1, "txen_pin": 52, "rxen_pin": 53, @@ -64,6 +66,7 @@ "reset_pin": 54, "busy_pin": 123, "irq_pin": 55, + "radio_timing_delay": 0.012, "en_pin": -1, "txen_pin": 52, "rxen_pin": 53, diff --git a/radio-settings.json b/radio-settings.json index 9b0ae506..0e9aa5bd 100644 --- a/radio-settings.json +++ b/radio-settings.json @@ -186,6 +186,7 @@ "ch341-usb-sx1262": { "name": "CH341 USB-SPI + SX1262 (example)", "description": "SX1262 via CH341 USB-to-SPI adapter. NOTE: pin numbers are CH341 GPIO 0-7, not BCM.", + "connection_type": "usb", "radio_type": "sx1262_ch341", "vid": 6790, "pid": 21778, @@ -286,6 +287,66 @@ "preamble_length": 17, "use_gpiod_backend": true, "gpio_chip": 1 + }, + "ultrapeaterzero-e22": { + "name": "Zindello Industries UltraPeaterZero E22", + "bus_id": 0, + "cs_id": 0, + "cs_pin": 24, + "reset_pin": 25, + "busy_pin": 5, + "irq_pin": 12, + "txen_pin": 27, + "rxen_pin": 17, + "en_pins": [16], + "txled_pin": 21, + "rxled_pin": 20, + "tx_power": 22, + "use_dio2_rf": false, + "use_dio3_tcxo": true, + "preamble_length": 17 + }, + "ultrapeaterzero-e22p": { + "name": "Zindello Industries UltraPeaterZero E22P", + "bus_id": 0, + "cs_id": 0, + "cs_pin": 24, + "reset_pin": 25, + "busy_pin": 5, + "irq_pin": 12, + "txen_pin": 27, + "rxen_pin": -1, + "en_pins": [17, 16], + "txled_pin": 21, + "rxled_pin": 20, + "tx_power": 22, + "use_dio2_rf": false, + "use_dio3_tcxo": true, + "preamble_length": 17 + }, + "pymc_usb": { + "name": "pymc_usb modem (USB-CDC)", + "description": "ESP32-S3 / nRF52 board running pymc_usb firmware as a USB-CDC LoRa modem. Pick this if the modem is plugged into the host's USB port (e.g. /dev/ttyACM0). Edit the 'pymc_usb' section after first-run to point at the right serial device.", + "connection_type": "usb", + "radio_type": "pymc_usb", + "tx_power": 22, + "preamble_length": 16 + }, + "pymc_tcp": { + "name": "pymc_tcp modem (Wi-Fi / Ethernet)", + "description": "ESP32 board running pymc_usb firmware exposed as a TCP server over Wi-Fi or Ethernet. After first-run, set 'pymc_tcp.host' to the modem's LAN address or mDNS name (e.g. pymc-3e2834.local).", + "connection_type": "network", + "radio_type": "pymc_tcp", + "tx_power": 22, + "preamble_length": 16 + }, + "kiss": { + "name": "KISS modem (serial)", + "description": "MeshCore KISS modem over serial - requires pyMC_core with KISS support.", + "connection_type": "usb", + "radio_type": "kiss", + "tx_power": 14, + "preamble_length": 17 } } -} +} \ No newline at end of file diff --git a/repeater/config.py b/repeater/config.py index 3ce3670a..8c7d975e 100644 --- a/repeater/config.py +++ b/repeater/config.py @@ -2,13 +2,71 @@ import logging import os from pathlib import Path -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, overload import yaml logger = logging.getLogger("Config") +class NullRadio: + """No-op radio used when radio_type disables hardware initialization.""" + + def __init__(self): + self._rx_callback = None + + def begin(self): + return True + + async def send(self, data: bytes): + raise RuntimeError("Radio is disabled (radio_type is null/none)") + + async def wait_for_rx(self) -> bytes: + import asyncio + + while True: + await asyncio.sleep(3600) + + def sleep(self): + return None + + def get_last_rssi(self) -> int: + return 0 + + def get_last_snr(self) -> float: + return 0.0 + + def set_rx_callback(self, callback): + self._rx_callback = callback + + def check_radio_health(self): + return True + + +def resolve_storage_dir( + config: Dict[str, Any], + *, + config_path: Optional[str] = None, + default: str = "/var/lib/pymc_repeater", +) -> Path: + + storage_dir_cfg = ( + config.get("storage", {}).get("storage_dir") + or config.get("storage_dir") + or default + ) + + storage_dir = Path(str(storage_dir_cfg)).expanduser() + if not storage_dir.is_absolute(): + if config_path: + base_dir = Path(config_path).expanduser().resolve().parent + storage_dir = (base_dir / storage_dir).resolve() + else: + storage_dir = storage_dir.resolve() + + return storage_dir + + def get_node_info(config: Dict[str, Any]) -> Dict[str, Any]: """ Extract node name, radio configuration, and MQTT settings from config. @@ -65,6 +123,16 @@ def load_config(config_path: Optional[str] = None) -> Dict[str, Any]: except Exception as e: raise RuntimeError(f"Failed to load configuration from {config_path}: {e}") from e + storage_dir = resolve_storage_dir(config, config_path=config_path) + if "storage" not in config or not isinstance(config.get("storage"), dict): + config["storage"] = {} + config["storage"]["storage_dir"] = str(storage_dir) + + if config.get("storage_dir"): + logger.warning( + "Deprecated config key 'storage_dir' detected; prefer 'storage.storage_dir'." + ) + if "mesh" not in config: config["mesh"] = {} @@ -79,6 +147,37 @@ def load_config(config_path: Optional[str] = None) -> Dict[str, Any]: "cert_store_dir": "/etc/pymc_repeater/glass", } + if "gps" not in config: + config["gps"] = { + "enabled": False, + "api_fallback_to_config_location": True, + "advertise_gps_location": False, + "location_precision_digits": None, + "source": "serial", + "device": "/dev/serial0", + "baud_rate": 9600, + "read_timeout_seconds": 1.0, + "reconnect_interval_seconds": 5.0, + "stale_after_seconds": 10.0, + "retain_sentences": 25, + "validate_checksum": True, + "require_checksum": False, + "time_sync_enabled": True, + "time_sync_interval_seconds": 3600.0, + "time_sync_min_offset_seconds": 1.0, + "time_sync_min_valid_year": 2020, + "persist_gps_fix_to_config": False, + "persist_gps_fix_interval_seconds": 600.0, + } + + if "sensors" not in config: + config["sensors"] = { + "enabled": False, + "poll_interval_seconds": 30.0, + "auto_install_packages": False, + "definitions": [], + } + # Ensure repeater.security exists with defaults for upgrades from older configs if "repeater" not in config: config["repeater"] = {} @@ -234,7 +333,13 @@ def _load_or_create_identity_key(path: Optional[str] = None) -> bytes: def get_radio_for_board(board_config: dict): - def _parse_int(value, *, default=None) -> int: + @overload + def _parse_int(value, *, default: None = None) -> Optional[int]: ... + + @overload + def _parse_int(value, *, default: int) -> int: ... + + def _parse_int(value, *, default=None): if value is None: return default if isinstance(value, int): @@ -243,7 +348,30 @@ def _parse_int(value, *, default=None) -> int: return int(value.strip().rstrip(','), 0) raise ValueError(f"Invalid int value type: {type(value)}") - radio_type = board_config.get("radio_type", "sx1262").lower().strip() + def _parse_int_list(value): + if value is None: + return None + if isinstance(value, (list, tuple)): + return [_parse_int(item) for item in value] + if isinstance(value, str): + stripped = value.strip() + if not stripped: + return [] + if stripped[0] == "[" and stripped[-1] == "]": + stripped = stripped[1:-1] + return [_parse_int(item) for item in stripped.split(",") if item.strip()] + raise ValueError(f"Invalid int list value type: {type(value)}") + + radio_type_raw = board_config.get("radio_type") + if radio_type_raw is None: + radio_type = "none" + else: + radio_type = str(radio_type_raw).lower().strip() + + if radio_type in ("", "none", "null", "disabled", "off", "no_radio"): + logger.warning("Radio disabled by configuration (radio_type=%r)", radio_type_raw) + return NullRadio() + if radio_type == "kiss-modem": radio_type = "kiss" @@ -286,7 +414,6 @@ def _parse_int(value, *, default=None) -> int: "rxen_pin": _parse_int(spi_config["rxen_pin"]), "txled_pin": _parse_int(spi_config.get("txled_pin", -1), default=-1), "rxled_pin": _parse_int(spi_config.get("rxled_pin", -1), default=-1), - "en_pin": _parse_int(spi_config.get("en_pin", -1), default=-1), "use_dio3_tcxo": spi_config.get("use_dio3_tcxo", False), "dio3_tcxo_voltage": float(spi_config.get("dio3_tcxo_voltage", 1.8)), "use_dio2_rf": spi_config.get("use_dio2_rf", False), @@ -297,15 +424,24 @@ def _parse_int(value, *, default=None) -> int: "bandwidth": int(radio_config["bandwidth"]), "coding_rate": radio_config["coding_rate"], "preamble_length": radio_config["preamble_length"], - "sync_word": radio_config["sync_word"], + "sync_word": _parse_int(radio_config.get("sync_word", 0x12)), } + en_pin = _parse_int(spi_config.get("en_pin"), default=None) + en_pins = _parse_int_list(spi_config.get("en_pins")) + if en_pin is not None: + combined_config["en_pin"] = en_pin + if en_pins is not None: + combined_config["en_pins"] = en_pins + # Add optional GPIO parameters if specified in config # These wont be supported by older versions of pymc_core if "gpio_chip" in spi_config: combined_config["gpio_chip"] = _parse_int(spi_config["gpio_chip"], default=0) if "use_gpiod_backend" in spi_config: combined_config["use_gpiod_backend"] = spi_config["use_gpiod_backend"] + if "radio_timing_delay" in spi_config: + combined_config["radio_timing_delay"] = float(spi_config["radio_timing_delay"]) radio = SX1262Radio.get_instance(**combined_config) @@ -363,6 +499,97 @@ def _parse_int(value, *, default=None) -> int: return radio + elif radio_type == "pymc_tcp": + try: + from pymc_core.hardware.tcp_radio import TCPLoRaRadio + except ImportError: + raise RuntimeError( + "pymc_tcp radio requires pyMC_core >= the release that includes " + "PR pyMC-dev/pyMC_core#68 (merged 2026-05-13). " + "Reinstall the [hardware] extra to pick it up." + ) from None + + tcp_cfg = board_config.get("pymc_tcp") + if not tcp_cfg: + raise ValueError( + "Missing 'pymc_tcp' section in configuration file for radio_type: pymc_tcp" + ) + + host = tcp_cfg.get("host") + if not host: + raise ValueError( + "Missing 'host' in 'pymc_tcp' section (modem hostname or LAN IP)" + ) + + radio_cfg = board_config.get("radio") or {} + radio = TCPLoRaRadio( + host=host, + port=int(tcp_cfg.get("port", 5055)), + token=tcp_cfg.get("token", ""), + connect_timeout=float(tcp_cfg.get("connect_timeout", 5.0)), + frequency=int(radio_cfg.get("frequency", 869618000)), + bandwidth=int(radio_cfg.get("bandwidth", 62500)), + spreading_factor=int(radio_cfg.get("spreading_factor", 8)), + coding_rate=int(radio_cfg.get("coding_rate", 8)), + tx_power=int(radio_cfg.get("tx_power", 22)), + sync_word=_parse_int(radio_cfg.get("sync_word", 0x12), default=0x12), + preamble_length=int(radio_cfg.get("preamble_length", 16)), + lbt_enabled=bool(tcp_cfg.get("lbt_enabled", True)), + lbt_max_attempts=int(tcp_cfg.get("lbt_max_attempts", 5)), + ) + + try: + radio.begin() + except Exception as e: + raise RuntimeError(f"Failed to initialize pymc_tcp radio: {e}") from e + + return radio + + elif radio_type == "pymc_usb": + try: + from pymc_core.hardware.usb_radio import USBLoRaRadio + except ImportError: + raise RuntimeError( + "pymc_usb radio requires pyMC_core >= the release that includes " + "PR pyMC-dev/pyMC_core#68 (merged 2026-05-13). " + "Reinstall the [hardware] extra to pick it up." + ) from None + + usb_cfg = board_config.get("pymc_usb") + if not usb_cfg: + raise ValueError( + "Missing 'pymc_usb' section in configuration file for radio_type: pymc_usb" + ) + + port = usb_cfg.get("port") + if not port: + raise ValueError( + "Missing 'port' in 'pymc_usb' section (e.g. /dev/ttyACM0)" + ) + + radio_cfg = board_config.get("radio") or {} + radio = USBLoRaRadio( + port=port, + baudrate=int(usb_cfg.get("baudrate", 921600)), + frequency=int(radio_cfg.get("frequency", 869618000)), + bandwidth=int(radio_cfg.get("bandwidth", 62500)), + spreading_factor=int(radio_cfg.get("spreading_factor", 8)), + coding_rate=int(radio_cfg.get("coding_rate", 8)), + tx_power=int(radio_cfg.get("tx_power", 22)), + sync_word=_parse_int(radio_cfg.get("sync_word", 0x12), default=0x12), + preamble_length=int(radio_cfg.get("preamble_length", 16)), + lbt_enabled=bool(usb_cfg.get("lbt_enabled", True)), + lbt_max_attempts=int(usb_cfg.get("lbt_max_attempts", 5)), + ) + + try: + radio.begin() + except Exception as e: + raise RuntimeError(f"Failed to initialize pymc_usb radio: {e}") from e + + return radio + raise RuntimeError( - f"Unknown radio type: {radio_type}. Supported: sx1262, sx1262_ch341, kiss (or kiss-modem)" + f"Unknown radio type: {radio_type}. " + "Supported: sx1262, sx1262_ch341, kiss (or kiss-modem), pymc_tcp, pymc_usb" ) diff --git a/repeater/config_manager.py b/repeater/config_manager.py index 66af0e11..56cb05e9 100644 --- a/repeater/config_manager.py +++ b/repeater/config_manager.py @@ -21,6 +21,129 @@ def __init__(self, config_path: str, config: dict, daemon_instance=None): self.config_path = config_path self.config = config self.daemon = daemon_instance + + def _get_live_radio_snapshot(self) -> Dict[str, Any]: + radio_cfg = self.config.get("radio", {}) or {} + return { + "frequency": int(radio_cfg.get("frequency", 0) or 0), + "bandwidth": int(radio_cfg.get("bandwidth", 0) or 0), + "spreading_factor": int(radio_cfg.get("spreading_factor", 0) or 0), + "coding_rate": int(radio_cfg.get("coding_rate", 0) or 0), + "tx_power": int(radio_cfg.get("tx_power", 0) or 0), + } + + def _sync_repeater_handler_radio_config(self, radio_cfg: Dict[str, Any]) -> None: + repeater_handler = getattr(self.daemon, "repeater_handler", None) + if not repeater_handler or not hasattr(repeater_handler, "radio_config"): + return + + if not isinstance(repeater_handler.radio_config, dict): + repeater_handler.radio_config = {} + + repeater_handler.radio_config.update( + { + key: value + for key, value in radio_cfg.items() + if value not in (None, 0) + } + ) + + def _kiss_transport_restart_required(self) -> bool: + radio = getattr(self.daemon, "radio", None) + kiss_cfg = self.config.get("kiss", {}) or {} + if radio is None or not kiss_cfg: + return False + + runtime_port = getattr(radio, "port", None) + runtime_baudrate = getattr(radio, "baudrate", None) + + configured_port = kiss_cfg.get("port") + configured_baudrate = kiss_cfg.get("baud_rate") + + if configured_port and runtime_port and str(configured_port) != str(runtime_port): + logger.info("KISS port change detected; service restart required") + return True + + if configured_baudrate and runtime_baudrate and int(configured_baudrate) != int(runtime_baudrate): + logger.info("KISS baud rate change detected; service restart required") + return True + + return False + + def _apply_live_radio_config(self) -> bool: + radio = getattr(self.daemon, "radio", None) + if radio is None: + logger.warning("Radio not available for live update") + return False + + radio_cfg = self._get_live_radio_snapshot() + + try: + if hasattr(radio, "configure_radio"): + if hasattr(radio, "radio_config") and isinstance(radio.radio_config, dict): + radio.radio_config.update(radio_cfg) + + applied = radio.configure_radio( + frequency=radio_cfg["frequency"], + bandwidth=radio_cfg["bandwidth"], + spreading_factor=radio_cfg["spreading_factor"], + coding_rate=radio_cfg["coding_rate"], + ) + if not applied: + logger.warning("Live radio reconfiguration failed") + return False + else: + current_frequency = getattr(radio, "frequency", None) + current_bandwidth = getattr(radio, "bandwidth", None) + current_spreading_factor = getattr(radio, "spreading_factor", None) + current_coding_rate = getattr(radio, "coding_rate", None) + current_tx_power = getattr(radio, "tx_power", None) + + if ( + current_frequency != radio_cfg["frequency"] + and hasattr(radio, "set_frequency") + and not radio.set_frequency(radio_cfg["frequency"]) + ): + return False + + if ( + current_tx_power != radio_cfg["tx_power"] + and hasattr(radio, "set_tx_power") + and not radio.set_tx_power(radio_cfg["tx_power"]) + ): + return False + + coding_rate_changed = current_coding_rate != radio_cfg["coding_rate"] + if coding_rate_changed: + setattr(radio, "coding_rate", radio_cfg["coding_rate"]) + + if current_spreading_factor != radio_cfg["spreading_factor"]: + if not hasattr(radio, "set_spreading_factor"): + return False + if not radio.set_spreading_factor(radio_cfg["spreading_factor"]): + return False + + if current_bandwidth != radio_cfg["bandwidth"]: + if not hasattr(radio, "set_bandwidth"): + return False + if not radio.set_bandwidth(radio_cfg["bandwidth"]): + return False + elif coding_rate_changed: + if hasattr(radio, "set_bandwidth"): + if not radio.set_bandwidth(radio_cfg["bandwidth"]): + return False + elif hasattr(radio, "set_spreading_factor"): + if not radio.set_spreading_factor(radio_cfg["spreading_factor"]): + return False + else: + return False + + self._sync_repeater_handler_radio_config(radio_cfg) + logger.info("Applied live radio configuration to running daemon") + return True + except Exception as e: + logger.error(f"Failed to apply live radio config: {e}", exc_info=True) + return False def save_to_file(self) -> bool: """ @@ -66,6 +189,7 @@ def live_update_daemon(self, sections: Optional[List[str]] = None) -> bool: try: daemon_config = self.daemon.config + live_update_ok = True # Default sections to update if not specified if sections is None: @@ -112,8 +236,18 @@ def live_update_daemon(self, sections: Optional[List[str]] = None) -> bool: path_hash_mode = 0 self.daemon.dispatcher.set_default_path_hash_mode(path_hash_mode) logger.info(f"Reloaded path hash mode: mesh.path_hash_mode={path_hash_mode}") + + if 'radio_type' in sections: + logger.info("radio_type change detected; service restart required") + live_update_ok = False + + if 'kiss' in sections and self._kiss_transport_restart_required(): + live_update_ok = False + + if 'radio' in sections: + live_update_ok = self._apply_live_radio_config() and live_update_ok - return True + return live_update_ok except Exception as e: logger.error(f"Failed to live update daemon config: {e}", exc_info=True) @@ -141,7 +275,7 @@ def update_and_save(self, - live_updated: bool - Whether daemon was live updated - error: str (optional) - Error message if failed """ - result = { + result: Dict[str, Any] = { "success": False, "saved": False, "live_updated": False diff --git a/repeater/data_acquisition/__init__.py b/repeater/data_acquisition/__init__.py index c0134218..0c1f2382 100644 --- a/repeater/data_acquisition/__init__.py +++ b/repeater/data_acquisition/__init__.py @@ -1,5 +1,6 @@ from .glass_handler import GlassHandler +from .gps_service import GPSService from .rrdtool_handler import RRDToolHandler from .sqlite_handler import SQLiteHandler from .storage_collector import StorageCollector -__all__ = ["SQLiteHandler", "RRDToolHandler", "StorageCollector", "GlassHandler"] +__all__ = ["SQLiteHandler", "RRDToolHandler", "StorageCollector", "GlassHandler", "GPSService"] diff --git a/repeater/data_acquisition/gps_service.py b/repeater/data_acquisition/gps_service.py new file mode 100644 index 00000000..1be44425 --- /dev/null +++ b/repeater/data_acquisition/gps_service.py @@ -0,0 +1,1166 @@ +""" +GPS/NMEA acquisition and diagnostics support. + +The service intentionally keeps the NMEA parser local and dependency-light. It +accepts raw NMEA sentences from a serial receiver or from a file source used by +external bridge processes, then exposes a JSON-serializable snapshot for the +HTTP API. +""" + +from __future__ import annotations + +import json +import logging +import math +import threading +import time +from collections import Counter, deque +from copy import deepcopy +from datetime import datetime, timezone +from pathlib import Path +from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple + +logger = logging.getLogger("GPSService") + + +FIX_QUALITY_LABELS = { + 0: "no fix", + 1: "GPS", + 2: "DGPS", + 4: "RTK fixed", + 5: "RTK float", + 6: "estimated", + 7: "manual", + 8: "simulation", +} + +GSA_FIX_TYPE_LABELS = { + 1: "no fix", + 2: "2D fix", + 3: "3D fix", +} + + +def _to_float(value: Any) -> Optional[float]: + if value in (None, ""): + return None + try: + result = float(value) + except (TypeError, ValueError): + return None + return result if math.isfinite(result) else None + + +def _to_int(value: Any) -> Optional[int]: + if value in (None, ""): + return None + try: + return int(value) + except (TypeError, ValueError): + return None + + +def _is_valid_latitude(value: Optional[float]) -> bool: + return value is not None and -90.0 <= value <= 90.0 + + +def _is_valid_longitude(value: Optional[float]) -> bool: + return value is not None and -180.0 <= value <= 180.0 + + +def _is_zero_coordinate(latitude: Optional[float], longitude: Optional[float]) -> bool: + return latitude == 0.0 and longitude == 0.0 + + +def _normalize_precision_digits(value: Any) -> Optional[int]: + digits = _to_int(value) + if digits is None: + return None + return max(0, min(8, digits)) + + +def _nmea_checksum(payload: str) -> int: + checksum = 0 + for char in payload: + checksum ^= ord(char) + return checksum + + +def _parse_lat_lon(value: str, hemisphere: str) -> Optional[float]: + if not value or not hemisphere: + return None + + dot = value.find(".") + if dot < 0: + dot = len(value) + + # Latitude is ddmm.mmmm, longitude is dddmm.mmmm. + degree_digits = dot - 2 + if degree_digits <= 0: + return None + + try: + degrees = float(value[:degree_digits]) + minutes = float(value[degree_digits:]) + except ValueError: + return None + + decimal = degrees + minutes / 60.0 + if hemisphere.upper() in ("S", "W"): + decimal *= -1 + return round(decimal, 8) + + +def _format_time(value: str) -> Optional[str]: + if not value or len(value) < 6: + return None + try: + hour = int(value[0:2]) + minute = int(value[2:4]) + second_float = float(value[4:]) + except ValueError: + return None + second = int(second_float) + microsecond = int(round((second_float - second) * 1_000_000)) + if microsecond >= 1_000_000: + second += 1 + microsecond -= 1_000_000 + try: + return f"{hour:02d}:{minute:02d}:{second:02d}.{microsecond:06d}Z" + except ValueError: + return None + + +def _format_date(value: str) -> Optional[str]: + if not value or len(value) != 6: + return None + try: + day = int(value[0:2]) + month = int(value[2:4]) + year_2 = int(value[4:6]) + except ValueError: + return None + + # NMEA RMC uses two-digit years. GPS modules in this project are modern, + # but keep 1980-2079 rollover behavior for old sample data. + year = 2000 + year_2 if year_2 < 80 else 1900 + year_2 + try: + return datetime(year, month, day, tzinfo=timezone.utc).date().isoformat() + except ValueError: + return None + + +def _combine_datetime_utc(date_value: Optional[str], time_value: Optional[str]) -> Optional[str]: + if not date_value or not time_value: + return None + try: + time_part = time_value.rstrip("Z") + return f"{date_value}T{time_part}+00:00" + except Exception: + return None + + +def _parse_datetime_utc(value: Optional[str]) -> Optional[datetime]: + if not value: + return None + try: + parsed = datetime.fromisoformat(value.replace("Z", "+00:00")) + except ValueError: + return None + if parsed.tzinfo is None: + parsed = parsed.replace(tzinfo=timezone.utc) + return parsed.astimezone(timezone.utc) + + +def _set_system_clock_from_datetime(value: datetime): + if not hasattr(time, "clock_settime") or not hasattr(time, "CLOCK_REALTIME"): + raise RuntimeError("time.clock_settime(CLOCK_REALTIME) is not available") + time.clock_settime(time.CLOCK_REALTIME, value.timestamp()) + + +class NMEAParser: + """Small NMEA parser focused on diagnostics fields used by GPS receivers.""" + + def __init__( + self, + *, + validate_checksum: bool = True, + require_checksum: bool = False, + retain_sentences: int = 25, + stale_after_seconds: float = 10.0, + ): + self.validate_checksum = validate_checksum + self.require_checksum = require_checksum + self.retain_sentences = max(0, int(retain_sentences)) + self.stale_after_seconds = max(1.0, float(stale_after_seconds)) + self._lock = threading.RLock() + self._reset_unlocked() + + def _reset_unlocked(self): + self.position: Dict[str, Any] = { + "latitude": None, + "longitude": None, + "altitude_m": None, + "geoid_separation_m": None, + } + self.motion: Dict[str, Any] = { + "speed_knots": None, + "speed_kmh": None, + "course_degrees": None, + "magnetic_variation_degrees": None, + } + self.accuracy: Dict[str, Any] = { + "hdop": None, + "pdop": None, + "vdop": None, + } + self.time_data: Dict[str, Any] = { + "utc_time": None, + "date": None, + "datetime_utc": None, + } + self.fix: Dict[str, Any] = { + "valid": False, + "status": None, + "quality": None, + "quality_label": FIX_QUALITY_LABELS[0], + "gsa_fix_type": None, + "gsa_fix_type_label": None, + } + self.satellites: Dict[str, Any] = { + "used_count": None, + "used_prns": [], + "in_view_count": None, + "in_view": [], + "snr": { + "min": None, + "max": None, + "avg": None, + }, + } + self.nmea: Dict[str, Any] = { + "last_sentence": None, + "last_sentence_type": None, + "last_talker": None, + "seen_sentence_types": [], + "sentence_counters": {}, + "valid_checksum_count": 0, + "invalid_checksum_count": 0, + "missing_checksum_count": 0, + "recent_sentences": [], + } + self.raw_attributes: Dict[str, Any] = {} + self.last_update = None + self.last_error = None + self._sentence_counters: Counter = Counter() + self._recent_sentences = deque(maxlen=self.retain_sentences) + self._unhandled_sentence_types = set() + + def reset(self): + with self._lock: + self._reset_unlocked() + + def ingest_many(self, lines: Iterable[str]): + for line in lines: + self.ingest_sentence(line) + + def ingest_sentence(self, sentence: str) -> bool: + parsed = self._split_sentence(sentence) + with self._lock: + if parsed is None: + return False + + raw, payload, checksum_valid, talker, sentence_type, fields = parsed + if checksum_valid is False: + self.nmea["invalid_checksum_count"] += 1 + self.last_error = "NMEA checksum mismatch" + if self.validate_checksum: + return False + elif checksum_valid is True: + self.nmea["valid_checksum_count"] += 1 + else: + self.nmea["missing_checksum_count"] += 1 + if self.require_checksum: + self.last_error = "NMEA checksum missing" + return False + + now = time.time() + self.last_update = now + self.last_error = None + self._sentence_counters[sentence_type] += 1 + self.nmea["last_sentence"] = raw + self.nmea["last_sentence_type"] = sentence_type + self.nmea["last_talker"] = talker + self.nmea["seen_sentence_types"] = sorted(self._sentence_counters.keys()) + self.nmea["sentence_counters"] = dict(self._sentence_counters) + if self.retain_sentences: + self._recent_sentences.append( + { + "timestamp": datetime.fromtimestamp(now, timezone.utc).isoformat(), + "sentence_type": sentence_type, + "sentence": raw, + } + ) + self.nmea["recent_sentences"] = list(self._recent_sentences) + + handler = getattr(self, f"_parse_{sentence_type.lower()}", None) + if handler: + handler(fields) + else: + self._unhandled_sentence_types.add(sentence_type) + self.raw_attributes["unhandled_sentence_types"] = sorted( + self._unhandled_sentence_types + ) + + self._refresh_derived_unlocked() + return True + + def _split_sentence( + self, sentence: str + ) -> Optional[Tuple[str, str, Optional[bool], str, str, List[str]]]: + raw = (sentence or "").strip() + if not raw: + return None + + if raw.startswith("$"): + raw_no_dollar = raw[1:] + else: + raw_no_dollar = raw + + payload = raw_no_dollar + checksum_valid: Optional[bool] = None + if "*" in raw_no_dollar: + payload, supplied_checksum = raw_no_dollar.split("*", 1) + supplied_checksum = supplied_checksum[:2] + try: + expected = int(supplied_checksum, 16) + checksum_valid = _nmea_checksum(payload) == expected + except ValueError: + checksum_valid = False + + fields = payload.split(",") + if not fields or len(fields[0]) < 3: + return None + + sentence_id = fields[0].upper() + talker = sentence_id[:-3] or None + sentence_type = sentence_id[-3:] + return raw, payload, checksum_valid, talker, sentence_type, fields + + def _parse_rmc(self, fields: List[str]): + # $GPRMC,time,status,lat,N,lon,E,sog,cog,date,magvar,E/W,... + self.raw_attributes["RMC"] = { + "utc_time_raw": self._field(fields, 1), + "status": self._field(fields, 2), + "date_raw": self._field(fields, 9), + "mode": self._field(fields, 12), + "nav_status": self._field(fields, 13), + } + status = (self._field(fields, 2) or "").upper() + self.fix["status"] = "valid" if status == "A" else "invalid" if status == "V" else status + self.fix["valid"] = status == "A" or bool(self.fix.get("quality")) + if status == "A" and self.fix.get("quality") is None: + self.fix["quality_label"] = "RMC valid" + + latitude = _parse_lat_lon(self._field(fields, 3), self._field(fields, 4)) + longitude = _parse_lat_lon(self._field(fields, 5), self._field(fields, 6)) + if latitude is not None: + self.position["latitude"] = latitude + if longitude is not None: + self.position["longitude"] = longitude + + speed_knots = _to_float(self._field(fields, 7)) + if speed_knots is not None: + self.motion["speed_knots"] = speed_knots + self.motion["speed_kmh"] = round(speed_knots * 1.852, 3) + + course = _to_float(self._field(fields, 8)) + if course is not None: + self.motion["course_degrees"] = course + + mag_var = _to_float(self._field(fields, 10)) + mag_dir = (self._field(fields, 11) or "").upper() + if mag_var is not None: + self.motion["magnetic_variation_degrees"] = -mag_var if mag_dir == "W" else mag_var + + utc_time = _format_time(self._field(fields, 1)) + date = _format_date(self._field(fields, 9)) + if utc_time: + self.time_data["utc_time"] = utc_time + if date: + self.time_data["date"] = date + self.time_data["datetime_utc"] = _combine_datetime_utc( + self.time_data.get("date"), self.time_data.get("utc_time") + ) + + def _parse_gga(self, fields: List[str]): + # $GPGGA,time,lat,N,lon,E,quality,num_sats,hdop,alt,M,geoid,M,... + quality = _to_int(self._field(fields, 6)) + satellites_used = _to_int(self._field(fields, 7)) + self.raw_attributes["GGA"] = { + "utc_time_raw": self._field(fields, 1), + "fix_quality_raw": self._field(fields, 6), + "dgps_age": self._field(fields, 13), + "dgps_station_id": self._field(fields, 14), + } + if quality is not None: + self.fix["quality"] = quality + self.fix["quality_label"] = FIX_QUALITY_LABELS.get(quality, f"quality {quality}") + self.fix["valid"] = quality > 0 or self.fix.get("status") == "valid" + + latitude = _parse_lat_lon(self._field(fields, 2), self._field(fields, 3)) + longitude = _parse_lat_lon(self._field(fields, 4), self._field(fields, 5)) + if latitude is not None: + self.position["latitude"] = latitude + if longitude is not None: + self.position["longitude"] = longitude + + if satellites_used is not None: + self.satellites["used_count"] = satellites_used + + hdop = _to_float(self._field(fields, 8)) + if hdop is not None: + self.accuracy["hdop"] = hdop + + altitude = _to_float(self._field(fields, 9)) + if altitude is not None: + self.position["altitude_m"] = altitude + + geoid_sep = _to_float(self._field(fields, 11)) + if geoid_sep is not None: + self.position["geoid_separation_m"] = geoid_sep + + utc_time = _format_time(self._field(fields, 1)) + if utc_time: + self.time_data["utc_time"] = utc_time + self.time_data["datetime_utc"] = _combine_datetime_utc( + self.time_data.get("date"), self.time_data.get("utc_time") + ) + + def _parse_gsa(self, fields: List[str]): + # $GPGSA,mode,fix_type,sv1..sv12,pdop,hdop,vdop + fix_type = _to_int(self._field(fields, 2)) + used_prns = [value for value in fields[3:15] if value] + self.raw_attributes["GSA"] = { + "mode": self._field(fields, 1), + } + if fix_type is not None: + self.fix["gsa_fix_type"] = fix_type + self.fix["gsa_fix_type_label"] = GSA_FIX_TYPE_LABELS.get(fix_type, f"type {fix_type}") + self.fix["valid"] = fix_type > 1 or self.fix.get("valid", False) + + self.satellites["used_prns"] = used_prns + if used_prns: + self.satellites["used_count"] = len(used_prns) + + pdop = _to_float(self._field(fields, 15)) + hdop = _to_float(self._field(fields, 16)) + vdop = _to_float(self._field(fields, 17)) + if pdop is not None: + self.accuracy["pdop"] = pdop + if hdop is not None: + self.accuracy["hdop"] = hdop + if vdop is not None: + self.accuracy["vdop"] = vdop + + def _parse_gsv(self, fields: List[str]): + # $GPGSV,total_msgs,msg_num,sats_in_view,prn,elev,az,snr,... + total_messages = _to_int(self._field(fields, 1)) + message_number = _to_int(self._field(fields, 2)) + satellites_in_view = _to_int(self._field(fields, 3)) + current = [] if message_number == 1 else list(self.satellites.get("in_view") or []) + + for idx in range(4, len(fields), 4): + prn = self._field(fields, idx) + if not prn: + continue + satellite = { + "prn": prn, + "elevation_degrees": _to_int(self._field(fields, idx + 1)), + "azimuth_degrees": _to_int(self._field(fields, idx + 2)), + "snr_db": _to_float(self._field(fields, idx + 3)), + } + current.append(satellite) + + # Deduplicate by PRN while preserving last value for each satellite. + by_prn = {sat["prn"]: sat for sat in current} + in_view = sorted(by_prn.values(), key=lambda item: item["prn"]) + self.satellites["in_view"] = in_view + self.satellites["in_view_count"] = satellites_in_view + self.raw_attributes["GSV"] = { + "total_messages": total_messages, + "last_message_number": message_number, + } + + def _parse_vtg(self, fields: List[str]): + # $GPVTG,cog,T,cog_magnetic,M,sog_knots,N,sog_kmh,K,... + course_true = _to_float(self._field(fields, 1)) + course_magnetic = _to_float(self._field(fields, 3)) + speed_knots = _to_float(self._field(fields, 5)) + speed_kmh = _to_float(self._field(fields, 7)) + if course_true is not None: + self.motion["course_degrees"] = course_true + if speed_knots is not None: + self.motion["speed_knots"] = speed_knots + if speed_kmh is not None: + self.motion["speed_kmh"] = speed_kmh + self.raw_attributes["VTG"] = { + "course_magnetic_degrees": course_magnetic, + "mode": self._field(fields, 9), + } + + @staticmethod + def _field(fields: List[str], index: int) -> str: + return fields[index] if index < len(fields) else "" + + def _normalize_raw_attributes_unlocked(self): + if self._unhandled_sentence_types: + self.raw_attributes["unhandled_sentence_types"] = sorted(self._unhandled_sentence_types) + + def _refresh_derived_unlocked(self): + snrs = [ + sat.get("snr_db") + for sat in self.satellites.get("in_view", []) + if sat.get("snr_db") is not None + ] + if snrs: + self.satellites["snr"] = { + "min": min(snrs), + "max": max(snrs), + "avg": round(sum(snrs) / len(snrs), 3), + } + else: + self.satellites["snr"] = {"min": None, "max": None, "avg": None} + self._normalize_raw_attributes_unlocked() + + def snapshot(self) -> Dict[str, Any]: + with self._lock: + now = time.time() + age = now - self.last_update if self.last_update else None + if age is not None and age < 0: + age = 0.0 + stale = age is None or age > self.stale_after_seconds + fix_valid = bool(self.fix.get("valid")) and not stale + if self.last_error: + state = "error" + elif age is None: + state = "no_data" + elif stale: + state = "stale" + elif fix_valid: + state = "valid_fix" + else: + state = "invalid_fix" + + return { + "status": { + "state": state, + "fix_valid": fix_valid, + "stale": stale, + "age_seconds": round(age, 3) if age is not None else None, + "last_update": ( + datetime.fromtimestamp(self.last_update, timezone.utc).isoformat() + if self.last_update + else None + ), + "last_error": self.last_error, + }, + "fix": deepcopy(self.fix), + "position": deepcopy(self.position), + "motion": deepcopy(self.motion), + "accuracy": deepcopy(self.accuracy), + "time": deepcopy(self.time_data), + "satellites": deepcopy(self.satellites), + "nmea": deepcopy(self.nmea), + "raw_attributes": deepcopy(self.raw_attributes), + } + + +class GPSService: + """Runtime GPS acquisition service.""" + + def __init__( + self, + config: Dict[str, Any], + *, + clock_setter: Optional[Callable[[datetime], None]] = None, + time_provider: Optional[Callable[[], float]] = None, + location_update_callback: Optional[Callable[[Dict[str, Any]], bool]] = None, + ): + gps_config = config.get("gps", {}) if isinstance(config, dict) else {} + repeater_config = config.get("repeater", {}) if isinstance(config, dict) else {} + self.config = gps_config + self.enabled = bool(gps_config.get("enabled", False)) + self.api_fallback_to_config_location = bool( + gps_config.get("api_fallback_to_config_location", True) + ) + self.advertise_gps_location = bool( + gps_config.get("advertise_gps_location", False) + ) + self.location_precision_digits = _normalize_precision_digits( + gps_config.get("location_precision_digits") + ) + self.source = str(gps_config.get("source", "serial")).lower() + self.device = gps_config.get("device", "/dev/serial0") + self.baud_rate = int(gps_config.get("baud_rate", 9600)) + self.read_timeout_seconds = float(gps_config.get("read_timeout_seconds", 1.0)) + self.reconnect_interval_seconds = float(gps_config.get("reconnect_interval_seconds", 5.0)) + self.poll_interval_seconds = float(gps_config.get("poll_interval_seconds", 2.0)) + self.source_path = gps_config.get("source_path") or gps_config.get("snapshot_path") + self.repeater_config = repeater_config + self.time_sync_enabled = bool(gps_config.get("time_sync_enabled", True)) + self.time_sync_interval_seconds = max( + 1.0, float(gps_config.get("time_sync_interval_seconds", 3600.0)) + ) + self.time_sync_min_offset_seconds = max( + 0.0, float(gps_config.get("time_sync_min_offset_seconds", 1.0)) + ) + self.time_sync_min_valid_year = int(gps_config.get("time_sync_min_valid_year", 2020)) + self._clock_setter = clock_setter or _set_system_clock_from_datetime + self._time_provider = time_provider or time.time + self.persist_gps_fix_enabled = bool( + gps_config.get("persist_gps_fix_to_config", False) + ) + self.persist_gps_fix_interval_seconds = max( + 1.0, float(gps_config.get("persist_gps_fix_interval_seconds", 600.0)) + ) + self._location_update_callback = location_update_callback + self._location_update_lock = threading.RLock() + self._last_location_update_monotonic: Optional[float] = None + self._location_update_status: Dict[str, Any] = { + "enabled": self.persist_gps_fix_enabled, + "state": "disabled" if not self.persist_gps_fix_enabled else "waiting_for_fix", + "last_attempt": None, + "last_success": None, + "last_error": None, + "last_latitude": None, + "last_longitude": None, + "interval_seconds": self.persist_gps_fix_interval_seconds, + } + self._time_sync_lock = threading.RLock() + self._last_time_sync_monotonic: Optional[float] = None + self._time_sync_status: Dict[str, Any] = { + "enabled": self.time_sync_enabled, + "state": "disabled" if not self.time_sync_enabled else "waiting_for_fix", + "last_attempt": None, + "last_success": None, + "last_error": None, + "last_gps_time": None, + "last_offset_seconds": None, + "interval_seconds": self.time_sync_interval_seconds, + "min_offset_seconds": self.time_sync_min_offset_seconds, + "min_valid_year": self.time_sync_min_valid_year, + } + self.parser = NMEAParser( + validate_checksum=bool(gps_config.get("validate_checksum", True)), + require_checksum=bool(gps_config.get("require_checksum", False)), + retain_sentences=int(gps_config.get("retain_sentences", 25)), + stale_after_seconds=float(gps_config.get("stale_after_seconds", 10.0)), + ) + self._stop_event = threading.Event() + self._thread: Optional[threading.Thread] = None + self._running = False + self._last_source_error: Optional[str] = None + self._last_file_content: Optional[str] = None + + def start(self): + if not self.enabled: + return + if self._thread and self._thread.is_alive(): + return + + target = self._run_file_loop if self.source == "file" else self._run_serial_loop + self._stop_event.clear() + self._thread = threading.Thread(target=target, name="gps-service", daemon=True) + self._thread.start() + self._running = True + logger.info("GPS service started using %s source", self.source) + + def stop(self, timeout: float = 2.0): + self._stop_event.set() + if self._thread and self._thread.is_alive(): + self._thread.join(timeout=timeout) + self._running = False + logger.info("GPS service stopped") + + def ingest_sentence(self, sentence: str) -> bool: + accepted = self.parser.ingest_sentence(sentence) + if accepted: + self._maybe_sync_system_time() + self._maybe_update_repeater_location() + return accepted + + def get_summary(self) -> Dict[str, Any]: + snapshot = self.get_snapshot() + return { + "enabled": snapshot["enabled"], + "source": snapshot["source"], + "status": snapshot["status"], + "fix": { + "valid": snapshot["fix"].get("valid"), + "quality": snapshot["fix"].get("quality"), + "quality_label": snapshot["fix"].get("quality_label"), + }, + "position": snapshot["position"], + "position_meta": snapshot.get("position_meta"), + "gps_position": snapshot.get("gps_position"), + "manual_position": snapshot.get("manual_position"), + "time_sync": snapshot.get("time_sync"), + "location_update": snapshot.get("location_update"), + "satellites": { + "used_count": snapshot["satellites"].get("used_count"), + "in_view_count": snapshot["satellites"].get("in_view_count"), + "snr": snapshot["satellites"].get("snr"), + }, + "repeater_location": snapshot.get("repeater_location"), + } + + def _apply_precision(self, value: Optional[float]) -> Optional[float]: + if value is None: + return None + if self.location_precision_digits is None: + return value + return round(value, self.location_precision_digits) + + def _resolve_repeater_location(self, snapshot: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + fallback_lat = _to_float(self.repeater_config.get("latitude")) + fallback_lon = _to_float(self.repeater_config.get("longitude")) + fallback_location = { + "latitude": fallback_lat if fallback_lat is not None else 0.0, + "longitude": fallback_lon if fallback_lon is not None else 0.0, + "source": "config", + "advertise_gps_location": self.advertise_gps_location, + "location_precision_digits": self.location_precision_digits, + } + + if not self.advertise_gps_location: + return fallback_location + + snapshot = snapshot or {} + gps_fix_valid = bool(snapshot.get("status", {}).get("fix_valid")) + gps_position = snapshot.get("gps_position") or {} + gps_lat = _to_float(gps_position.get("latitude")) + gps_lon = _to_float(gps_position.get("longitude")) + + if gps_fix_valid and _is_valid_latitude(gps_lat) and _is_valid_longitude(gps_lon): + return { + "latitude": self._apply_precision(gps_lat), + "longitude": self._apply_precision(gps_lon), + "source": "gps", + "advertise_gps_location": True, + "location_precision_digits": self.location_precision_digits, + } + + return { + **fallback_location, + "source": "config_fallback_no_valid_gps_fix", + } + + def get_repeater_location(self) -> Dict[str, Any]: + """Return coordinates used for repeater-originated location fields. + + This is intentionally opt-in for GPS-derived coordinates so deployments + can keep static site coordinates unless explicitly configured. + """ + snapshot = self.parser.snapshot() + self._apply_effective_position(snapshot) + return self._resolve_repeater_location(snapshot) + + def get_snapshot(self) -> Dict[str, Any]: + snapshot = self.parser.snapshot() + self._apply_effective_position(snapshot) + snapshot.update( + { + "enabled": self.enabled, + "running": self._running and bool(self._thread and self._thread.is_alive()), + "source": { + "type": self.source, + "device": self.device if self.source == "serial" else None, + "baud_rate": self.baud_rate if self.source == "serial" else None, + "source_path": self.source_path if self.source == "file" else None, + "read_timeout_seconds": self.read_timeout_seconds, + "poll_interval_seconds": self.poll_interval_seconds, + "stale_after_seconds": self.parser.stale_after_seconds, + "advertise_gps_location": self.advertise_gps_location, + "location_precision_digits": self.location_precision_digits, + }, + "time_sync": self._get_time_sync_status(snapshot), + "repeater_location": self._resolve_repeater_location(snapshot), + "location_update": self._get_location_update_status(snapshot), + } + ) + if not self.enabled: + snapshot["status"]["state"] = "disabled" + snapshot["status"]["last_error"] = None + elif self._last_source_error: + snapshot["status"]["last_error"] = self._last_source_error + if snapshot["status"]["state"] in ("no_data", "stale"): + snapshot["status"]["state"] = "error" + return snapshot + + def _get_location_update_status(self, snapshot: Dict[str, Any]) -> Dict[str, Any]: + with self._location_update_lock: + status = deepcopy(self._location_update_status) + + if not self.enabled or not self.persist_gps_fix_enabled: + status["state"] = "disabled" + return status + if self._location_update_callback is None: + status["state"] = "unconfigured" + return status + if status.get("state") in ("updated", "error", "skipped"): + return status + if not snapshot.get("status", {}).get("fix_valid"): + status["state"] = "waiting_for_fix" + else: + position = snapshot.get("gps_position") or snapshot.get("position") or {} + latitude = _to_float(position.get("latitude")) + longitude = _to_float(position.get("longitude")) + if not _is_valid_latitude(latitude) or not _is_valid_longitude(longitude): + status["state"] = "waiting_for_position" + elif _is_zero_coordinate(latitude, longitude): + status["state"] = "waiting_for_position" + else: + status["state"] = "ready" + return status + + def _record_location_update_status( + self, + *, + state: str, + latitude: Optional[float] = None, + longitude: Optional[float] = None, + error: Optional[str] = None, + success: bool = False, + ): + timestamp = datetime.now(timezone.utc).isoformat() + with self._location_update_lock: + self._location_update_status.update( + { + "enabled": self.persist_gps_fix_enabled, + "state": state, + "last_attempt": timestamp, + "last_error": error, + "last_latitude": latitude, + "last_longitude": longitude, + "interval_seconds": self.persist_gps_fix_interval_seconds, + } + ) + if success: + self._location_update_status["last_success"] = timestamp + + def _maybe_update_repeater_location(self): + if not self.enabled or not self.persist_gps_fix_enabled: + return + if self._location_update_callback is None: + return + + now_monotonic = time.monotonic() + with self._location_update_lock: + if ( + self._last_location_update_monotonic is not None + and now_monotonic - self._last_location_update_monotonic + < self.persist_gps_fix_interval_seconds + ): + return + + snapshot = self.parser.snapshot() + if not snapshot.get("status", {}).get("fix_valid"): + return + + position = snapshot.get("position") or {} + latitude = _to_float(position.get("latitude")) + longitude = _to_float(position.get("longitude")) + if not _is_valid_latitude(latitude) or not _is_valid_longitude(longitude): + return + if _is_zero_coordinate(latitude, longitude): + return + + effective_latitude = self._apply_precision(latitude) + effective_longitude = self._apply_precision(longitude) + if not _is_valid_latitude(effective_latitude) or not _is_valid_longitude( + effective_longitude + ): + return + + self._last_location_update_monotonic = now_monotonic + payload = { + "latitude": effective_latitude, + "longitude": effective_longitude, + "altitude_m": _to_float(position.get("altitude_m")), + "fix": deepcopy(snapshot.get("fix") or {}), + "status": deepcopy(snapshot.get("status") or {}), + "time": deepcopy(snapshot.get("time") or {}), + "location_precision_digits": self.location_precision_digits, + } + try: + updated = bool(self._location_update_callback(payload)) + except Exception as exc: + self._record_location_update_status( + state="error", + latitude=effective_latitude, + longitude=effective_longitude, + error=f"{type(exc).__name__}: {exc}", + ) + logger.warning("GPS repeater location update failed: %s", exc) + return + + self._record_location_update_status( + state="updated" if updated else "skipped", + latitude=effective_latitude, + longitude=effective_longitude, + success=updated, + ) + + @staticmethod + def _extract_manual_position(repeater_config: Dict[str, Any]) -> Optional[Dict[str, Any]]: + latitude = _to_float(repeater_config.get("latitude")) + longitude = _to_float(repeater_config.get("longitude")) + if not _is_valid_latitude(latitude) or not _is_valid_longitude(longitude): + return None + # The packaged default is 0,0. Treat it as unset so a fresh install does + # not show Null Island while the GPS is still searching for a fix. + if _is_zero_coordinate(latitude, longitude): + return None + return { + "latitude": latitude, + "longitude": longitude, + "altitude_m": None, + "geoid_separation_m": None, + "source": "manual_config", + } + + def _apply_effective_position(self, snapshot: Dict[str, Any]): + gps_position = deepcopy(snapshot.get("position") or {}) + manual_position = deepcopy(self._extract_manual_position(self.repeater_config)) + gps_fix_valid = bool(snapshot.get("status", {}).get("fix_valid")) + use_manual = ( + self.api_fallback_to_config_location + and manual_position is not None + and not gps_fix_valid + ) + + if use_manual: + effective_position = { + **gps_position, + "latitude": manual_position["latitude"], + "longitude": manual_position["longitude"], + } + position_source = "manual_config" + position_source_label = "manual config until GPS fix" + else: + effective_position = gps_position + position_source = "gps" + position_source_label = "GPS fix" if gps_fix_valid else "GPS estimate" + + snapshot["gps_position"] = gps_position + snapshot["manual_position"] = manual_position + snapshot["position"] = effective_position + snapshot["position_meta"] = { + "source": position_source, + "source_label": position_source_label, + "policy": "fallback_to_config" + if self.api_fallback_to_config_location + else "gps_only", + "manual_config_available": manual_position is not None, + "gps_fix_valid": gps_fix_valid, + } + + def _set_source_error(self, message: Optional[str]): + self._last_source_error = message + if message: + self.parser.last_error = message + logger.warning("GPS source error: %s", message) + else: + self.parser.last_error = None + + def _get_time_sync_status(self, snapshot: Dict[str, Any]) -> Dict[str, Any]: + with self._time_sync_lock: + status = deepcopy(self._time_sync_status) + + if not self.enabled: + status["state"] = "disabled" + return status + if not self.time_sync_enabled: + status["state"] = "disabled" + return status + if status.get("state") in ("synced", "error", "in_sync", "ignored"): + return status + if not snapshot.get("status", {}).get("fix_valid"): + status["state"] = "waiting_for_fix" + elif not snapshot.get("time", {}).get("datetime_utc"): + status["state"] = "waiting_for_time" + else: + status["state"] = "ready" + return status + + def _record_time_sync_status( + self, + *, + state: str, + gps_time: Optional[datetime] = None, + offset_seconds: Optional[float] = None, + error: Optional[str] = None, + success: bool = False, + ): + timestamp = datetime.now(timezone.utc).isoformat() + with self._time_sync_lock: + self._time_sync_status.update( + { + "enabled": self.time_sync_enabled, + "state": state, + "last_attempt": timestamp, + "last_error": error, + "last_gps_time": gps_time.isoformat() if gps_time else None, + "last_offset_seconds": ( + round(offset_seconds, 3) if offset_seconds is not None else None + ), + "interval_seconds": self.time_sync_interval_seconds, + "min_offset_seconds": self.time_sync_min_offset_seconds, + "min_valid_year": self.time_sync_min_valid_year, + } + ) + if success: + self._time_sync_status["last_success"] = timestamp + + def _maybe_sync_system_time(self): + if not self.enabled or not self.time_sync_enabled: + return + + now_monotonic = time.monotonic() + with self._time_sync_lock: + if ( + self._last_time_sync_monotonic is not None + and now_monotonic - self._last_time_sync_monotonic + < self.time_sync_interval_seconds + ): + return + + snapshot = self.parser.snapshot() + if not snapshot.get("status", {}).get("fix_valid"): + return + + gps_time = _parse_datetime_utc(snapshot.get("time", {}).get("datetime_utc")) + if gps_time is None: + return + + if gps_time.year < self.time_sync_min_valid_year: + self._record_time_sync_status( + state="ignored", + gps_time=gps_time, + error=( + f"GPS time year {gps_time.year} is older than " + f"minimum {self.time_sync_min_valid_year}" + ), + ) + return + + system_now = self._time_provider() + offset_seconds = gps_time.timestamp() - system_now + self._last_time_sync_monotonic = now_monotonic + if abs(offset_seconds) < self.time_sync_min_offset_seconds: + self._record_time_sync_status( + state="in_sync", + gps_time=gps_time, + offset_seconds=offset_seconds, + success=True, + ) + return + + try: + self._clock_setter(gps_time) + except Exception as exc: + self._record_time_sync_status( + state="error", + gps_time=gps_time, + offset_seconds=offset_seconds, + error=f"{type(exc).__name__}: {exc}", + ) + logger.warning("GPS system time sync failed: %s", exc) + return + + self._record_time_sync_status( + state="synced", + gps_time=gps_time, + offset_seconds=offset_seconds, + success=True, + ) + self.parser.last_update = self._time_provider() + logger.info( + "System clock synchronized from GPS time %s (offset %.3fs)", + gps_time.isoformat(), + offset_seconds, + ) + + def _run_serial_loop(self): + try: + import serial # type: ignore + except ImportError: + self._set_source_error("pyserial is not installed") + self._running = False + return + + while not self._stop_event.is_set(): + try: + with serial.Serial( + self.device, + self.baud_rate, + timeout=self.read_timeout_seconds, + ) as port: + self._set_source_error(None) + while not self._stop_event.is_set(): + line = port.readline() + if not line: + continue + sentence = line.decode("ascii", errors="ignore").strip() + if sentence: + self.ingest_sentence(sentence) + except Exception as exc: + self._set_source_error(f"{type(exc).__name__}: {exc}") + self._stop_event.wait(self.reconnect_interval_seconds) + + self._running = False + + def _run_file_loop(self): + if not self.source_path: + self._set_source_error("gps.source_path is required for file source") + self._running = False + return + + path = Path(self.source_path) + while not self._stop_event.is_set(): + try: + content = path.read_text(encoding="utf-8") + if content != self._last_file_content: + self._last_file_content = content + self._set_source_error(None) + lines = self._extract_file_sentences(content) + for line in lines: + self.ingest_sentence(line) + except FileNotFoundError: + self._set_source_error(f"GPS source file not found: {path}") + except Exception as exc: + self._set_source_error(f"{type(exc).__name__}: {exc}") + self._stop_event.wait(self.poll_interval_seconds) + + self._running = False + + @staticmethod + def _extract_file_sentences(content: str) -> List[str]: + stripped = content.strip() + if not stripped: + return [] + if stripped.startswith("{"): + payload = json.loads(stripped) + if isinstance(payload.get("sentences"), list): + return [str(item) for item in payload["sentences"]] + if payload.get("last_sentence"): + return [str(payload["last_sentence"])] + if payload.get("nmea"): + nmea = payload["nmea"] + if isinstance(nmea, dict) and nmea.get("last_sentence"): + return [str(nmea["last_sentence"])] + if isinstance(nmea, list): + return [str(item) for item in nmea] + return [] + return [line.strip() for line in stripped.splitlines() if line.strip()] diff --git a/repeater/data_acquisition/letsmesh_handler.py b/repeater/data_acquisition/letsmesh_handler.py deleted file mode 100644 index 88c0f6a1..00000000 --- a/repeater/data_acquisition/letsmesh_handler.py +++ /dev/null @@ -1,732 +0,0 @@ -import base64 -import binascii -import json -import logging -import threading -from datetime import datetime, timedelta -from typing import Callable, Dict, List, Optional - -import paho.mqtt.client as mqtt -from nacl.signing import SigningKey - -# Try to import datetime.UTC (Python 3.11+) otherwise fallback to timezone.utc -try: - from datetime import UTC -except Exception: - from datetime import timezone - UTC = timezone.utc - -from repeater import __version__ - -# Try to import paho-mqtt error code mappings -try: - from paho.mqtt.reasoncodes import ReasonCode - - HAS_REASON_CODES = True -except ImportError: - HAS_REASON_CODES = False - -logger = logging.getLogger("LetsMeshHandler") - - -# -------------------------------------------------------------------- -# Helper: Base64URL without padding -# -------------------------------------------------------------------- -def b64url(x: bytes) -> str: - return base64.urlsafe_b64encode(x).rstrip(b"=").decode() - - -# -------------------------------------------------------------------- -# Let's Mesh MQTT Broker List (WebSocket Secure) -# -------------------------------------------------------------------- -LETSMESH_BROKERS = [ - { - "name": "Europe (LetsMesh v1)", - "host": "mqtt-eu-v1.letsmesh.net", - "port": 443, - "audience": "mqtt-eu-v1.letsmesh.net", - }, - { - "name": "US West (LetsMesh v1)", - "host": "mqtt-us-v1.letsmesh.net", - "port": 443, - "audience": "mqtt-us-v1.letsmesh.net", - }, -] - - -# ==================================================================== -# Single Broker Connection Manager -# ==================================================================== -class _BrokerConnection: - """ - Manages a single MQTT broker connection with independent lifecycle. - Internal class - not exposed publicly. - """ - - def __init__( - self, - broker: dict, - local_identity, - public_key: str, - iata_code: str, - jwt_expiry_minutes: int, - use_tls: bool, - email: str, - owner: str, - broker_index: int = 0, - on_connect_callback: Optional[Callable] = None, - on_disconnect_callback: Optional[Callable] = None, - ): - self.broker = broker - self.local_identity = local_identity - self.public_key = public_key.upper() - self.iata_code = iata_code - self.jwt_expiry_minutes = jwt_expiry_minutes - self.broker_index = broker_index - self.use_tls = use_tls - self.email = email - self.owner = owner - self._on_connect_callback = on_connect_callback - self._on_disconnect_callback = on_disconnect_callback - self._connect_time = None - self._tls_verified = False - self._running = False - self._reconnect_attempts = 0 - self._reconnect_timer = None - self._max_reconnect_delay = 300 # 5 minutes max - self._jwt_refresh_timer = None - self._shutdown_requested = False - client_id = f"meshcore_{self.public_key}_{broker['host']}" - self.client = mqtt.Client(client_id=client_id, transport="websockets") - self.client.on_connect = self._on_connect - self.client.on_disconnect = self._on_disconnect - - def _generate_jwt(self) -> str: - """Generate MeshCore-style Ed25519 JWT token""" - now = datetime.now(UTC) - - header = {"alg": "Ed25519", "typ": "JWT"} - - payload = { - "publicKey": self.public_key.upper(), - "aud": self.broker["audience"], - "iat": int(now.timestamp()), - "exp": int((now + timedelta(minutes=self.jwt_expiry_minutes)).timestamp()), - } - - # Only include email/owner for verified TLS connections - if self.use_tls and self._tls_verified and (self.email or self.owner): - payload["email"] = self.email - payload["owner"] = self.owner - else: - payload["email"] = "" - payload["owner"] = "" - - # Encode header and payload (compact JSON - no spaces) - header_b64 = b64url(json.dumps(header, separators=(",", ":")).encode()) - payload_b64 = b64url(json.dumps(payload, separators=(",", ":")).encode()) - - signing_input = f"{header_b64}.{payload_b64}".encode() - - # Sign using LocalIdentity (supports both standard and firmware keys) - try: - signature = self.local_identity.sign(signing_input) - except Exception as e: - logger.error(f"JWT signing failed for {self.broker['name']}: {e}") - logger.error(f" - public_key: {self.public_key}") - logger.error(f" - signing_input length: {len(signing_input)}") - raise - - signature_hex = binascii.hexlify(signature).decode() - token = f"{header_b64}.{payload_b64}.{signature_hex}" - - logger.debug(f"JWT token generated for {self.broker['name']}: {token[:50]}...") - - return token - - def _on_connect(self, client, userdata, flags, rc): - """MQTT connection callback""" - if rc == 0: - logger.info(f"Connected to {self.broker['name']}") - self._running = True - self._reconnect_attempts = 0 # Reset counter on success - self._schedule_jwt_refresh() # Schedule proactive JWT refresh - if self._on_connect_callback: - self._on_connect_callback(self.broker["name"]) - else: - error_msg = get_mqtt_error_message(rc, is_disconnect=False) - logger.error(f"Failed to connect to {self.broker['name']}: {error_msg}") - self._schedule_reconnect() - - def _on_disconnect(self, client, userdata, rc): - """MQTT disconnection callback""" - was_running = self._running - self._running = False - - if self._shutdown_requested: - logger.info(f"Clean disconnect from {self.broker['name']}") - if self._on_disconnect_callback: - self._on_disconnect_callback(self.broker["name"]) - return - - if rc != 0: # Unexpected disconnect - error_msg = get_mqtt_error_message(rc, is_disconnect=True) - logger.warning(f"Disconnected from {self.broker['name']} (rc={rc}): {error_msg}") - if was_running: # Only reconnect if we were intentionally connected - self._schedule_reconnect(reason=error_msg) - else: - logger.info(f"Clean disconnect from {self.broker['name']}") - - if self._on_disconnect_callback: - self._on_disconnect_callback(self.broker["name"]) - - def _schedule_reconnect(self, reason: str = "connection lost"): - """Schedule reconnection with exponential backoff""" - if self._shutdown_requested: - return - - if self._reconnect_timer: - self._reconnect_timer.cancel() - - # Exponential backoff: 5s, 10s, 20s, 40s, 80s, up to max - delay = min(5 * (2**self._reconnect_attempts), self._max_reconnect_delay) - self._reconnect_attempts += 1 - - logger.info( - f"Scheduling reconnect to {self.broker['name']} in {delay}s (attempt {self._reconnect_attempts}, reason: {reason})" - ) - self._reconnect_timer = threading.Timer(delay, lambda: self._attempt_reconnect(reason)) - self._reconnect_timer.daemon = True - self._reconnect_timer.start() - - def _attempt_reconnect(self, reason: str = "connection lost"): - """Attempt to reconnect to broker with fresh JWT""" - if self._shutdown_requested: - return - - try: - logger.info(f"Attempting reconnection to {self.broker['name']} (reason: {reason})...") - - # Stop the loop if it's still running (websocket mode requires clean restart) - try: - self.client.loop_stop() - except Exception: - pass - - self._set_jwt_credentials() - - # Reconnect and restart loop - self.client.connect(self.broker["host"], self.broker["port"], keepalive=60) - self.client.loop_start() - self._loop_running = True - except Exception as e: - logger.error(f"Reconnection failed for {self.broker['name']}: {e}") - self._schedule_reconnect() # Try again later - - def _set_jwt_credentials(self): - """Set JWT token credentials before connecting (CONNECT handshake only)""" - try: - token = self._generate_jwt() - username = f"v1_{self.public_key}" - self.client.username_pw_set(username=username, password=token) - self._connect_time = datetime.now(UTC) - logger.debug(f"JWT credentials set for {self.broker['name']}") - logger.debug(f"Using username: {username}") - logger.debug(f"Public key: {self.public_key[:16]}...{self.public_key[-16:]}") - except Exception as e: - logger.error(f"Failed to set JWT credentials for {self.broker['name']}: {e}") - raise - - def connect(self): - """Establish connection to broker""" - self._shutdown_requested = False - - # Conditional TLS setup - if self.use_tls: - import ssl - - self.client.tls_set(cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS_CLIENT) - self.client.tls_insecure_set(False) - self._tls_verified = True - protocol = "wss" - else: - protocol = "ws" - - # Set JWT credentials before CONNECT handshake - self._set_jwt_credentials() - - logger.info( - f"Connecting to {self.broker['name']} " - f"({protocol}://{self.broker['host']}:{self.broker['port']}) ..." - ) - - self.client.connect(self.broker["host"], self.broker["port"], keepalive=60) - self.client.loop_start() - self._loop_running = True - - def disconnect(self): - """Disconnect from broker""" - self._shutdown_requested = True - self._running = False - self._loop_running = False - - # Cancel any pending timers - if self._reconnect_timer: - self._reconnect_timer.cancel() - self._reconnect_timer = None - if self._jwt_refresh_timer: - self._jwt_refresh_timer.cancel() - self._jwt_refresh_timer = None - - self.client.loop_stop() - self.client.disconnect() - logger.info(f"Disconnected from {self.broker['name']}") - - def publish(self, topic: str, payload: str, retain: bool = False): - """Publish message to broker""" - if self._running: - result = self.client.publish(topic, payload, retain=retain) - return result - return None - - def is_connected(self) -> bool: - """Check if connection is active""" - return self._running - - def has_pending_reconnect(self) -> bool: - """Check if a reconnection is scheduled""" - return self._reconnect_timer is not None and self._reconnect_timer.is_alive() - - def should_reconnect_for_token_expiry(self) -> bool: - """Check if connection should be reconnected due to JWT expiry (at 80% of lifetime)""" - if not self._connect_time: - return False - elapsed = (datetime.now(UTC) - self._connect_time).total_seconds() - expiry_seconds = self.jwt_expiry_minutes * 60 - # Stagger refresh by 5% per broker to prevent simultaneous disconnects - # Broker 0: 80%, Broker 1: 85%, Broker 2: 90%, etc. - stagger_offset = self.broker_index * 0.05 - refresh_threshold = 0.80 + stagger_offset - return elapsed >= expiry_seconds * refresh_threshold - - def _schedule_jwt_refresh(self): - """Schedule proactive JWT refresh before token expires""" - if self._jwt_refresh_timer: - self._jwt_refresh_timer.cancel() - - expiry_seconds = self.jwt_expiry_minutes * 60 - # Stagger refresh by 5% per broker to prevent simultaneous disconnects - # Broker 0: 80%, Broker 1: 85%, Broker 2: 90%, etc. - stagger_offset = self.broker_index * 0.05 - refresh_threshold = 0.80 + stagger_offset - refresh_delay = expiry_seconds * refresh_threshold - - logger.info( - f"JWT refresh scheduled for {self.broker['name']} in {refresh_delay:.0f}s " - f"({refresh_threshold*100:.0f}% of {self.jwt_expiry_minutes}min token lifetime)" - ) - self._jwt_refresh_timer = threading.Timer(refresh_delay, self.reconnect_for_token_expiry) - self._jwt_refresh_timer.daemon = True - self._jwt_refresh_timer.start() - - def reconnect_for_token_expiry(self): - """Proactively reconnect with new JWT before current one expires""" - if not self._running: - return - - logger.info(f"JWT token expiring soon for {self.broker['name']}, refreshing...") - self._running = False - self._jwt_refresh_timer = None - - self._schedule_reconnect(reason="JWT token expiry") - self.client.disconnect() - - -# ==================================================================== -# MeshCore → MQTT Publisher with Ed25519 auth token -# ==================================================================== -class MeshCoreToMqttJwtPusher: - - def __init__( - self, - local_identity, - config: dict, - jwt_expiry_minutes: int = 10, - use_tls: bool = True, - stats_provider: Optional[Callable[[], dict]] = None, - ): - # Store local identity and get public key - self.local_identity = local_identity - public_key = local_identity.get_public_key().hex().upper() - - # Extract values from config - from ..config import get_node_info - - node_info = get_node_info(config) - - iata_code = node_info["iata_code"] - broker_index = node_info.get("broker_index") - self.email = node_info.get("email", "") - self.owner = node_info.get("owner", "") - status_interval = node_info["status_interval"] - node_name = node_info["node_name"] - radio_config = node_info["radio_config"] - - # Get additional brokers from config (optional) - letsmesh_config = config.get("letsmesh", {}) - additional_brokers = letsmesh_config.get("additional_brokers", []) - - # Determine which brokers to connect to - if broker_index == -2: - # Custom brokers only - no built-in brokers - self.brokers = [] - logger.info("Custom broker mode: using only user-defined brokers") - elif broker_index is None or broker_index == -1: - # Connect to all built-in brokers + additional ones - self.brokers = LETSMESH_BROKERS.copy() - logger.info( - f"Multi-broker mode: connecting to all {len(LETSMESH_BROKERS)} built-in brokers" - ) - else: - - if broker_index >= len(LETSMESH_BROKERS): - raise ValueError(f"Invalid broker_index {broker_index}") - self.brokers = [LETSMESH_BROKERS[broker_index]] - logger.info(f"Single broker mode: connecting to {self.brokers[0]['name']}") - - # Add additional brokers from config - if additional_brokers: - for broker_config in additional_brokers: - if all(k in broker_config for k in ["name", "host", "port", "audience"]): - self.brokers.append(broker_config) - logger.info(f"Added custom broker: {broker_config['name']}") - else: - logger.warning(f"Skipping invalid broker config: {broker_config}") - - # Validate that we have at least one broker - if not self.brokers: - raise ValueError( - "No brokers configured. Either set broker_index to a valid value " - "or provide additional_brokers in config." - ) - - self.local_identity = local_identity - self.public_key = public_key - self.iata_code = iata_code - self.jwt_expiry_minutes = jwt_expiry_minutes - self.use_tls = use_tls - self.status_interval = status_interval - self.app_version = __version__ - self.node_name = node_name - self.radio_config = radio_config - self.stats_provider = stats_provider - self._status_task = None - self._running = False - self._shutdown_requested = False - self._lock = threading.Lock() - self._connect_timers: List[threading.Timer] = [] - - # Create broker connections - self.connections: List[_BrokerConnection] = [] - for idx, broker in enumerate(self.brokers): - conn = _BrokerConnection( - broker=broker, - local_identity=self.local_identity, - public_key=self.public_key, - iata_code=self.iata_code, - jwt_expiry_minutes=self.jwt_expiry_minutes, - use_tls=self.use_tls, - email=self.email, - owner=self.owner, - broker_index=idx, - on_connect_callback=self._on_broker_connected, - on_disconnect_callback=self._on_broker_disconnected, - ) - self.connections.append(conn) - - logger.info(f"Initialized with {len(self.connections)} broker connection(s)") - - def _on_broker_connected(self, broker_name: str): - """Callback when a broker connects""" - if self._shutdown_requested: - return - - # Publish initial status on first connection - if not self._status_task and self.status_interval > 0: - self._running = True - self.publish_status( - state="online", origin=self.node_name, radio_config=self.radio_config - ) - # Start heartbeat thread - self._status_task = threading.Thread(target=self._status_heartbeat_loop, daemon=True) - self._status_task.start() - logger.info(f"Started status heartbeat (interval: {self.status_interval}s)") - - def _on_broker_disconnected(self, broker_name: str): - """Callback when a broker disconnects""" - # Check if all connections are down AND none have pending reconnects - all_down = all(not conn.is_connected() for conn in self.connections) - any_reconnecting = any(conn.has_pending_reconnect() for conn in self.connections) - - if all_down and not any_reconnecting: - logger.warning("All broker connections lost with no pending reconnects") - elif all_down: - logger.info("All brokers temporarily disconnected, reconnects pending") - - def connect(self): - """Establish connections to all configured brokers""" - self._shutdown_requested = False - self._connect_timers = [] - - for idx, conn in enumerate(self.connections): - try: - if idx == 0: - # Connect first broker immediately - conn.connect() - else: - # Stagger additional brokers using background timers - delay = idx * 30 - logger.info(f"Staggering connection to {conn.broker['name']} by {delay}s") - timer = threading.Timer(delay, lambda c=conn: self._delayed_connect(c)) - timer.daemon = True - timer.start() - self._connect_timers.append(timer) - except Exception as e: - logger.error(f"Failed to connect to {conn.broker['name']}: {e}") - - def _delayed_connect(self, conn): - """Connect a broker after a delay (called by timer)""" - if self._shutdown_requested: - return - - try: - conn.connect() - except Exception as e: - logger.error(f"Failed to connect to {conn.broker['name']}: {e}") - - def disconnect(self): - """Disconnect from all brokers""" - self._shutdown_requested = True - - # Cancel any delayed connect timers first. - for timer in self._connect_timers: - try: - timer.cancel() - except Exception: - pass - self._connect_timers = [] - - # Stop the heartbeat loop - self._running = False - - # Publish offline status before disconnecting - try: - self.publish_status(state="offline", origin=self.node_name, radio_config=self.radio_config) - except Exception: - pass - - # Disconnect all brokers - for conn in self.connections: - try: - conn.disconnect() - except Exception as e: - logger.error(f"Error disconnecting from {conn.broker['name']}: {e}") - - self._status_task = None - logger.info("Disconnected from all brokers") - - def _status_heartbeat_loop(self): - """Background thread that publishes periodic status updates""" - import time - - while self._running: - try: - # Publish status (JWT refresh now handled by individual broker timers) - self.publish_status( - state="online", origin=self.node_name, radio_config=self.radio_config - ) - logger.debug(f"Status heartbeat sent (next in {self.status_interval}s)") - - time.sleep(self.status_interval) - except Exception as e: - logger.error(f"Status heartbeat error: {e}") - time.sleep(self.status_interval) - - # ---------------------------------------------------------------- - # Packet helpers - # ---------------------------------------------------------------- - def _process_packet(self, pkt: dict) -> dict: - return {"timestamp": datetime.now(UTC).isoformat(), "origin_id": self.public_key, **pkt} - - def _topic(self, subtopic: str) -> str: - return f"meshcore/{self.iata_code}/{self.public_key}/{subtopic}" - - def publish_packet(self, pkt: dict, subtopic="packets", retain=False): - return self.publish(subtopic, self._process_packet(pkt), retain) - - def publish_raw_data(self, raw_hex: str, subtopic="raw", retain=False): - pkt = {"type": "raw", "data": raw_hex, "bytes": len(raw_hex) // 2} - return self.publish_packet(pkt, subtopic, retain) - - def publish_status( - self, - state: str = "online", - location: Optional[dict] = None, - extra_stats: Optional[dict] = None, - origin: Optional[str] = None, - radio_config: Optional[str] = None, - ): - """ - Publish device status/heartbeat message - - Args: - state: Device state (online/offline) - location: Optional dict with latitude/longitude - extra_stats: Optional additional statistics to include - origin: Node name/description - radio_config: Radio configuration string (freq,bw,sf,cr) - """ - # Get live stats from provider if available - if self.stats_provider: - live_stats = self.stats_provider() - else: - live_stats = {"uptime_secs": 0, "packets_sent": 0, "packets_received": 0} - - status = { - "status": state, - "timestamp": datetime.now(UTC).isoformat(), - "origin": origin or self.node_name, - "origin_id": self.public_key, - "model": "PyMC-Repeater", - "firmware_version": self.app_version, - "radio": radio_config or self.radio_config, - "client_version": f"pyMC_repeater/{self.app_version}", - "stats": {**live_stats, "errors": 0, "queue_len": 0, **(extra_stats or {})}, - } - - if location: - status["location"] = location - - return self.publish("status", status, retain=False) - - def publish(self, subtopic: str, payload: dict, retain: bool = False): - """Publish message to all connected brokers""" - topic = self._topic(subtopic) - message = json.dumps(payload) - - results = [] - with self._lock: - for conn in self.connections: - if conn.is_connected(): - result = conn.publish(topic, message, retain=retain) - results.append((conn.broker["name"], result)) - logger.debug(f"Published to {conn.broker['name']}/{topic}") - - if not results: - logger.warning(f"No active broker connections for publishing to {topic}") - - return results - - -# ==================================================================== -# Helper Functions -# ==================================================================== - - -def get_mqtt_error_message(rc: int, is_disconnect: bool = False) -> str: - """ - Get human-readable MQTT error message. - - Args: - rc: Return code from paho-mqtt - is_disconnect: True if from on_disconnect, False if from on_connect - - Returns: - Human-readable error message - """ - if HAS_REASON_CODES: - try: - # ReasonCode object has getName() method and value property - reason = ReasonCode(mqtt.CONNACK if not is_disconnect else mqtt.DISCONNECT, identifier=rc) - name = reason.getName() if hasattr(reason, 'getName') else str(reason) - return f"{name} (code {rc})" - except Exception as e: - # Log the exception for debugging - logger.debug(f"Could not decode reason code {rc}: {e}") - - # Fallback to manual mappings - Extended with MQTT v5 codes - connect_errors = { - 0: "Connection accepted", - 1: "Incorrect protocol version", - 2: "Invalid client identifier", - 3: "Server unavailable", - 4: "Bad username or password (JWT invalid)", - 5: "Not authorized (JWT signature/format invalid)", - # MQTT v5 codes - 128: "Unspecified error", - 129: "Malformed packet", - 130: "Protocol error", - 131: "Implementation specific error", - 132: "Unsupported protocol version", - 133: "Client identifier not valid", - 134: "Bad username or password", - 135: "Not authorized", - 136: "Server unavailable", - 137: "Server busy", - 138: "Banned", - 140: "Bad authentication method", - 144: "Topic name invalid", - 149: "Packet too large", - 151: "Quota exceeded", - 153: "Payload format invalid", - 154: "Retain not supported", - 155: "QoS not supported", - 156: "Use another server", - 157: "Server moved", - 159: "Connection rate exceeded", - } - - disconnect_errors = { - 0: "Normal disconnect", - 1: "Unacceptable protocol version", - 2: "Identifier rejected", - 3: "Server unavailable", - 4: "Bad username or password", - 5: "Not authorized", - 7: "Connection lost / network error", - 16: "Connection lost / protocol error", - 17: "Client timeout", - # MQTT v5 codes - 4: "Disconnect with Will message", - 128: "Unspecified error", - 129: "Malformed packet", - 130: "Protocol error", - 131: "Implementation specific error", - 135: "Not authorized", - 137: "Server busy", - 139: "Server shutting down", - 141: "Keep alive timeout", - 142: "Session taken over", - 143: "Topic filter invalid", - 144: "Topic name invalid", - 147: "Receive maximum exceeded", - 148: "Topic alias invalid", - 149: "Packet too large", - 150: "Message rate too high", - 151: "Quota exceeded", - 152: "Administrative action", - 153: "Payload format invalid", - 154: "Retain not supported", - 155: "QoS not supported", - 156: "Use another server", - 157: "Server moved", - 158: "Shared subscriptions not supported", - 159: "Connection rate exceeded", - 160: "Maximum connect time", - 161: "Subscription identifiers not supported", - 162: "Wildcard subscriptions not supported", - } - - error_dict = disconnect_errors if is_disconnect else connect_errors - return error_dict.get(rc, f"Unknown error code {rc}") diff --git a/repeater/data_acquisition/mqtt_handler.py b/repeater/data_acquisition/mqtt_handler.py index 1985d173..c1a78adf 100644 --- a/repeater/data_acquisition/mqtt_handler.py +++ b/repeater/data_acquisition/mqtt_handler.py @@ -5,7 +5,7 @@ import string import threading from datetime import datetime, timedelta -from typing import Callable, Dict, List, Optional +from typing import Any, Callable, Dict, List, Optional import paho.mqtt.client as mqtt from nacl.signing import SigningKey @@ -18,6 +18,7 @@ UTC = timezone.utc from repeater import __version__, config +from repeater.presets import get_preset # Try to import paho-mqtt error code mappings try: @@ -25,6 +26,7 @@ HAS_REASON_CODES = True except ImportError: + ReasonCode = None HAS_REASON_CODES = False logger = logging.getLogger("MQTTHandler") @@ -36,30 +38,118 @@ def b64url(x: bytes) -> str: return base64.urlsafe_b64encode(x).rstrip(b"=").decode() -LETSMESH_BROKERS = [ - { - "name": "Europe (LetsMesh v1)", - "host": "mqtt-eu-v1.letsmesh.net", - "port": 443, - "audience": "mqtt-eu-v1.letsmesh.net", - "use_jwt_auth": True, - "tls": { - "enabled": True, - "insecure": False, - }, - }, - { - "name": "US West (LetsMesh v1)", - "host": "mqtt-us-v1.letsmesh.net", - "port": 443, - "audience": "mqtt-us-v1.letsmesh.net", - "use_jwt_auth": True, - "tls": { - "enabled": True, - "insecure": False, - }, - }, -] + +def _summarize_payload_for_log(payload: Any, message: Optional[str] = None) -> str: + """Return a compact single-line payload summary for debug logging.""" + if message is None: + try: + message = json.dumps(payload) + except Exception: + message = str(payload) + + if isinstance(payload, list): + item_bits = [] + if payload and isinstance(payload[0], dict): + item_bits.append(_summarize_payload_for_log(payload[0])) + return f"items={len(payload)}, bytes={len(message.encode('utf-8'))}" + ( + f", first={{ {item_bits[0]} }}" if item_bits else "" + ) + + if not isinstance(payload, dict): + return f"type={type(payload).__name__}, bytes={len(message.encode('utf-8'))}" + + summary_fields = [] + for key in ("type", "packet_type", "route", "origin", "status", "hash", "RSSI", "SNR"): + value = payload.get(key) + if value not in (None, ""): + summary_fields.append(f"{key}={value}") + + if "len" in payload: + summary_fields.append(f"len={payload['len']}") + if "payload_len" in payload: + summary_fields.append(f"payload_len={payload['payload_len']}") + if "raw" in payload: + summary_fields.append(f"raw_bytes={len(str(payload['raw'])) // 2}") + + if not summary_fields: + keys = ",".join(sorted(payload.keys())[:6]) + if len(payload) > 6: + keys += ",..." + summary_fields.append(f"keys={keys}") + + summary_fields.append(f"bytes={len(message.encode('utf-8'))}") + return ", ".join(summary_fields) + + +def _truncate_middle(text: str, prefix: int = 24, suffix: int = 16) -> str: + """Truncate long strings by keeping the beginning and end visible.""" + if len(text) <= prefix + suffix + 5: + return text + return f"{text[:prefix]} ... {text[-suffix:]}" + + +# -------------------------------------------------------------------- +# Format family +# -------------------------------------------------------------------- +# Format values that belong to the MeshCoreToMQTT (MC2MQTT) protocol family. +# All MC2MQTT brokers share the topic structure: meshcore/{IATA}/{PUBLIC_KEY}/... +# Adding a new MC2MQTT-compatible platform = add its format value here AND +# drop a matching presets/.yaml. The legacy "mqtt" format is NOT in this +# tuple - it speaks the operator-defined custom topic structure instead. +MC2MQTT_FORMATS = ("meshcoretomqtt", "letsmesh", "waev") + + +# -------------------------------------------------------------------- +# Preset expansion helpers (used during broker-list assembly below). +# +# A user's brokers: list may contain a mix of: +# * preset references: {preset: } -> expands to N broker dicts +# * full broker dicts: {name, host, port, ...} -> used as-is +# +# Expansion is two passes so the rules are obvious and order-independent +# in spirit, but order-dependent in practice (later wins on name collision): +# Pass 1 - replace every {preset: ...} entry in place with the bundled +# broker list. Unknown preset is dropped with a warning. +# Pass 2 - walk left-to-right; if an entry's name already appeared +# earlier, shallow-merge the LATER entry onto the EARLIER one +# and drop the duplicate. Place override entries AFTER preset +# entries to make them win. +# -------------------------------------------------------------------- +def _expand_preset_entries(brokers: List[dict]) -> List[dict]: + """Pass 1: replace every {preset: } entry with the preset's brokers.""" + expanded: List[dict] = [] + for entry in brokers: + if isinstance(entry, dict) and "preset" in entry and "name" not in entry: + preset_name = entry["preset"] + preset = get_preset(preset_name) + preset_brokers = preset.get("brokers", []) if preset else [] + if not preset_brokers: + logger.warning(f"Unknown or empty broker preset '{preset_name}' - skipping") + continue + logger.info(f"Expanded preset '{preset_name}' into {len(preset_brokers)} broker(s)") + expanded.extend(preset_brokers) + else: + expanded.append(entry) + return expanded + + +def _merge_overrides_by_name(brokers: List[dict]) -> List[dict]: + """Pass 2: collapse duplicates by name; the LATER entry's fields win.""" + by_index: Dict[str, int] = {} + result: List[dict] = [] + for entry in brokers: + if not isinstance(entry, dict): + result.append(entry) + continue + name = entry.get("name") + if name and name in by_index: + # Shallow-merge: later entry's keys overwrite earlier entry's keys. + result[by_index[name]] = {**result[by_index[name]], **entry} + else: + if name: + by_index[name] = len(result) + result.append(entry) + return result # ==================================================================== @@ -101,8 +191,10 @@ def __init__( self._reconnect_attempts = 0 self._reconnect_timer = None self._max_reconnect_delay = 300 # 5 minutes max + self._keepalive = broker.get("keepalive", 30) # default tighter than paho's 60s to beat NAT/proxy timeouts self._jwt_refresh_timer = None self._shutdown_requested = False + self._last_jwt_claims = None self.transport = broker.get('transport', 'websockets') self.use_jwt_auth = broker.get('use_jwt_auth', False) @@ -117,6 +209,8 @@ def __init__( client_id = f"meshcore_{self.public_key}_{broker['host']}_{self.format}" self.client = mqtt.Client(client_id=client_id, transport=self.transport) + if hasattr(self.client, "on_pre_connect"): + self.client.on_pre_connect = self._on_pre_connect self.client.on_connect = self._on_connect self.client.on_disconnect = self._on_disconnect @@ -130,11 +224,13 @@ def __init__( if self.base_topic is None: if self.format == "mqtt": + # Custom MQTT family: operator-defined topic, not meshcore convention. self.base_topic = f"meshcore/repeater/{self.node_name}" - elif self.format == "letsmesh": + elif self.format in MC2MQTT_FORMATS: + # MC2MQTT family: canonical meshcoretomqtt topic structure. self.base_topic = f"meshcore/{self.iata_code}/{self.public_key}" else: - logger.warning(f"Unknown broker format '{self.format}' for {self.broker['name']}, using default base topic") + logger.warning(f"Unknown broker format '{self.format}' for {self.broker['name']}, defaulting to MC2MQTT topic structure") self.base_topic = f"meshcore/{self.iata_code}/{self.public_key}" from pymc_core.protocol.utils import PAYLOAD_TYPES @@ -170,6 +266,13 @@ def _generate_jwt(self) -> str: payload["email"] = "" payload["owner"] = "" + self._last_jwt_claims = { + "aud": payload.get("aud"), + "iat": payload.get("iat"), + "exp": payload.get("exp"), + "public_key_suffix": self.public_key[-12:], + } + # Encode header and payload (compact JSON - no spaces) header_b64 = b64url(json.dumps(header, separators=(",", ":")).encode()) payload_b64 = b64url(json.dumps(payload, separators=(",", ":")).encode()) @@ -198,6 +301,10 @@ def _on_connect(self, client, userdata, flags, rc): logger.info(f"Connected to {self.broker['name']}") self._running = True self._reconnect_attempts = 0 # Reset counter on success + # Successful connect can race with a previously scheduled timer; cancel it. + if self._reconnect_timer: + self._reconnect_timer.cancel() + self._reconnect_timer = None if self.use_jwt_auth: self._schedule_jwt_refresh() # Schedule proactive JWT refresh if self._on_connect_callback: @@ -205,7 +312,14 @@ def _on_connect(self, client, userdata, flags, rc): else: error_msg = get_mqtt_error_message(rc, is_disconnect=False) logger.error(f"Failed to connect to {self.broker['name']}: {error_msg}") - self._schedule_reconnect() + self._schedule_reconnect(reason=error_msg) + + def _on_pre_connect(self, client, userdata): + """Refresh credentials before each connect/reconnect attempt.""" + if self._shutdown_requested: + return + if self.use_jwt_auth: + self._set_credentials() def _on_disconnect(self, client, userdata, rc): """MQTT disconnection callback""" @@ -220,7 +334,13 @@ def _on_disconnect(self, client, userdata, rc): if rc != 0: # Unexpected disconnect error_msg = get_mqtt_error_message(rc, is_disconnect=True) - logger.warning(f"Disconnected from {self.broker['name']} (rc={rc}): {error_msg}") + if was_running: + logger.warning(f"Disconnected from {self.broker['name']} (rc={rc}): {error_msg}") + else: + logger.debug( + f"Duplicate disconnect callback from {self.broker['name']} while already disconnected " + f"(rc={rc}): {error_msg}" + ) if was_running: # Only reconnect if we were intentionally connected self._schedule_reconnect(reason=error_msg) else: @@ -253,6 +373,13 @@ def _attempt_reconnect(self, reason: str = "connection lost"): if self._shutdown_requested: return + # Timer has fired; clear handle so state reflects reality. + self._reconnect_timer = None + + if self._running: + logger.debug(f"Skipping reconnect to {self.broker['name']} - already connected") + return + try: logger.info(f"Attempting reconnection to {self.broker['name']} (reason: {reason})...") @@ -265,7 +392,7 @@ def _attempt_reconnect(self, reason: str = "connection lost"): self._set_credentials() # Reconnect and restart loop - self.client.connect(self.broker["host"], self.broker["port"], keepalive=60) + self.client.connect(self.broker["host"], self.broker["port"], keepalive=self._keepalive) self.client.loop_start() self._loop_running = True except Exception as e: @@ -280,9 +407,10 @@ def _set_credentials(self): token = self._generate_jwt() username = f"v1_{self.public_key}" self.client.username_pw_set(username=username, password=token) - logger.debug(f"Credentials set for {self.broker['name']}") - logger.debug(f"Using username: {username}") - logger.debug(f"Public key: {self.public_key[:16]}...{self.public_key[-16:]}") + logger.debug( + f"Credentials set for {self.broker['name']}: " + f"user=v1_{self.public_key[:8]}...{self.public_key[-8:]}" + ) elif self.username and self.password: logger.info(f"Using provided credentials for {self.broker['name']} (username: {self.username})") self.client.username_pw_set(username=self.username, password=self.password) @@ -305,19 +433,22 @@ def connect(self): return if self.transport == "websockets": - if self.tls and self.tls.get("enabled", True): - import ssl - - self.client.tls_set(cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS_CLIENT) - self.client.tls_insecure_set(self.tls.get("insecure", False)) - self._tls_verified = True - protocol = "wss" - else: protocol = "ws" elif self.transport == "tcp": protocol = "mqtt" else: raise ValueError(f"Invalid transport '{self.transport}' for {self.broker['name']}") + + # Setup TLS independent of transport - MQTT over TLS can be used with both websockets and raw TCP + if self.tls and self.tls.get("enabled", False): + import ssl + self.client.tls_set(cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS_CLIENT) + self.client.tls_insecure_set(self.tls.get("insecure", False)) + self._tls_verified = True + + # Ensure to update the protocol is we're running TLS on websockets + if( self.transport == "websockets" ): + protocol = "wss" # Set JWT credentials before CONNECT handshake self._set_credentials() @@ -327,7 +458,7 @@ def connect(self): f"({protocol}://{self.broker['host']}:{self.broker['port']}) ..." ) - self.client.connect(self.broker["host"], self.broker["port"], keepalive=60) + self.client.connect(self.broker["host"], self.broker["port"], keepalive=self._keepalive) self.client.loop_start() self._loop_running = True @@ -360,9 +491,13 @@ def publish(self, subtopic: str, payload: str, retain: bool = False, qos: int = retain = self.retain_status qos = 1 if self.retain_status else 0 - logger.debug(f"Publishing to topic '{self.base_topic}/{subtopic}' with payload: [{payload}]. Running={self._running}. Retain={retain}, QoS={qos}") + full_topic = f"{self.base_topic}/{subtopic}" + logger.debug( + f"Publishing topic='{_truncate_middle(full_topic)}', bytes={len(payload.encode('utf-8'))}, " + f"running={self._running}, retain={retain}, qos={qos}" + ) if self._running: - result = self.client.publish(f"{self.base_topic}/{subtopic}", payload, retain=retain, qos=qos) + result = self.client.publish(full_topic, payload, retain=retain, qos=qos) return result else: logger.warning(f"Cannot publish to {self.broker['name']} - not connected") @@ -485,12 +620,38 @@ def __init__( imported_letsmesh_configs = self.convert_letsmesh_to_broker_config(letsmesh_config) brokers.extend(imported_letsmesh_configs) + # Expand any {preset: } entries (from user config OR legacy + # migrators) into concrete broker dicts, then collapse duplicates so + # later overrides win. Result feeds the validation loop unchanged. + brokers = _expand_preset_entries(brokers) + brokers = _merge_overrides_by_name(brokers) + + # Known MC2MQTT hostnames that must never use format: mqtt. + # If a user's saved config has the wrong format (common after manual editing + # or an old UI version), auto-correct it so diagnostic topics aren't sent + # to brokers that will reject them and close the connection (rc=16). + _MC2MQTT_HOSTS = { + "letsmesh.net", + "waev.app", + "meshcoretomqtt", + } + self.brokers = [] if brokers: for broker_config in brokers: if all(k in broker_config for k in ["name", "host", "port", "enabled"]): + host = broker_config.get("host", "") + fmt = broker_config.get("format", "") + if fmt == "mqtt" and any(mc2 in host for mc2 in _MC2MQTT_HOSTS): + corrected = broker_config.get("name", host) + logger.warning( + f"Broker '{corrected}' has format=mqtt but host '{host}' is a MC2MQTT " + f"endpoint — auto-correcting to format=letsmesh. " + f"Update your config.yaml to silence this warning." + ) + broker_config = {**broker_config, "format": "letsmesh"} self.brokers.append(broker_config) - logger.info(f"Added broker: {broker_config['name']}") + logger.info(f"Added broker: {broker_config['name']} (format={broker_config.get('format', 'unknown')})") else: logger.warning(f"Skipping invalid broker config: {broker_config}") @@ -549,75 +710,59 @@ def convert_mqtt_to_broker_config(self, mqtt_cfg: dict) -> dict: } def convert_letsmesh_to_broker_config(self, letsmesh_cfg: dict) -> List[dict]: - """Convert LetsMesh config format to internal broker config format""" - - brokers = [] - - enabled = letsmesh_cfg.get("enabled", False) + """Migrate the legacy ``letsmesh:`` config block into preset-style entries. + + Emits a list that the preset-expansion pass will turn into the same + broker dicts the old hard-coded migrator used to produce. Specifically: - idx = letsmesh_cfg.get("broker_index", None) - if idx == 0 or idx == 1: - broker_info = LETSMESH_BROKERS[idx] - logger.info(f"Imported LetsMesh broker from 'letsmesh' config: {broker_info['name']}") - brokers.append({ + * ``broker_index == -1`` -> both LetsMesh brokers (the preset default). + * ``broker_index == 0`` -> Europe only (US disabled via override). + * ``broker_index == 1`` -> US only (Europe disabled via override). + * ``additional_brokers`` -> appended verbatim after the preset reference. + * ``enabled: false`` -> overrides every preset broker as disabled. + """ + enabled = letsmesh_cfg.get("enabled", False) + idx = letsmesh_cfg.get("broker_index", -1) + + # Resolve preset broker names so we can build accurate "disable" overrides. + preset_brokers = get_preset("letsmesh").get("brokers", []) + eu_name = preset_brokers[0]["name"] if len(preset_brokers) > 0 else "Europe (LetsMesh v1)" + us_name = preset_brokers[1]["name"] if len(preset_brokers) > 1 else "US West (LetsMesh v1)" + + entries: List[dict] = [{"preset": "letsmesh"}] + + # Honor broker_index by disabling the broker the legacy user did not pick. + if idx == 0: + entries.append({"name": us_name, "enabled": False}) + elif idx == 1: + entries.append({"name": eu_name, "enabled": False}) + + # Honor the legacy enabled flag by overriding every preset broker. + if not enabled: + for b in preset_brokers: + entries.append({"name": b["name"], "enabled": False}) + + # Append any user-defined additional brokers as full entries. + for add_broker in letsmesh_cfg.get("additional_brokers", []): + logger.info(f"Imported additional LetsMesh broker from 'letsmesh' config: {add_broker.get('name')}") + entries.append({ "enabled": enabled, - "name": broker_info["name"], - "host": broker_info["host"], - "port": broker_info["port"], - "audience": broker_info["audience"], - "use_jwt_auth": True, - "transport": "websockets", + "name": add_broker["name"], + "host": add_broker["host"], + "port": add_broker["port"], + "audience": add_broker["audience"], + "use_jwt_auth": add_broker.get("use_jwt_auth", True), + "transport": add_broker.get("transport", "websockets"), "format": "letsmesh", "base_topic": None, "retain_status": False, "tls": { - "enabled": True, - "insecure": False, + "enabled": add_broker.get("tls", {}).get("enabled", True), + "insecure": add_broker.get("tls", {}).get("insecure", False), }, }) - elif idx < 0: - if idx == -1: - brokers.extend({ - "enabled": enabled, - "name": broker_info["name"], - "host": broker_info["host"], - "port": broker_info["port"], - "audience": broker_info["audience"], - "use_jwt_auth": True, - "transport": "websockets", - "format": "letsmesh", - "base_topic": None, - "retain_status": False, - "tls": { - "enabled": True, - "insecure": False, - }, - } for broker_info in LETSMESH_BROKERS) - - additional = letsmesh_cfg.get("additional_brokers", []) - for add_broker in additional: - logger.info(f"Imported additional LetsMesh broker from 'letsmesh' config: {add_broker['name']}") - brokers.append({ - "enabled": enabled, - "name": add_broker["name"], - "host": add_broker["host"], - "port": add_broker["port"], - "audience": add_broker["audience"], - "use_jwt_auth": True, - "transport": "websockets", - "use_jwt_auth": add_broker.get("use_jwt_auth", True), - "transport": add_broker.get("transport", "websockets"), - "format": "letsmesh", - "base_topic": None, - "retain_status": False, - "tls": { - "enabled": add_broker.get("tls", {}).get("enabled", True), - "insecure": add_broker.get("tls", {}).get("insecure", False), - } - }) - - - return brokers + + return entries def _on_broker_connected(self, broker_name: str): """Callback when a broker connects""" @@ -785,7 +930,7 @@ def publish(self, subtopic: str, payload: dict, retain: bool = False, qos: int = message = json.dumps(payload) # _BrokerConnection now handles topic prefixing, so we only log the subtopic here - logger.debug(f"Publishing to topic '{subtopic}' with payload: {message}") + logger.debug(f"Publishing topic='{subtopic}', {_summarize_payload_for_log(payload, message)}") packet_type = payload.get("type") @@ -799,6 +944,8 @@ def publish(self, subtopic: str, payload: dict, retain: bool = False, qos: int = result = conn.publish(subtopic, message, retain=retain, qos=qos) results.append((conn.broker["name"], result)) logger.debug(f"Published to {conn.broker['name']} -- {subtopic}") + elif conn.enabled == False: + results.append((conn.broker["name"], "Skipped due to being disabled")) if not results: logger.warning(f"No active broker connections for publishing to {subtopic}") @@ -807,23 +954,35 @@ def publish(self, subtopic: str, payload: dict, retain: bool = False, qos: int = def publish_mqtt(self, payload: dict, subtopic: str, retain: bool = False, qos: int = 0): - """Publish message to all connected brokers""" + """Publish message to brokers using the legacy custom-MQTT format only. + + This path exists for diagnostic streams (advert, noise_floor, crc_errors) + that were originally only published to ``format: mqtt`` brokers. MC2MQTT + family brokers (letsmesh, waev, meshcoretomqtt) intentionally skip these + topics today. + """ message = json.dumps(payload) # _BrokerConnection now handles topic prefixing, so we only log the subtopic here - logger.debug(f"Publishing to topic '{subtopic}' with payload: {message}") + logger.debug(f"Publishing topic='{subtopic}', {_summarize_payload_for_log(payload, message)}") results = [] with self._lock: for conn in self.connections: if conn.enabled and conn.is_connected(): if conn.format != "mqtt": - logger.debug(f"Skipped publishing to {conn.broker['name']} (wrong format)") - results.append((conn.broker["name"], None)) # Indicate skipped due to format mismatch + # Custom-MQTT-only path; MC2MQTT brokers are intentionally skipped here. + logger.debug( + f"Skipped publishing to {conn.broker['name']} " + f"(intentional: publish_mqtt only targets legacy mqtt format; broker format={conn.format})" + ) + results.append((conn.broker["name"], None)) continue result = conn.publish(subtopic, message, retain=retain, qos=qos) results.append((conn.broker["name"], result)) - logger.debug(f"Published to {conn.broker['name']} -- {subtopic}") + logger.debug(f"Published to {conn.broker['name']} (format={conn.format}) -- {subtopic}") + elif conn.enabled == False: + results.append((conn.broker["name"], "Skipped due to being disabled")) if not results: logger.warning(f"No active broker connections for publishing to {subtopic}") @@ -887,7 +1046,7 @@ def get_mqtt_error_message(rc: int, is_disconnect: bool = False) -> str: 4: "Bad username or password", 5: "Not authorized", 7: "Connection lost / network error", - 16: "Connection lost / protocol error", + 16: "The connection was lost.", 17: "Client timeout", # MQTT v5 codes 4: "Disconnect with Will message", @@ -920,7 +1079,7 @@ def get_mqtt_error_message(rc: int, is_disconnect: bool = False) -> str: 162: "Wildcard subscriptions not supported", } - if HAS_REASON_CODES: + if HAS_REASON_CODES and ReasonCode is not None: try: reason = ReasonCode(mqtt.CONNACK if not is_disconnect else mqtt.DISCONNECT, identifier=rc) @@ -932,5 +1091,13 @@ def get_mqtt_error_message(rc: int, is_disconnect: bool = False) -> str: if _fallback is None: logger.debug(f"Could not decode reason code {rc}: {e}") + if is_disconnect: + try: + paho_error = mqtt.error_string(rc) + if paho_error and paho_error != "Unknown error.": + return paho_error + except Exception: + pass + error_dict = disconnect_errors if is_disconnect else connect_errors return error_dict.get(rc, f"Unknown error code {rc}") diff --git a/repeater/data_acquisition/sqlite_handler.py b/repeater/data_acquisition/sqlite_handler.py index 415abd0f..4c0a636b 100644 --- a/repeater/data_acquisition/sqlite_handler.py +++ b/repeater/data_acquisition/sqlite_handler.py @@ -1557,12 +1557,14 @@ def get_cumulative_counts(self) -> dict: return {"rx_total": 0, "tx_total": 0, "drop_total": 0, "type_counts": {}} def get_adverts_by_contact_type( - self, contact_type: str, limit: Optional[int] = None, hours: Optional[int] = None + self, contact_type: str, limit: Optional[int] = None, offset: Optional[int] = None, hours: Optional[int] = None ) -> List[dict]: try: if limit is None: limit = 500 + if offset is None: + offset = 0 with self._connect() as conn: conn.row_factory = sqlite3.Row @@ -1584,8 +1586,9 @@ def get_adverts_by_contact_type( query += " ORDER BY timestamp DESC" if limit is not None: - query += " LIMIT ?" + query += " LIMIT ? OFFSET ?" params.append(limit) + params.append(offset) rows = conn.execute(query, params).fetchall() @@ -1617,6 +1620,27 @@ def get_adverts_by_contact_type( logger.error(f"Failed to get adverts by contact_type '{contact_type}': {e}") return [] + def get_adverts_count_by_contact_type( + self, contact_type: str, hours: Optional[int] = None + ) -> int: + """Get total count of adverts for a specific contact type.""" + try: + with self._connect() as conn: + query = "SELECT COUNT(*) as total FROM adverts WHERE contact_type = ?" + params = [contact_type] + + if hours is not None: + cutoff = time.time() - (hours * 3600) + query += " AND timestamp > ?" + params.append(cutoff) + + row = conn.execute(query, params).fetchone() + return row[0] if row else 0 + + except Exception as e: + logger.error(f"Failed to get adverts count for contact_type '{contact_type}': {e}") + return 0 + def generate_transport_key(self, name: str, key_length_bytes: int = 32) -> str: """ Generate a transport key using the proper MeshCore key derivation. diff --git a/repeater/data_acquisition/storage_collector.py b/repeater/data_acquisition/storage_collector.py index ec924067..bc0a5b2c 100644 --- a/repeater/data_acquisition/storage_collector.py +++ b/repeater/data_acquisition/storage_collector.py @@ -6,6 +6,8 @@ from pathlib import Path from typing import Any, Dict, Optional +from repeater.config import resolve_storage_dir + from .mqtt_handler import MeshCoreToMqttPusher from .rrdtool_handler import RRDToolHandler from .sqlite_handler import SQLiteHandler @@ -21,12 +23,7 @@ def __init__(self, config: dict, local_identity=None, repeater_handler=None): self.glass_publish_callback = None self._pending_tasks = set() - storage_dir_cfg = ( - config.get("storage", {}).get("storage_dir") - or config.get("storage_dir") - or "/var/lib/pymc_repeater" - ) - self.storage_dir = Path(storage_dir_cfg) + self.storage_dir = resolve_storage_dir(config) self.storage_dir.mkdir(parents=True, exist_ok=True) self.sqlite_handler = SQLiteHandler(self.storage_dir) @@ -214,7 +211,13 @@ def _publish_packet_sync(self, packet_record: dict, skip_mqtt: bool): self._publish_packet_to_mqtt(packet_record) def _publish_packet_to_mqtt(self, packet_record: dict): - """Publish packet to mqtt broker if enabled and allowed""" + """Publish packet to mqtt broker if enabled and allowed. + + The ``duration`` field in the published JSON is sourced from + ``packet_record['airtime_ms']``, populated upstream by + RepeaterHandler._build_packet_record using the Semtech reference + time-on-air formula. No recomputation is needed here. + """ if not self.mqtt_handler: return diff --git a/repeater/data_acquisition/storage_utils.py b/repeater/data_acquisition/storage_utils.py index f0d07514..1fd4ab2c 100644 --- a/repeater/data_acquisition/storage_utils.py +++ b/repeater/data_acquisition/storage_utils.py @@ -38,6 +38,12 @@ def from_packet_record( """ Create PacketRecord from internal packet_record format. + The ``duration`` field is sourced from ``packet_record['airtime_ms']``, + which RepeaterHandler._build_packet_record populates using the + Semtech-reference time-on-air formula on the active radio settings. + Records produced by older code paths that pre-date that field fall + back to 0 to preserve legacy behavior. + Args: packet_record: Internal packet record dictionary origin: Node name @@ -57,6 +63,8 @@ def from_packet_record( route_map = {1: "F", 2: "D"} route = route_map.get(packet_record.get("route", 0), str(packet_record.get("route", 0))) + airtime_ms = float(packet_record.get("airtime_ms", 0.0) or 0.0) + return cls( origin=origin, origin_id=origin_id, @@ -73,7 +81,7 @@ def from_packet_record( SNR=str(packet_record.get("snr", 0)), RSSI=str(packet_record.get("rssi", 0)), score=str(int(packet_record.get("score", 0) * 1000)), - duration="0", + duration=str(int(round(airtime_ms))), hash=packet_record.get("packet_hash", ""), ) diff --git a/repeater/engine.py b/repeater/engine.py index c7c2bf3a..0ca401f2 100644 --- a/repeater/engine.py +++ b/repeater/engine.py @@ -36,7 +36,7 @@ LOOP_DETECT_MODERATE = "moderate" LOOP_DETECT_STRICT = "strict" -# Thresholds for 1-byte path hashes loop detection. +# Thresholds for flood loop detection (hash-size-aware: 1, 2, or 3 bytes per hop). # Count how many times our own hash already exists in the incoming FLOOD path. # If occurrences >= threshold, treat as loop and drop. LOOP_DETECT_MAX_COUNTERS = { @@ -590,6 +590,20 @@ def _build_packet_record( pkt_hash = packet_hash or packet.calculate_packet_hash().hex().upper() payload = getattr(packet, "payload", None) payload_len = len(payload or b"") + + # LoRa time-on-air for this packet (Semtech reference formula). + # Computed once here so every downstream consumer (MQTT, SQLite, Glass, + # websocket) reads the same value instead of recomputing or shipping + # zeros. The same calculator is used by the RX accumulator and the + # duty-cycle gate, keeping reporting and metering aligned. + airtime_ms = 0.0 + try: + raw_len = packet.get_raw_length() if hasattr(packet, "get_raw_length") else 0 + if raw_len > 0: + airtime_ms = float(self.airtime_mgr.calculate_airtime(raw_len)) + except Exception as e: + logger.debug(f"Could not compute airtime for packet record: {e}") + return { "timestamp": time.time(), "header": ( @@ -608,6 +622,7 @@ def _build_packet_record( snr, payload_len, self.radio_config["spreading_factor"] ), "tx_delay_ms": tx_delay_ms, + "airtime_ms": airtime_ms, "transmitted": transmitted, "is_duplicate": is_duplicate, "packet_hash": pkt_hash[:16], @@ -727,8 +742,14 @@ def _is_flood_looped(self, packet: Packet, mode: Optional[str] = None) -> bool: if max_counter is None: return False + hash_size = packet.get_path_hash_size() + hop_count = packet.get_path_hash_count() path = packet.path or bytearray() - local_count = sum(1 for hop in path if hop == self.local_hash) + local_hash = self.local_hash_bytes[:hash_size] + local_count = sum( + 1 for i in range(hop_count) + if bytes(path[i * hash_size:(i + 1) * hash_size]) == local_hash + ) return local_count >= max_counter def _check_transport_codes(self, packet: Packet) -> Tuple[bool, str]: diff --git a/repeater/handler_helpers/protocol_request.py b/repeater/handler_helpers/protocol_request.py index 4295693f..ca8d4aee 100644 --- a/repeater/handler_helpers/protocol_request.py +++ b/repeater/handler_helpers/protocol_request.py @@ -296,9 +296,14 @@ def _handle_get_neighbours(self, client, timestamp: int, req_data: bytes): raw_neighbors = storage.get_neighbors() now = time.time() - # Build sortable list: (pubkey_hex, heard_seconds_ago, snr) + # Build sortable list from zero-hop repeaters only: (pubkey_hex, heard_seconds_ago, snr) entries = [] for pubkey_hex, info in raw_neighbors.items(): + is_repeater = bool(info.get("is_repeater", False)) + zero_hop = bool(info.get("zero_hop", False)) + if not (is_repeater and zero_hop): + continue + last_seen = info.get("last_seen", 0) or 0 heard_ago = max(0, int(now - last_seen)) snr_raw = info.get("snr", 0) or 0 @@ -344,8 +349,8 @@ def _handle_get_neighbours(self, client, timestamp: int, req_data: bytes): header = struct.pack(" None: self._pending_tasks.add(task) @@ -166,9 +167,29 @@ def register_identity( self.room_servers[hash_byte] = room_server - # Start sync loop - start_task = asyncio.create_task(room_server.start()) - self._track_task(start_task) + # Start sync loop — may be called from a non-async HTTP handler thread + try: + loop = asyncio.get_running_loop() + start_task = loop.create_task(room_server.start()) + self._track_task(start_task) + except RuntimeError: + # No running event loop in this thread + if self._loop and self._loop.is_running(): + future = asyncio.run_coroutine_threadsafe( + room_server.start(), self._loop + ) + future.add_done_callback( + lambda f: logger.error( + f"Room server '{name}' failed: {f.exception()}", + exc_info=f.exception(), + ) + if not f.cancelled() and f.exception() + else None + ) + else: + logger.error( + f"Cannot start room server '{name}': no event loop available" + ) logger.info( f"Registered room server '{name}': hash=0x{hash_byte:02X}, " diff --git a/repeater/main.py b/repeater/main.py index 2910b28c..da4a1098 100644 --- a/repeater/main.py +++ b/repeater/main.py @@ -8,9 +8,10 @@ import time from repeater.companion.utils import validate_companion_node_name, normalize_companion_identity_key -from repeater.config import get_radio_for_board, load_config, save_config +from repeater.config import NullRadio, get_radio_for_board, load_config, save_config from repeater.config_manager import ConfigManager from repeater.data_acquisition.glass_handler import GlassHandler +from repeater.data_acquisition.gps_service import GPSService from repeater.engine import RepeaterHandler from repeater.handler_helpers import ( AdvertHelper, @@ -23,6 +24,7 @@ ) from repeater.identity_manager import IdentityManager from repeater.packet_router import PacketRouter +from repeater.sensors import SensorManager from repeater.web.http_server import HTTPStatsServer, _log_buffer logger = logging.getLogger("RepeaterDaemon") @@ -49,12 +51,16 @@ def __init__(self, config: dict, radio=None): self.path_helper = None self.protocol_request_helper = None self.glass_handler = None + self.gps_service = None + self.sensor_manager = None self.acl = None self.router = None self.companion_bridges: dict[int, object] = {} self.companion_frame_servers: list = [] self._shutdown_started = False self._main_task = None + self.radio_status = "unknown" + self.radio_error = None log_level = config.get("logging", {}).get("level", "INFO") logging.basicConfig( @@ -93,11 +99,34 @@ async def initialize(self): #----------------------------------------------- if self.radio is None: - radio_type = self.config.get("radio_type", "sx1262") + radio_type_raw = self.config.get("radio_type") + radio_type = "none" if radio_type_raw is None else str(radio_type_raw) + radio_type_lower = radio_type.lower().strip() + radio_explicitly_disabled = radio_type_lower in ( + "", + "none", + "null", + "disabled", + "off", + "no_radio", + ) logger.info(f"Initializing radio hardware... (radio_type={radio_type})") try: self.radio = get_radio_for_board(self.config) + if isinstance(self.radio, NullRadio): + self.radio_status = "disabled" if radio_explicitly_disabled else "degraded" + if self.radio_status == "disabled": + self.radio_error = None + else: + self.radio_error = ( + self.radio_error + or f"Radio type '{radio_type}' unavailable; running in no-radio mode" + ) + else: + self.radio_status = "ok" + self.radio_error = None + # KISS modem: schedule RX callbacks on the event loop for thread safety if hasattr(self.radio, "set_event_loop"): self.radio.set_event_loop(asyncio.get_running_loop()) @@ -129,7 +158,14 @@ async def initialize(self): logger.info("Radio hardware initialized") except Exception as e: logger.error(f"Failed to initialize radio hardware: {e}") - raise RuntimeError("Repeater requires real LoRa hardware") from e + self.radio_status = "degraded" + self.radio_error = str(e) + logger.warning( + "Radio type '%s' unavailable; starting in no-radio mode to keep service alive. " + "Check radio configuration and hardware mapping.", + radio_type, + ) + self.radio = NullRadio() try: from pymc_core import LocalIdentity @@ -262,6 +298,23 @@ async def initialize(self): ) logger.info("Config manager initialized") + self.sensor_manager = SensorManager(self.config) + self.sensor_manager.start() + if self.sensor_manager.get_summary().get("loaded", 0): + logger.info("Sensor manager initialized") + else: + logger.info("No configured sensors loaded") + + self.gps_service = GPSService( + self.config, + location_update_callback=self._update_repeater_location_from_gps, + ) + self.gps_service.start() + if self.config.get("gps", {}).get("enabled", False): + logger.info("GPS diagnostics initialized") + else: + logger.info("GPS diagnostics disabled") + # Initialize text message helper with per-identity ACLs self.text_helper = TextHelper( identity_manager=self.identity_manager, @@ -278,6 +331,7 @@ async def initialize(self): ), # For room server database send_advert_callback=self.send_advert, # For CLI advert command ) + self.text_helper._loop = asyncio.get_running_loop() # Register default repeater identity for text messages self.text_helper.register_identity( @@ -916,6 +970,16 @@ def get_stats(self) -> dict: except Exception: stats["public_key"] = None + if self.gps_service: + stats["gps"] = self.gps_service.get_summary() + + if self.sensor_manager: + stats["sensors"] = self.sensor_manager.get_summary() + + stats["radio_status"] = self.radio_status + if self.radio_error: + stats["radio_error"] = self.radio_error + return stats async def _get_companion_stats(self, stats_type: int) -> dict: @@ -991,6 +1055,13 @@ async def send_advert(self) -> bool: node_name = repeater_config.get("node_name", "Repeater") latitude = repeater_config.get("latitude", 0.0) longitude = repeater_config.get("longitude", 0.0) + location_source = "config" + + if self.gps_service: + location = self.gps_service.get_repeater_location() + latitude = location.get("latitude", latitude) + longitude = location.get("longitude", longitude) + location_source = str(location.get("source", location_source)) flags = ADVERT_FLAG_IS_REPEATER | ADVERT_FLAG_HAS_NAME @@ -1013,13 +1084,68 @@ async def send_advert(self) -> bool: self.repeater_handler.mark_seen(packet) logger.debug("Marked own advert as seen in duplicate cache") - logger.info(f"Sent flood advert '{node_name}' at ({latitude: .6f}, {longitude: .6f})") + logger.info( + "Sent flood advert '%s' at (% .6f, % .6f) source=%s", + node_name, + latitude, + longitude, + location_source, + ) return True except Exception as e: logger.error(f"Failed to send advert: {e}", exc_info=True) return False + def _update_repeater_location_from_gps(self, location: dict) -> bool: + """Persist the latest valid GPS fix as the repeater's advertised location.""" + latitude = location.get("latitude") + longitude = location.get("longitude") + if latitude is None or longitude is None: + return False + + repeater_config = self.config.setdefault("repeater", {}) + current_latitude = repeater_config.get("latitude") + current_longitude = repeater_config.get("longitude") + try: + if ( + current_latitude is not None + and current_longitude is not None + and abs(float(current_latitude) - float(latitude)) < 0.000001 + and abs(float(current_longitude) - float(longitude)) < 0.000001 + ): + return False + except (TypeError, ValueError): + pass + + updates = { + "repeater": { + "latitude": float(latitude), + "longitude": float(longitude), + } + } + if self.config_manager: + result = self.config_manager.update_and_save( + updates=updates, + live_update=True, + live_update_sections=["repeater"], + ) + if not result.get("success"): + logger.warning( + "GPS location fix could not update repeater config: %s", + result.get("error", "unknown error"), + ) + return False + else: + repeater_config.update(updates["repeater"]) + + logger.info( + "Updated repeater location from GPS fix: latitude=%.6f longitude=%.6f", + latitude, + longitude, + ) + return True + def _signal_shutdown(self, sig, loop): """Handle SIGTERM/SIGINT by scheduling async shutdown.""" if self._shutdown_started: @@ -1076,6 +1202,20 @@ async def _shutdown(self): except Exception as e: logger.warning(f"Error stopping Glass handler: {e}") + # Stop sensor manager. + if self.sensor_manager: + try: + self.sensor_manager.stop() + except Exception as e: + logger.warning(f"Error stopping sensor manager: {e}") + + # Stop GPS diagnostics. + if self.gps_service: + try: + self.gps_service.stop() + except Exception as e: + logger.warning(f"Error stopping GPS diagnostics: {e}") + # Close storage publishers (MQTT/LetsMesh) to stop their worker threads. try: if self.repeater_handler and self.repeater_handler.storage: @@ -1096,7 +1236,9 @@ async def _shutdown(self): # Release CH341 USB device if in use try: - if self.config.get("radio_type", "sx1262").lower() == "sx1262_ch341": + radio_type_raw = self.config.get("radio_type") + radio_type = "" if radio_type_raw is None else str(radio_type_raw).lower() + if radio_type == "sx1262_ch341": from pymc_core.hardware.ch341.ch341_async import CH341Async CH341Async.reset_instance() diff --git a/repeater/presets/__init__.py b/repeater/presets/__init__.py new file mode 100644 index 00000000..432c92e8 --- /dev/null +++ b/repeater/presets/__init__.py @@ -0,0 +1,60 @@ +"""Bundled MQTT broker presets. + +Each sibling ``*.yaml`` file in this package defines a named preset - a +ready-to-use list of broker dicts for a known MeshCoreToMQTT (MC2MQTT) +network. Presets ship with the package, so a ``pip install -U`` is enough +to pick up new endpoints without editing user config. + +Public API: + get_preset(name) -> dict (the parsed YAML, or {} if unknown) + list_presets() -> sorted list of preset names + +The loader is lazy: nothing is read or parsed at import time. The first +call discovers sibling YAML files via ``importlib.resources`` and caches +the parsed dicts for the lifetime of the process. +""" + +from __future__ import annotations + +import logging +from importlib.resources import files +from pathlib import Path +from typing import Dict, List + +import yaml + +logger = logging.getLogger("Presets") + +# Cache of parsed presets, keyed by name (e.g. "waev"). Populated on first +# call to _load_all(); never cleared. +_CACHE: Dict[str, dict] = {} +_LOADED: bool = False + + +def _load_all() -> Dict[str, dict]: + """Discover and parse every bundled ``*.yaml`` file once.""" + global _LOADED + if _LOADED: + return _CACHE + for resource in files(__package__).iterdir(): + # importlib.resources.Traversable: only consider real files ending in .yaml + name = getattr(resource, "name", "") + if not name.endswith(".yaml"): + continue + try: + with resource.open("r", encoding="utf-8") as f: + _CACHE[Path(name).stem] = yaml.safe_load(f) or {} + except Exception as e: # pragma: no cover - defensive + logger.warning(f"Failed to load preset '{name}': {e}") + _LOADED = True + return _CACHE + + +def get_preset(name: str) -> dict: + """Return the parsed preset dict, or ``{}`` if no such preset exists.""" + return _load_all().get(name, {}) + + +def list_presets() -> List[str]: + """Return the sorted list of bundled preset names.""" + return sorted(_load_all().keys()) diff --git a/repeater/presets/letsmesh.yaml b/repeater/presets/letsmesh.yaml new file mode 100644 index 00000000..ed0ee703 --- /dev/null +++ b/repeater/presets/letsmesh.yaml @@ -0,0 +1,44 @@ +# LetsMesh MC2MQTT broker preset. +# +# LetsMesh is the operator of the public MeshCore Packet Analyzer +# infrastructure. These brokers speak the MeshCoreToMQTT (MC2MQTT) +# protocol with the "letsmesh" format flavor, which today shares the +# canonical MC2MQTT topic structure (meshcore/{IATA}/{PUBLIC_KEY}/...). +# +# Reference all LetsMesh endpoints with: brokers: [{preset: letsmesh}] +# +# Note: order matters for backward compatibility with the legacy +# letsmesh.broker_index field. Index 0 is Europe, index 1 is US West. +# +# Optional UI metadata. Consumed by the GET /api/broker_presets endpoint +# so the React/Vue admin can render this preset in the "From Template" +# dropdown. `display_name` and `website` are advisory only — they are +# never read by the runtime broker connection code. +display_name: "LetsMesh" +website: "https://letsmesh.net" +brokers: + - name: "Europe (LetsMesh v1)" + enabled: true + host: mqtt-eu-v1.letsmesh.net + port: 443 + transport: "websockets" + audience: "mqtt-eu-v1.letsmesh.net" + use_jwt_auth: true + format: letsmesh + retain_status: false + tls: + enabled: true + insecure: false + + - name: "US West (LetsMesh v1)" + enabled: true + host: mqtt-us-v1.letsmesh.net + port: 443 + transport: "websockets" + audience: "mqtt-us-v1.letsmesh.net" + use_jwt_auth: true + format: letsmesh + retain_status: false + tls: + enabled: true + insecure: false diff --git a/repeater/presets/meshmapper.yaml b/repeater/presets/meshmapper.yaml new file mode 100644 index 00000000..c3cc2957 --- /dev/null +++ b/repeater/presets/meshmapper.yaml @@ -0,0 +1,33 @@ +# MeshMapper MC2MQTT broker preset. +# +# MeshMapper (https://meshmapper.net) is a community MeshCore visualization +# and analytics platform. Their single ingest broker speaks the standard +# MeshCoreToMQTT (MC2MQTT) protocol with the canonical +# `meshcore/{IATA}/{PUBLIC_KEY}/...` topic structure. Today the operator +# does not differentiate from the LetsMesh format flavor, so this preset +# uses `format: letsmesh` to match the published wire contract; bump to +# a dedicated `meshmapper` format value (and the corresponding entry in +# MC2MQTT_FORMATS in `repeater/data_acquisition/mqtt_handler.py`) only +# when there's a real wire-level deviation to express. +# +# Reference all MeshMapper endpoints with: brokers: [{preset: meshmapper}] +# +# Optional UI metadata. Consumed by the GET /api/broker_presets endpoint +# so the React/Vue admin can render this preset in the "From Template" +# dropdown. `display_name` and `website` are advisory only — they are +# never read by the runtime broker connection code. +display_name: "MeshMapper" +website: "https://meshmapper.net" +brokers: + - name: "MeshMapper" + enabled: true + host: mqtt.meshmapper.cc + port: 443 + transport: "websockets" + audience: "mqtt.meshmapper.cc" + use_jwt_auth: true + format: letsmesh + retain_status: false + tls: + enabled: true + insecure: false diff --git a/repeater/presets/waev.yaml b/repeater/presets/waev.yaml new file mode 100644 index 00000000..3c61ee1c --- /dev/null +++ b/repeater/presets/waev.yaml @@ -0,0 +1,38 @@ +# Waev MC2MQTT broker preset. +# +# Waev is a real-time telemetry, monitoring, and analytics platform for +# MeshCore radio networks. These brokers speak the MeshCoreToMQTT +# (MC2MQTT) protocol with the "waev" format flavor, which today shares +# the canonical MC2MQTT topic structure (meshcore/{IATA}/{PUBLIC_KEY}/...) +# and is reserved for future Waev-specific deviations. +# +# Reference all Waev endpoints with: brokers: [{preset: waev}] +# +# Redundancy model: a single client connection to `mqtt.waev.app`. The +# Waev edge Worker (see waev/src/router.ts: MQTT_PRIMARY_FAILOVER_TIMEOUT_MS) +# fans the WebSocket upgrade to broker A first with a 1500 ms timeout, +# then transparently retries against broker B on failure. Operators who +# want to pin to a single container can edit the broker after import and +# set `host`/`audience` to one of: +# - mqtt-a.waev.app (force primary, no failover) +# - mqtt-b.waev.app (force backup) +# +# Optional UI metadata. Consumed by the GET /api/broker_presets endpoint +# so the React/Vue admin can render this preset in the "From Template" +# dropdown. `display_name` and `website` are advisory only — they are +# never read by the runtime broker connection code. +display_name: "Waev" +website: "https://waev.app" +brokers: + - name: "Waev" + enabled: true + host: mqtt.waev.app + port: 443 + transport: "websockets" + audience: "mqtt.waev.app" + use_jwt_auth: true + format: waev + retain_status: true + tls: + enabled: true + insecure: false diff --git a/repeater/sensors/__init__.py b/repeater/sensors/__init__.py new file mode 100644 index 00000000..6625af9c --- /dev/null +++ b/repeater/sensors/__init__.py @@ -0,0 +1,12 @@ +from .base import SensorBase +from .manager import SensorManager +from .registry import SensorRegistry + +# HardwareStatsSensor is optional (requires psutil); import directly if needed: +# from repeater.sensors.hardware_stats import HardwareStatsSensor + +__all__ = [ + "SensorBase", + "SensorManager", + "SensorRegistry", +] diff --git a/repeater/sensors/base.py b/repeater/sensors/base.py new file mode 100644 index 00000000..1aaefb09 --- /dev/null +++ b/repeater/sensors/base.py @@ -0,0 +1,118 @@ +from __future__ import annotations + +import importlib.util +import logging +import subprocess +import sys +from abc import ABC, abstractmethod +from datetime import datetime, timezone +from typing import Any, Dict, Iterable, Optional, Tuple + + +class SensorBase(ABC): + """Base class for lightweight sensor plug-ins.""" + + sensor_type = "sensor" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log: Optional[logging.Logger] = None): + self.name = name + self.config = config or {} + self.settings = self.config.get("settings", {}) if isinstance(self.config, dict) else {} + self.enabled = bool(self.config.get("enabled", True)) if isinstance(self.config, dict) else True + self.log = log or logging.getLogger(self.__class__.__name__) + + @abstractmethod + def _read(self) -> Dict[str, Any]: + """Read the sensor and return a raw payload dictionary.""" + + def read(self) -> Dict[str, Any]: + timestamp = datetime.now(timezone.utc).isoformat() + if not self.enabled: + return self._result(ok=False, timestamp=timestamp, error="disabled") + + try: + data = self._read() + except Exception as exc: + self.log.warning("Sensor read failed for %s: %s", self.name, exc) + return self._result(ok=False, timestamp=timestamp, error=f"{type(exc).__name__}: {exc}") + + if data is None: + data = {} + if not isinstance(data, dict): + data = {"value": data} + + return self._result(ok=True, timestamp=timestamp, data=data) + + def _result( + self, + *, + ok: bool, + timestamp: str, + data: Optional[Dict[str, Any]] = None, + error: Optional[str] = None, + ) -> Dict[str, Any]: + result: Dict[str, Any] = { + "name": self.name, + "type": self.sensor_type, + "ok": ok, + "timestamp": timestamp, + "data": data or {}, + } + if error: + result["error"] = error + return result + + def _auto_install_enabled(self) -> bool: + """Return true when package auto-install is enabled for this sensor.""" + raw = self.config.get("auto_install_packages") if isinstance(self.config, dict) else False + return bool(raw) + + def ensure_python_modules(self, modules: Iterable[Tuple[str, str]]) -> bool: + """Ensure Python modules are importable; optionally install via pip if missing. + + modules: iterable of (import_name, pip_package_name). + """ + missing: list[Tuple[str, str]] = [] + for import_name, package_name in modules: + if importlib.util.find_spec(import_name) is None: + missing.append((import_name, package_name)) + + if not missing: + return True + + if not self._auto_install_enabled(): + names = ", ".join(pkg for _, pkg in missing) + self.log.warning( + "Missing sensor dependencies for %s: %s (set auto_install_packages=true to install automatically)", + self.name, + names, + ) + return False + + for import_name, package_name in missing: + self.log.info("Installing missing dependency for %s: %s", self.name, package_name) + result = subprocess.run( + [sys.executable, "-m", "pip", "install", package_name], + capture_output=True, + text=True, + check=False, + ) + if result.returncode != 0: + self.log.warning( + "Failed installing %s for %s: %s", + package_name, + self.name, + (result.stderr or result.stdout or "unknown error").strip(), + ) + return False + + if importlib.util.find_spec(import_name) is None: + self.log.warning( + "Dependency %s installed but module %s still unavailable for %s", + package_name, + import_name, + self.name, + ) + return False + + return True diff --git a/repeater/sensors/ens210.py b/repeater/sensors/ens210.py new file mode 100644 index 00000000..4ab6f29b --- /dev/null +++ b/repeater/sensors/ens210.py @@ -0,0 +1,106 @@ +""" +ENS210 relative humidity and temperature sensor plug-in. + +Requires: pip install smbus2 + +Config example: + - type: ens210 + name: "ambient" + enabled: true + auto_install_packages: false + settings: + i2c_address: 0x43 # Default ENS210 I2C address + bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + read_timeout_seconds: 1.0 # Max time to wait for valid data (polls every 50 ms) +""" + +from __future__ import annotations + +import time +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + +# ENS210 register addresses +_REG_SENS_RUN = 0x21 +_REG_SENS_START = 0x22 +_REG_T_VAL = 0x30 +_REG_H_VAL = 0x33 + + +@SensorRegistry.register("ens210") +class ENS210Sensor(SensorBase): + sensor_type = "ens210" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + self.i2c_address = int(self.settings.get("i2c_address", 0x43)) + self.bus_number = int(self.settings.get("bus_number", 1)) + self._poll_interval = 0.05 # 50 ms between validity checks + self._poll_attempts = max(1, int(float(self.settings.get("read_timeout_seconds", 1.0)) / self._poll_interval)) + + self.available = False + if not self.ensure_python_modules( + [ + ("smbus2", "smbus2"), + ] + ): + return + + try: + import smbus2 # type: ignore[import-not-found] + + self._smbus2 = smbus2 + # Verify the bus is accessible + smbus2.SMBus(self.bus_number).close() + self.available = True + self.log.info( + "ENS210 initialized (addr=0x%02X, bus=%d)", + self.i2c_address, + self.bus_number, + ) + except Exception as exc: + self.log.warning( + "ENS210 init failed (addr=0x%02X, bus=%d): %s", + self.i2c_address, + self.bus_number, + exc, + ) + self.available = False + + def _read(self) -> Dict[str, Any]: + """Read temperature and humidity from ENS210.""" + if not self.available: + raise RuntimeError("ENS210 device not available") + + bus = self._smbus2.SMBus(self.bus_number) + try: + bus.write_byte_data(self.i2c_address, _REG_SENS_RUN, 0x03) + bus.write_byte_data(self.i2c_address, _REG_SENS_START, 0x03) + + for _ in range(self._poll_attempts): + time.sleep(self._poll_interval) + t_data = bus.read_i2c_block_data(self.i2c_address, _REG_T_VAL, 3) + h_data = bus.read_i2c_block_data(self.i2c_address, _REG_H_VAL, 3) + if (t_data[2] & 0x01) and (h_data[2] & 0x01): + break + else: + raise RuntimeError( + f"ENS210 measurement timed out after {self._poll_attempts * self._poll_interval:.1f}s" + ) + + t_raw = t_data[0] | (t_data[1] << 8) + h_raw = h_data[0] | (h_data[1] << 8) + + return { + "temperature_c": round(t_raw / 64.0 - 273.15, 2), + "humidity_pct": round(h_raw / 512.0, 2), + } + except RuntimeError: + raise + except Exception as exc: + raise RuntimeError(f"ENS210 read failed: {exc}") from exc + finally: + bus.close() diff --git a/repeater/sensors/hardware_stats.py b/repeater/sensors/hardware_stats.py new file mode 100644 index 00000000..ef49d7c3 --- /dev/null +++ b/repeater/sensors/hardware_stats.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +from typing import Any, Dict + +from repeater.data_acquisition.hardware_stats import HardwareStatsCollector + +from .base import SensorBase +from .registry import SensorRegistry + + +@SensorRegistry.register("hardware_stats") +class HardwareStatsSensor(SensorBase): + sensor_type = "hardware_stats" + + def __init__(self, name: str, config: Dict[str, Any] | None = None, log=None): + super().__init__(name=name, config=config, log=log) + self.collector = HardwareStatsCollector() + + def _read(self) -> Dict[str, Any]: + return self.collector.get_stats() diff --git a/repeater/sensors/ina219.py b/repeater/sensors/ina219.py new file mode 100644 index 00000000..a0f063b2 --- /dev/null +++ b/repeater/sensors/ina219.py @@ -0,0 +1,142 @@ +""" +INA219 current/voltage/power monitor sensor plug-in. + +Requires: pip install smbus2 + +Config example: + - type: ina219 + name: "power_monitor" + enabled: true + auto_install_packages: false + settings: + i2c_address: 0x40 # Default INA219 I2C address + bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + max_expected_amps: 2.0 + shunt_ohms: 0.1 # 0.1 Ohm shunt resistor +""" + +from __future__ import annotations + +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + +# INA219 register map +_REG_CONFIG = 0x00 +_REG_SHUNT_VOLTAGE = 0x01 +_REG_BUS_VOLTAGE = 0x02 +_REG_POWER = 0x03 +_REG_CURRENT = 0x04 +_REG_CALIBRATION = 0x05 + +# 32V range, 320mV shunt range, 12-bit ADC, continuous shunt+bus conversion +_CONFIG_32V_320MV_CONTINUOUS = 0x399F + + +@SensorRegistry.register("ina219") +class INA219Sensor(SensorBase): + sensor_type = "ina219" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + self.i2c_address = int(self.settings.get("i2c_address", 0x40)) + self.bus_number = int(self.settings.get("bus_number", 1)) + self.max_expected_amps = float(self.settings.get("max_expected_amps", 2.0)) + self.shunt_ohms = float(self.settings.get("shunt_ohms", 0.1)) + + # INA219 calibration math from datasheet + if self.max_expected_amps <= 0: + self.max_expected_amps = 2.0 + if self.shunt_ohms <= 0: + self.shunt_ohms = 0.1 + + self.current_lsb = self.max_expected_amps / 32768.0 + cal = int(0.04096 / (self.current_lsb * self.shunt_ohms)) + self.calibration = max(1, min(cal, 0xFFFF)) + self.power_lsb = self.current_lsb * 20.0 + + self.available = False + if not self.ensure_python_modules( + [ + ("smbus2", "smbus2"), + ] + ): + return + + try: + import smbus2 # type: ignore[import-not-found] + + self._smbus2 = smbus2 + + # Verify bus is accessible and program sensor once + bus = smbus2.SMBus(self.bus_number) + try: + self._write_register(bus, _REG_CONFIG, _CONFIG_32V_320MV_CONTINUOUS) + self._write_register(bus, _REG_CALIBRATION, self.calibration) + finally: + bus.close() + + self.available = True + self.log.info( + "INA219 initialized (addr=0x%02X, bus=%d, shunt=%.3fΩ, max_A=%.1f)", + self.i2c_address, + self.bus_number, + self.shunt_ohms, + self.max_expected_amps, + ) + except Exception as exc: + self.log.warning( + "INA219 init failed (addr=0x%02X, bus=%d): %s", + self.i2c_address, + self.bus_number, + exc, + ) + self.available = False + + @staticmethod + def _swap_word(value: int) -> int: + return ((value & 0xFF) << 8) | ((value >> 8) & 0xFF) + + def _write_register(self, bus, register: int, value: int) -> None: + bus.write_word_data(self.i2c_address, register, self._swap_word(value & 0xFFFF)) + + def _read_register(self, bus, register: int) -> int: + return self._swap_word(bus.read_word_data(self.i2c_address, register)) + + @staticmethod + def _to_signed_16(value: int) -> int: + return value - 0x10000 if value & 0x8000 else value + + def _read(self) -> Dict[str, Any]: + """Read voltage, current, and power from INA219.""" + if not self.available: + raise RuntimeError("INA219 device not available") + + try: + bus = self._smbus2.SMBus(self.bus_number) + try: + # Reapply calibration in case the chip was reset externally. + self._write_register(bus, _REG_CALIBRATION, self.calibration) + + raw_bus = self._read_register(bus, _REG_BUS_VOLTAGE) + raw_shunt = self._to_signed_16(self._read_register(bus, _REG_SHUNT_VOLTAGE)) + raw_current = self._to_signed_16(self._read_register(bus, _REG_CURRENT)) + raw_power = self._read_register(bus, _REG_POWER) + finally: + bus.close() + + bus_voltage_v = ((raw_bus >> 3) & 0x1FFF) * 0.004 + shunt_voltage_v = raw_shunt * 0.00001 + current_ma = raw_current * self.current_lsb * 1000.0 + power_mw = raw_power * self.power_lsb * 1000.0 + + return { + "bus_voltage_v": round(bus_voltage_v, 3), + "shunt_voltage_v": round(shunt_voltage_v, 5), + "current_ma": round(current_ma, 2), + "power_mw": round(power_mw, 2), + } + except Exception as exc: + raise RuntimeError(f"INA219 read failed: {exc}") from exc diff --git a/repeater/sensors/manager.py b/repeater/sensors/manager.py new file mode 100644 index 00000000..5edf39e8 --- /dev/null +++ b/repeater/sensors/manager.py @@ -0,0 +1,176 @@ +from __future__ import annotations + +import importlib +import logging +import threading +from typing import Any, Dict, List, Optional + +from .registry import SensorRegistry + + +class SensorManager: + """Load and read sensor plug-ins declared in config with background polling.""" + + def __init__( + self, + config: Dict[str, Any], + *, + log: Optional[logging.Logger] = None, + registry: type[SensorRegistry] = SensorRegistry, + ): + self.config = config if isinstance(config, dict) else {} + self.log = log or logging.getLogger(self.__class__.__name__) + self.registry = registry + self.sensors = [] + + # Background polling + self._poll_thread: Optional[threading.Thread] = None + self._stop_event = threading.Event() + self._latest_readings: List[Dict[str, Any]] = [] + self._readings_lock = threading.RLock() + self._running = False + + self.reload() + + def _get_sensor_definitions(self) -> List[Dict[str, Any]]: + """Extract sensor definitions from config.""" + section = self.config.get("sensors", {}) + if not isinstance(section, dict): + return [] + global_auto_install = bool(section.get("auto_install_packages", False)) + definitions = section.get("definitions") or section.get("sensors") + if not isinstance(definitions, list): + return [] + out: List[Dict[str, Any]] = [] + for d in definitions: + if not isinstance(d, dict): + continue + entry = dict(d) + entry.setdefault("auto_install_packages", global_auto_install) + out.append(entry) + return out + + def _load_sensor_module(self, sensor_type: str) -> None: + """Import sensor module so @SensorRegistry.register decorators execute.""" + module_name = str(sensor_type).strip().lower().replace("-", "_") + package_name = __name__.rsplit(".", 1)[0] + importlib.import_module(f"{package_name}.{module_name}") + + def reload(self) -> None: + self.sensors = [] + for definition in self._get_sensor_definitions(): + if not definition.get("enabled", True): + continue + + sensor_type = definition.get("type") + name = definition.get("name") or str(sensor_type or "sensor") + if not sensor_type: + self.log.warning("Skipping sensor definition %r: missing type", name) + continue + + try: + self._load_sensor_module(sensor_type) + sensor = self.registry.create(sensor_type, name=name, config=definition) + except Exception as exc: + self.log.warning("Skipping sensor %r of type %r: %s", name, sensor_type, exc) + continue + + self.sensors.append(sensor) + + def start(self) -> None: + if self._running: + return + self.reload() + + # Start background polling thread if enabled and sensors exist + section = self.config.get("sensors", {}) + if not isinstance(section, dict) or not section.get("enabled", False): + self.log.debug("Sensor manager disabled in config") + return + + if not self.sensors: + self.log.debug("No sensors loaded; skipping background polling") + return + + self._stop_event.clear() + self._poll_thread = threading.Thread( + target=self._poll_loop, name="sensor-manager", daemon=True + ) + self._poll_thread.start() + self._running = True + self.log.info("Sensor manager polling started (%d sensors)", len(self.sensors)) + + def stop(self) -> None: + if not self._running: + return + self._stop_event.set() + if self._poll_thread and self._poll_thread.is_alive(): + self._poll_thread.join(timeout=2.0) + self._running = False + self.log.info("Sensor manager polling stopped") + + def read_all(self) -> List[Dict[str, Any]]: + readings: List[Dict[str, Any]] = [] + for sensor in self.sensors: + try: + readings.append(sensor.read()) + except Exception as exc: + self.log.warning("Sensor manager caught read error for %s: %s", sensor.name, exc) + readings.append( + { + "name": sensor.name, + "type": getattr(sensor, "sensor_type", "sensor"), + "ok": False, + "timestamp": None, + "data": {}, + "error": f"{type(exc).__name__}: {exc}", + } + ) + return readings + + def _poll_loop(self) -> None: + """Background thread: poll sensors at configured interval and cache readings.""" + section = self.config.get("sensors", {}) + poll_interval = 30.0 + if isinstance(section, dict): + try: + poll_interval = float(section.get("poll_interval_seconds", 30.0)) + except (TypeError, ValueError): + pass + + self.log.debug("Sensor polling loop started (interval=%.1f sec)", poll_interval) + + while not self._stop_event.is_set(): + try: + readings = self.read_all() + with self._readings_lock: + self._latest_readings = readings + except Exception as exc: + self.log.warning("Sensor poll cycle failed: %s", exc) + + # Wait for next poll or stop signal + self._stop_event.wait(poll_interval) + + self.log.debug("Sensor polling loop stopped") + + def get_summary(self) -> Dict[str, Any]: + section = self.config.get("sensors", {}) + poll_interval = 30.0 + if isinstance(section, dict): + try: + poll_interval = float(section.get("poll_interval_seconds", 30.0)) + except (TypeError, ValueError): + pass + + # Get cached readings (or empty list if not running) + with self._readings_lock: + readings = list(self._latest_readings) if self._latest_readings else [] + + return { + "enabled": bool(isinstance(section, dict) and section.get("enabled", False)), + "poll_interval_seconds": poll_interval, + "configured": len(self._get_sensor_definitions()), + "loaded": len(self.sensors), + "running": self._running, + "readings": readings, + } diff --git a/repeater/sensors/registry.py b/repeater/sensors/registry.py new file mode 100644 index 00000000..5fa615cb --- /dev/null +++ b/repeater/sensors/registry.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +from typing import Any, Callable, Dict, Optional + +from .base import SensorBase + + +class SensorRegistry: + _factories: Dict[str, Callable[..., SensorBase]] = {} + + @classmethod + def register(cls, sensor_type: str, factory: Optional[Callable[..., SensorBase]] = None): + """Register a sensor factory or class under a sensor type.""" + key = str(sensor_type).strip().lower() + + def _decorator(target): + cls._factories[key] = target + return target + + if factory is not None: + cls._factories[key] = factory + return factory + return _decorator + + @classmethod + def create(cls, sensor_type: str, name: str, config: Optional[Dict[str, Any]] = None, **kwargs) -> SensorBase: + key = str(sensor_type).strip().lower() + factory = cls._factories.get(key) + if factory is None: + raise ValueError(f"Unknown sensor type: {sensor_type}") + + if isinstance(factory, type) and issubclass(factory, SensorBase): + return factory(name=name, config=config, **kwargs) + return factory(name=name, config=config, **kwargs) + + @classmethod + def available_types(cls) -> list[str]: + return sorted(cls._factories) diff --git a/repeater/sensors/shtc3.py b/repeater/sensors/shtc3.py new file mode 100644 index 00000000..7ec30993 --- /dev/null +++ b/repeater/sensors/shtc3.py @@ -0,0 +1,110 @@ +""" +SHTC3 temperature and humidity sensor plug-in (RAK1901 WisBlock sensor). + +Requires: pip install smbus2 + +The SHTC3 uses 16-bit command words and requires a raw I2C read (no register +byte prefix), so smbus2.i2c_rdwr is used instead of the standard SMBus API. + +Config example: + - type: shtc3 + name: "ambient" + enabled: true + auto_install_packages: false + settings: + i2c_address: 0x70 # SHTC3 fixed I2C address + bus_number: 1 # I2C bus number (1 for Raspberry Pi default) +""" + +from __future__ import annotations + +import time +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + +# SHTC3 two-byte command words +_CMD_WAKE = [0x35, 0x17] +_CMD_MEAS = [0x7C, 0xA2] # T-first, normal power mode +_CMD_SLEEP = [0xB0, 0x98] + + +@SensorRegistry.register("shtc3") +class SHTC3Sensor(SensorBase): + sensor_type = "shtc3" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + self.i2c_address = int(self.settings.get("i2c_address", 0x70)) + self.bus_number = int(self.settings.get("bus_number", 1)) + + self.available = False + + if not self.ensure_python_modules([("smbus2", "smbus2")]): + return + + try: + import smbus2 # type: ignore[import-not-found] + self._smbus2 = smbus2 + + # Verify sensor is reachable: wake then immediately sleep + bus = smbus2.SMBus(self.bus_number) + try: + bus.i2c_rdwr(smbus2.i2c_msg.write(self.i2c_address, _CMD_WAKE)) + time.sleep(0.002) + bus.i2c_rdwr(smbus2.i2c_msg.write(self.i2c_address, _CMD_SLEEP)) + finally: + bus.close() + + self.available = True + self.log.info( + "SHTC3 initialized (addr=0x%02X, bus=%d)", + self.i2c_address, + self.bus_number, + ) + except Exception as exc: + self.log.warning( + "SHTC3 init failed (addr=0x%02X, bus=%d): %s", + self.i2c_address, + self.bus_number, + exc, + ) + self.available = False + + def _read(self) -> Dict[str, Any]: + """Read temperature and humidity from SHTC3.""" + if not self.available: + raise RuntimeError("SHTC3 device not available") + + smbus2 = self._smbus2 + bus = smbus2.SMBus(self.bus_number) + try: + bus.i2c_rdwr(smbus2.i2c_msg.write(self.i2c_address, _CMD_WAKE)) + time.sleep(0.002) + bus.i2c_rdwr(smbus2.i2c_msg.write(self.i2c_address, _CMD_MEAS)) + time.sleep(0.02) # measurement takes ~12 ms in normal power mode + + r = smbus2.i2c_msg.read(self.i2c_address, 6) + bus.i2c_rdwr(r) + data = list(r) + + bus.i2c_rdwr(smbus2.i2c_msg.write(self.i2c_address, _CMD_SLEEP)) + + # Bytes: T_MSB, T_LSB, T_CRC, RH_MSB, RH_LSB, RH_CRC + t_raw = (data[0] << 8) | data[1] + rh_raw = (data[3] << 8) | data[4] + temp_c = round(-45.0 + 175.0 * t_raw / 65536.0, 2) + temp_f = round(temp_c * 9.0 / 5.0 + 32.0, 2) + rh = round(100.0 * rh_raw / 65536.0, 2) + + return { + "temperature_c": temp_c, + "temperature_f": temp_f, + "humidity_pct": rh, + } + except Exception as exc: + raise RuntimeError(f"SHTC3 read failed: {exc}") from exc + finally: + bus.close() diff --git a/repeater/sensors/waveshare_ups_d.py b/repeater/sensors/waveshare_ups_d.py new file mode 100644 index 00000000..5b62232d --- /dev/null +++ b/repeater/sensors/waveshare_ups_d.py @@ -0,0 +1,148 @@ +""" +Waveshare UPS HAT (D) battery monitor plug-in — INA219 at I2C 0x43. + +Reads a single 21700 Li-ion cell via INA219. Reports voltage, current, +power, battery percent, and charge state. + +Requires: pip install smbus2 + +Config example: + - type: waveshare_ups_d + name: "battery" + enabled: true + auto_install_packages: false + settings: + i2c_address: 0x43 # Waveshare UPS HAT (D) fixed address + bus_number: 1 # I2C bus number (1 for Raspberry Pi default) +""" + +from __future__ import annotations + +import time +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + +# INA219 register addresses +_REG_CONFIG = 0x00 +_REG_SHUNT = 0x01 +_REG_BUS = 0x02 +_REG_POWER = 0x03 +_REG_CURRENT = 0x04 +_REG_CAL = 0x05 + +# 32V range, ±320mV gain, 128-sample averaging, continuous shunt+bus +_CONFIG_VALUE = 0x3FFF + +# Waveshare UPS HAT (D) calibration — 0.01Ω shunt (per Waveshare sample code) +# current_lsb ≈ 0.1524 mA/LSB, power_lsb = current_lsb × 20 +_CAL_VALUE = 26868 +_CURRENT_LSB = 0.0001524 # A per LSB +_POWER_LSB = _CURRENT_LSB * 20.0 # W per LSB + + +def _voltage_to_percent(v: float) -> int: + """Piecewise linear SoC estimate for a single 21700 Li-ion cell (3.0–4.2 V).""" + if v >= 4.20: return 100 + if v >= 4.00: return int(85 + (v - 4.00) / 0.20 * 15) + if v >= 3.80: return int(60 + (v - 3.80) / 0.20 * 25) + if v >= 3.70: return int(40 + (v - 3.70) / 0.10 * 20) + if v >= 3.50: return int(15 + (v - 3.50) / 0.20 * 25) + if v >= 3.00: return int( (v - 3.00) / 0.50 * 15) + return 0 + + +@SensorRegistry.register("waveshare_ups_d") +class WaveshareUpsDSensor(SensorBase): + sensor_type = "waveshare_ups_d" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + self.i2c_address = int(self.settings.get("i2c_address", 0x43)) + self.bus_number = int(self.settings.get("bus_number", 1)) + + self.available = False + + if not self.ensure_python_modules([("smbus2", "smbus2")]): + return + + try: + import smbus2 # type: ignore[import-not-found] + self._smbus2 = smbus2 + + bus = smbus2.SMBus(self.bus_number) + try: + self._write(bus, _REG_CONFIG, _CONFIG_VALUE) + self._write(bus, _REG_CAL, _CAL_VALUE) + # 128-sample averaging takes ~68 ms; wait for first conversion + time.sleep(0.15) + finally: + bus.close() + + self.available = True + self.log.info( + "Waveshare UPS HAT (D) INA219 initialized (addr=0x%02X, bus=%d)", + self.i2c_address, + self.bus_number, + ) + except Exception as exc: + self.log.warning( + "Waveshare UPS HAT (D) init failed (addr=0x%02X, bus=%d): %s", + self.i2c_address, + self.bus_number, + exc, + ) + + def _write(self, bus, reg: int, val: int) -> None: + bus.write_i2c_block_data( + self.i2c_address, reg, [(val >> 8) & 0xFF, val & 0xFF] + ) + + def _read_u(self, bus, reg: int) -> int: + d = bus.read_i2c_block_data(self.i2c_address, reg, 2) + return (d[0] << 8) | d[1] + + def _read_s(self, bus, reg: int) -> int: + v = self._read_u(bus, reg) + return v - 0x10000 if v & 0x8000 else v + + def _read(self) -> Dict[str, Any]: + """Read voltage, current, power, and derived battery state.""" + if not self.available: + raise RuntimeError("Waveshare UPS HAT (D) not available") + + try: + bus = self._smbus2.SMBus(self.bus_number) + try: + # Re-apply calibration in case of external reset + self._write(bus, _REG_CAL, _CAL_VALUE) + + bus_v = (self._read_u(bus, _REG_BUS) >> 3) * 4 / 1000.0 + shunt_mv = self._read_s(bus, _REG_SHUNT) * 0.01 + current_ma = self._read_s(bus, _REG_CURRENT) * _CURRENT_LSB * 1000.0 + power_mw = self._read_u(bus, _REG_POWER) * _POWER_LSB * 1000.0 + finally: + bus.close() + + pct = _voltage_to_percent(bus_v) + + # HAT (D) sign convention: negative = charging, positive = discharging + if current_ma < -50: + state = "charging" + elif current_ma > 50: + state = "discharging" + else: + state = "idle" + + return { + "bus_voltage_v": round(bus_v, 3), + "shunt_voltage_mv": round(shunt_mv, 2), + "current_ma": round(current_ma, 1), + "power_mw": round(power_mw, 1), + "battery_percent": pct, + "charge_state": state, + } + except Exception as exc: + raise RuntimeError(f"Waveshare UPS HAT (D) read failed: {exc}") from exc diff --git a/repeater/sensors/waveshare_ups_e.py b/repeater/sensors/waveshare_ups_e.py new file mode 100644 index 00000000..0ec3e5cc --- /dev/null +++ b/repeater/sensors/waveshare_ups_e.py @@ -0,0 +1,149 @@ +""" +Waveshare UPS HAT (E) battery monitor plug-in — BMS MCU at I2C 0x2D. + +The HAT (E) uses a dedicated BMS chip (not an INA219) that exposes charge +state, pack voltage/current, per-cell voltages, remaining capacity in mAh, +and time-to-empty / time-to-full estimates directly via I2C registers. + +Requires: pip install smbus2 + +Config example: + - type: waveshare_ups_e + name: "battery" + enabled: true + auto_install_packages: false + settings: + i2c_address: 0x2D # Waveshare UPS HAT (E) fixed address + bus_number: 1 # I2C bus number (1 for Raspberry Pi default) + low_cell_mv: 3150 # Per-cell warning threshold in mV +""" + +from __future__ import annotations + +from typing import Any, Dict, Optional + +from .base import SensorBase +from .registry import SensorRegistry + +# Register map +_REG_STATUS = 0x02 # 1 byte — charge state flags +_REG_VBUS = 0x10 # 6 bytes — input (VBUS) voltage, current, power +_REG_BATT = 0x20 # 12 bytes — pack voltage, current, percent, mAh, time +_REG_CELLS = 0x30 # 8 bytes — four cell voltages (LE uint16 each) + +# Charge state flag bits +_FLAG_FAST_CHARGE = 0x40 +_FLAG_CHARGING = 0x80 +_FLAG_DISCHARGING = 0x20 + + +def _u16le(data: list, offset: int) -> int: + return data[offset] | (data[offset + 1] << 8) + + +@SensorRegistry.register("waveshare_ups_e") +class WaveshareUpsESensor(SensorBase): + sensor_type = "waveshare_ups_e" + + def __init__(self, name: str, config: Optional[Dict[str, Any]] = None, log=None): + super().__init__(name=name, config=config, log=log) + + addr = self.settings.get("i2c_address", 0x2D) + self.i2c_address = int(addr, 0) if isinstance(addr, str) else int(addr) + self.bus_number = int(self.settings.get("bus_number", 1)) + self.low_cell_mv = int(self.settings.get("low_cell_mv", 3150)) + + self.available = False + + if not self.ensure_python_modules([("smbus2", "smbus2")]): + return + + try: + import smbus2 # type: ignore[import-not-found] + self._smbus2 = smbus2 + + bus = smbus2.SMBus(self.bus_number) + try: + bus.read_i2c_block_data(self.i2c_address, _REG_STATUS, 1) + finally: + bus.close() + + self.available = True + self.log.info( + "Waveshare UPS HAT (E) initialized (addr=0x%02X, bus=%d)", + self.i2c_address, + self.bus_number, + ) + except Exception as exc: + self.log.warning( + "Waveshare UPS HAT (E) init failed (addr=0x%02X, bus=%d): %s", + self.i2c_address, + self.bus_number, + exc, + ) + + def _read(self) -> Dict[str, Any]: + """Read all battery state from the HAT (E) BMS.""" + if not self.available: + raise RuntimeError("Waveshare UPS HAT (E) not available") + + try: + bus = self._smbus2.SMBus(self.bus_number) + try: + status = bus.read_i2c_block_data(self.i2c_address, _REG_STATUS, 1)[0] + vb = bus.read_i2c_block_data(self.i2c_address, _REG_VBUS, 6) + bd = bus.read_i2c_block_data(self.i2c_address, _REG_BATT, 12) + cd = bus.read_i2c_block_data(self.i2c_address, _REG_CELLS, 8) + finally: + bus.close() + + # Charge state + if status & _FLAG_FAST_CHARGE: charge_state = "fast_charging" + elif status & _FLAG_CHARGING: charge_state = "charging" + elif status & _FLAG_DISCHARGING: charge_state = "discharging" + else: charge_state = "idle" + + # VBUS (input power from charger) + vbus_voltage_mv = _u16le(vb, 0) + vbus_current_ma = _u16le(vb, 2) + vbus_power_mw = _u16le(vb, 4) + + # Battery pack + batt_voltage_mv = _u16le(bd, 0) + batt_current_ma = _u16le(bd, 2) + if batt_current_ma > 0x7FFF: # signed 16-bit + batt_current_ma -= 0xFFFF + batt_percent = _u16le(bd, 4) + remaining_mah = _u16le(bd, 6) + time_remaining = _u16le(bd, 8) + time_to_full = _u16le(bd, 10) + + # Per-cell voltages (4 cells) + cells_mv = [ + _u16le(cd, 0), _u16le(cd, 2), + _u16le(cd, 4), _u16le(cd, 6), + ] + + result: Dict[str, Any] = { + "charge_state": charge_state, + "battery_voltage_mv": batt_voltage_mv, + "battery_current_ma": batt_current_ma, + "battery_percent": batt_percent, + "remaining_capacity_mah": remaining_mah, + "vbus_voltage_mv": vbus_voltage_mv, + "vbus_current_ma": vbus_current_ma, + "vbus_power_mw": vbus_power_mw, + "cell_voltages_mv": cells_mv, + "low_cell_warning": any(0 < v < self.low_cell_mv for v in cells_mv), + } + + # Only include whichever time estimate is relevant + if batt_current_ma < 0: + result["time_to_empty_min"] = time_remaining + else: + result["time_to_full_min"] = time_to_full + + return result + + except Exception as exc: + raise RuntimeError(f"Waveshare UPS HAT (E) read failed: {exc}") from exc diff --git a/repeater/service_utils.py b/repeater/service_utils.py index a127e48c..c52902d7 100644 --- a/repeater/service_utils.py +++ b/repeater/service_utils.py @@ -6,14 +6,18 @@ import logging import os import subprocess -from typing import Tuple +import threading +import time +from typing import Dict, Optional, Tuple logger = logging.getLogger("ServiceUtils") INIT_SCRIPT = "/etc/init.d/S80pymc-repeater" +BUILDROOT_METADATA_PATH = "/etc/pymc-image-build-id" +_CONTAINER_RESTART_DELAY_SECONDS = 1.0 def is_buildroot() -> bool: - if os.path.exists("/etc/pymc-image-build-id"): + if os.path.exists(BUILDROOT_METADATA_PATH): return True if os.path.exists("/etc/os-release"): try: @@ -24,6 +28,70 @@ def is_buildroot() -> bool: return False +def get_buildroot_image_info() -> Dict[str, str]: + info: Dict[str, str] = {} + + try: + with open(BUILDROOT_METADATA_PATH, "r", encoding="utf-8") as handle: + for line in handle: + line = line.strip() + if not line or "=" not in line: + continue + key, value = line.split("=", 1) + info[key.strip()] = value.strip() + except OSError: + return {} + + return info + + +def get_buildroot_image_version() -> Optional[str]: + return get_buildroot_image_info().get("image_version") + + +def is_container() -> bool: + """Detect common Docker/LXC/containerized environments.""" + if os.path.exists("/.dockerenv") or os.environ.get("container"): + return True + + try: + with open("/proc/1/environ", "rb") as handle: + if b"container=" in handle.read(): + return True + except (OSError, PermissionError): + pass + + try: + with open("/proc/1/cgroup", "r", encoding="utf-8") as handle: + cgroup_data = handle.read() + if any(token in cgroup_data for token in ("docker", "containerd", "kubepods", "lxc")): + return True + except OSError: + pass + + return os.path.exists("/run/host/container-manager") + + +def _schedule_container_exit(delay_seconds: float = _CONTAINER_RESTART_DELAY_SECONDS) -> None: + """Exit the current process shortly after returning success to the caller.""" + + def _exit_process() -> None: + time.sleep(delay_seconds) + logger.warning("Exiting repeater process to trigger container restart") + os._exit(0) + + threading.Thread(target=_exit_process, name="container-restart-exit", daemon=True).start() + + +def get_container_restart_message() -> str: + """Return the user-facing restart message for containerized installs.""" + return ( + "Container restart initiated. " + "If you are running pyMC Repeater via Docker or Home Assistant, pull or rebuild " + "a newer image for packaged image updates to take effect." + ) + + def restart_service() -> Tuple[bool, str]: """ Restart the pymc-repeater service. @@ -36,6 +104,11 @@ def restart_service() -> Tuple[bool, str]: Returns: Tuple[bool, str]: (success, message) """ + if is_container(): + _schedule_container_exit() + logger.info("Container environment detected; scheduled process exit for container restart") + return True, get_container_restart_message() + if is_buildroot(): if not os.path.exists(INIT_SCRIPT): logger.error("Buildroot init script not found: %s", INIT_SCRIPT) diff --git a/repeater/web/api_endpoints.py b/repeater/web/api_endpoints.py index 47760380..e0b806d2 100644 --- a/repeater/web/api_endpoints.py +++ b/repeater/web/api_endpoints.py @@ -15,7 +15,8 @@ find_companion_index, heal_companion_empty_names, ) -from repeater.config import update_unscoped_flood_policy +from repeater.config import resolve_storage_dir, update_unscoped_flood_policy +from repeater.service_utils import get_buildroot_image_info from .auth.middleware import require_auth from .auth_endpoints import AuthAPIEndpoints @@ -41,9 +42,12 @@ # System # GET /api/stats - Get system statistics +# GET /api/gps - Get local GPS diagnostics and parsed NMEA attributes +# GET /api/gps_stream - GPS diagnostics SSE stream # GET /api/logs - Get system logs # GET /api/hardware_stats - Get hardware statistics # GET /api/hardware_processes - Get process information +# GET /api/validate_config - Validate config.yaml syntax and required settings # POST /api/restart_service - Restart the repeater service # GET /api/openapi - Get OpenAPI specification @@ -56,6 +60,7 @@ # POST /api/update_advert_rate_limit_config - Update advert rate limiting settings # GET /api/mqtt_status - Get MQTT Observer connection status # POST /api/update_mqtt_config - Update MQTT Observer configuration +# GET /api/broker_presets - List bundled MC2MQTT broker presets (waev, letsmesh, …) # Packets # GET /api/packet_stats?hours=24 - Get packet statistics @@ -131,8 +136,10 @@ # Setup Wizard # GET /api/needs_setup - Check if repeater needs initial setup +# GET /api/site_info - Get site identification name (public, no auth required) # GET /api/hardware_options - Get available hardware configurations # GET /api/radio_presets - Get radio preset configurations +# GET /api/serial_ports - Discover available serial/USB modem device paths # POST /api/setup_wizard - Complete initial setup wizard # Backup & Restore @@ -293,6 +300,25 @@ def _process_gauge_data(self, data_points, timestamps_ms): values = [v if v is not None else 0 for v in data_points] return [[timestamps_ms[i], values[i]] for i in range(min(len(values), len(timestamps_ms)))] + def _setup_status_from_config(self, config: dict) -> tuple[bool, dict]: + """Return whether first-run setup should still be available.""" + node_name = config.get("repeater", {}).get("node_name", "") + has_default_name = node_name in ["mesh-repeater-01", ""] + + admin_password = config.get("repeater", {}).get("security", {}).get("admin_password", "") + has_default_password = admin_password in ["admin123", ""] + + radio_type_raw = config.get("radio_type") + radio_type = "" if radio_type_raw is None else str(radio_type_raw).lower().strip() + radio_not_configured = radio_type in ("", "none", "null", "disabled", "off", "no_radio") + + reasons = { + "default_name": has_default_name, + "default_password": has_default_password, + "radio_not_configured": radio_not_configured, + } + return has_default_name or has_default_password or radio_not_configured, reasons + # ============================================================================ # SETUP WIZARD ENDPOINTS # ============================================================================ @@ -302,30 +328,38 @@ def _process_gauge_data(self, data_points, timestamps_ms): def needs_setup(self): """Check if the repeater needs initial setup configuration""" try: - config = self.config - - # Check for default values that indicate first-time setup - node_name = config.get("repeater", {}).get("node_name", "") - has_default_name = node_name in ["mesh-repeater-01", ""] + # Prefer the on-disk config so this reflects current persisted state. + import yaml - admin_password = ( - config.get("repeater", {}).get("security", {}).get("admin_password", "") - ) - has_default_password = admin_password in ["admin123", ""] + config = self.config + try: + with open(self._config_path, "r") as f: + config = yaml.safe_load(f) or {} + except Exception: + # Fall back to in-memory config if file cannot be read. + pass - needs_setup = has_default_name or has_default_password + needs_setup, reasons = self._setup_status_from_config(config) return { "needs_setup": needs_setup, - "reasons": { - "default_name": has_default_name, - "default_password": has_default_password, - }, + "reasons": reasons, } except Exception as e: logger.error(f"Error checking setup status: {e}") return {"needs_setup": False, "error": str(e)} + @cherrypy.expose + @cherrypy.tools.json_out() + def site_info(self): + """Return the site identification name (public endpoint, no auth required).""" + try: + site_name = self.config.get("web", {}).get("site_name", "") or "" + return {"success": True, "site_name": str(site_name)} + except Exception as e: + logger.error(f"Error serving site_info: {e}") + return {"success": True, "site_name": ""} + @cherrypy.expose @cherrypy.tools.json_out() def hardware_options(self): @@ -334,12 +368,7 @@ def hardware_options(self): import json # Check config-based location first, then development location - storage_dir_cfg = ( - self.config.get("storage", {}).get("storage_dir") - or self.config.get("storage_dir") - or "/var/lib/pymc_repeater" - ) - config_dir = Path(storage_dir_cfg) + config_dir = resolve_storage_dir(self.config, config_path=self._config_path) installed_path = config_dir / "radio-settings.json" dev_path = os.path.join(os.path.dirname(__file__), "..", "..", "radio-settings.json") @@ -361,16 +390,6 @@ def hardware_options(self): } ) - # Add MeshCore KISS modem option (serial TNC) - hardware_list.append( - { - "key": "kiss", - "name": "KISS modem (serial)", - "description": "MeshCore KISS modem over serial – requires pyMC_core with KISS support", - "config": {}, - } - ) - return {"hardware": hardware_list} except Exception as e: logger.error(f"Error loading hardware options: {e}") @@ -384,12 +403,7 @@ def radio_presets(self): import json # Check config-based location first, then development location - storage_dir_cfg = ( - self.config.get("storage", {}).get("storage_dir") - or self.config.get("storage_dir") - or "/var/lib/pymc_repeater" - ) - config_dir = Path(storage_dir_cfg) + config_dir = resolve_storage_dir(self.config, config_path=self._config_path) installed_path = config_dir / "radio-presets.json" dev_path = os.path.join(os.path.dirname(__file__), "..", "..", "radio-presets.json") @@ -414,6 +428,50 @@ def radio_presets(self): logger.error(f"Error loading radio presets: {e}") return {"error": str(e)} + @cherrypy.expose + @cherrypy.tools.json_out() + def serial_ports(self): + """Discover available serial/USB modem device paths.""" + try: + devices = [] + + # Preferred: pyserial provides stable metadata (VID/PID, product, serial number). + try: + from serial.tools import list_ports + + for port in list_ports.comports(): + label_parts = [port.device] + if getattr(port, "description", None): + label_parts.append(str(port.description)) + if getattr(port, "hwid", None) and str(port.hwid) != "n/a": + label_parts.append(str(port.hwid)) + devices.append( + { + "device": str(port.device), + "description": " - ".join(label_parts), + } + ) + except Exception: + # Fallback for environments where pyserial is unavailable. + import glob + + for pattern in ("/dev/ttyACM*", "/dev/ttyUSB*", "/dev/ttyS*", "/dev/serial/by-id/*"): + for dev in glob.glob(pattern): + devices.append({"device": str(dev), "description": str(dev)}) + + # De-duplicate by device path while preserving the first description. + dedup = {} + for item in devices: + dev = item.get("device") + if dev and dev not in dedup: + dedup[dev] = item + + sorted_devices = sorted(dedup.values(), key=lambda x: x["device"]) + return self._success(sorted_devices) + except Exception as e: + logger.error(f"Error discovering serial ports: {e}") + return self._error(str(e)) + @cherrypy.expose @cherrypy.tools.json_out() @cherrypy.tools.json_in() @@ -423,6 +481,24 @@ def setup_wizard(self): self._require_post() data = cherrypy.request.json + import yaml + + # Setup wizard is first-run only. After setup, use /auth/change_password + # and /api/update_radio_config for subsequent changes. + try: + with open(self._config_path, "r") as f: + current_config = yaml.safe_load(f) or {} + except Exception: + current_config = self.config or {} + + needs_setup, _ = self._setup_status_from_config(current_config) + if not needs_setup: + cherrypy.response.status = 403 + return { + "success": False, + "error": "Setup is already complete. Use authenticated endpoints for configuration changes.", + } + # Validate required fields node_name = data.get("node_name", "").strip() if not node_name: @@ -445,12 +521,7 @@ def setup_wizard(self): import json - storage_dir_cfg = ( - self.config.get("storage", {}).get("storage_dir") - or self.config.get("storage_dir") - or "/var/lib/pymc_repeater" - ) - config_dir = Path(storage_dir_cfg) + config_dir = resolve_storage_dir(self.config, config_path=self._config_path) installed_path = config_dir / "radio-settings.json" dev_path = os.path.join(os.path.dirname(__file__), "..", "..", "radio-settings.json") hardware_file = str(installed_path) if installed_path.exists() else dev_path @@ -468,8 +539,6 @@ def setup_wizard(self): else: hw_config = {} - import yaml - # Read current config first so we can update it with open(self._config_path, "r") as f: config_yaml = yaml.safe_load(f) @@ -493,15 +562,75 @@ def setup_wizard(self): config_yaml["radio"]["bandwidth"] = int(bw_khz * 1000) config_yaml["radio"]["coding_rate"] = int(radio_preset.get("coding_rate", 5)) + tx_power_raw = radio_preset.get("tx_power") + tx_power_preset = None + if tx_power_raw not in (None, ""): + try: + tx_power_preset = int(tx_power_raw) + except (TypeError, ValueError): + return {"success": False, "error": "TX power must be an integer"} + if tx_power_preset < -9 or tx_power_preset > 22: + return { + "success": False, + "error": "TX power must be between -9 and +22 dBm", + } + if hardware_key == "kiss": # KISS modem: set radio_type and kiss section (port/baud from request or defaults) config_yaml["radio_type"] = "kiss" kiss_port = (data.get("kiss_port") or "").strip() or "/dev/ttyUSB0" kiss_baud = int(data.get("kiss_baud_rate", data.get("kiss_baud", 115200))) config_yaml["kiss"] = {"port": kiss_port, "baud_rate": kiss_baud} - config_yaml["radio"]["tx_power"] = int(radio_preset.get("tx_power", 14)) + config_yaml["radio"]["tx_power"] = tx_power_preset if tx_power_preset is not None else 14 if "preamble_length" not in config_yaml["radio"]: config_yaml["radio"]["preamble_length"] = 17 + elif hardware_key == "pymc_usb": + # pymc_usb modem: external SX1262 board over USB-CDC. + # Accept pymc_usb_port / pymc_usb_baudrate from the request body + # (mirrors the KISS pattern) so a future SPA can expose inputs; + # fall back to /dev/ttyACM0 at 921600 baud, which matches the + # firmware default and the typical USB-CDC modem device on Linux. + config_yaml["radio_type"] = "pymc_usb" + usb_port = (data.get("pymc_usb_port") or "").strip() or "/dev/ttyACM0" + usb_baud = int(data.get("pymc_usb_baudrate", data.get("pymc_usb_baud", 921600))) + pymc_usb_section = config_yaml.setdefault("pymc_usb", {}) + pymc_usb_section["port"] = usb_port + pymc_usb_section["baudrate"] = usb_baud + pymc_usb_section.setdefault("lbt_enabled", True) + pymc_usb_section.setdefault("lbt_max_attempts", 5) + if tx_power_preset is not None: + config_yaml["radio"]["tx_power"] = tx_power_preset + elif "tx_power" in hw_config: + config_yaml["radio"]["tx_power"] = hw_config.get("tx_power", 22) + if "preamble_length" in hw_config: + config_yaml["radio"]["preamble_length"] = hw_config.get("preamble_length", 16) + elif hardware_key == "pymc_tcp": + # pymc_tcp modem: external SX1262 board exposed as TCP over Wi-Fi/Ethernet. + # 'host' has no sensible default — must be the modem's LAN address or + # mDNS name. Accept it from the request body if the SPA provides it, + # otherwise write a clearly-placeholder hostname so the file is valid + # YAML and the user gets a startup error pointing them at the right + # section to edit (see config.py: ValueError 'Missing host …'). + config_yaml["radio_type"] = "pymc_tcp" + tcp_host = (data.get("pymc_tcp_host") or "").strip() or "REPLACE_WITH_MODEM_HOST" + tcp_port = int(data.get("pymc_tcp_port", 5055)) + pymc_tcp_section = config_yaml.setdefault("pymc_tcp", {}) + pymc_tcp_section["host"] = tcp_host + pymc_tcp_section["port"] = tcp_port + tcp_token = data.get("pymc_tcp_token") + if tcp_token is not None: + pymc_tcp_section["token"] = str(tcp_token) + else: + pymc_tcp_section.setdefault("token", "") + pymc_tcp_section.setdefault("connect_timeout", 5.0) + pymc_tcp_section.setdefault("lbt_enabled", True) + pymc_tcp_section.setdefault("lbt_max_attempts", 5) + if tx_power_preset is not None: + config_yaml["radio"]["tx_power"] = tx_power_preset + elif "tx_power" in hw_config: + config_yaml["radio"]["tx_power"] = hw_config.get("tx_power", 22) + if "preamble_length" in hw_config: + config_yaml["radio"]["preamble_length"] = hw_config.get("preamble_length", 16) else: # SX1262 / sx1262_ch341: radio_type and optional CH341 from hw_config if "radio_type" in hw_config: @@ -520,7 +649,9 @@ def setup_wizard(self): if pid is not None: config_yaml["ch341"]["pid"] = pid - if "tx_power" in hw_config: + if tx_power_preset is not None: + config_yaml["radio"]["tx_power"] = tx_power_preset + elif "tx_power" in hw_config: config_yaml["radio"]["tx_power"] = hw_config.get("tx_power", 22) if "preamble_length" in hw_config: config_yaml["radio"]["preamble_length"] = hw_config.get("preamble_length", 17) @@ -543,6 +674,8 @@ def setup_wizard(self): config_yaml["sx1262"]["rxen_pin"] = hw_config.get("rxen_pin", -1) if "en_pin" in hw_config: config_yaml["sx1262"]["en_pin"] = hw_config.get("en_pin", -1) + if "en_pins" in hw_config: + config_yaml["sx1262"]["en_pins"] = hw_config.get("en_pins", []) if "cs_pin" in hw_config: config_yaml["sx1262"]["cs_pin"] = hw_config.get("cs_pin", -1) if "txled_pin" in hw_config: @@ -586,7 +719,7 @@ def delayed_restart(): result_config = { "node_name": node_name, "hardware": hardware_key, - "radio_type": config_yaml.get("radio_type", "sx1262"), + "radio_type": config_yaml.get("radio_type"), "frequency": freq_mhz, "spreading_factor": radio_preset.get("spreading_factor"), "bandwidth": radio_preset.get("bandwidth"), @@ -595,6 +728,15 @@ def delayed_restart(): if hardware_key == "kiss": result_config["kiss_port"] = config_yaml.get("kiss", {}).get("port") result_config["kiss_baud_rate"] = config_yaml.get("kiss", {}).get("baud_rate") + elif hardware_key == "pymc_usb": + pymc_usb_cfg = config_yaml.get("pymc_usb", {}) + result_config["pymc_usb_port"] = pymc_usb_cfg.get("port") + result_config["pymc_usb_baudrate"] = pymc_usb_cfg.get("baudrate") + elif hardware_key == "pymc_tcp": + pymc_tcp_cfg = config_yaml.get("pymc_tcp", {}) + result_config["pymc_tcp_host"] = pymc_tcp_cfg.get("host") + result_config["pymc_tcp_port"] = pymc_tcp_cfg.get("port") + # token deliberately omitted from response (sensitive) return { "success": True, "message": "Setup completed successfully. Service is restarting...", @@ -616,6 +758,15 @@ def delayed_restart(): def stats(self): try: stats = self.stats_getter() if self.stats_getter else {} + # Include active radio configuration in stats so UI can hydrate + # directly from this endpoint without additional config fetches. + stats["radio_type"] = self.config.get("radio_type") + stats["sx1262"] = self.config.get("sx1262", {}) + stats["ch341"] = self.config.get("ch341", {}) + stats["kiss"] = self.config.get("kiss", {}) + stats["pymc_usb"] = self.config.get("pymc_usb", {}) + stats["pymc_tcp"] = self.config.get("pymc_tcp", {}) + stats["site_name"] = self.config.get("web", {}).get("site_name", "") stats["version"] = __version__ try: import pymc_core @@ -623,11 +774,145 @@ def stats(self): stats["core_version"] = pymc_core.__version__ except ImportError: stats["core_version"] = "unknown" + image_info = get_buildroot_image_info() + if image_info: + if image_info.get("image_name"): + stats["image_name"] = image_info["image_name"] + if image_info.get("image_version"): + stats["image_version"] = image_info["image_version"] return stats except Exception as e: logger.error(f"Error serving stats: {e}") return {"error": str(e)} + @cherrypy.expose + @cherrypy.tools.json_out() + def gps(self): + """Get full local GPS diagnostics and parsed NMEA attributes.""" + try: + gps_service = getattr(self.daemon_instance, "gps_service", None) + if gps_service: + return self._success(gps_service.get_snapshot()) + + return self._success( + { + "enabled": False, + "running": False, + "source": self.config.get("gps", {}), + "status": { + "state": "disabled", + "fix_valid": False, + "stale": True, + "age_seconds": None, + "last_update": None, + "last_error": "GPS service is not initialized", + }, + "fix": { + "valid": False, + "status": None, + "quality": None, + "quality_label": "no fix", + "gsa_fix_type": None, + "gsa_fix_type_label": None, + }, + "position": { + "latitude": None, + "longitude": None, + "altitude_m": None, + "geoid_separation_m": None, + }, + "motion": { + "speed_knots": None, + "speed_kmh": None, + "course_degrees": None, + "magnetic_variation_degrees": None, + }, + "accuracy": {"hdop": None, "pdop": None, "vdop": None}, + "time": {"utc_time": None, "date": None, "datetime_utc": None}, + "location_update": { + "enabled": False, + "state": "disabled", + "last_attempt": None, + "last_success": None, + "last_error": None, + "last_latitude": None, + "last_longitude": None, + "interval_seconds": None, + }, + "satellites": { + "used_count": None, + "used_prns": [], + "in_view_count": None, + "in_view": [], + "snr": {"min": None, "max": None, "avg": None}, + }, + "nmea": { + "last_sentence": None, + "last_sentence_type": None, + "last_talker": None, + "seen_sentence_types": [], + "sentence_counters": {}, + "valid_checksum_count": 0, + "invalid_checksum_count": 0, + "missing_checksum_count": 0, + "recent_sentences": [], + }, + "raw_attributes": {}, + } + ) + except Exception as e: + logger.error(f"Error serving GPS diagnostics: {e}", exc_info=True) + return self._error(e) + + @cherrypy.expose + def gps_stream(self): + """Server-Sent Events stream for GPS diagnostics snapshots.""" + cherrypy.response.headers["Content-Type"] = "text/event-stream" + cherrypy.response.headers["Cache-Control"] = "no-cache" + cherrypy.response.headers["Connection"] = "keep-alive" + + def generate(): + last_snapshot_json: Optional[str] = None + last_keepalive = time.time() + + try: + yield ( + f"data: {json.dumps({'type': 'connected', 'message': 'Connected to GPS stream'})}" + "\n\n" + ) + + while True: + response = self.gps() + if response.get("success"): + snapshot = response.get("data") + snapshot_json = json.dumps(snapshot, sort_keys=True, default=str) + + if snapshot_json != last_snapshot_json: + yield ( + f"data: {json.dumps({'type': 'snapshot', 'data': snapshot})}" + "\n\n" + ) + last_snapshot_json = snapshot_json + last_keepalive = time.time() + elif (time.time() - last_keepalive) >= 15: + yield f"data: {json.dumps({'type': 'keepalive'})}\n\n" + last_keepalive = time.time() + else: + yield ( + f"data: {json.dumps({'type': 'error', 'error': response.get('error', 'GPS stream error')})}" + "\n\n" + ) + + time.sleep(1.0) + except GeneratorExit: + logger.debug("GPS SSE stream closed by client") + except Exception as exc: + logger.error(f"GPS SSE stream error: {exc}", exc_info=True) + + return generate() + + gps_stream._cp_config = {"response.stream": True} + @cherrypy.expose @cherrypy.tools.json_out() def send_advert(self): @@ -1035,6 +1320,60 @@ def mqtt_status(self): logger.error(f"Error getting MQTT status: {e}") return self._error(str(e)) + @cherrypy.expose + @cherrypy.tools.json_out() + def broker_presets(self): + """List bundled MC2MQTT broker presets. + + GET /api/broker_presets + + Returns the sorted list of ``repeater/presets/*.yaml`` packaged + with this build, in a UI-ready shape so the admin frontend's + "From Template" dropdown does not need to bundle its own copy + of the broker catalogue. + + Response: + { + "success": true, + "data": [ + { + "id": "waev", # preset filename stem + "name": "Waev", # YAML display_name, or titlecased id + "website": "https://waev.app", # optional, omitted if absent + "brokers": [ ... raw broker dicts from the YAML ... ] + }, + ... + ] + } + + Unauthenticated by design - the response contains only public + broker hostnames and TLS hints, mirroring the access policy on + ``mqtt_status``. + """ + self._set_cors_headers() + try: + # Imported lazily so a broken/missing yaml in the presets + # package never blocks process startup; the loader logs and + # skips bad files. + from repeater.presets import get_preset, list_presets + + data = [] + for preset_id in list_presets(): + preset = get_preset(preset_id) or {} + entry = { + "id": preset_id, + "name": preset.get("display_name") or preset_id.title(), + "brokers": list(preset.get("brokers", [])), + } + website = preset.get("website") + if website: + entry["website"] = website + data.append(entry) + return self._success(data) + except Exception as e: + logger.error(f"Error listing broker presets: {e}") + return self._error(str(e)) + @cherrypy.expose @cherrypy.tools.json_out() @cherrypy.tools.json_in() @@ -1085,6 +1424,13 @@ def update_mqtt_config(self): for i, b in enumerate(brokers): if not isinstance(b, dict): return self._error(f"Broker at index {i} must be an object") + + # Bundled preset reference: {preset: }. Pass through + # unchanged - the MQTT handler expands it on next start. + if "preset" in b and "name" not in b: + validated.append({"preset": str(b["preset"]).strip()}) + continue + for field in ("name", "host", "port", "format"): if not b.get(field, ""): return self._error(f"Broker at index {i} missing required field: {field}") @@ -1174,6 +1520,280 @@ def restart_service(self): logger.error(f"Error in restart_service endpoint: {e}", exc_info=True) return self._error(e) + @cherrypy.expose + @cherrypy.tools.json_out() + def validate_config(self): + """Validate config.yaml syntax and required settings without restarting.""" + self._set_cors_headers() + + if cherrypy.request.method == "OPTIONS": + return "" + + if cherrypy.request.method != "GET": + cherrypy.response.status = 405 + cherrypy.response.headers["Allow"] = "GET" + raise cherrypy.HTTPError(405, "Method not allowed. This endpoint requires GET.") + + try: + import yaml + + errors = [] + warnings = [] + + def add_error(path: str, message: str): + errors.append({"path": path, "message": message}) + + def add_warning(path: str, message: str): + warnings.append({"path": path, "message": message}) + + def as_int(value, path: str): + if isinstance(value, bool): + add_error(path, "must be an integer") + return None + try: + return int(value) + except (TypeError, ValueError): + add_error(path, "must be an integer") + return None + + def as_float(value, path: str): + if isinstance(value, bool): + add_error(path, "must be a number") + return None + try: + return float(value) + except (TypeError, ValueError): + add_error(path, "must be a number") + return None + + try: + with open(self._config_path, "r", encoding="utf-8") as f: + config_yaml = yaml.safe_load(f) + except FileNotFoundError: + add_error("config", f"Configuration file not found: {self._config_path}") + config_yaml = None + except yaml.YAMLError as e: + mark = getattr(e, "problem_mark", None) + if mark is not None: + add_error( + "config", + f"YAML syntax error at line {mark.line + 1}, column {mark.column + 1}: {e}", + ) + else: + add_error("config", f"YAML syntax error: {e}") + config_yaml = None + except Exception as e: + add_error("config", f"Failed to read configuration: {e}") + config_yaml = None + + if config_yaml is not None and not isinstance(config_yaml, dict): + add_error("config", "Top-level YAML value must be a mapping/object") + config_yaml = None + + if isinstance(config_yaml, dict): + repeater = config_yaml.get("repeater") + if not isinstance(repeater, dict): + add_error("repeater", "Missing required section 'repeater'") + repeater = {} + + node_name = (repeater.get("node_name") if isinstance(repeater, dict) else "") or "" + node_name = str(node_name).strip() + if not node_name: + add_error("repeater.node_name", "Node name is required") + elif len(node_name.encode("utf-8")) > 31: + add_error("repeater.node_name", "Node name too long (max 31 bytes in UTF-8)") + + security = repeater.get("security") if isinstance(repeater, dict) else None + if not isinstance(security, dict): + add_error("repeater.security", "Missing required section 'repeater.security'") + security = {} + + admin_password = (security.get("admin_password") if isinstance(security, dict) else "") or "" + if not str(admin_password).strip(): + add_error("repeater.security.admin_password", "Admin password is required") + + radio_type_raw = config_yaml.get("radio_type") + radio_type = "" if radio_type_raw is None else str(radio_type_raw).strip().lower() + if radio_type == "kiss-modem": + radio_type = "kiss" + + known_radio_types = { + "sx1262", + "sx1262_ch341", + "kiss", + "pymc_tcp", + "pymc_usb", + "none", + "null", + "disabled", + "off", + "no_radio", + "", + } + if radio_type not in known_radio_types: + add_error( + "radio_type", + "Unsupported radio_type. Supported: sx1262, sx1262_ch341, kiss, pymc_tcp, pymc_usb, none/null", + ) + + radio_disabled = radio_type in ("", "none", "null", "disabled", "off", "no_radio") + radio = config_yaml.get("radio") + + if not radio_disabled: + if not isinstance(radio, dict): + add_error("radio", "Missing required section 'radio'") + radio = {} + + frequency = as_float((radio or {}).get("frequency"), "radio.frequency") + if frequency is None: + add_error("radio.frequency", "Frequency is required") + elif frequency < 100_000_000 or frequency > 1_000_000_000: + add_error("radio.frequency", "Frequency must be 100-1000 MHz") + + bandwidth = as_int((radio or {}).get("bandwidth"), "radio.bandwidth") + valid_bw = [7800, 10400, 15600, 20800, 31250, 41700, 62500, 125000, 250000, 500000] + if bandwidth is None: + add_error("radio.bandwidth", "Bandwidth is required") + elif bandwidth not in valid_bw: + add_error("radio.bandwidth", f"Bandwidth must be one of {[b / 1000 for b in valid_bw]} kHz") + + spreading_factor = as_int((radio or {}).get("spreading_factor"), "radio.spreading_factor") + if spreading_factor is None: + add_error("radio.spreading_factor", "Spreading factor is required") + elif spreading_factor < 5 or spreading_factor > 12: + add_error("radio.spreading_factor", "Spreading factor must be 5-12") + + coding_rate = as_int((radio or {}).get("coding_rate"), "radio.coding_rate") + if coding_rate is None: + add_error("radio.coding_rate", "Coding rate is required") + elif coding_rate < 5 or coding_rate > 8: + add_error("radio.coding_rate", "Coding rate must be 5-8 (for 4/5 to 4/8)") + + tx_power = as_int((radio or {}).get("tx_power"), "radio.tx_power") + if tx_power is None: + add_error("radio.tx_power", "TX power is required") + elif tx_power < -9 or tx_power > 30: + add_error("radio.tx_power", "TX power must be between -9 and +30 dBm") + + preamble_length = as_int((radio or {}).get("preamble_length"), "radio.preamble_length") + if preamble_length is None: + add_error("radio.preamble_length", "Preamble length is required") + elif preamble_length <= 0: + add_error("radio.preamble_length", "Preamble length must be greater than zero") + + if radio_type in ("sx1262", "sx1262_ch341"): + sx1262_cfg = config_yaml.get("sx1262") + if not isinstance(sx1262_cfg, dict): + add_error("sx1262", "Missing required section 'sx1262'") + sx1262_cfg = {} + + required_sx1262_keys = [ + "bus_id", + "cs_id", + "cs_pin", + "reset_pin", + "busy_pin", + "irq_pin", + "txen_pin", + "rxen_pin", + ] + for key in required_sx1262_keys: + value = sx1262_cfg.get(key) if isinstance(sx1262_cfg, dict) else None + parsed = as_int(value, f"sx1262.{key}") + if parsed is None: + add_error(f"sx1262.{key}", f"Missing or invalid required setting '{key}'") + + en_pins = sx1262_cfg.get("en_pins") if isinstance(sx1262_cfg, dict) else None + if en_pins is not None: + if not isinstance(en_pins, list): + add_error("sx1262.en_pins", "en_pins must be a list of integers") + else: + for idx, pin in enumerate(en_pins): + if as_int(pin, f"sx1262.en_pins[{idx}]") is None: + add_error( + f"sx1262.en_pins[{idx}]", + "Each en_pins entry must be an integer", + ) + + if radio_type == "sx1262_ch341": + ch341_cfg = config_yaml.get("ch341") + if not isinstance(ch341_cfg, dict): + add_error("ch341", "Missing required section 'ch341' for radio_type sx1262_ch341") + ch341_cfg = {} + for key in ("vid", "pid"): + value = ch341_cfg.get(key) if isinstance(ch341_cfg, dict) else None + parsed = as_int(value, f"ch341.{key}") + if parsed is None: + add_error(f"ch341.{key}", f"Missing or invalid required setting '{key}'") + + if radio_type == "kiss": + kiss_cfg = config_yaml.get("kiss") + if not isinstance(kiss_cfg, dict): + add_error("kiss", "Missing required section 'kiss' for radio_type kiss") + kiss_cfg = {} + port = (kiss_cfg.get("port") if isinstance(kiss_cfg, dict) else "") or "" + if not str(port).strip(): + add_error("kiss.port", "KISS port is required") + baud = as_int((kiss_cfg or {}).get("baud_rate"), "kiss.baud_rate") + if baud is None: + add_error("kiss.baud_rate", "KISS baud_rate is required") + elif baud <= 0: + add_error("kiss.baud_rate", "KISS baud_rate must be greater than zero") + + if radio_type == "pymc_usb": + usb_cfg = config_yaml.get("pymc_usb") + if not isinstance(usb_cfg, dict): + add_error("pymc_usb", "Missing required section 'pymc_usb' for radio_type pymc_usb") + usb_cfg = {} + port = (usb_cfg.get("port") if isinstance(usb_cfg, dict) else "") or "" + if not str(port).strip(): + add_error("pymc_usb.port", "pymc_usb.port is required") + baud = as_int((usb_cfg or {}).get("baudrate"), "pymc_usb.baudrate") + if baud is not None and baud <= 0: + add_error("pymc_usb.baudrate", "pymc_usb.baudrate must be greater than zero") + + if radio_type == "pymc_tcp": + tcp_cfg = config_yaml.get("pymc_tcp") + if not isinstance(tcp_cfg, dict): + add_error("pymc_tcp", "Missing required section 'pymc_tcp' for radio_type pymc_tcp") + tcp_cfg = {} + host = (tcp_cfg.get("host") if isinstance(tcp_cfg, dict) else "") or "" + host_str = str(host).strip() + if not host_str: + add_error("pymc_tcp.host", "pymc_tcp.host is required") + elif host_str == "REPLACE_WITH_MODEM_HOST": + add_error("pymc_tcp.host", "Replace placeholder host with your modem hostname or IP") + port = as_int((tcp_cfg or {}).get("port"), "pymc_tcp.port") + if port is None: + add_error("pymc_tcp.port", "pymc_tcp.port is required") + elif port < 1 or port > 65535: + add_error("pymc_tcp.port", "pymc_tcp.port must be 1-65535") + + if radio_disabled: + add_warning("radio_type", "Radio is disabled (radio_type none/null/off)") + + valid = len(errors) == 0 + return self._success( + { + "valid": valid, + "blocked_restart": not valid, + "errors": errors, + "warnings": warnings, + "summary": { + "error_count": len(errors), + "warning_count": len(warnings), + }, + "config_path": self._config_path, + "message": "Configuration is valid" if valid else "Configuration has validation errors", + } + ) + + except cherrypy.HTTPError: + raise + except Exception as e: + logger.error(f"Error validating configuration: {e}", exc_info=True) + return self._error(str(e)) + @cherrypy.expose @cherrypy.tools.json_out() def logs(self): @@ -2136,25 +2756,26 @@ def generate(): @cherrypy.expose @cherrypy.tools.json_out() - def adverts_by_contact_type(self, contact_type=None, limit=None, hours=None): + def adverts_by_contact_type(self, contact_type=None, limit=None, offset=None, hours=None): try: if not contact_type: return self._error("contact_type parameter is required") limit_int = int(limit) if limit is not None else None + offset_int = int(offset) if offset is not None else None hours_int = int(hours) if hours is not None else None storage = self._get_storage() adverts = storage.sqlite_handler.get_adverts_by_contact_type( - contact_type=contact_type, limit=limit_int, hours=hours_int + contact_type=contact_type, limit=limit_int, offset=offset_int, hours=hours_int ) return self._success( adverts, count=len(adverts), contact_type=contact_type, - filters={"contact_type": contact_type, "limit": limit_int, "hours": hours_int}, + filters={"contact_type": contact_type, "limit": limit_int, "offset": offset_int, "hours": hours_int}, ) except ValueError as e: @@ -2163,6 +2784,33 @@ def adverts_by_contact_type(self, contact_type=None, limit=None, hours=None): logger.error(f"Error getting adverts by contact type: {e}") return self._error(e) + @cherrypy.expose + @cherrypy.tools.json_out() + def adverts_count_by_contact_type(self, contact_type=None, hours=None): + """Get the total count of adverts for a specific contact type.""" + try: + if not contact_type: + return self._error("contact_type parameter is required") + + hours_int = int(hours) if hours is not None else None + + storage = self._get_storage() + count = storage.sqlite_handler.get_adverts_count_by_contact_type( + contact_type=contact_type, hours=hours_int + ) + + return self._success( + {"count": count}, + contact_type=contact_type, + hours=hours_int, + ) + + except ValueError as e: + return self._error(f"Invalid parameter format: {e}") + except Exception as e: + logger.error(f"Error getting adverts count by contact type: {e}") + return self._error(e) + @cherrypy.expose @cherrypy.tools.json_out() def advert_rate_limit_stats(self): @@ -2430,6 +3078,8 @@ def ping_neighbor(self): # 0 = 1-byte (legacy), 1 = 2-byte, 2 = 3-byte path_hash_mode = self.config.get("mesh", {}).get("path_hash_mode", 0) byte_count = {0: 1, 1: 2, 2: 3}.get(path_hash_mode, 1) + + trace_flags = {1: 0x00, 2: 0x01}.get(byte_count, 0x00) hex_chars = byte_count * 2 max_hash = (1 << (byte_count * 8)) - 1 @@ -2464,7 +3114,7 @@ def ping_neighbor(self): path_bytes = list(target_hash.to_bytes(byte_count, "big")) packet = PacketBuilder.create_trace( - tag=trace_tag, auth_code=0x12345678, flags=0x00, path=path_bytes + tag=trace_tag, auth_code=0x12345678, flags=trace_flags, path=path_bytes ) # Wait for response with timeout @@ -4645,8 +5295,21 @@ def config_import(self): # Sections we allow to be imported ALLOWED_SECTIONS = { - "repeater", "mesh", "radio", "identities", "delays", - "ch341", "web", "letsmesh", "glass", "logging", "radio_type", + "repeater", + "mesh", + "radio", + "sx1262", + "ch341", + "kiss", + "pymc_usb", + "pymc_tcp", + "identities", + "delays", + "web", + "letsmesh", + "glass", + "logging", + "radio_type", } updated_sections = [] @@ -4690,7 +5353,15 @@ def config_import(self): existing = cur_by_name.get(entry.get("name"), {}) entry["identity_key"] = existing.get("identity_key", "") - if section == "radio": + if section in { + "radio", + "sx1262", + "ch341", + "kiss", + "pymc_usb", + "pymc_tcp", + "radio_type", + }: restart_required = True if section == "radio_type": diff --git a/repeater/web/html/assets/CADCalibration-gZQwotT3.css b/repeater/web/html/assets/CADCalibration-C4Y61LYy.css similarity index 68% rename from repeater/web/html/assets/CADCalibration-gZQwotT3.css rename to repeater/web/html/assets/CADCalibration-C4Y61LYy.css index 2fe46cd3..cae17263 100644 --- a/repeater/web/html/assets/CADCalibration-gZQwotT3.css +++ b/repeater/web/html/assets/CADCalibration-C4Y61LYy.css @@ -1 +1 @@ -.glass-card[data-v-60d82848]{background:var(--color-glass-bg);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid var(--color-glass-border);box-shadow:var(--color-glass-shadow)} +.glass-card[data-v-950ea1f9]{background:var(--color-glass-bg);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid var(--color-glass-border);box-shadow:var(--color-glass-shadow)} diff --git a/repeater/web/html/assets/CADCalibration-CK9zSc8M.js b/repeater/web/html/assets/CADCalibration-CK9zSc8M.js deleted file mode 100644 index 2c2af328..00000000 --- a/repeater/web/html/assets/CADCalibration-CK9zSc8M.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./chunk-DECur_0Z.js";import{C as t,S as n,f as r,ft as i,g as a,l as o,o as s,p as c,pt as l,s as u,u as d,w as f,z as p}from"./runtime-core.esm-bundler-HnidnMFy.js";import{c as m,t as h}from"./api-CbM6k1ZB.js";import{t as g}from"./system-BH4r-ii6.js";import{t as _}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as v}from"./plotly.min-Dl7ekyci.js";var y=e(v(),1),ee={class:`p-6 space-y-6`},b={class:`glass-card rounded-[15px] p-6`},te={class:`flex justify-center`},ne={class:`flex gap-4`},re=[`disabled`],ie=[`disabled`],ae={class:`glass-card rounded-[15px] p-6 space-y-4`},oe={class:`text-content-primary dark:text-content-primary`},se={key:0,class:`p-4 bg-primary/10 border border-primary/30 rounded-lg`},ce={class:`text-content-primary dark:text-primary`},le={class:`space-y-2`},ue={class:`w-full bg-white/10 rounded-full h-2`},de={class:`text-content-secondary dark:text-content-muted text-sm`},fe={class:`grid grid-cols-2 md:grid-cols-4 gap-4`},x={class:`glass-card rounded-[15px] p-4 text-center`},S={class:`text-2xl font-bold text-primary`},C={class:`glass-card rounded-[15px] p-4 text-center`},w={class:`text-2xl font-bold text-primary`},T={class:`glass-card rounded-[15px] p-4 text-center`},E={class:`text-2xl font-bold text-primary`},D={class:`glass-card rounded-[15px] p-4 text-center`},O={class:`text-2xl font-bold text-primary`},k={key:0,class:`glass-card rounded-[15px] p-6 space-y-4`},A={key:0,class:`p-4 bg-accent-green/10 border border-accent-green/30 rounded-lg`},j={class:`text-content-primary dark:text-content-primary mb-4`},M={key:1,class:`p-4 bg-secondary/20 border border-secondary/40 rounded-lg`},N=_(a({name:`CADCalibrationView`,__name:`CADCalibration`,setup(e){let a=g(),_=s(()=>document.documentElement.classList.contains(`dark`)),v=()=>{let e=_.value;return{title:e?`#F9FAFB`:`#111827`,subtitle:e?`#9CA3AF`:`#6B7280`,axis:e?`#D1D5DB`:`#374151`,tick:e?`#9CA3AF`:`#6B7280`,grid:e?`rgba(148, 163, 184, 0.1)`:`rgba(107, 114, 128, 0.15)`,zeroline:e?`rgba(148, 163, 184, 0.2)`:`rgba(107, 114, 128, 0.25)`,line:e?`rgba(148, 163, 184, 0.3)`:`rgba(107, 114, 128, 0.35)`,colorbarBorder:e?`rgba(255,255,255,0.2)`:`rgba(0,0,0,0.15)`,markerLine:e?`rgba(255,255,255,0.2)`:`rgba(0,0,0,0.15)`}},N=p(!1),P=p(null),F=p(null),I=p({}),L=p(null),R=p([]),z=p({}),B=p(`Ready to start calibration`),V=p(0),H=p(0),U=p(0),W=p(0),G=p(0),K=p(0),q=p(null),J=p(!1),Y=p(!1),X=p(!1),Z=p(!1),Q=null,pe={responsive:!0,displayModeBar:!0,modeBarButtonsToRemove:[`pan2d`,`select2d`,`lasso2d`,`autoScale2d`],displaylogo:!1,toImageButtonOptions:{format:`png`,filename:`cad-calibration-heatmap`,height:600,width:800,scale:2}};function me(){let e=v(),t=[{x:[],y:[],z:[],mode:`markers`,type:`scatter`,marker:{size:12,color:[],colorscale:[[0,`rgba(75, 85, 99, 0.4)`],[.1,`rgba(6, 182, 212, 0.3)`],[.5,`rgba(6, 182, 212, 0.6)`],[1,`rgba(16, 185, 129, 0.9)`]],showscale:!0,colorbar:{title:{text:`Detection Rate (%)`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},bgcolor:`rgba(0,0,0,0)`,bordercolor:e.colorbarBorder,borderwidth:1,thickness:15},line:{color:e.markerLine,width:1}},hovertemplate:`Peak: %{x}
Min: %{y}
Detection Rate: %{marker.color:.1f}%
`,name:`Test Results`}],n={title:{text:`CAD Detection Rate
Channel Activity Detection Calibration`,font:{color:e.title,size:18},x:.5},xaxis:{title:{text:`CAD Peak Threshold`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},gridcolor:e.grid,zerolinecolor:e.zeroline,linecolor:e.line},yaxis:{title:{text:`CAD Min Threshold`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},gridcolor:e.grid,zerolinecolor:e.zeroline,linecolor:e.line},plot_bgcolor:`rgba(0, 0, 0, 0)`,paper_bgcolor:`rgba(0, 0, 0, 0)`,font:{color:e.title,family:`Inter, system-ui, sans-serif`},margin:{l:80,r:80,t:100,b:80},showlegend:!1};y.default.newPlot(`plotly-chart`,t,n,pe)}function he(){if(Object.keys(I.value).length===0)return;let e=Object.values(I.value),t=[],n=[],r=[];for(let i of e)t.push(i.det_peak),n.push(i.det_min),r.push(i.detection_rate);let i={x:[t],y:[n],"marker.color":[r],hovertemplate:`Peak: %{x}
Min: %{y}
Detection Rate: %{marker.color:.1f}%
Status: Tested
`};y.default.restyle(`plotly-chart`,i,[0])}async function ge(){try{let e=await h.post(`/cad-calibration-start`,{samples:10,delay_ms:50});if(e.success)N.value=!0,P.value=Date.now(),a.setCadCalibrationRunning(!0),I.value={},R.value=[],z.value={},L.value=null,J.value=!1,Y.value=!1,X.value=!1,Z.value=!1,U.value=0,W.value=0,G.value=0,K.value=0,V.value=0,H.value=0,Q=setInterval(()=>{P.value&&(K.value=Math.floor((Date.now()-P.value)/1e3))},1e3),_e();else throw Error(e.error||`Failed to start calibration`)}catch(e){B.value=`Error: ${e instanceof Error?e.message:`Unknown error`}`}}async function $(){try{(await h.post(`/cad-calibration-stop`)).success&&(N.value=!1,a.setCadCalibrationRunning(!1),F.value&&=(F.value.close(),null),Q&&=(clearInterval(Q),null))}catch(e){console.error(`Failed to stop calibration:`,e)}}function _e(){F.value&&F.value.close();let e=m(),t=e?`?token=${encodeURIComponent(e)}`:``;F.value=new EventSource(`/api/cad-calibration-stream${t}`),F.value.onmessage=function(e){try{ve(JSON.parse(e.data))}catch(e){console.error(`Failed to parse SSE data:`,e)}},F.value.onerror=function(e){console.error(`SSE connection error:`,e),N.value||(F.value&&=(F.value.close(),null))}}function ve(e){switch(e.type){case`status`:B.value=e.message||`Status update`,e.test_ranges&&(q.value=e.test_ranges,J.value=!0);break;case`progress`:V.value=e.current||0,H.value=e.total||0,U.value=e.current||0;break;case`result`:if(e.det_peak!==void 0&&e.det_min!==void 0&&e.detection_rate!==void 0&&e.detections!==void 0&&e.samples!==void 0){let t=`${e.det_peak}_${e.det_min}`;I.value[t]={det_peak:e.det_peak,det_min:e.det_min,detection_rate:e.detection_rate,detections:e.detections,samples:e.samples},he(),ye()}break;case`complete`:case`completed`:N.value=!1,B.value=e.message||`Calibration completed`,a.setCadCalibrationRunning(!1),be(),F.value&&=(F.value.close(),null),Q&&=(clearInterval(Q),null);break;case`error`:B.value=`Error: ${e.message}`,a.setCadCalibrationRunning(!1),$();break}}function ye(){let e=Object.values(I.value).map(e=>e.detection_rate);e.length!==0&&(W.value=Math.max(...e),G.value=e.reduce((e,t)=>e+t,0)/e.length)}function be(){Y.value=!0;let e=null,t=0;for(let n of Object.values(I.value))n.detection_rate>t&&(t=n.detection_rate,e=n);L.value=e,e&&t>0?(X.value=!0,Z.value=!1):(X.value=!1,Z.value=!0)}async function xe(){if(!L.value){B.value=`Error: No calibration results to save`;return}try{let e=await h.post(`/save_cad_settings`,{peak:L.value.det_peak,min_val:L.value.det_min,detection_rate:L.value.detection_rate});if(e.success)B.value=`Settings saved! Peak=${L.value.det_peak}, Min=${L.value.det_min} applied to configuration.`;else throw Error(e.error||`Failed to save settings`)}catch(e){B.value=`Error: Failed to save settings: ${e instanceof Error?e.message:`Unknown error`}`}}return n(()=>{me()}),t(()=>{F.value&&F.value.close(),Q&&clearInterval(Q),a.setCadCalibrationRunning(!1),document.getElementById(`plotly-chart`)&&y.default.purge(`plotly-chart`)}),(e,t)=>(f(),d(`div`,ee,[t[14]||=u(`div`,null,[u(`h1`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` CAD Calibration Tool `),u(`p`,{class:`text-content-secondary dark:text-content-muted mt-2`},` Channel Activity Detection calibration `)],-1),u(`div`,b,[u(`div`,te,[u(`div`,ne,[u(`button`,{onClick:ge,disabled:N.value,class:`flex items-center gap-3 px-6 py-3 bg-accent-green/10 hover:bg-accent-green/20 disabled:bg-gray-500/10 text-accent-green disabled:text-gray-400 rounded-lg border border-accent-green/30 disabled:border-gray-500/20 transition-colors disabled:cursor-not-allowed`},[...t[0]||=[r(`
Start Calibration
Begin testing
`,2)]],8,re),u(`button`,{onClick:$,disabled:!N.value,class:`flex items-center gap-3 px-6 py-3 bg-accent-red/10 hover:bg-accent-red/20 disabled:bg-gray-500/10 text-accent-red disabled:text-gray-400 rounded-lg border border-accent-red/30 disabled:border-gray-500/20 transition-colors disabled:cursor-not-allowed`},[...t[1]||=[r(`
Stop
Halt calibration
`,2)]],8,ie)])])]),u(`div`,ae,[u(`div`,oe,l(B.value),1),J.value&&q.value?(f(),d(`div`,se,[u(`div`,ce,[t[2]||=u(`strong`,null,`Configuration:`,-1),c(` SF`+l(q.value.spreading_factor)+` | Peak: `+l(q.value.peak_min)+` - `+l(q.value.peak_max)+` | Min: `+l(q.value.min_min)+` - `+l(q.value.min_max)+` | `+l((q.value.peak_max-q.value.peak_min+1)*(q.value.min_max-q.value.min_min+1))+` tests `,1)])])):o(``,!0),u(`div`,le,[u(`div`,ue,[u(`div`,{class:`bg-gradient-to-r from-primary to-accent-green h-2 rounded-full transition-all duration-300`,style:i({width:H.value>0?`${V.value/H.value*100}%`:`0%`})},null,4)]),u(`div`,de,l(V.value)+` / `+l(H.value)+` tests completed `,1)])]),u(`div`,fe,[u(`div`,x,[u(`div`,S,l(U.value),1),t[3]||=u(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Tests Completed`,-1)]),u(`div`,C,[u(`div`,w,l(W.value.toFixed(1))+`%`,1),t[4]||=u(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},` Best Detection Rate `,-1)]),u(`div`,T,[u(`div`,E,l(G.value.toFixed(1))+`%`,1),t[5]||=u(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Average Rate`,-1)]),u(`div`,D,[u(`div`,O,l(K.value)+`s`,1),t[6]||=u(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Elapsed Time`,-1)])]),t[15]||=u(`div`,{class:`glass-card rounded-[15px] p-6`},[u(`div`,{id:`plotly-chart`,class:`w-full h-96`})],-1),Y.value?(f(),d(`div`,k,[t[13]||=u(`h3`,{class:`text-xl font-bold text-content-primary dark:text-content-primary`},` Calibration Results `,-1),X.value&&L.value?(f(),d(`div`,A,[t[11]||=u(`h4`,{class:`font-medium text-accent-green mb-2`},`Optimal Settings Found:`,-1),u(`p`,j,[t[7]||=c(` Peak: `,-1),u(`strong`,null,l(L.value.det_peak),1),t[8]||=c(`, Min: `,-1),u(`strong`,null,l(L.value.det_min),1),t[9]||=c(`, Rate: `,-1),u(`strong`,null,l(L.value.detection_rate.toFixed(1))+`%`,1)]),u(`div`,{class:`flex justify-center`},[u(`button`,{onClick:xe,class:`flex items-center gap-3 px-6 py-3 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},[...t[10]||=[r(`
Save Settings
Apply to configuration
`,2)]])])])):o(``,!0),Z.value?(f(),d(`div`,M,[...t[12]||=[u(`h4`,{class:`font-medium text-secondary mb-2`},`No Optimal Settings Found`,-1),u(`p`,{class:`text-content-secondary dark:text-content-muted`},` All tested combinations showed low detection rates. Consider running calibration again or adjusting test parameters. `,-1)]])):o(``,!0)])):o(``,!0)]))}}),[[`__scopeId`,`data-v-60d82848`]]);export{N as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/CADCalibration-CMgcsyU9.js b/repeater/web/html/assets/CADCalibration-CMgcsyU9.js new file mode 100644 index 00000000..a898cb2f --- /dev/null +++ b/repeater/web/html/assets/CADCalibration-CMgcsyU9.js @@ -0,0 +1 @@ +import{r as e}from"./chunk-DECur_0Z.js";import{Ct as t,D as n,E as r,St as i,Y as a,f as o,g as s,k as c,l,m as u,o as d,p as f,r as p,s as m,u as h}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{l as ee,t as g}from"./api-3gMnsCKh.js";import{t as te}from"./system-DbBvxitf.js";import{t as _}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{n as ne}from"./index-DTUpsCzx.js";import{t as v}from"./plotly.min-BmxIBpZZ.js";var y=e(v(),1),re={class:`p-6 space-y-6`},b={class:`glass-card rounded-[15px] p-6`},x={class:`flex justify-center`},S={class:`flex gap-4`},ie=[`disabled`],ae=[`disabled`],oe={class:`glass-card rounded-[15px] p-6 space-y-4`},se={class:`text-content-primary dark:text-content-primary`},ce={class:`flex items-center justify-between gap-4 px-4 bg-primary/10 border border-primary/30 rounded-lg h-[52px] overflow-hidden`},le={key:0,class:`text-content-primary dark:text-primary text-sm`},ue={key:1,class:`text-content-muted dark:text-content-muted text-sm italic`},de={key:2,class:`text-content-primary dark:text-content-primary text-sm`},fe={key:3,class:`text-content-secondary dark:text-content-muted text-sm`},pe={class:`space-y-2`},me={class:`w-full bg-white/10 rounded-full h-2`},he={class:`text-content-secondary dark:text-content-muted text-sm`},C={class:`grid grid-cols-2 md:grid-cols-4 gap-4`},w={class:`glass-card rounded-[15px] p-4 text-center`},T={class:`text-2xl font-bold text-primary`},E={class:`glass-card rounded-[15px] p-4 text-center`},D={class:`text-2xl font-bold text-primary`},O={class:`glass-card rounded-[15px] p-4 text-center`},k={class:`text-2xl font-bold text-primary`},A={class:`glass-card rounded-[15px] p-4 text-center`},j={class:`text-2xl font-bold text-primary`},M=_(s({name:`CADCalibrationView`,__name:`CADCalibration`,setup(e){let s=te(),_=d(()=>document.documentElement.classList.contains(`dark`)),v=()=>{let e=_.value;return{title:e?`#F9FAFB`:`#111827`,subtitle:e?`#9CA3AF`:`#6B7280`,axis:e?`#D1D5DB`:`#374151`,tick:e?`#9CA3AF`:`#6B7280`,grid:e?`rgba(148, 163, 184, 0.1)`:`rgba(107, 114, 128, 0.15)`,zeroline:e?`rgba(148, 163, 184, 0.2)`:`rgba(107, 114, 128, 0.25)`,line:e?`rgba(148, 163, 184, 0.3)`:`rgba(107, 114, 128, 0.35)`,colorbarBorder:e?`rgba(255,255,255,0.2)`:`rgba(0,0,0,0.15)`,markerLine:e?`rgba(255,255,255,0.2)`:`rgba(0,0,0,0.15)`}},M=a(!1),N=a(null),P=a(null),F=a({}),I=a(null),L=a([]),R=a({}),z=a(`Ready to start calibration`),B=a(0),V=a(0),H=a(0),U=a(0),W=a(0),G=a(0),K=a(null),q=a(!1),J=a(!1),Y=a(!1),X=a(!1),Z=null,ge={responsive:!0,displayModeBar:!0,modeBarButtonsToRemove:[`pan2d`,`select2d`,`lasso2d`,`autoScale2d`],displaylogo:!1,toImageButtonOptions:{format:`png`,filename:`cad-calibration-heatmap`,height:600,width:800,scale:2}};function _e(){let e=v(),t=[{x:[],y:[],z:[],mode:`markers`,type:`scatter`,marker:{size:12,color:[],colorscale:[[0,`rgba(75, 85, 99, 0.4)`],[.1,`rgba(6, 182, 212, 0.3)`],[.5,`rgba(6, 182, 212, 0.6)`],[1,`rgba(16, 185, 129, 0.9)`]],showscale:!0,colorbar:{title:{text:`Detection Rate (%)`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},bgcolor:`rgba(0,0,0,0)`,bordercolor:e.colorbarBorder,borderwidth:1,thickness:15},line:{color:e.markerLine,width:1}},hovertemplate:`Peak: %{x}
Min: %{y}
Detection Rate: %{marker.color:.1f}%
`,name:`Test Results`}],n={title:{text:`CAD Detection Rate
Channel Activity Detection Calibration`,font:{color:e.title,size:18},x:.5},xaxis:{title:{text:`CAD Peak Threshold`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},gridcolor:e.grid,zerolinecolor:e.zeroline,linecolor:e.line},yaxis:{title:{text:`CAD Min Threshold`,font:{color:e.axis,size:14}},tickfont:{color:e.tick},gridcolor:e.grid,zerolinecolor:e.zeroline,linecolor:e.line},plot_bgcolor:`rgba(0, 0, 0, 0)`,paper_bgcolor:`rgba(0, 0, 0, 0)`,font:{color:e.title,family:`Inter, system-ui, sans-serif`},margin:{l:80,r:80,t:100,b:80},showlegend:!1};y.default.newPlot(`plotly-chart`,t,n,ge)}function ve(){if(Object.keys(F.value).length===0)return;let e=Object.values(F.value),t=[],n=[],r=[];for(let i of e)t.push(i.det_peak),n.push(i.det_min),r.push(i.detection_rate);let i={x:[t],y:[n],"marker.color":[r],hovertemplate:`Peak: %{x}
Min: %{y}
Detection Rate: %{marker.color:.1f}%
Status: Tested
`};y.default.restyle(`plotly-chart`,i,[0])}async function ye(){try{let e=await g.post(`/cad-calibration-start`,{samples:10,delay_ms:50});if(e.success)M.value=!0,N.value=Date.now(),s.setCadCalibrationRunning(!0),F.value={},L.value=[],R.value={},I.value=null,q.value=!1,J.value=!1,Y.value=!1,X.value=!1,H.value=0,U.value=0,W.value=0,G.value=0,B.value=0,V.value=0,Z=setInterval(()=>{N.value&&(G.value=Math.floor((Date.now()-N.value)/1e3))},1e3),be();else throw Error(e.error||`Failed to start calibration`)}catch(e){z.value=`Error: ${e instanceof Error?e.message:`Unknown error`}`}}async function Q(){try{(await g.post(`/cad-calibration-stop`)).success&&(M.value=!1,s.setCadCalibrationRunning(!1),P.value&&=(P.value.close(),null),Z&&=(clearInterval(Z),null))}catch(e){console.error(`Failed to stop calibration:`,e)}}function be(){P.value&&P.value.close();let e=ee(),t=e?`?token=${encodeURIComponent(e)}`:``;P.value=new EventSource(`/api/cad-calibration-stream${t}`),P.value.onmessage=function(e){try{xe(JSON.parse(e.data))}catch(e){console.error(`Failed to parse SSE data:`,e)}},P.value.onerror=function(e){console.error(`SSE connection error:`,e),M.value||(P.value&&=(P.value.close(),null))}}function xe(e){switch(e.type){case`status`:z.value=e.message||`Status update`,e.test_ranges&&(K.value=e.test_ranges,q.value=!0);break;case`progress`:B.value=e.current||0,V.value=e.total||0,H.value=e.current||0;break;case`result`:if(e.det_peak!==void 0&&e.det_min!==void 0&&e.detection_rate!==void 0&&e.detections!==void 0&&e.samples!==void 0){let t=`${e.det_peak}_${e.det_min}`;F.value[t]={det_peak:e.det_peak,det_min:e.det_min,detection_rate:e.detection_rate,detections:e.detections,samples:e.samples},ve(),Se()}break;case`complete`:case`completed`:M.value=!1,z.value=e.message||`Calibration completed`,s.setCadCalibrationRunning(!1),Ce(),P.value&&=(P.value.close(),null),Z&&=(clearInterval(Z),null);break;case`error`:z.value=`Error: ${e.message}`,s.setCadCalibrationRunning(!1),Q();break}}function Se(){let e=Object.values(F.value).map(e=>e.detection_rate);e.length!==0&&(U.value=Math.max(...e),W.value=e.reduce((e,t)=>e+t,0)/e.length)}function Ce(){J.value=!0;let e=null,t=0;for(let n of Object.values(F.value))n.detection_rate>t&&(t=n.detection_rate,e=n);I.value=e,e&&t>0?(Y.value=!0,X.value=!1):(Y.value=!1,X.value=!0)}let $=a(!1);async function we(){if(!I.value){z.value=`Error: No calibration results to save`;return}try{let e=await g.post(`/save_cad_settings`,{peak:I.value.det_peak,min_val:I.value.det_min,detection_rate:I.value.detection_rate});if(e.success)$.value=!0;else throw Error(e.error||`Failed to save settings`)}catch(e){z.value=`Error: Failed to save settings: ${e instanceof Error?e.message:`Unknown error`}`}}return r(()=>{_e()}),n(()=>{P.value&&P.value.close(),Z&&clearInterval(Z),s.setCadCalibrationRunning(!1),document.getElementById(`plotly-chart`)&&y.default.purge(`plotly-chart`)}),(e,n)=>(c(),h(p,null,[m(`div`,re,[n[13]||=m(`div`,null,[m(`h1`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` CAD Calibration Tool `),m(`p`,{class:`text-content-secondary dark:text-content-muted mt-2`},` Channel Activity Detection calibration `)],-1),m(`div`,b,[m(`div`,x,[m(`div`,S,[m(`button`,{onClick:ye,disabled:M.value,class:`flex items-center gap-3 px-6 py-3 bg-accent-green/10 hover:bg-accent-green/20 disabled:bg-gray-500/10 text-accent-green disabled:text-gray-400 rounded-lg border border-accent-green/30 disabled:border-gray-500/20 transition-colors disabled:cursor-not-allowed`},[...n[1]||=[o(`
Start Calibration
Begin testing
`,2)]],8,ie),m(`button`,{onClick:Q,disabled:!M.value,class:`flex items-center gap-3 px-6 py-3 bg-accent-red/10 hover:bg-accent-red/20 disabled:bg-gray-500/10 text-accent-red disabled:text-gray-400 rounded-lg border border-accent-red/30 disabled:border-gray-500/20 transition-colors disabled:cursor-not-allowed`},[...n[2]||=[o(`
Stop
Halt calibration
`,2)]],8,ae)])])]),m(`div`,oe,[m(`div`,se,t(z.value),1),m(`div`,ce,[!J.value&&q.value&&K.value?(c(),h(`div`,le,[n[3]||=m(`strong`,null,`Configuration:`,-1),f(` SF`+t(K.value.spreading_factor)+` | Peak: `+t(K.value.peak_min)+`–`+t(K.value.peak_max)+` | Min: `+t(K.value.min_min)+`–`+t(K.value.min_max)+` | `+t((K.value.peak_max-K.value.peak_min+1)*(K.value.min_max-K.value.min_min+1))+` tests `,1)])):J.value?Y.value&&I.value?(c(),h(`div`,de,[n[4]||=m(`span`,{class:`text-accent-green font-medium`},`Optimal settings found — `,-1),n[5]||=f(` Peak: `,-1),m(`strong`,null,t(I.value.det_peak),1),n[6]||=f(`, Min: `,-1),m(`strong`,null,t(I.value.det_min),1),n[7]||=f(`, Rate: `,-1),m(`strong`,null,t(I.value.detection_rate.toFixed(1))+`%`,1)])):X.value?(c(),h(`div`,fe,` No optimal settings found. Consider running calibration again. `)):l(``,!0):(c(),h(`div`,ue,` Awaiting calibration… `)),Y.value&&I.value?(c(),h(`button`,{key:4,onClick:we,class:`btn-primary flex-shrink-0 flex items-center gap-2`},[...n[8]||=[m(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[m(`path`,{d:`M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`})],-1),f(` Save Settings `,-1)]])):l(``,!0)]),m(`div`,pe,[m(`div`,me,[m(`div`,{class:`bg-gradient-to-r from-primary to-accent-green h-2 rounded-full transition-all duration-300`,style:i({width:V.value>0?`${B.value/V.value*100}%`:`0%`})},null,4)]),m(`div`,he,t(B.value)+` / `+t(V.value)+` tests completed `,1)])]),m(`div`,C,[m(`div`,w,[m(`div`,T,t(H.value),1),n[9]||=m(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Tests Completed`,-1)]),m(`div`,E,[m(`div`,D,t(U.value.toFixed(1))+`%`,1),n[10]||=m(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},` Best Detection Rate `,-1)]),m(`div`,O,[m(`div`,k,t(W.value.toFixed(1))+`%`,1),n[11]||=m(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Average Rate`,-1)]),m(`div`,A,[m(`div`,j,t(G.value)+`s`,1),n[12]||=m(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Elapsed Time`,-1)])]),n[14]||=m(`div`,{class:`glass-card rounded-[15px] p-6`},[m(`div`,{id:`plotly-chart`,class:`w-full h-96`})],-1)]),u(ne,{modelValue:$.value,"onUpdate:modelValue":n[0]||=e=>$.value=e,title:`CAD Calibration Saved: Restart Required`,message:`In order for the CAD Calibration settings to take effect and the noise floor to return to normal, the service needs to be restarted.`},null,8,[`modelValue`])],64))}}),[[`__scopeId`,`data-v-950ea1f9`]]);export{M as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/ChartCard-Dv7_dbhW.js b/repeater/web/html/assets/ChartCard-Dv7_dbhW.js new file mode 100644 index 00000000..2a8f2c93 --- /dev/null +++ b/repeater/web/html/assets/ChartCard-Dv7_dbhW.js @@ -0,0 +1,3 @@ +import{Ct as e,M as t,R as n,Y as r,g as i,k as a,l as o,m as s,s as c,u as l,w as u}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{t as d}from"./api-3gMnsCKh.js";import{t as f}from"./Spinner-CcYauG9D.js";function p(e){return e+.5|0}var m=(e,t,n)=>Math.max(Math.min(e,n),t);function h(e){return m(p(e*2.55),0,255)}function g(e){return m(p(e*255),0,255)}function _(e){return m(p(e/2.55)/100,0,1)}function v(e){return m(p(e*100),0,100)}var y={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},b=[...`0123456789ABCDEF`],x=e=>b[e&15],S=e=>b[(e&240)>>4]+b[e&15],C=e=>(e&240)>>4==(e&15),w=e=>C(e.r)&&C(e.g)&&C(e.b)&&C(e.a);function T(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&y[e[1]]*17,g:255&y[e[2]]*17,b:255&y[e[3]]*17,a:t===5?y[e[4]]*17:255}:(t===7||t===9)&&(n={r:y[e[1]]<<4|y[e[2]],g:y[e[3]]<<4|y[e[4]],b:y[e[5]]<<4|y[e[6]],a:t===9?y[e[7]]<<4|y[e[8]]:255})),n}var E=(e,t)=>e<255?t(e):``;function D(e){var t=w(e)?x:S;return e?`#`+t(e.r)+t(e.g)+t(e.b)+E(e.a,t):void 0}var ee=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function O(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function te(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function ne(e,t,n){let r=O(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function re(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=re(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function ae(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(g)}function oe(e,t,n){return ae(O,e,t,n)}function se(e,t,n){return ae(ne,e,t,n)}function ce(e,t,n){return ae(te,e,t,n)}function le(e){return(e%360+360)%360}function ue(e){let t=ee.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?h(+t[5]):g(+t[5]));let i=le(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?se(i,a,o):t[1]===`hsv`?ce(i,a,o):oe(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function de(e,t){var n=ie(e);n[0]=le(n[0]+t),n=oe(n),e.r=n[0],e.g=n[1],e.b=n[2]}function fe(e){if(!e)return;let t=ie(e),n=t[0],r=v(t[1]),i=v(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${_(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var pe={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},me={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function he(){let e={},t=Object.keys(me),n=Object.keys(pe),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var ge;function _e(e){ge||(ge=he(),ge.transparent=[0,0,0,0]);let t=ge[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var ve=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function ye(e){let t=ve.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?h(e):m(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?h(r):m(r,0,255)),i=255&(t[4]?h(i):m(i,0,255)),a=255&(t[6]?h(a):m(a,0,255)),{r,g:i,b:a,a:n}}}function be(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${_(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var xe=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Se=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Ce(e,t,n){let r=Se(_(e.r)),i=Se(_(e.g)),a=Se(_(e.b));return{r:g(xe(r+n*(Se(_(t.r))-r))),g:g(xe(i+n*(Se(_(t.g))-i))),b:g(xe(a+n*(Se(_(t.b))-a))),a:e.a+n*(t.a-e.a)}}function we(e,t,n){if(e){let r=ie(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=oe(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Te(e,t){return e&&Object.assign(t||{},e)}function Ee(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=g(e[3]))):(t=Te(e,{r:0,g:0,b:0,a:1}),t.a=g(t.a)),t}function De(e){return e.charAt(0)===`r`?ye(e):ue(e)}var Oe=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Ee(t):n===`string`&&(r=T(t)||_e(t)||De(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Te(this._rgb);return e&&(e.a=_(e.a)),e}set rgb(e){this._rgb=Ee(e)}rgbString(){return this._valid?be(this._rgb):void 0}hexString(){return this._valid?D(this._rgb):void 0}hslString(){return this._valid?fe(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Ce(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=g(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=p(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return we(this._rgb,2,e),this}darken(e){return we(this._rgb,2,-e),this}saturate(e){return we(this._rgb,1,e),this}desaturate(e){return we(this._rgb,1,-e),this}rotate(e){return de(this._rgb,e),this}};function ke(){}var Ae=(()=>{let e=0;return()=>e++})();function k(e){return e==null}function A(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function j(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function M(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function N(e,t){return M(e)?e:t}function P(e,t){return e===void 0?t:e}var je=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,Me=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function F(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function I(e,t,n,r){let i,a,o;if(A(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function Ve(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function He(e){let t=Ve(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function Ue(e,t){return(Be[t]||(Be[t]=He(t)))(e)}function We(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ge=e=>e!==void 0,Ke=e=>typeof e==`function`,qe=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function Je(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var L=Math.PI,R=2*L,Ye=R+L,Xe=1/0,Ze=L/180,z=L/2,Qe=L/4,$e=L*2/3,et=Math.log10,B=Math.sign;function tt(e,t,n){return Math.abs(e-t)e-t).pop(),t}function it(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function at(e){return!it(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function ot(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function st(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function ht(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var gt=(e,t,n,r)=>ht(e,n,r?r=>{let i=e[r][t];return ie[r][t]ht(e,n,r=>e[r][t]>=n);function vt(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+We(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function xt(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(yt.forEach(t=>{delete e[t]}),delete e._chartjs)}function St(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var Ct=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function wt(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,Ct.call(window,()=>{r=!1,e.apply(t,n)}))}}function Tt(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var Et=e=>e===`start`?`left`:e===`end`?`right`:`center`,G=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,Dt=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function Ot(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(gt(c,u,d).lo,n?r:gt(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!k(e[s.axis]));i-=Math.max(0,e)}i=U(i,0,r-1)}if(m){let e=Math.max(gt(c,o.axis,f,!0).hi+1,n?0:gt(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!k(e[s.axis]));e+=Math.max(0,t)}a=U(e,i,r)-i}else a=r-i}return{start:i,count:a}}function kt(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var At=e=>e===0||e===1,jt=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*R/n)),Mt=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*R/n)+1,Nt={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*z)+1,easeOutSine:e=>Math.sin(e*z),easeInOutSine:e=>-.5*(Math.cos(L*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>At(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>At(e)?e:jt(e,.075,.3),easeOutElastic:e=>At(e)?e:Mt(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return At(e)?e:e<.5?.5*jt(e*2,t,n):.5+.5*Mt(e*2-1,t,n)},easeInBack(e){let t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){let t=1.70158;return--e*e*((t+1)*e+t)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-Nt.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?Nt.easeInBounce(e*2)*.5:Nt.easeOutBounce(e*2-1)*.5+.5};function Pt(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function Ft(e){return Pt(e)?e:new Oe(e)}function It(e){return Pt(e)?e:new Oe(e).saturate(.5).darken(.1).hexString()}var Lt=[`x`,`y`,`borderWidth`,`radius`,`tension`],Rt=[`color`,`borderColor`,`backgroundColor`];function zt(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:Rt},numbers:{type:`number`,properties:Lt}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function Bt(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Vt=new Map;function Ht(e,t){t||={};let n=e+JSON.stringify(t),r=Vt.get(n);return r||(r=new Intl.NumberFormat(e,t),Vt.set(n,r)),r}function Ut(e,t,n){return Ht(t,n).format(e)}var Wt={values(e){return A(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Gt(e,n)}let o=et(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),Ut(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(et(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Wt.numeric.call(this,e,t,n):``}};function Gt(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Kt={formatters:Wt};function qt(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Kt.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var Jt=Object.create(null),Yt=Object.create(null);function Xt(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>It(t.backgroundColor),this.hoverBorderColor=(e,t)=>It(t.borderColor),this.hoverColor=(e,t)=>It(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Zt(this,e,t)}get(e){return Xt(this,e)}describe(e,t){return Zt(Yt,e,t)}override(e,t){return Zt(Jt,e,t)}route(e,t,n,r){let i=Xt(this,e),a=Xt(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return j(e)?Object.assign({},t,e):P(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[zt,Bt,qt]);function Qt(e){return!e||k(e.size)||k(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function $t(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function en(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function on(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,dn(e,a),c=0;c+e||0;function bn(e,t){let n={},r=j(t),i=r?Object.keys(t):t,a=j(e)?r?n=>P(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=yn(a(e));return n}function xn(e){return bn(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function Sn(e){return bn(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function q(e){let t=xn(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function J(e,t){e||={},t||=K.font;let n=P(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=P(e.style,t.style);r&&!(``+r).match(_n)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:P(e.family,t.family),lineHeight:vn(P(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:P(e.weight,t.weight),string:``};return i.string=Qt(i),i}function Cn(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function Tn(e,t){return Object.assign(Object.create(e),t)}function En(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Hn(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>En([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return jn(n,r,()=>Vn(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Un(e).includes(t)},ownKeys(e){return Un(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function Dn(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:On(e,r),setContext:t=>Dn(e,t,n,r),override:i=>Dn(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return jn(e,t,()=>Mn(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function On(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:Ke(n)?n:()=>n,isIndexable:Ke(r)?r:()=>r}}var kn=(e,t)=>e?e+We(t):t,An=(e,t)=>j(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function jn(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function Mn(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return Ke(s)&&o.isScriptable(t)&&(s=Nn(t,s,e,n)),A(s)&&s.length&&(s=Pn(t,s,e,o.isIndexable)),An(t,s)&&(s=Dn(s,i,a&&a[t],o)),s}function Nn(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),An(e,c)&&(c=Rn(i._scopes,i,e,c)),c}function Pn(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(j(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Rn(r,i,e,c);t.push(Dn(n,a,o&&o[e],s))}}return t}function Fn(e,t,n){return Ke(e)?e(t,n):e}var In=(e,t)=>e===!0?t:typeof e==`string`?Ue(t,e):void 0;function Ln(e,t,n,r,i){for(let a of t){let t=In(n,a);if(t){e.add(t);let a=Fn(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Rn(e,t,n,r){let i=t._rootScopes,a=Fn(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=zn(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=zn(s,o,a,c,r),c===null)?!1:En(Array.from(s),[``],i,a,()=>Bn(t,n,r))}function zn(e,t,n,r,i){for(;n;)n=Ln(e,t,n,r,i);return n}function Bn(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return A(i)&&j(n)?n:i||{}}function Vn(e,t,n,r){let i;for(let a of t)if(i=Hn(kn(a,e),n),i!==void 0)return An(e,i)?Rn(n,r,e,i):i}function Hn(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Un(e){let t=e._keys;return t||=e._keys=Wn(e._scopes),t}function Wn(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}var Gn=2**-52||1e-14,Kn=(e,t)=>te===`x`?`y`:`x`;function Jn(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=dt(a,i),c=dt(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Yn(e,t,n){let r=e.length,i,a,o,s,c,l=Kn(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)Zn(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function ar(e,t){return ir(e).getPropertyValue(t)}var or=[`top`,`right`,`bottom`,`left`];function sr(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=or[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var cr=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function lr(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(cr(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function ur(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=ir(n),a=i.boxSizing===`border-box`,o=sr(i,`padding`),s=sr(i,`border`,`width`),{x:c,y:l,box:u}=lr(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function dr(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&nr(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=ir(a),s=sr(o,`border`,`width`),c=sr(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=rr(o.maxWidth,a,`clientWidth`),i=rr(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Xe,maxHeight:i||Xe}}var fr=e=>Math.round(e*10)/10;function pr(e,t,n,r){let i=ir(e),a=sr(i,`margin`),o=rr(i.maxWidth,e,`clientWidth`)||Xe,s=rr(i.maxHeight,e,`clientHeight`)||Xe,c=dr(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=sr(i,`border`,`width`),t=sr(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=fr(Math.min(l,o,c.maxWidth)),u=fr(Math.min(u,s,c.maxHeight)),l&&!u&&(u=fr(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=fr(Math.floor(u*r))),{width:l,height:u}}function mr(e,t,n){let r=t||1,i=fr(e.height*r),a=fr(e.width*r);e.height=fr(e.height),e.width=fr(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var hr=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};tr()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function gr(e,t){let n=ar(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function _r(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function vr(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function yr(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=_r(e,i,n),s=_r(i,a,n),c=_r(a,t,n);return _r(_r(o,s,n),_r(s,c,n),n)}var br=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},xr=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Sr(e,t,n){return e?br(t,n):xr()}function Cr(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function wr(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function Tr(e){return e===`angle`?{between:pt,compare:ft,normalize:H}:{between:W,compare:(e,t)=>e-t,normalize:e=>e}}function Er({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function Dr(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=Tr(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(Er({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(Er({start:g,end:d,loop:f,count:o,style:p})),m}function kr(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function jr(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function Mr(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=Ar(n,i,a,r);return r===!0?Nr(e,[{start:o,end:s,loop:a}],n,t):Nr(e,jr(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,Ct.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Vr=`transparent`,Hr={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=Ft(e||Vr),i=r.valid&&Ft(t||Vr);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Ur=class{constructor(e,t,n,r){let i=t[n];r=Cn([e.to,r,i,e.from]);let a=Cn([e.from,i,r]);this._active=!0,this._fn=e.fn||Hr[e.type||typeof a],this._easing=Nt[e.easing]||Nt.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=Cn([e.to,t,r,e.from]),this._from=Cn([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!j(i))return;let a={};for(let e of t)a[e]=i[e];(A(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Kr(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Gr(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Ur(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Br.add(this._chart,n),!0}};function Gr(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function ii(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=ei(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function oi(e,t){return Tn(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function si(e,t,n){return Tn(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function ci(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var li=e=>e===`reset`||e===`none`,ui=(e,t)=>t?e:Object.assign({},e),di=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Xr(n,!0),values:null},fi=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=$r(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&ci(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=P(n.xAxisID,ai(e,`x`)),a=t.yAxisID=P(n.yAxisID,ai(e,`y`)),o=t.rAxisID=P(n.rAxisID,ai(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&xt(this._data,this),e._stacked&&ci(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(j(t)){let e=this._cachedMeta;this._data=Qr(t,e)}else if(n!==t){if(n){xt(n,this);let e=this._cachedMeta;ci(e),e._parsed=[]}t&&Object.isExtensible(t)&&bt(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=$r(t.vScale,t),t.stack!==n.stack&&(r=!0,ci(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(ii(this,t._parsed),t._stacked=$r(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length?!0:n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=A(r[e])?this.parseArrayData(n,r,e,t):j(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(ui(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Wr(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||li(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){li(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!li(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function mi(e){let t=e.iScale,n=pi(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(Ge(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function vi(e,t,n,r){return A(e)?_i(e,t,n,r):t[n.axis]=n.parse(e,r),t}function yi(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):B(e)}function Si(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(k(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[P(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;ipt(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>pt(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(z,u,f),_=m(L,l,d),v=m(L+z,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var Ai=class extends fi{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(j(n[e])){let{key:e=`value`}=this._parsing;i=t=>+Ue(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*R:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Ut(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=k(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},Mi=class extends fi{static id=`scatter`;static defaults={datasetElementType:!1,dataElementType:`point`,showLine:!1,fill:!1};static overrides={interaction:{mode:`point`},scales:{x:{type:`linear`},y:{type:`linear`}}};getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y);return{label:n[e]||``,value:`(`+o+`, `+s+`)`}}update(e){let t=this._cachedMeta,{data:n=[]}=t,r=this.chart._animationsDisabled,{start:i,count:a}=Ot(t,n,r);if(this._drawStart=i,this._drawCount=a,kt(t)&&(i=0,a=n.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:i,_dataset:a}=t;i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!a._decimated,i.points=n;let o=this.resolveDatasetElementOptions(e);o.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:o},e)}else this.datasetElementType&&=(delete t.dataset,!1);this.updateElements(n,i,a,e)}addElements(){let{showLine:e}=this.options;!this.datasetElementType&&e&&(this.datasetElementType=this.chart.registry.getElement(`line`)),super.addElements()}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,l=this.resolveDataElementOptions(t,r),u=this.getSharedOptions(l),d=this.includeOptions(r,u),f=a.axis,p=o.axis,{spanGaps:m,segment:h}=this.options,g=at(m)?m:1/0,_=this.chart._animationsDisabled||i||r===`none`,v=t>0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}};function Ni(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var Pi={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return Ni()}parse(){return Ni()}format(){return Ni()}add(){return Ni()}diff(){return Ni()}startOf(){return Ni()}endOf(){return Ni()}}};function Fi(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?_t:gt;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!k(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!k(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Ii(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Ui={evaluateInteractionItems:Ii,modes:{index(e,t,n,r){let i=ur(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Ri(e,i,a,r,o):Vi(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=ur(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Ri(e,i,a,r,o):Vi(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Ki(e,t){return e.filter(e=>Wi.indexOf(e.pos)===-1&&e.box.axis===t)}function qi(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Ji(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=qi(Gi(t,`left`),!0),i=qi(Gi(t,`right`)),a=qi(Gi(t,`top`),!0),o=qi(Gi(t,`bottom`)),s=Ki(t,`x`),c=Ki(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Gi(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function Qi(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function $i(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function ea(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!j(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&$i(o,a.getPadding());let s=Math.max(0,t.outerWidth-Qi(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-Qi(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function ta(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function na(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function ra(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);$i(f,q(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Xi(c.concat(l),d);ra(s.fullSize,p,d,m),ra(c,p,d,m),ra(l,p,d,m)&&ra(c,p,d,m),ta(p),aa(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,aa(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},I(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},oa=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},sa=class extends oa{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},ca=`$chartjs`,la={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},ua=e=>e===null||e===``;function da(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[ca]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,ua(i)){let t=gr(e,`width`);t!==void 0&&(e.width=t)}if(ua(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=gr(e,`height`);t!==void 0&&(e.height=t)}return e}var fa=hr?{passive:!0}:!1;function pa(e,t,n){e&&e.addEventListener(t,n,fa)}function ma(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,fa)}function ha(e,t){let n=la[e.type]||e.type,{x:r,y:i}=ur(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ga(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function _a(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ga(n.addedNodes,r),t&&=!ga(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function va(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ga(n.removedNodes,r),t&&=!ga(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var ya=new Map,ba=0;function xa(){let e=window.devicePixelRatio;e!==ba&&(ba=e,ya.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Sa(e,t){ya.size||window.addEventListener(`resize`,xa),ya.set(e,t)}function Ca(e){ya.delete(e),ya.size||window.removeEventListener(`resize`,xa)}function wa(e,t,n){let r=e.canvas,i=r&&nr(r);if(!i)return;let a=wt((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),Sa(e,a),o}function Ta(e,t,n){n&&n.disconnect(),t===`resize`&&Ca(e)}function Ea(e,t,n){let r=e.canvas,i=wt(t=>{e.ctx!==null&&n(ha(t,e))},e);return pa(r,t,i),i}var Da=class extends oa{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(da(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[ca])return!1;let n=t[ca].initial;[`height`,`width`].forEach(e=>{let r=n[e];k(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[ca],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:_a,detach:va,resize:wa}[t]||Ea)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:Ta,detach:Ta,resize:Ta}[t]||ma)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return pr(e,t,n,r)}isAttached(e){let t=e&&nr(e);return!!(t&&t.isConnected)}};function Oa(e){return!tr()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?sa:Da}var ka=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return at(this.x)&&at(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function Aa(e,t){let n=e.options.ticks,r=ja(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?Na(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Pa(t,l,a,o/i),l;let u=Ma(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Fa(t,l,u,k(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function Na(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Ra=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,za=(e,t)=>Math.min(t||e,e);function Ba(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function Ha(e,t){I(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:N(t,N(n,t)),max:N(n,N(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){F(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=wn(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=U(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Ua(e.grid)-t.padding-Wa(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=ct(Math.min(Math.asin(U((l.highest.height+6)/o,-1,1)),Math.asin(U(s/c,-1,1))-Math.asin(U(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){F(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){F(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Wa(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Ua(i)+a):(e.height=this.maxHeight,e.width=Ua(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=V(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){F(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return mt(this._alignToPixels?tn(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+(s?1:0),u=Ua(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return tn(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,D;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,D=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,D=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(j(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,D=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(j(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,E=e.right}let ee=P(r.ticks.maxTicksLimit,l),O=Math.max(1,Math.ceil(l/ee));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:D,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:ee,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-V(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);K.route(a,i,c,s)})}function $a(e){return`id`in e&&`defaults`in e}var X=new class{constructor(){this.controllers=new Xa(fi,`datasets`,!0),this.elements=new Xa(ka,`elements`),this.plugins=new Xa(Object,`plugins`),this.scales=new Xa(Ya,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):I(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=We(e);F(n[`before`+r],[],n),t[e](n),F(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function to(e){let t={},n=[],r=Object.keys(X.plugins.items);for(let e=0;e1&&co(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function fo(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function po(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return fo(e,`x`,n[0])||fo(e,`y`,n[0])}return{}}function mo(e,t){let n=Jt[e.type]||{scales:{}},r=t.scales||{},i=ao(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!j(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=uo(t,o,po(t,e),K.scales[o.type]),c=so(s,i),l=n.scales||{};a[t]=Re(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||ao(i,t),s=(Jt[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=oo(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),Re(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];Re(t,[K.scales[t.type],K.scale])}),a}function ho(e){let t=e.options||={};t.plugins=P(t.plugins,{}),t.scales=mo(e,t)}function go(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function _o(e){return e||={},e.data=go(e.data),ho(e),e}var vo=new Map,yo=new Set;function bo(e,t){let n=vo.get(e);return n||(n=t(),vo.set(e,n),yo.add(n)),n}var xo=(e,t,n)=>{let r=Ue(t,n);r!==void 0&&e.add(r)},So=class{constructor(e){this._config=_o(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=go(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),ho(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return bo(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return bo(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return bo(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return bo(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>xo(s,e,t))),t.forEach(e=>xo(s,r,e)),t.forEach(e=>xo(s,Jt[i]||{},e)),t.forEach(e=>xo(s,K,e)),t.forEach(e=>xo(s,Yt,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),yo.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,Jt[t]||{},K.datasets[t]||{},{type:t},K,Yt]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=Co(this._resolverCache,e,r),s=a;if(To(a,t)){i.$shared=!1,n=Ke(n)?n():n;let t=this.createResolver(e,n,o);s=Dn(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=Co(this._resolverCache,e,n);return j(t)?Dn(i,t,void 0,r):i}};function Co(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:En(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var wo=e=>j(e)&&Object.getOwnPropertyNames(e).some(t=>Ke(e[t]));function To(e,t){let{isScriptable:n,isIndexable:r}=On(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(Ke(o)||wo(o))||a&&A(o))return!0}return!1}var Eo=`4.5.1`,Do=[`top`,`bottom`,`left`,`right`,`chartArea`];function Oo(e,t){return e===`top`||e===`bottom`||Do.indexOf(e)===-1&&t===`x`}function ko(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function Ao(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),F(n&&n.onComplete,[e],t)}function jo(e){let t=e.chart,n=t.options.animation;F(n&&n.onProgress,[e],t)}function Mo(e){return tr()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var No={},Po=e=>{let t=Mo(e);return Object.values(No).filter(e=>e.canvas===t).pop()};function Fo(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Io(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Lo=class{static defaults=K;static instances=No;static overrides=Jt;static registry=X;static version=Eo;static getChart=Po;static register(...e){X.add(...e),Ro()}static unregister(...e){X.remove(...e),Ro()}constructor(e,t){let n=this.config=new So(t),r=Mo(e),i=Po(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(Oa(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Ae(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new eo,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Tt(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],No[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Br.listen(this,`complete`,Ao),Br.listen(this,`progress`,jo),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return k(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return X}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():mr(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return nn(this.canvas,this.ctx),this}stop(){return Br.stop(this),this}resize(e,t){Br.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,mr(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),F(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){I(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=uo(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),I(i,t=>{let i=t.options,a=i.id,o=uo(a,i),s=P(i.type,t.dtype);(i.position===void 0||Oo(i.position,o)!==Oo(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(X.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),I(r,(e,t)=>{e||delete n[t]}),I(n,e=>{Y.configure(this,e,e.options),Y.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(ko(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){I(this.scales,e=>{Y.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!qe(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Fo(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Y.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],I(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=zr(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&sn(t,r),e.controller.draw(),r&&cn(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return on(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Ui.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=Tn(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);Ge(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Br.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};I(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){I(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},I(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});Ne(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=Je(e),c=Io(e,this._lastEvent,n,s);n&&(this._lastEvent=null,F(i.onHover,[e,o,this],this),s&&F(i.onClick,[e,o,this],this));let l=!Ne(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Ro(){return I(Lo.instances,e=>e._plugins.invalidate())}function zo(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,H(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,H(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*H(r-n));if(u===`round`)e.arc(i,a,t,n-L/2,r+L/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+L/2)+i,c=-o*Math.sin(n+L/2)+a,l=o*Math.cos(r+L/2)+i,u=o*Math.sin(r+L/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Bo(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+z,r-z),e.closePath(),e.clip()}function Vo(e){return bn(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Ho(e,t,n,r){let i=Vo(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return U(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:U(i.innerStart,0,o),innerEnd:U(i.innerEnd,0,o)}}function Uo(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Wo(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/L)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Ho(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,T=_-y/C,E=f+b,D=f+x,ee=g+b/E,O=_-x/D;if(e.beginPath(),a){let t=(w+T)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,T),y>0){let t=Uo(C,T,o,s);e.arc(t.x,t.y,y,T,_+z)}let n=Uo(D,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Uo(D,O,o,s);e.arc(t.x,t.y,x,_+z,O+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Uo(E,ee,o,s);e.arc(t.x,t.y,b,ee+Math.PI,g-z)}let i=Uo(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Uo(S,w,o,s);e.arc(t.x,t.y,v,g-z,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(T)*d+o,i=Math.sin(T)*d+s;e.lineTo(r,i)}e.closePath()}function Go(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Wo(e,t,n,r,c,i);for(let t=0;t=L&&p===0&&u!==`miter`&&zo(e,t,h),a||(Wo(e,t,n,r,h,i),e.stroke())}var qo=class extends ka{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=ut(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=P(l,o-a),f=pt(r,a,o)&&a!==o,p=d>=R||f,m=W(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>R?Math.floor(n/R):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(L,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Go(e,this,s,i,a),Ko(e,this,s,i,a),e.restore()}};function Jo(e,t,n=t){e.lineCap=P(n.borderCapStyle,t.borderCapStyle),e.setLineDash(P(n.borderDash,t.borderDash)),e.lineDashOffset=P(n.borderDashOffset,t.borderDashOffset),e.lineJoin=P(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=P(n.borderWidth,t.borderWidth),e.strokeStyle=P(n.borderColor,t.borderColor)}function Yo(e,t,n){e.lineTo(n.x,n.y)}function Xo(e){return e.stepped?ln:e.tension||e.cubicInterpolationMode===`monotone`?un:Yo}function Zo(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function es(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?$o:Qo}function ts(e){return e.stepped?vr:e.tension||e.cubicInterpolationMode===`monotone`?yr:_r}function ns(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Jo(e,t.options),e.stroke(i)}function rs(e,t,n,r){let{segments:i,options:a}=t,o=es(t);for(let s of i)Jo(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var is=typeof Path2D==`function`;function as(e,t,n,r){is&&!t.options.segment?ns(e,t,n,r):rs(e,t,n,r)}var os=class extends ka{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;er(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=Mr(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=kr(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=ts(n),c,l;for(c=0,l=a.length;c{t=Ss(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function Ss(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function Cs(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function ws(e,t){let n=[],r=!1;return A(e)?(r=!0,n=e):n=xs(e,t),n.length?new os({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function Ts(e){return e&&e.fill!==!1}function Es(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!M(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function Ds(e,t,n){let r=js(e);if(j(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return M(i)&&Math.floor(i)===i?Os(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function Os(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function ks(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:j(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function As(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:j(e)?e.value:t.getBaseValue(),r}function js(e){let t=e.options,n=t.fill,r=P(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function Ms(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=Ns(t,n);s.push(ws({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&Hs(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;Ts(n)&&Hs(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!Ts(r)||n.drawTime!==`beforeDatasetDraw`||Hs(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},Xs=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},Zs=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,Qs=class extends ka{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=F(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=J(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=Xs(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=$s(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=Sr(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=G(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=G(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=G(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=G(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;sn(e,this),this._draw(),cn(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=K.color,s=Sr(e.rtl,this.left,this.width),c=J(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=Xs(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=P(n.lineWidth,1);if(r.fillStyle=P(n.fillStyle,o),r.lineCap=P(n.lineCap,`butt`),r.lineDashOffset=P(n.lineDashOffset,0),r.lineJoin=P(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=P(n.strokeStyle,o),r.setLineDash(P(n.lineDash,[])),a.usePointStyle)an(r,{radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},s.xPlus(e,p/2),t+d,a.pointStyleWidth&&p);else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=Sn(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?hn(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){mn(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:G(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:G(i,this.top+y+l,this.bottom-t[0].height),line:0},Cr(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;if(s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=G(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=G(i,this.top+y+l,this.bottom-t[f.line].height)),g(s.x(S),C,o),S=Dt(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=nc(o,e)+l}else f.y+=b}),wr(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=J(t.font),r=q(t.padding);if(!t.display)return;let i=Sr(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=G(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+G(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=G(o,u,u+d);a.textAlign=i.textAlign(Et(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,mn(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=J(e.font),n=q(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(W(e,this.left,this.right)&&W(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function tc(e,t,n){let r=e;return typeof t.text!=`string`&&(r=nc(t,n)),r}function nc(e,t){return t*(e.text?e.text.length:0)}function rc(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var ic={id:`legend`,_element:Qs,start(e,t,n){let r=e.legend=new Qs({ctx:e.ctx,options:n,chart:e});Y.configure(e,r,n),Y.addBox(e,r)},stop(e){Y.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Y.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=q(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},ac=class extends ka{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=A(n.text)?n.text.length:1;this._padding=q(n.padding);let i=r*J(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=G(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=G(o,r,t),s=L*-.5):(l=i-e,u=G(o,t,r),s=L*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=J(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);mn(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:Et(t.align),textBaseline:`middle`,translation:[i,a]})}};function oc(e,t){let n=new ac({ctx:e.ctx,options:t,chart:e});Y.configure(e,n,t),Y.addBox(e,n),e.titleBlock=n}var sc={id:`title`,_element:ac,start(e,t,n){oc(e,n)},stop(e){let t=e.titleBlock;Y.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Y.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},cc={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` +`):e}function uc(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function dc(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=J(t.bodyFont),l=J(t.titleFont),u=J(t.footerFont),d=a.length,f=i.length,p=r.length,m=q(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,I(e.title,y),n.font=c.string,I(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,I(r,e=>{I(e.before,y),I(e.lines,y),I(e.after,y)}),v=0,n.font=u.string,I(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function fc(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function pc(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function mc(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),pc(l,e,t,n)&&(l=`center`),l}function hc(e,t,n){let r=n.yAlign||t.yAlign||fc(e,n);return{xAlign:n.xAlign||t.xAlign||mc(e,t,n,r),yAlign:r}}function gc(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function _c(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function vc(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=Sn(o),m=gc(t,s),h=_c(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:U(m,0,r.width-t.width),y:U(h,0,r.height-t.height)}}function yc(e,t,n){let r=q(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function bc(e){return Z([],lc(e))}function xc(e,t,n){return Tn(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Sc(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Cc={beforeTitle:ke,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=Sc(n,e);Z(t.before,lc(Q(i,`beforeLabel`,this,e))),Z(t.lines,Q(i,`label`,this,e)),Z(t.after,lc(Q(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return bc(Q(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Q(n,`beforeFooter`,this,e),i=Q(n,`footer`,this,e),a=Q(n,`afterFooter`,this,e),o=[];return o=Z(o,lc(r)),o=Z(o,lc(i)),o=Z(o,lc(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),I(o,t=>{let n=Sc(e.callbacks,t);r.push(Q(n,`labelColor`,this,t)),i.push(Q(n,`labelPointStyle`,this,t)),a.push(Q(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=cc[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=dc(this,n),o=Object.assign({},e,t),s=hc(this.chart,n,o),c=vc(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=Sn(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=Sr(n.rtl,this.x,this.width);for(e.x=yc(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=J(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,hn(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),hn(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=J(n.bodyFont),d=u.lineHeight,f=0,p=Sr(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=yc(this,h,n),t.fillStyle=n.bodyColor,I(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=cc[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=dc(this,e),o=Object.assign({},n,this._size),s=hc(t,e,o),c=vc(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=q(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),Cr(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),wr(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!Ne(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!Ne(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=cc[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Tc={id:`tooltip`,_element:wc,positioners:cc,afterInit(e,t,n){n&&(e.tooltip=new wc({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Cc},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]},Ec=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Dc(e,t,n,r){let i=e.indexOf(t);return i===-1?Ec(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Oc=(e,t)=>e===null?null:U(Math.round(e),0,t);function kc(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function jc(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!k(a),_=!k(o),v=!k(c),y=(h-m)/(u+1),b=nt((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=nt(w*b/p/f)*f),k(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&ot((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=tt(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max(lt(b),lt(S));x=10**(k(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&tt(n[n.length-1].value,o,Mc(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Mc(e,t,{horizontal:n,minRotation:r}){let i=V(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Nc=class extends Ya{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return k(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=B(r),t=B(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=jc({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&st(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return Ut(e,this.chart.options.locale,this.options.ticks.format)}},Pc=class extends Nc{static id=`linear`;static defaults={ticks:{callback:Kt.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=M(e)?e:0,this.max=M(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=V(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Fc=e=>Math.floor(et(e)),Ic=(e,t)=>10**(Fc(e)+t);function Lc(e){return e/10**Fc(e)==1}function Rc(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function zc(e,t){let n=Fc(t-e);for(;Rc(e,t,n)>10;)n++;for(;Rc(e,t,n)<10;)n--;return Math.min(n,Fc(e))}function Bc(e,{min:t,max:n}){t=N(e.min,t);let r=[],i=Fc(t),a=zc(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=N(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=N(e.max,f);return r.push({value:p,major:Lc(p),significand:d}),r}(class extends Ya{static id=`logarithmic`;static defaults={ticks:{callback:Kt.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Nc.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return M(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=M(e)?Math.max(0,e):null,this.max=M(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!M(this._userMin)&&(this.min=e===Ic(this.min,0)?Ic(this.min,-1):Ic(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Ic(n,-1)),a(Ic(r,1)))),n<=0&&i(Ic(r,-1)),r<=0&&a(Ic(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Bc({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&st(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:Ut(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=et(e),this._valueRange=et(this.max)-et(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(et(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}});function Vc(e){let t=e.ticks;if(t.display&&e.display){let e=q(t.backdropPadding);return P(t.font&&t.font.size,K.font.size)+e.height}return 0}function Hc(e,t,n){return n=A(n)?n:[n],{w:en(e,t.string,n),h:n.length*t.lineHeight}}function Uc(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function Wc(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?L/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function Kc(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(ct(H(c.angle+z))),u=Zc(c.y,s.h,l),d=Yc(l),f=Xc(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function qc(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(on({x:n,y:r},t)||on({x:n,y:a},t)||on({x:i,y:r},t)||on({x:i,y:a},t))}function Jc(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Vc(a)/2,additionalAngle:o?L/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function Qc(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!k(s)){let n=Sn(t.borderRadius),c=q(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),hn(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function $c(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));Qc(n,a,t);let o=J(a.font),{x:s,y:c,textAlign:l}=t;mn(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function el(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,R);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=F(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?Wc(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=R/(this._pointLabels.length||1),n=this.options.startAngle||0;return H(e*t+V(n))}getDistanceFromCenterForValue(e){if(k(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(k(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);tl(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=J(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=q(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}mn(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}});var rl={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},$=Object.keys(rl);function il(e,t){return e-t}function al(e,t){if(k(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),M(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(at(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function ol(e,t,n,r){let i=$.length;for(let a=$.indexOf(e);a=$.indexOf(n);a--){let n=$[a];if(rl[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return $[n?$.indexOf(n):0]}function cl(e){for(let t=$.indexOf(e)+1,n=$.length;t=t?n[r]:n[i];e[a]=!0}}function ul(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function dl(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=U(t,0,a),n=U(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||ol(i.minUnit,t,n,this._getLabelCapacity(t)),o=P(r.ticks.stepSize,1),s=a===`week`?i.isoWeekday:!1,c=at(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return F(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=gt(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=gt(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}(class extends fl{static id=`timeseries`;static defaults=fl.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=pl(t,this.min),this._tableRange=pl(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(pl(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return pl(this._table,n*this._tableRange+this._minPos,!0)}});async function ml(e,t,n={}){let{connectTimeoutMs:r=15e3,idleTimeoutMs:i=5e3,onPhaseChange:a}=n,o=new AbortController,s=!1,c=null,l=setTimeout(()=>{s||o.abort(Error(`Connection timeout`))},r),u=()=>{c&&clearTimeout(c),c=setTimeout(()=>{o.abort(Error(`Stream stalled`))},i)};a?.(`connecting`);try{return await d.get(e,t,{signal:o.signal,timeout:0,onDownloadProgress:e=>{!s&&(e.loaded??0)>0?(s=!0,clearTimeout(l),a?.(`receiving`),u()):s&&u()}})}finally{clearTimeout(l),c&&clearTimeout(c)}}var hl={class:`relative`},gl={key:0,class:`absolute inset-0 flex flex-col items-center justify-center bg-surface/80 backdrop-blur-sm z-10`},_l={key:0,class:`mt-2 text-sm text-content-secondary`},vl={key:1,class:`absolute top-3 right-3 flex items-center gap-1.5 z-10`},yl={key:2,class:`absolute inset-0 flex flex-col items-center justify-center bg-surface/80 backdrop-blur-sm z-10`},bl={class:`text-xs text-content-secondary mt-1 max-w-[12rem] text-center`},xl={key:0,class:`mt-2 text-xs text-content-muted`},Sl=i({__name:`ChartCard`,props:{isLoading:{type:Boolean},isUpdating:{type:Boolean},error:{},status:{},autoRetryMs:{}},emits:[`retry`],setup(i,{emit:d}){let p=i,m=d,h=r(0),g=null,_=null,v=()=>{g&&=(clearInterval(g),null),_&&=(clearTimeout(_),null),h.value=0};return n(()=>p.error,e=>{if(v(),!e)return;let t=p.autoRetryMs??3e4;h.value=Math.round(t/1e3),g=setInterval(()=>{h.value=Math.max(0,h.value-1),h.value===0&&v()},1e3),_=setTimeout(()=>{v(),m(`retry`)},t)}),u(v),(n,r)=>(a(),l(`div`,hl,[t(n.$slots,`default`),i.isLoading?(a(),l(`div`,gl,[s(f),i.status?(a(),l(`p`,_l,e(i.status),1)):o(``,!0)])):i.isUpdating&&!i.error?(a(),l(`div`,vl,[s(f,{size:`xs`,color:`current`,class:`text-content-muted`}),r[1]||=c(`span`,{class:`text-xs text-content-muted`},`Updating`,-1)])):o(``,!0),i.error&&!i.isLoading?(a(),l(`div`,yl,[r[2]||=c(`svg`,{xmlns:`http://www.w3.org/2000/svg`,class:`w-8 h-8 text-accent-red mb-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})],-1),r[3]||=c(`p`,{class:`text-sm font-semibold text-content-primary`},`Loading Failed`,-1),c(`p`,bl,e(i.error),1),c(`button`,{class:`btn-secondary mt-3 text-xs px-3 py-1.5`,onClick:r[0]||=e=>m(`retry`)},`Retry`),h.value>0?(a(),l(`p`,xl,`Retrying in `+e(h.value)+`s`,1)):o(``,!0)])):o(``,!0)]))}});export{ic as _,vs as a,Ai as c,Pc as d,cs as f,Ys as g,Pi as h,Oi as i,ji as l,fl as m,ml as n,Ac as o,Mi as p,qo as r,Lo as s,Sl as t,os as u,sc as v,Tc as y}; \ No newline at end of file diff --git a/repeater/web/html/assets/Companions-CPdWnFPt.js b/repeater/web/html/assets/Companions-CPdWnFPt.js new file mode 100644 index 00000000..6b745f30 --- /dev/null +++ b/repeater/web/html/assets/Companions-CPdWnFPt.js @@ -0,0 +1 @@ +import{Ct as e,E as t,R as n,S as r,V as i,Y as a,c as o,f as ee,g as s,i as c,j as l,k as u,l as d,m as f,nt as p,o as m,p as h,r as g,s as _,u as v,xt as y}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{a as b,i as x,s as S,u as C}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as w}from"./api-3gMnsCKh.js";import{t as T}from"./Spinner-CcYauG9D.js";import{n as E}from"./index-DTUpsCzx.js";import{t as D}from"./ConfirmDialog-DBlDmP2I.js";import{t as O}from"./MessageDialog-bhwyqS5K.js";var k={role:`dialog`,"aria-describedby":`import-modal-description`,class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-lg w-full max-h-[90vh] overflow-y-auto`},A={id:`import-modal-description`,class:`text-content-secondary dark:text-content-muted text-sm mb-4`},j={class:`mb-4`},M={class:`flex items-center gap-2 mb-2`},N={key:0,class:`text-content-muted dark:text-content-muted text-xs mb-2`},P={key:1,class:`flex flex-wrap gap-3 ml-6`},F=[`value`],I={class:`text-content-primary dark:text-content-primary text-sm capitalize`},L={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},R={class:`flex flex-wrap gap-3 mb-2`},z=[`value`],B={class:`text-content-primary dark:text-content-primary text-sm`},V={class:`flex flex-wrap items-center gap-2 mt-2`},H={class:`flex items-center gap-2`},te={key:1,class:`text-content-muted dark:text-content-muted text-sm`},ne={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},re={class:`flex flex-wrap items-center gap-2`},ie={key:0,role:`alert`,class:`mb-4 p-3 rounded-lg bg-accent-red/10 dark:bg-accent-red/20 border border-accent-red/30 text-accent-red text-sm`},U={key:1,class:`text-content-muted dark:text-content-muted text-sm mb-4`},ae={class:`flex justify-end gap-3`},W=[`disabled`],G=[`disabled`],K=s({name:`ImportRepeaterContactsModal`,__name:`ImportRepeaterContactsModal`,props:{isOpen:{type:Boolean},companionName:{}},emits:[`close`,`imported`],setup(t,{emit:ee}){let s=[`companion`,`repeater`,`room_server`,`sensor`],f=[{label:`All time`,value:null},{label:`Last 24 hours`,value:24},{label:`Last 7 days`,value:168},{label:`Last 30 days`,value:720},{label:`Custom`,value:`custom`}].slice(0,4),y=t,T=ee,E=a(!1),D=a(null),O=a(!0),K=a([]),q=a(null),J=a(``),Y=a(``),X=a(null),oe=a(null);function Z(){let e=q.value;if(e===null||e===`custom`){if(e===`custom`){let e=J.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}return}return e}function Q(){let e=Y.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}function se(){O.value=!0,K.value=[],q.value=null,J.value=``,Y.value=``,D.value=null}n(()=>y.isOpen,e=>{e&&(se(),r(()=>{oe.value?.focus()}))}),n(q,e=>{e===`custom`&&r(()=>{X.value?.focus()})});let ce=m(()=>{let e=O.value?`All types`:K.value.map(e=>e.replace(`_`,` `)).join(`, `),t,n=q.value;if(n===null)t=`all time`;else if(n===`custom`){let e=Z();t=e===void 0?`custom`:`last ${e} hours`}else t=n===24?`last 24 hours`:n===168?`last 7 days`:n===720?`last 30 days`:`all time`;let r=Q(),i=r===void 0?`no limit`:`max ${r} contacts`;return`Import: ${e}, ${t}, ${i}.`});function le(){if(q.value===`custom`){let e=Z();if(e===void 0||e<1)return`Custom recency must be at least 1 hour.`}let e=Q();if(Y.value!==``&&(e===void 0||e<1))return`Limit must be at least 1.`;if(!O.value&&K.value.length===0)return`Select at least one contact type or use All types.`;if(!O.value){let e=K.value.filter(e=>!s.includes(e));if(e.length>0)return`Invalid contact type: ${e.join(`, `)}`}return null}async function ue(){D.value=null;let e=le();if(e){D.value=e;return}let t={companion_name:y.companionName};!O.value&&K.value.length>0&&(t.contact_types=[...K.value]);let n=Z();n!==void 0&&(t.hours=n);let r=Q();r!==void 0&&(t.limit=r),E.value=!0;try{let e=await w.importRepeaterContacts(t);e.success&&e.data?(T(`imported`,e.data.imported),T(`close`)):D.value=e.error||`Import failed.`}catch(e){D.value=e instanceof Error?e.message:`Import failed.`}finally{E.value=!1}}function de(e){e.key===`Escape`&&T(`close`)}return(n,r)=>(u(),o(c,{to:`body`},[t.isOpen?(u(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[350] p-4`,onClick:r[7]||=C(e=>T(`close`),[`self`]),onKeydown:de},[_(`div`,k,[r[18]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Import repeater contacts `,-1),_(`p`,A,[r[8]||=h(` Seed `,-1),_(`strong`,null,e(t.companionName),1),r[9]||=h(` with contacts from the repeater's adverts. Results are ordered by most recent first. `,-1)]),_(`div`,j,[r[11]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Contact types `,-1),_(`label`,M,[i(_(`input`,{ref_key:`firstFocusRef`,ref:oe,"onUpdate:modelValue":r[0]||=e=>O.value=e,type:`checkbox`,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[x,O.value]]),r[10]||=_(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`All types`,-1)]),O.value?(u(),v(`p`,N,` Uncheck to filter by type (repeater, companion, room server, sensor). `)):d(``,!0),O.value?d(``,!0):(u(),v(`div`,P,[(u(),v(g,null,l(s,t=>_(`label`,{key:t,class:`flex items-center gap-2`},[i(_(`input`,{"onUpdate:modelValue":r[1]||=e=>K.value=e,type:`checkbox`,value:t,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,F),[[x,K.value]]),_(`span`,I,e(t.replace(`_`,` `)),1)])),64))]))]),_(`div`,L,[r[13]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Recency `,-1),_(`div`,R,[(u(!0),v(g,null,l(p(f),t=>(u(),v(`label`,{key:t.label,class:`flex items-center gap-2`},[i(_(`input`,{"onUpdate:modelValue":r[2]||=e=>q.value=e,type:`radio`,value:t.value,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,z),[[b,q.value]]),_(`span`,B,e(t.label),1)]))),128))]),_(`div`,V,[_(`label`,H,[i(_(`input`,{"onUpdate:modelValue":r[3]||=e=>q.value=e,type:`radio`,value:`custom`,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[b,q.value]]),r[12]||=_(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`Custom:`,-1)]),q.value===`custom`?i((u(),v(`input`,{key:0,ref_key:`customHoursInputRef`,ref:X,"onUpdate:modelValue":r[4]||=e=>J.value=e,type:`number`,min:`1`,placeholder:`e.g. 48`,class:`w-24 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-1.5 text-content-primary dark:text-content-primary text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512)),[[S,J.value,void 0,{number:!0}]]):d(``,!0),q.value===`custom`?(u(),v(`span`,te,`hours`)):d(``,!0)])]),_(`div`,ne,[r[16]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Max contacts (optional) `,-1),_(`div`,re,[r[14]||=_(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`Import at most`,-1),i(_(`input`,{"onUpdate:modelValue":r[5]||=e=>Y.value=e,type:`number`,inputmode:`numeric`,min:`1`,placeholder:`No limit`,class:`w-32 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512),[[S,Y.value,void 0,{number:!0}]]),r[15]||=_(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`contacts`,-1)]),r[17]||=_(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-1`},` Leave empty for no cap. Server caps at companion max. `,-1)]),D.value?(u(),v(`div`,ie,e(D.value),1)):d(``,!0),D.value?d(``,!0):(u(),v(`p`,U,e(ce.value),1)),_(`div`,ae,[_(`button`,{type:`button`,disabled:E.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors disabled:opacity-50`,onClick:r[6]||=e=>T(`close`)},` Cancel `,8,W),_(`button`,{type:`button`,disabled:E.value,class:`btn-primary`,onClick:ue},e(E.value?`Importing…`:`Import`),9,G)])])],32)):d(``,!0)]))}}),q={class:`p-6 space-y-6`},J={key:0,class:`grid grid-cols-1 md:grid-cols-3 gap-4`},Y={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},X={class:`flex items-center justify-between`},oe={class:`text-3xl font-bold text-content-primary dark:text-content-primary mb-1`},Z={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},Q={class:`flex items-center justify-between`},se={class:`text-3xl font-bold text-primary mb-1`},ce={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},le={class:`flex items-center justify-between`},ue={key:0,class:`w-6 h-6 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},de={key:1,class:`w-6 h-6 text-accent-yellow`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},fe={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},pe={key:0,class:`flex items-center justify-center py-12`},me={class:`text-center`},he={key:1,class:`flex items-center justify-center py-12`},ge={class:`text-center`},_e={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},ve={key:2,class:`space-y-4`},ye={class:`flex items-start justify-between`},be={class:`flex-1`},xe={class:`flex items-center gap-3 mb-4`},Se={class:`relative`},Ce={key:0,class:`absolute inset-0 bg-accent-green/50 rounded-full animate-ping`},we={class:`text-xl font-bold text-content-primary dark:text-content-primary`},Te={key:0,class:`text-content-muted dark:text-content-muted text-sm`},Ee={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3`},De={class:`text-content-primary dark:text-content-primary/90 ml-2`},Oe={class:`text-content-primary dark:text-content-primary/90 ml-2`},ke={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ae={class:`flex items-center gap-2`},je={key:0,class:`text-content-primary dark:text-content-primary/90 font-mono ml-2 text-xs`},Me={key:1,class:`text-content-muted dark:text-content-muted ml-2 text-xs`},Ne=[`onClick`],Pe={class:`text-xs text-content-muted dark:text-content-muted`},Fe={key:0,class:`ml-2 font-mono text-content-primary dark:text-content-primary/90 break-all`},Ie={key:1,class:`ml-2 text-content-muted dark:text-content-muted`},Le={class:`ml-4 flex flex-wrap gap-2`},Re=[`onClick`],ze=[`onClick`],Be=[`onClick`],Ve={key:3,class:`text-center py-12 text-content-secondary dark:text-content-muted`},He={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Ue={class:`space-y-4`},We={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Ge={key:0},Ke={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},qe={class:`grid grid-cols-2 gap-4`},Je={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Ye={class:`space-y-4`},Xe={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Ze={key:0},Qe={class:`grid grid-cols-2 gap-4`},$e=5050,et=1,tt=65535,nt=s({name:`CompanionsView`,__name:`Companions`,setup(n){let r=a(!1),s=a(null),p=a(null),b=a(!1),x=a(!1),k=a(!1),A=a(null),j=a(``),M=a(!1),N=a(!1),P=a(new Set),F=a(!1),I=a(``),L=a(!1),R=a(``),z=a(!1),B=a({message:``,variant:`success`}),V=a({name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}});t(async()=>{await H()});async function H(){r.value=!0,s.value=null;try{let e=await w.getIdentities();e.success?p.value=e.data:s.value=e.error||`Failed to load identities`}catch(e){s.value=e instanceof Error?e.message:`Failed to load identities`}finally{r.value=!1}}async function te(){try{let e=await w.createIdentity({...V.value,settings:{node_name:V.value.settings.node_name||V.value.name,tcp_port:V.value.settings.tcp_port??5e3,bind_address:V.value.settings.bind_address||`0.0.0.0`}});e.success?(b.value=!1,W(),await H(),U(e.message||`Companion created successfully!`,`success`)):U(`Failed to create companion: ${e.error}`,`error`)}catch(e){U(`Error creating companion: ${e}`,`error`)}}async function ne(){let e={name:j.value,identity_key:A.value.identity_key,type:`companion`,settings:{node_name:A.value.settings?.node_name,tcp_port:A.value.settings?.tcp_port,bind_address:A.value.settings?.bind_address}};A.value.name!==j.value&&(e.new_name=A.value.name);try{let t=await w.updateIdentity(e);t.success?(x.value=!1,A.value=null,await H(),k.value=!0):U(`Failed to update companion: ${t.error}`,`error`)}catch(e){U(`Error updating companion: ${e}`,`error`)}}function re(e){I.value=e,F.value=!0}async function ie(){let e=I.value;F.value=!1;try{let t=await w.deleteIdentity(e,`companion`);t.success?(await H(),U(t.message||`Companion deleted successfully!`,`success`)):U(`Failed to delete companion: ${t.error}`,`error`)}catch(e){U(`Error deleting companion: ${e}`,`error`)}finally{I.value=``}}function U(e,t){B.value={message:e,variant:t},z.value=!0}function ae(e){A.value=JSON.parse(JSON.stringify(e)),j.value=A.value.name,delete A.value.new_name,A.value.settings||(A.value.settings={node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}),N.value=!1,x.value=!0}function W(){V.value={name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}},M.value=!1}function G(){b.value=!1,x.value=!1,A.value=null,M.value=!1,N.value=!1,W()}function nt(e){P.value.has(e)?P.value.delete(e):P.value.add(e)}let rt=()=>p.value?.configured_companions??[],it=m(()=>p.value?.configured_companions?.length??0),at=m(()=>p.value?.configured_companions?.filter(e=>e.registered).length??0),$=m(()=>at.value===it.value);function ot(){let e=rt();if(e.length===0)return $e;let t=e.map(e=>e.settings?.tcp_port??5e3),n=Math.max(...t)+1;return Math.min(tt,Math.max(et,n))}function st(){W(),V.value.settings.tcp_port=ot(),b.value=!0}function ct(e){R.value=e,L.value=!0}function lt(){L.value=!1,R.value=``}function ut(e){U(`Imported ${e} contact${e===1?``:`s`}.`,`success`),lt()}return(t,n)=>(u(),v(g,null,[_(`div`,q,[_(`div`,{class:`relative overflow-hidden rounded-[20px] p-6 mb-6 glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10`},[n[18]||=_(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/20 via-secondary/10 to-accent-purple/20 opacity-50`},null,-1),n[19]||=_(`div`,{class:`absolute inset-0 bg-gradient-to-tl from-accent-green/10 via-transparent to-primary/10 animate-pulse`},null,-1),_(`div`,{class:`relative flex items-center justify-between`},[n[17]||=ee(`

Companions

Manage companion identities (TCP frame server)

`,1),_(`button`,{onClick:st,class:`group relative px-6 py-3 bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary rounded-[12px] border border-primary/50 transition-all hover:scale-105 hover:shadow-lg hover:shadow-primary/20`},[...n[16]||=[_(`span`,{class:`flex items-center gap-2`},[_(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})]),h(` Add Companion `)],-1)]])])]),p.value&&it.value>0?(u(),v(`div`,J,[_(`div`,Y,[_(`div`,X,[_(`div`,null,[n[20]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Total Configured `,-1),_(`div`,oe,e(it.value),1)]),n[21]||=_(`div`,{class:`bg-background-mute dark:bg-white/10 p-3 rounded-[12px]`},[_(`svg`,{class:`w-6 h-6 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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 0z`})])],-1)])]),_(`div`,Z,[_(`div`,Q,[_(`div`,null,[n[22]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Currently Registered `,-1),_(`div`,se,e(at.value),1)]),n[23]||=_(`div`,{class:`bg-primary/20 p-3 rounded-[12px]`},[_(`svg`,{class:`w-6 h-6 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})])],-1)])]),_(`div`,ce,[_(`div`,le,[_(`div`,null,[n[24]||=_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Status `,-1),_(`div`,{class:y([`text-3xl font-bold`,$.value?`text-accent-green`:`text-accent-yellow`])},e($.value?`Synced`:`Out of Sync`),3)]),_(`div`,{class:y([`p-3 rounded-[12px]`,$.value?`bg-accent-green/20`:`bg-accent-yellow/20`])},[$.value?(u(),v(`svg`,ue,[...n[25]||=[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(u(),v(`svg`,de,[...n[26]||=[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2)])])])):d(``,!0),_(`div`,fe,[r.value?(u(),v(`div`,pe,[_(`div`,me,[f(T,{class:`mx-auto mb-4`}),n[27]||=_(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading companions... `,-1)])])):s.value?(u(),v(`div`,he,[_(`div`,ge,[n[28]||=_(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load companions`,-1),_(`div`,_e,e(s.value),1),_(`button`,{onClick:H,class:`btn-primary`},` Retry `)])])):p.value&&rt().length>0?(u(),v(`div`,ve,[(u(!0),v(g,null,l(rt(),t=>(u(),v(`div`,{key:t.name,class:`glass-card backdrop-blur-xl rounded-[15px] p-5 border border-stroke-subtle dark:border-white/10`},[_(`div`,ye,[_(`div`,be,[_(`div`,xe,[_(`div`,Se,[t.registered?(u(),v(`div`,Ce)):d(``,!0),_(`div`,{class:y([`relative w-3 h-3 rounded-full`,t.registered?`bg-accent-green`:`bg-accent-red`])},null,2)]),_(`h3`,we,e(t.name),1),_(`span`,{class:y([`px-3 py-1 text-xs font-semibold rounded-full`,t.registered?`bg-accent-green/20 text-accent-green border border-accent-green/30`:`bg-accent-red/20 text-accent-red border border-accent-red/30`])},e(t.registered?`● Active`:`○ Inactive`),3),t.hash?(u(),v(`span`,Te,e(t.hash),1)):d(``,!0)]),_(`div`,Ee,[_(`div`,null,[n[29]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Node Name:`,-1),_(`span`,De,e(t.settings?.node_name||t.name),1)]),_(`div`,null,[n[30]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`TCP Port:`,-1),_(`span`,Oe,e(t.settings?.tcp_port??5e3),1)]),_(`div`,null,[n[31]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Bind Address:`,-1),_(`span`,ke,e(t.settings?.bind_address||`0.0.0.0`),1)]),_(`div`,Ae,[n[32]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Identity Key:`,-1),P.value.has(t.name)?(u(),v(`span`,je,e(t.identity_key),1)):(u(),v(`span`,Me,`••••••••••••••••`)),_(`button`,{onClick:e=>nt(t.name),class:`text-primary/70 hover:text-primary text-xs underline`},e(P.value.has(t.name)?`Hide`:`Show`),9,Ne)])]),_(`div`,Pe,[n[33]||=_(`span`,{class:`text-content-muted dark:text-content-muted`},`Public Key:`,-1),t.public_key?(u(),v(`span`,Fe,e(t.public_key),1)):(u(),v(`span`,Ie,`—`))])]),_(`div`,Le,[_(`button`,{onClick:e=>ct(t.name),class:`btn-primary-xs`},` Import contacts `,8,Re),_(`button`,{onClick:e=>ae(t),class:`btn-primary-xs`},` Edit `,8,ze),_(`button`,{onClick:e=>re(t.name),class:`btn-danger-xs`},` Delete `,8,Be)])])]))),128))])):(u(),v(`div`,Ve,[n[34]||=_(`svg`,{class:`w-16 h-16 mx-auto mb-4 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[_(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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 0z`})],-1),n[35]||=_(`p`,{class:`text-lg mb-2`},`No companions configured`,-1),n[36]||=_(`p`,{class:`text-sm mb-4`},` Add a companion to run a TCP frame server for firmware or other clients `,-1),_(`button`,{onClick:st,class:`btn-primary`},` + Add Companion `)]))]),(u(),o(c,{to:`body`},[b.value?(u(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[300] p-4`,onClick:n[6]||=C(e=>b.value=!1,[`self`])},[_(`div`,He,[n[43]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Add Companion `,-1),_(`div`,Ue,[_(`div`,null,[n[37]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),i(_(`input`,{"onUpdate:modelValue":n[0]||=e=>V.value.name=e,type:`text`,placeholder:`e.g., TestCompanion`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,V.value.name]])]),_(`div`,null,[_(`label`,We,[n[38]||=h(` Identity Key (Optional) `,-1),_(`button`,{onClick:n[1]||=e=>M.value=!M.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},e(M.value?`Hide`:`Show/Edit`),1)]),M.value?(u(),v(`div`,Ge,[i(_(`input`,{"onUpdate:modelValue":n[2]||=e=>V.value.identity_key=e,type:`text`,placeholder:`Leave empty to auto-generate (32 bytes hex)`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,V.value.identity_key]]),n[39]||=_(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` 32 or 64 bytes hex. Leave empty to auto-generate. `,-1)])):(u(),v(`div`,Ke,` Will be auto-generated if not provided `))]),_(`div`,null,[n[40]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),i(_(`input`,{"onUpdate:modelValue":n[3]||=e=>V.value.settings.node_name=e,type:`text`,placeholder:`Display name (defaults to Name)`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,V.value.settings.node_name]])]),_(`div`,qe,[_(`div`,null,[n[41]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),i(_(`input`,{"onUpdate:modelValue":n[4]||=e=>V.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,V.value.settings.tcp_port,void 0,{number:!0}]])]),_(`div`,null,[n[42]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),i(_(`input`,{"onUpdate:modelValue":n[5]||=e=>V.value.settings.bind_address=e,type:`text`,placeholder:`0.0.0.0`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,V.value.settings.bind_address]])])])]),_(`div`,{class:`flex justify-end gap-3 mt-6`},[_(`button`,{onClick:G,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),_(`button`,{onClick:te,class:`btn-primary`},` Create `)])])])):d(``,!0)])),(u(),o(c,{to:`body`},[x.value&&A.value?(u(),v(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-lg flex items-center justify-center z-[300] p-4`,onClick:C(G,[`self`])},[_(`div`,Je,[n[49]||=_(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Edit Companion `,-1),_(`div`,Ye,[_(`div`,null,[n[44]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),i(_(`input`,{"onUpdate:modelValue":n[7]||=e=>A.value.name=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,A.value.name]])]),_(`div`,null,[_(`label`,Xe,[n[45]||=h(` Identity Key (Optional) `,-1),_(`button`,{onClick:n[8]||=e=>N.value=!N.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},e(N.value?`Hide`:`Show/Edit`),1)]),N.value?(u(),v(`div`,Ze,[i(_(`input`,{"onUpdate:modelValue":n[9]||=e=>A.value.identity_key=e,type:`text`,placeholder:`Leave empty to keep current key`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,A.value.identity_key]])])):d(``,!0)]),_(`div`,null,[n[46]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),i(_(`input`,{"onUpdate:modelValue":n[10]||=e=>A.value.settings.node_name=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,A.value.settings.node_name]])]),_(`div`,Qe,[_(`div`,null,[n[47]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),i(_(`input`,{"onUpdate:modelValue":n[11]||=e=>A.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,A.value.settings.tcp_port,void 0,{number:!0}]])]),_(`div`,null,[n[48]||=_(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),i(_(`input`,{"onUpdate:modelValue":n[12]||=e=>A.value.settings.bind_address=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[S,A.value.settings.bind_address]])])])]),_(`div`,{class:`flex justify-end gap-3 mt-6`},[_(`button`,{onClick:G,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),_(`button`,{onClick:ne,class:`btn-primary`},` Update `)])])])):d(``,!0)]))]),f(K,{"is-open":L.value,"companion-name":R.value,onClose:lt,onImported:ut},null,8,[`is-open`,`companion-name`]),f(D,{show:F.value,title:`Delete Companion`,message:`Are you sure you want to delete '${I.value}'? Restart required to fully remove.`,"confirm-text":`Delete`,"cancel-text":`Cancel`,variant:`danger`,onClose:n[13]||=e=>F.value=!1,onConfirm:ie},null,8,[`show`,`message`]),f(O,{show:z.value,message:B.value.message,variant:B.value.variant,onClose:n[14]||=e=>z.value=!1},null,8,[`show`,`message`,`variant`]),f(E,{modelValue:k.value,"onUpdate:modelValue":n[15]||=e=>k.value=e,message:`Companion settings have been saved. A service restart is required for the changes to take effect.`},null,8,[`modelValue`])],64))}});export{nt as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Companions-Cm95T8nb.js b/repeater/web/html/assets/Companions-Cm95T8nb.js deleted file mode 100644 index 5f9553df..00000000 --- a/repeater/web/html/assets/Companions-Cm95T8nb.js +++ /dev/null @@ -1 +0,0 @@ -import{E as e,K as t,S as n,b as r,dt as i,f as a,g as o,j as s,k as c,l,m as u,o as d,p as f,pt as p,r as m,s as h,u as g,w as _,z as v}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as y}from"./api-CbM6k1ZB.js";import{f as b,h as x,l as S,u as C}from"./index-BFltqMtv.js";import{t as w}from"./ConfirmDialog-PLW-eI8u.js";import{t as T}from"./MessageDialog-CEzYMZ-3.js";var E={id:`import-modal-description`,class:`text-content-secondary dark:text-content-muted text-sm mb-4`},D={class:`mb-4`},O={class:`flex items-center gap-2 mb-2`},k={key:0,class:`text-content-muted dark:text-content-muted text-xs mb-2`},A={key:1,class:`flex flex-wrap gap-3 ml-6`},j=[`value`],M={class:`text-content-primary dark:text-content-primary text-sm capitalize`},N={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},P={class:`flex flex-wrap gap-3 mb-2`},F=[`value`],ee={class:`text-content-primary dark:text-content-primary text-sm`},te={class:`flex flex-wrap items-center gap-2 mt-2`},ne={class:`flex items-center gap-2`},I={key:1,class:`text-content-muted dark:text-content-muted text-sm`},L={class:`border-t border-stroke-subtle dark:border-white/10 pt-4 mt-4 mb-4`},R={class:`flex flex-wrap items-center gap-2`},z={key:0,role:`alert`,class:`mb-4 p-3 rounded-lg bg-accent-red/10 dark:bg-accent-red/20 border border-accent-red/30 text-accent-red text-sm`},B={key:1,class:`text-content-muted dark:text-content-muted text-sm mb-4`},V={class:`flex justify-end gap-3`},H=[`disabled`],U=[`disabled`],W=o({name:`ImportRepeaterContactsModal`,__name:`ImportRepeaterContactsModal`,props:{isOpen:{type:Boolean},companionName:{}},emits:[`close`,`imported`],setup(n,{emit:i}){let a=[`companion`,`repeater`,`room_server`,`sensor`],o=[{label:`All time`,value:null},{label:`Last 24 hours`,value:24},{label:`Last 7 days`,value:168},{label:`Last 30 days`,value:720},{label:`Custom`,value:`custom`}].slice(0,4),u=n,w=i,T=v(!1),W=v(null),G=v(!0),K=v([]),q=v(null),J=v(``),Y=v(``),X=v(null),Z=v(null);function Q(){let e=q.value;if(e===null||e===`custom`){if(e===`custom`){let e=J.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}return}return e}function $(){let e=Y.value;if(e===``||e===null)return;let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0}function re(){G.value=!0,K.value=[],q.value=null,J.value=``,Y.value=``,W.value=null}c(()=>u.isOpen,e=>{e&&(re(),r(()=>{Z.value?.focus()}))}),c(q,e=>{e===`custom`&&r(()=>{X.value?.focus()})});let ie=d(()=>{let e=G.value?`All types`:K.value.map(e=>e.replace(`_`,` `)).join(`, `),t,n=q.value;if(n===null)t=`all time`;else if(n===`custom`){let e=Q();t=e===void 0?`custom`:`last ${e} hours`}else t=n===24?`last 24 hours`:n===168?`last 7 days`:n===720?`last 30 days`:`all time`;let r=$(),i=r===void 0?`no limit`:`max ${r} contacts`;return`Import: ${e}, ${t}, ${i}.`});function ae(){if(q.value===`custom`){let e=Q();if(e===void 0||e<1)return`Custom recency must be at least 1 hour.`}let e=$();if(Y.value!==``&&(e===void 0||e<1))return`Limit must be at least 1.`;if(!G.value&&K.value.length===0)return`Select at least one contact type or use All types.`;if(!G.value){let e=K.value.filter(e=>!a.includes(e));if(e.length>0)return`Invalid contact type: ${e.join(`, `)}`}return null}async function oe(){W.value=null;let e=ae();if(e){W.value=e;return}let t={companion_name:u.companionName};!G.value&&K.value.length>0&&(t.contact_types=[...K.value]);let n=Q();n!==void 0&&(t.hours=n);let r=$();r!==void 0&&(t.limit=r),T.value=!0;try{let e=await y.importRepeaterContacts(t);e.success&&e.data?(w(`imported`,e.data.imported),w(`close`)):W.value=e.error||`Import failed.`}catch(e){W.value=e instanceof Error?e.message:`Import failed.`}finally{T.value=!1}}function se(e){e.target===e.currentTarget&&w(`close`)}function ce(e){e.key===`Escape`&&w(`close`)}return(r,i)=>n.isOpen?(_(),g(`div`,{key:0,class:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:se,onKeydown:ce},[h(`div`,{role:`dialog`,"aria-describedby":`import-modal-description`,class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-lg w-full max-h-[90vh] overflow-y-auto`,onClick:i[7]||=x(()=>{},[`stop`])},[i[18]||=h(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Import repeater contacts `,-1),h(`p`,E,[i[8]||=f(` Seed `,-1),h(`strong`,null,p(n.companionName),1),i[9]||=f(` with contacts from the repeater's adverts. Results are ordered by most recent first. `,-1)]),h(`div`,D,[i[11]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Contact types `,-1),h(`label`,O,[s(h(`input`,{ref_key:`firstFocusRef`,ref:Z,"onUpdate:modelValue":i[0]||=e=>G.value=e,type:`checkbox`,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[S,G.value]]),i[10]||=h(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`All types`,-1)]),G.value?(_(),g(`p`,k,` Uncheck to filter by type (repeater, companion, room server, sensor). `)):l(``,!0),G.value?l(``,!0):(_(),g(`div`,A,[(_(),g(m,null,e(a,e=>h(`label`,{key:e,class:`flex items-center gap-2`},[s(h(`input`,{"onUpdate:modelValue":i[1]||=e=>K.value=e,type:`checkbox`,value:e,class:`rounded border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,j),[[S,K.value]]),h(`span`,M,p(e.replace(`_`,` `)),1)])),64))]))]),h(`div`,N,[i[13]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Recency `,-1),h(`div`,P,[(_(!0),g(m,null,e(t(o),e=>(_(),g(`label`,{key:e.label,class:`flex items-center gap-2`},[s(h(`input`,{"onUpdate:modelValue":i[2]||=e=>q.value=e,type:`radio`,value:e.value,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,8,F),[[C,q.value]]),h(`span`,ee,p(e.label),1)]))),128))]),h(`div`,te,[h(`label`,ne,[s(h(`input`,{"onUpdate:modelValue":i[3]||=e=>q.value=e,type:`radio`,value:`custom`,class:`border-stroke-subtle dark:border-stroke/20 text-primary focus:ring-primary/50`},null,512),[[C,q.value]]),i[12]||=h(`span`,{class:`text-content-primary dark:text-content-primary text-sm`},`Custom:`,-1)]),q.value===`custom`?s((_(),g(`input`,{key:0,ref_key:`customHoursInputRef`,ref:X,"onUpdate:modelValue":i[4]||=e=>J.value=e,type:`number`,min:`1`,placeholder:`e.g. 48`,class:`w-24 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-1.5 text-content-primary dark:text-content-primary text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512)),[[b,J.value,void 0,{number:!0}]]):l(``,!0),q.value===`custom`?(_(),g(`span`,I,`hours`)):l(``,!0)])]),h(`div`,L,[i[16]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},` Max contacts (optional) `,-1),h(`div`,R,[i[14]||=h(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`Import at most`,-1),s(h(`input`,{"onUpdate:modelValue":i[5]||=e=>Y.value=e,type:`number`,inputmode:`numeric`,min:`1`,placeholder:`No limit`,class:`w-32 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50`},null,512),[[b,Y.value,void 0,{number:!0}]]),i[15]||=h(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`contacts`,-1)]),i[17]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-1`},` Leave empty for no cap. Server caps at companion max. `,-1)]),W.value?(_(),g(`div`,z,p(W.value),1)):l(``,!0),W.value?l(``,!0):(_(),g(`p`,B,p(ie.value),1)),h(`div`,V,[h(`button`,{type:`button`,disabled:T.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors disabled:opacity-50`,onClick:i[6]||=e=>w(`close`)},` Cancel `,8,H),h(`button`,{type:`button`,disabled:T.value,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors disabled:opacity-50`,onClick:oe},p(T.value?`Importing…`:`Import`),9,U)])])],32)):l(``,!0)}}),G={class:`p-6 space-y-6`},K={key:0,class:`grid grid-cols-1 md:grid-cols-2 gap-4`},q={class:`group relative overflow-hidden glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},J={class:`relative flex items-center justify-between`},Y={class:`text-3xl font-bold text-content-primary dark:text-content-primary`},X={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},Z={key:0,class:`flex items-center justify-center py-12`},Q={key:1,class:`flex items-center justify-center py-12`},$={class:`text-center`},re={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},ie={key:2,class:`space-y-4`},ae={class:`relative flex items-start justify-between`},oe={class:`flex-1`},se={class:`flex items-center gap-3 mb-4`},ce={class:`relative`},le={key:0,class:`absolute inset-0 bg-accent-green/50 rounded-full animate-ping`},ue={class:`text-xl font-bold text-content-primary dark:text-content-primary`},de={key:0,class:`text-content-muted dark:text-content-muted text-sm`},fe={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3`},pe={class:`text-content-primary dark:text-content-primary/90 ml-2`},me={class:`text-content-primary dark:text-content-primary/90 ml-2`},he={class:`text-content-primary dark:text-content-primary/90 ml-2`},ge={class:`flex items-center gap-2`},_e={key:0,class:`text-content-primary dark:text-content-primary/90 font-mono ml-2 text-xs`},ve={key:1,class:`text-content-muted dark:text-content-muted ml-2 text-xs`},ye=[`onClick`],be={class:`text-xs text-content-muted dark:text-content-muted`},xe={key:0,class:`ml-2 font-mono text-content-primary dark:text-content-primary/90 break-all`},Se={key:1,class:`ml-2 text-content-muted dark:text-content-muted`},Ce={class:`ml-4 flex flex-wrap gap-2`},we=[`onClick`],Te=[`onClick`],Ee=[`onClick`],De={key:3,class:`text-center py-12 text-content-secondary dark:text-content-muted`},Oe={key:1,class:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`},ke={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Ae={class:`space-y-4`},je={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Me={key:0},Ne={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},Pe={class:`grid grid-cols-2 gap-4`},Fe={key:2,class:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`},Ie={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Le={class:`space-y-4`},Re=[`value`],ze={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},Be={key:0},Ve={class:`grid grid-cols-2 gap-4`},He=5050,Ue=1,We=65535,Ge=o({name:`CompanionsView`,__name:`Companions`,setup(t){let r=v(!1),o=v(null),c=v(null),d=v(!1),x=v(!1),S=v(null),C=v(!1),E=v(!1),D=v(new Set),O=v(!1),k=v(``),A=v(!1),j=v(``),M=v(!1),N=v({message:``,variant:`success`}),P=v({name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}});n(async()=>{await F()});async function F(){r.value=!0,o.value=null;try{let e=await y.getIdentities();e.success?c.value=e.data:o.value=e.error||`Failed to load identities`}catch(e){o.value=e instanceof Error?e.message:`Failed to load identities`}finally{r.value=!1}}async function ee(){try{let e=await y.createIdentity({...P.value,settings:{node_name:P.value.settings.node_name||P.value.name,tcp_port:P.value.settings.tcp_port??5e3,bind_address:P.value.settings.bind_address||`0.0.0.0`}});e.success?(d.value=!1,z(),await F(),L(e.message||`Companion created successfully!`,`success`)):L(`Failed to create companion: ${e.error}`,`error`)}catch(e){L(`Error creating companion: ${e}`,`error`)}}async function te(){try{let e=await y.updateIdentity({name:S.value.name,new_name:S.value.new_name,identity_key:S.value.identity_key,type:`companion`,settings:{node_name:S.value.settings?.node_name,tcp_port:S.value.settings?.tcp_port,bind_address:S.value.settings?.bind_address}});e.success?(x.value=!1,S.value=null,await F(),L(e.message||`Companion updated successfully!`,`success`)):L(`Failed to update companion: ${e.error}`,`error`)}catch(e){L(`Error updating companion: ${e}`,`error`)}}function ne(e){k.value=e,O.value=!0}async function I(){let e=k.value;O.value=!1;try{let t=await y.deleteIdentity(e,`companion`);t.success?(await F(),L(t.message||`Companion deleted successfully!`,`success`)):L(`Failed to delete companion: ${t.error}`,`error`)}catch(e){L(`Error deleting companion: ${e}`,`error`)}finally{k.value=``}}function L(e,t){N.value={message:e,variant:t},M.value=!0}function R(e){S.value=JSON.parse(JSON.stringify(e)),S.value.settings||(S.value.settings={node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}),S.value.new_name=``,E.value=!1,x.value=!0}function z(){P.value={name:``,identity_key:``,type:`companion`,settings:{node_name:``,tcp_port:5e3,bind_address:`0.0.0.0`}},C.value=!1}function B(){d.value=!1,x.value=!1,S.value=null,C.value=!1,E.value=!1,z()}function V(e){D.value.has(e)?D.value.delete(e):D.value.add(e)}let H=()=>c.value?.configured_companions??[],U=()=>c.value?.total_configured_companions??0;function Ge(){let e=H();if(e.length===0)return He;let t=e.map(e=>e.settings?.tcp_port??5e3),n=Math.max(...t)+1;return Math.min(We,Math.max(Ue,n))}function Ke(){z(),P.value.settings.tcp_port=Ge(),d.value=!0}function qe(e){j.value=e,A.value=!0}function Je(){A.value=!1,j.value=``}function Ye(e){L(`Imported ${e} contact${e===1?``:`s`}.`,`success`),Je()}return(t,n)=>(_(),g(m,null,[h(`div`,G,[h(`div`,{class:`relative overflow-hidden rounded-[20px] p-6 mb-6 glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10`},[n[16]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/20 via-secondary/10 to-accent-purple/20 opacity-50`},null,-1),n[17]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-tl from-accent-green/10 via-transparent to-primary/10 animate-pulse`},null,-1),h(`div`,{class:`relative flex items-center justify-between`},[n[15]||=a(`

Companions

Manage companion identities (TCP frame server)

`,1),h(`button`,{onClick:Ke,class:`group relative px-6 py-3 bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary rounded-[12px] border border-primary/50 transition-all hover:scale-105 hover:shadow-lg hover:shadow-primary/20`},[...n[14]||=[h(`span`,{class:`flex items-center gap-2`},[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})]),f(` Add Companion `)],-1)]])])]),c.value&&U()>0?(_(),g(`div`,K,[h(`div`,q,[h(`div`,J,[h(`div`,null,[n[18]||=h(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Total Configured `,-1),h(`div`,Y,p(U()),1)])])])])):l(``,!0),h(`div`,X,[r.value?(_(),g(`div`,Z,[...n[19]||=[h(`div`,{class:`text-center`},[h(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full mx-auto mb-4`}),h(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading companions... `)],-1)]])):o.value?(_(),g(`div`,Q,[h(`div`,$,[n[20]||=h(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load companions`,-1),h(`div`,re,p(o.value),1),h(`button`,{onClick:F,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Retry `)])])):c.value&&H().length>0?(_(),g(`div`,ie,[(_(!0),g(m,null,e(H(),e=>(_(),g(`div`,{key:e.name,class:`group relative overflow-hidden glass-card backdrop-blur-xl rounded-[15px] p-5 border border-stroke-subtle dark:border-white/10 hover:border-primary/30 transition-all duration-300`},[h(`div`,ae,[h(`div`,oe,[h(`div`,se,[h(`div`,ce,[e.registered?(_(),g(`div`,le)):l(``,!0),h(`div`,{class:i([`relative w-3 h-3 rounded-full`,e.registered?`bg-accent-green`:`bg-accent-red`])},null,2)]),h(`h3`,ue,p(e.name),1),h(`span`,{class:i([`px-3 py-1 text-xs font-semibold rounded-full`,e.registered?`bg-accent-green/20 text-accent-green border border-accent-green/30`:`bg-accent-red/20 text-accent-red border border-accent-red/30`])},p(e.registered?`● Active`:`○ Inactive`),3),e.hash?(_(),g(`span`,de,p(e.hash),1)):l(``,!0)]),h(`div`,fe,[h(`div`,null,[n[21]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Node Name:`,-1),h(`span`,pe,p(e.settings?.node_name||e.name),1)]),h(`div`,null,[n[22]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`TCP Port:`,-1),h(`span`,me,p(e.settings?.tcp_port??5e3),1)]),h(`div`,null,[n[23]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Bind Address:`,-1),h(`span`,he,p(e.settings?.bind_address||`0.0.0.0`),1)]),h(`div`,ge,[n[24]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Identity Key:`,-1),D.value.has(e.name)?(_(),g(`span`,_e,p(e.identity_key),1)):(_(),g(`span`,ve,`••••••••••••••••`)),h(`button`,{onClick:t=>V(e.name),class:`text-primary/70 hover:text-primary text-xs underline`},p(D.value.has(e.name)?`Hide`:`Show`),9,ye)])]),h(`div`,be,[n[25]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Public Key:`,-1),e.public_key?(_(),g(`span`,xe,p(e.public_key),1)):(_(),g(`span`,Se,`—`))])]),h(`div`,Ce,[h(`button`,{onClick:t=>qe(e.name),class:`px-3 py-1 bg-primary/20 hover:bg-primary/30 text-primary rounded text-xs transition-colors`},` Import contacts `,8,we),h(`button`,{onClick:t=>R(e),class:`px-3 py-1 bg-primary/20 hover:bg-primary/30 text-primary rounded text-xs transition-colors`},` Edit `,8,Te),h(`button`,{onClick:t=>ne(e.name),class:`px-3 py-1 bg-accent-red/20 hover:bg-accent-red/30 text-accent-red rounded text-xs transition-colors`},` Delete `,8,Ee)])])]))),128))])):(_(),g(`div`,De,[n[26]||=h(`svg`,{class:`w-16 h-16 mx-auto mb-4 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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 0z`})],-1),n[27]||=h(`p`,{class:`text-lg mb-2`},`No companions configured`,-1),n[28]||=h(`p`,{class:`text-sm mb-4`},` Add a companion to run a TCP frame server for firmware or other clients `,-1),h(`button`,{onClick:Ke,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` + Add Companion `)]))]),d.value?(_(),g(`div`,Oe,[h(`div`,ke,[n[35]||=h(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Add Companion `,-1),h(`div`,Ae,[h(`div`,null,[n[29]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),s(h(`input`,{"onUpdate:modelValue":n[0]||=e=>P.value.name=e,type:`text`,placeholder:`e.g., TestCompanion`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,P.value.name]])]),h(`div`,null,[h(`label`,je,[n[30]||=f(` Identity Key (Optional) `,-1),h(`button`,{onClick:n[1]||=e=>C.value=!C.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},p(C.value?`Hide`:`Show/Edit`),1)]),C.value?(_(),g(`div`,Me,[s(h(`input`,{"onUpdate:modelValue":n[2]||=e=>P.value.identity_key=e,type:`text`,placeholder:`Leave empty to auto-generate (32 bytes hex)`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,P.value.identity_key]]),n[31]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` 32 or 64 bytes hex. Leave empty to auto-generate. `,-1)])):(_(),g(`div`,Ne,` Will be auto-generated if not provided `))]),h(`div`,null,[n[32]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),s(h(`input`,{"onUpdate:modelValue":n[3]||=e=>P.value.settings.node_name=e,type:`text`,placeholder:`Display name (defaults to Name)`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,P.value.settings.node_name]])]),h(`div`,Pe,[h(`div`,null,[n[33]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),s(h(`input`,{"onUpdate:modelValue":n[4]||=e=>P.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,P.value.settings.tcp_port,void 0,{number:!0}]])]),h(`div`,null,[n[34]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),s(h(`input`,{"onUpdate:modelValue":n[5]||=e=>P.value.settings.bind_address=e,type:`text`,placeholder:`0.0.0.0`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,P.value.settings.bind_address]])])])]),h(`div`,{class:`flex justify-end gap-3 mt-6`},[h(`button`,{onClick:B,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),h(`button`,{onClick:ee,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` Create `)])])])):l(``,!0),x.value&&S.value?(_(),g(`div`,Fe,[h(`div`,Ie,[n[42]||=h(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Edit Companion `,-1),h(`div`,Le,[h(`div`,null,[n[36]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Current Name`,-1),h(`input`,{value:S.value.name,disabled:``,type:`text`,class:`w-full bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-muted dark:text-content-muted cursor-not-allowed`},null,8,Re)]),h(`div`,null,[n[37]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`New Name (optional)`,-1),s(h(`input`,{"onUpdate:modelValue":n[6]||=e=>S.value.new_name=e,type:`text`,placeholder:`Leave empty to keep current name`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,S.value.new_name]])]),h(`div`,null,[h(`label`,ze,[n[38]||=f(` Identity Key (Optional) `,-1),h(`button`,{onClick:n[7]||=e=>E.value=!E.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},p(E.value?`Hide`:`Show/Edit`),1)]),E.value?(_(),g(`div`,Be,[s(h(`input`,{"onUpdate:modelValue":n[8]||=e=>S.value.identity_key=e,type:`text`,placeholder:`Leave empty to keep current key`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,S.value.identity_key]])])):l(``,!0)]),h(`div`,null,[n[39]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),s(h(`input`,{"onUpdate:modelValue":n[9]||=e=>S.value.settings.node_name=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,S.value.settings.node_name]])]),h(`div`,Ve,[h(`div`,null,[n[40]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`TCP Port`,-1),s(h(`input`,{"onUpdate:modelValue":n[10]||=e=>S.value.settings.tcp_port=e,type:`number`,min:`1`,max:`65535`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,S.value.settings.tcp_port,void 0,{number:!0}]])]),h(`div`,null,[n[41]||=h(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Bind Address`,-1),s(h(`input`,{"onUpdate:modelValue":n[11]||=e=>S.value.settings.bind_address=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[b,S.value.settings.bind_address]])])])]),h(`div`,{class:`flex justify-end gap-3 mt-6`},[h(`button`,{onClick:B,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),h(`button`,{onClick:te,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` Update `)])])])):l(``,!0)]),u(W,{"is-open":A.value,"companion-name":j.value,onClose:Je,onImported:Ye},null,8,[`is-open`,`companion-name`]),u(w,{show:O.value,title:`Delete Companion`,message:`Are you sure you want to delete '${k.value}'? Restart required to fully remove.`,"confirm-text":`Delete`,"cancel-text":`Cancel`,variant:`danger`,onClose:n[12]||=e=>O.value=!1,onConfirm:I},null,8,[`show`,`message`]),u(T,{show:M.value,message:N.value.message,variant:N.value.variant,onClose:n[13]||=e=>M.value=!1},null,8,[`show`,`message`,`variant`])],64))}});export{Ge as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Configuration-BoG9PyTQ.js b/repeater/web/html/assets/Configuration-BoG9PyTQ.js deleted file mode 100644 index 9cfa047c..00000000 --- a/repeater/web/html/assets/Configuration-BoG9PyTQ.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/leaflet-src-PYB8oVmQ.js","assets/chunk-DECur_0Z.js"])))=>i.map(i=>d[i]); -import{r as e}from"./chunk-DECur_0Z.js";import{A as t,C as n,D as r,E as i,K as a,R as o,S as s,b as c,c as l,dt as u,f as d,g as f,i as p,j as m,k as h,l as g,m as _,o as v,p as y,pt as b,r as x,s as S,u as C,w,x as T,z as E}from"./runtime-core.esm-bundler-HnidnMFy.js";import{o as D}from"./vue-router-Cr0wB7EX.js";import{a as O,n as k,t as A}from"./api-CbM6k1ZB.js";import{t as j}from"./system-BH4r-ii6.js";import{t as M}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{c as N,d as P,f as F,h as I,l as L,m as R,p as z,u as B}from"./index-BFltqMtv.js";import{t as V}from"./ConfirmDialog-PLW-eI8u.js";/* empty css */import{n as ee,t as H}from"./preferences-Bv8i60GL.js";var U={class:`space-y-4`},W={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500/50 rounded-lg p-3`},G={class:`text-green-600 dark:text-green-400 text-sm`},te={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500/50 rounded-lg p-3`},K={class:`text-red-600 dark:text-red-400 text-sm`},ne={class:`flex justify-end gap-2`},q=[`disabled`],J=[`disabled`],Y={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},X={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Z={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Q={key:1,class:`flex items-center gap-2`},re={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},$={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},ie={key:1},ae=[`value`],oe={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},se={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},ce={key:1},le=[`value`],ue={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},de={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},fe={key:1,class:`flex items-center gap-2`},pe={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},me={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},he={key:1},ge={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},_e={class:`text-content-primary dark:text-content-primary font-mono text-sm`},ve={key:2,class:`bg-yellow-500/10 dark:bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-3`},ye=f({__name:`RadioSettings`,setup(e){let t=j(),n=v(()=>t.stats?.config?.radio||{}),r=E(!1),a=E(!1),o=E(null),s=E(null),c=E(0),l=E(0),u=E(0),d=E(0),f=E(0),p=E(0),_=[{value:7.8,label:`7.8 kHz`},{value:10.4,label:`10.4 kHz`},{value:15.6,label:`15.6 kHz`},{value:20.8,label:`20.8 kHz`},{value:31.25,label:`31.25 kHz`},{value:41.7,label:`41.7 kHz`},{value:62.5,label:`62.5 kHz`},{value:125,label:`125 kHz`},{value:250,label:`250 kHz`},{value:500,label:`500 kHz`}];h(n,e=>{e&&!r.value&&(c.value=e.frequency?Number((e.frequency/1e6).toFixed(3)):0,l.value=e.spreading_factor??0,u.value=e.bandwidth?Number((e.bandwidth/1e3).toFixed(1)):0,d.value=e.tx_power??0,f.value=e.coding_rate??0,p.value=e.preamble_length??0)},{immediate:!0});let T=v(()=>{let e=n.value.frequency;return e?(e/1e6).toFixed(3)+` MHz`:`Not set`}),D=v(()=>{let e=n.value.bandwidth;return e?(e/1e3).toFixed(1)+` kHz`:`Not set`}),O=v(()=>{let e=n.value.tx_power;return e===void 0?`Not set`:e+` dBm`}),k=v(()=>{let e=n.value.coding_rate;return e?`4/`+e:`Not set`}),M=v(()=>{let e=n.value.preamble_length;return e?e+` symbols`:`Not set`}),N=v(()=>n.value.spreading_factor??`Not set`),I=()=>{r.value=!0,o.value=null,s.value=null},L=()=>{r.value=!1,o.value=null;let e=n.value;c.value=e.frequency?Number((e.frequency/1e6).toFixed(3)):0,l.value=e.spreading_factor??0,u.value=e.bandwidth?Number((e.bandwidth/1e3).toFixed(1)):0,d.value=e.tx_power??0,f.value=e.coding_rate??0,p.value=e.preamble_length??0},R=async()=>{a.value=!0,o.value=null,s.value=null;try{let e={};c.value&&(e.frequency=c.value*1e6),l.value&&(e.spreading_factor=l.value),u.value&&(e.bandwidth=u.value*1e3),d.value&&(e.tx_power=d.value),f.value&&(e.coding_rate=f.value);let n=(await A.post(`/update_radio_config`,e)).data;n.message||n.persisted?(s.value=n.message||`Settings saved successfully`,r.value=!1,await t.fetchStats(),setTimeout(()=>{s.value=null},3e3)):n.error?o.value=n.error:o.value=`Unknown response from server`}catch(e){console.error(`Failed to update radio settings:`,e),o.value=e.response?.data?.error||`Failed to update settings`}finally{a.value=!1}};return(e,t)=>(w(),C(`div`,U,[s.value?(w(),C(`div`,W,[S(`p`,G,b(s.value),1)])):g(``,!0),o.value?(w(),C(`div`,te,[S(`p`,K,b(o.value),1)])):g(``,!0),S(`div`,ne,[r.value?(w(),C(x,{key:1},[S(`button`,{onClick:L,disabled:a.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,q),S(`button`,{onClick:R,disabled:a.value,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},b(a.value?`Saving...`:`Save Changes`),9,J)],64)):(w(),C(`button`,{key:0,onClick:I,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Edit Settings `))]),S(`div`,Y,[S(`div`,X,[t[6]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Frequency`,-1),r.value?(w(),C(`div`,Q,[m(S(`input`,{"onUpdate:modelValue":t[0]||=e=>c.value=e,type:`number`,step:`0.001`,min:`100`,max:`1000`,class:`w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,c.value,void 0,{number:!0}]]),t[5]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`MHz`,-1)])):(w(),C(`div`,Z,b(T.value),1))]),S(`div`,re,[t[7]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Spreading Factor`,-1),r.value?(w(),C(`div`,ie,[m(S(`select`,{"onUpdate:modelValue":t[1]||=e=>l.value=e,class:`px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[(w(),C(x,null,i([5,6,7,8,9,10,11,12],e=>S(`option`,{key:e,value:e},b(e),9,ae)),64))],512),[[P,l.value,void 0,{number:!0}]])])):(w(),C(`div`,$,b(N.value),1))]),S(`div`,oe,[t[8]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Bandwidth`,-1),r.value?(w(),C(`div`,ce,[m(S(`select`,{"onUpdate:modelValue":t[2]||=e=>u.value=e,class:`px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[(w(),C(x,null,i(_,e=>S(`option`,{key:e.value,value:e.value},b(e.label),9,le)),64))],512),[[P,u.value,void 0,{number:!0}]])])):(w(),C(`div`,se,b(D.value),1))]),S(`div`,ue,[t[10]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`TX Power`,-1),r.value?(w(),C(`div`,fe,[m(S(`input`,{"onUpdate:modelValue":t[3]||=e=>d.value=e,type:`number`,min:`2`,max:`30`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,d.value,void 0,{number:!0}]]),t[9]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`dBm`,-1)])):(w(),C(`div`,de,b(O.value),1))]),S(`div`,pe,[t[12]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Coding Rate`,-1),r.value?(w(),C(`div`,he,[m(S(`select`,{"onUpdate:modelValue":t[4]||=e=>f.value=e,class:`px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[11]||=[S(`option`,{value:5},`4/5`,-1),S(`option`,{value:6},`4/6`,-1),S(`option`,{value:7},`4/7`,-1),S(`option`,{value:8},`4/8`,-1)]],512),[[P,f.value,void 0,{number:!0}]])])):(w(),C(`div`,me,b(k.value),1))]),S(`div`,ge,[t[13]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Preamble Length`,-1),S(`span`,_e,b(M.value),1)])]),r.value?(w(),C(`div`,ve,[...t[14]||=[S(`p`,{class:`text-yellow-700 dark:text-yellow-400 text-xs`},[S(`strong`,null,`Note:`),y(` Radio hardware changes (frequency, bandwidth, spreading factor, coding rate) may require a service restart to apply. `)],-1)]])):g(``,!0)]))}}),be={class:`glass-card border border-stroke-subtle dark:border-white/20 rounded-[15px] w-full max-w-3xl max-h-[90vh] flex flex-col shadow-2xl`},xe={class:`flex-1 relative min-h-[400px]`},Se={class:`p-6 border-t border-stroke-subtle dark:border-stroke/10 space-y-4`},Ce={class:`grid grid-cols-2 gap-4`},we=M(f({__name:`LocationPicker`,props:{isOpen:{type:Boolean},latitude:{},longitude:{}},emits:[`close`,`select`],setup(t,{emit:r}){let i=t,a=r,o=E(null),s=E(i.latitude||0),l=E(i.longitude||0),u=null,d=null,f=async()=>{if(o.value){p();try{let t=(await O(async()=>{let{default:t}=await import(`./leaflet-src-PYB8oVmQ.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default;delete t.Icon.Default.prototype._getIconUrl,t.Icon.Default.mergeOptions({iconRetinaUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png`,iconUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png`,shadowUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png`}),await c();let n=s.value||0,r=l.value||0,i=n===0&&r===0?2:13;u=t.map(o.value).setView([n,r],i);try{let e=t.tileLayer(`https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png`,{maxZoom:19,attribution:`© OpenStreetMap contributors © CARTO`,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`}),n=t.tileLayer(`https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png`,{maxZoom:19,attribution:``,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`});e.addTo(u),n.addTo(u)}catch(e){console.warn(`Error loading tiles:`,e)}(n!==0||r!==0)&&(d=t.marker([n,r]).addTo(u)),u.on(`click`,e=>{s.value=e.latlng.lat,l.value=e.latlng.lng,d?d.setLatLng(e.latlng):d=t.marker(e.latlng).addTo(u)}),setTimeout(()=>{u?.invalidateSize()},200)}catch(e){console.error(`Failed to initialize map:`,e)}}},p=()=>{u&&(u.remove(),u=null,d=null)};h(()=>i.isOpen,async e=>{e?(await c(),await f()):p()}),h(()=>[i.latitude,i.longitude],([e,t])=>{s.value=e,l.value=t});let _=()=>{a(`select`,{latitude:s.value,longitude:l.value}),a(`close`)},v=()=>{a(`close`)},b=()=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(async t=>{if(s.value=t.coords.latitude,l.value=t.coords.longitude,u){u.setView([s.value,l.value],13);let t=(await O(async()=>{let{default:t}=await import(`./leaflet-src-PYB8oVmQ.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default;d?d.setLatLng([s.value,l.value]):d=t.marker([s.value,l.value]).addTo(u)}},e=>{console.error(`Error getting location:`,e),alert(`Unable to get current location. Please check browser permissions.`)}):alert(`Geolocation is not supported by this browser.`)};return n(()=>{p()}),(e,n)=>t.isOpen?(w(),C(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:I(v,[`self`])},[S(`div`,be,[S(`div`,{class:`flex items-center justify-between p-6 border-b border-stroke-subtle dark:border-stroke/10`},[n[3]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Select Location `,-1),S(`button`,{onClick:v,class:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...n[2]||=[S(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`div`,xe,[S(`div`,{ref_key:`mapContainer`,ref:o,class:`absolute inset-0 rounded-b-[15px] overflow-hidden`},null,512)]),S(`div`,Se,[S(`div`,Ce,[S(`div`,null,[n[4]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Latitude`,-1),m(S(`input`,{"onUpdate:modelValue":n[0]||=e=>s.value=e,type:`number`,step:`0.000001`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary`,readonly:``},null,512),[[F,s.value,void 0,{number:!0}]])]),S(`div`,null,[n[5]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Longitude`,-1),m(S(`input`,{"onUpdate:modelValue":n[1]||=e=>l.value=e,type:`number`,step:`0.000001`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary`,readonly:``},null,512),[[F,l.value,void 0,{number:!0}]])])]),S(`div`,{class:`flex gap-3`},[S(`button`,{onClick:b,class:`flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm flex items-center justify-center gap-2`},[...n[6]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),y(` Use Current Location `,-1)]]),S(`button`,{onClick:v,class:`px-6 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm`},` Cancel `),S(`button`,{onClick:_,class:`px-6 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Select Location `)]),n[7]||=S(`p`,{class:`text-content-muted dark:text-content-muted text-xs text-center`},` Click on the map to select a location `,-1)])])])):g(``,!0)}}),[[`__scopeId`,`data-v-fd94857e`]]),Te={class:`space-y-4`},Ee={key:0,class:`bg-green-100 dark:bg-green-500/10 border border-green-300 dark:border-green-500/30 rounded-lg p-3`},De={class:`text-green-700 dark:text-green-400 text-sm`},Oe={key:1,class:`bg-red-100 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30 rounded-lg p-3`},ke={class:`text-red-700 dark:text-red-400 text-sm`},Ae={class:`flex justify-end gap-2`},je=[`disabled`],Me=[`disabled`],Ne={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},Pe={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Fe={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm break-all`},Ie={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Le={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all`},Re={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},ze={class:`flex flex-col items-end gap-1`},Be={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all sm:text-right sm:max-w-xs`},Ve={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},He={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ue={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},We={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ge={key:0,class:`flex justify-end`},Ke={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},qe={class:`text-content-primary dark:text-content-primary font-mono text-sm`},Je={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ye={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Xe={class:`flex flex-col py-2 gap-2`},Ze={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1`},Qe={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4`},$e={key:1,class:`flex items-center gap-2`},et={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] shadow-2xl w-full max-w-md p-6 space-y-4`},tt={class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},nt=[`maxlength`,`disabled`],rt={key:0,class:`text-red-500 text-xs mt-1`},it={key:1,class:`text-content-muted dark:text-content-muted text-xs mt-1`},at=[`disabled`],ot={key:0,class:`mt-2 bg-amber-500/10 border border-amber-500/30 rounded-lg p-3`},st={key:0,class:`flex items-center gap-3 bg-blue-500/10 border border-blue-500/30 rounded-lg p-3`},ct={class:`text-blue-700 dark:text-blue-400 text-xs font-medium`},lt={class:`text-blue-600 dark:text-blue-500 text-xs mt-0.5`},ut={key:1,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`},dt={class:`text-red-600 dark:text-red-400 text-sm`},ft={key:2,class:`bg-green-500/10 border border-green-600/40 dark:border-green-500/30 rounded-lg p-3 space-y-2`},pt={class:`text-green-600 dark:text-green-400 text-sm font-medium`},mt={class:`font-mono text-xs break-all text-content-primary dark:text-content-primary`},ht={key:3,class:`bg-amber-500/10 border border-amber-500/30 rounded-lg p-3`},gt={class:`flex gap-2 mt-3`},_t=[`disabled`],vt=[`disabled`],yt={class:`flex justify-end gap-3 mt-6`},bt=[`disabled`],xt=[`disabled`],St=f({__name:`RepeaterSettings`,setup(e){let t=j(),n=v(()=>t.stats?.config||{}),r=v(()=>n.value.repeater||{}),i=v(()=>t.stats),a=E(!1),o=E(!1),s=E(null),c=E(null),d=E(!1),f=E(``),D=E(0),O=E(0),k=E(0),M=E(1),N=v(()=>n.value.mesh||{});h([n,r,N],()=>{if(!a.value){f.value=n.value.node_name||``,D.value=r.value.latitude||0,O.value=r.value.longitude||0,k.value=r.value.send_advert_interval_hours||0;let e=N.value.path_hash_mode;M.value=e===0||e===1||e===2?e+1:1}},{immediate:!0});let L=v(()=>n.value.node_name||`Not set`),R=v(()=>i.value?.local_hash||`Not available`),z=v(()=>{let e=i.value?.public_key;return!e||e===`Not set`?`Not set`:e}),B=v(()=>{let e=r.value.latitude;return e&&e!==0?e.toFixed(6):`Not set`}),V=v(()=>{let e=r.value.longitude;return e&&e!==0?e.toFixed(6):`Not set`}),ee=v(()=>{let e=r.value.mode;return e?e===`no_tx`?`No TX`:e.charAt(0).toUpperCase()+e.slice(1):`Not set`}),H=v(()=>{let e=r.value.send_advert_interval_hours;return e===void 0?`Not set`:e===0?`Disabled`:e+` hour`+(e===1?``:`s`)}),U=v(()=>{let e=N.value.path_hash_mode;return e===0||e===1||e===2?e+1+(e===0?` byte`:` bytes`):`Not set`}),W=()=>{a.value=!0,s.value=null,c.value=null},G=()=>{a.value=!1,s.value=null,f.value=n.value.node_name||``,D.value=r.value.latitude||0,O.value=r.value.longitude||0,k.value=r.value.send_advert_interval_hours||0;let e=N.value.path_hash_mode;M.value=e===0||e===1||e===2?e+1:1},te=async()=>{o.value=!0,s.value=null,c.value=null;try{let e={};f.value&&(e.node_name=f.value),e.latitude=D.value,e.longitude=O.value,e.flood_advert_interval_hours=k.value,e.path_hash_mode=M.value-1;let n=(await A.post(`/update_radio_config`,e)).data;n.message||n.persisted?(c.value=n.message||`Settings saved successfully`,a.value=!1,await t.fetchStats(),setTimeout(()=>{c.value=null},3e3)):n.error?s.value=n.error:s.value=`Unknown response from server`}catch(e){console.error(`Failed to update repeater settings:`,e),s.value=e.response?.data?.error||`Failed to update settings`}finally{o.value=!1}},K=()=>{d.value=!0},ne=e=>{D.value=e.latitude,O.value=e.longitude},q=E(!1),J=E(``),Y=E(!1),X=E(null),Z=E(null),Q=E(!1),re=E(!1),$=E(!1),ie=E(0),ae=null,oe=v(()=>$.value?8:4),se=v(()=>{let e=J.value.trim();return!e||e.length>oe.value?!1:/^[0-9a-fA-F]+$/.test(e)}),ce=v(()=>{let e=J.value.trim().length;return e===0?``:e===1?`Very fast — ~16 attempts on average`:e===2?`Fast — ~256 attempts on average`:e===3?`Moderate — ~4,096 attempts, a few seconds`:e===4?`Slow — ~65,536 attempts, may take 10-30 seconds`:e===5?`Very slow — ~1 million attempts, could take minutes`:e===6?`Extremely slow — ~16 million attempts, could take a very long time`:e===7?`Extreme — ~268 million attempts, may not complete`:`Extreme — ~4 billion attempts, extremely unlikely to complete`}),le=()=>{ie.value=0,ae=setInterval(()=>{ie.value++},1e3)},ue=()=>{ae&&=(clearInterval(ae),null)};T(()=>ue());let de=()=>{J.value=``,X.value=null,Z.value=null,Q.value=!1,$.value=!1,q.value=!0},fe=async()=>{Y.value=!0,Z.value=null,X.value=null,le();try{let e=await A.generateVanityKey(J.value.trim());e.success&&e.data?X.value=e.data:Z.value=e.error||`Generation failed`}catch(e){let t=e;Z.value=t.response?.data?.error||t.message||`Generation failed`}finally{ue(),Y.value=!1}},pe=async()=>{if(X.value){re.value=!0,Z.value=null;try{let e=await A.generateVanityKey(J.value.trim(),!0);e.success&&e.data?(X.value=e.data,Q.value=!1,q.value=!1,c.value=`New identity key applied. Restart the repeater for the change to take effect.`,await t.fetchStats(),setTimeout(()=>{c.value=null},8e3)):Z.value=e.error||`Failed to apply key`}catch(e){let t=e;Z.value=t.response?.data?.error||t.message||`Failed to apply key`}finally{re.value=!1}}};return(e,t)=>(w(),C(`div`,Te,[c.value?(w(),C(`div`,Ee,[S(`p`,De,b(c.value),1)])):g(``,!0),s.value?(w(),C(`div`,Oe,[S(`p`,ke,b(s.value),1)])):g(``,!0),S(`div`,Ae,[a.value?(w(),C(x,{key:1},[S(`button`,{onClick:G,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,je),S(`button`,{onClick:te,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},b(o.value?`Saving...`:`Save Changes`),9,Me)],64)):(w(),C(`button`,{key:0,onClick:W,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Edit Settings `))]),S(`div`,Ne,[S(`div`,Pe,[t[13]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Node Name`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`text`,maxlength:`50`,class:`w-full sm:w-64 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`,placeholder:`Enter node name`},null,512)),[[F,f.value]]):(w(),C(`div`,Fe,b(L.value),1))]),S(`div`,Ie,[t[14]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Local Hash`,-1),S(`span`,Le,b(R.value),1)]),S(`div`,Re,[t[15]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm flex-shrink-0`},`Public Key`,-1),S(`div`,ze,[S(`span`,Be,b(z.value),1),S(`button`,{onClick:de,class:`px-2 py-1 text-xs bg-primary/10 hover:bg-primary/20 text-content-secondary dark:text-content-muted rounded border border-primary/30 transition-colors`},` Generate New Key `)])]),S(`div`,Ve,[t[16]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Latitude`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[1]||=e=>D.value=e,type:`number`,step:`0.000001`,min:`-90`,max:`90`,class:`w-full sm:w-48 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,D.value,void 0,{number:!0}]]):(w(),C(`div`,He,b(B.value),1))]),S(`div`,Ue,[t[17]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Longitude`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[2]||=e=>O.value=e,type:`number`,step:`0.000001`,min:`-180`,max:`180`,class:`w-full sm:w-48 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,O.value,void 0,{number:!0}]]):(w(),C(`div`,We,b(V.value),1))]),a.value?(w(),C(`div`,Ge,[S(`button`,{onClick:K,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm flex items-center gap-2`,title:`Pick location on map`},[...t[18]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),y(` Pick Location on Map `,-1)]])])):g(``,!0),S(`div`,Ke,[t[19]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Mode`,-1),S(`span`,qe,b(ee.value),1)]),S(`div`,Je,[t[21]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Path hash length`,-1),a.value?m((w(),C(`select`,{key:1,"onUpdate:modelValue":t[3]||=e=>M.value=e,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[20]||=[S(`option`,{value:1},`1 byte`,-1),S(`option`,{value:2},`2 bytes`,-1),S(`option`,{value:3},`3 bytes`,-1)]],512)),[[P,M.value,void 0,{number:!0}]]):(w(),C(`div`,Ye,b(U.value),1))]),S(`div`,Xe,[S(`div`,Ze,[t[23]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Periodic Advertisement Interval`,-1),a.value?(w(),C(`div`,$e,[m(S(`input`,{"onUpdate:modelValue":t[4]||=e=>k.value=e,type:`number`,min:`0`,max:`48`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,k.value,void 0,{number:!0}]]),t[22]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`hours`,-1)])):(w(),C(`div`,Qe,b(H.value),1))]),t[24]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`How often the repeater sends an advertisement packet (0 = disabled, 3-48 hours)`,-1)])]),_(we,{"is-open":d.value,latitude:D.value,longitude:O.value,onClose:t[5]||=e=>d.value=!1,onSelect:ne},null,8,[`is-open`,`latitude`,`longitude`]),(w(),l(p,{to:`body`},[q.value?(w(),C(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:t[12]||=I(e=>q.value=!1,[`self`])},[S(`div`,et,[t[32]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Generate Vanity Identity Key `,-1),t[33]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Generate a new Ed25519 identity key whose public key starts with your chosen hex prefix (0-9, A-F). Longer prefixes take more time to find. `,-1),S(`div`,null,[S(`label`,tt,`Hex Prefix (1-`+b(oe.value)+` characters)`,1),m(S(`input`,{"onUpdate:modelValue":t[6]||=e=>J.value=e,type:`text`,maxlength:oe.value,placeholder:`e.g. F8A1`,disabled:Y.value,class:`w-full px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-400 dark:placeholder-white/40 font-mono text-sm uppercase focus:outline-none focus:border-primary transition-colors disabled:opacity-50`},null,8,nt),[[F,J.value]]),J.value&&!se.value?(w(),C(`p`,rt,` Enter 1-`+b(oe.value)+` valid hex characters (0-9, A-F) `,1)):ce.value?(w(),C(`p`,it,b(ce.value),1)):g(``,!0)]),S(`div`,null,[S(`button`,{onClick:t[7]||=e=>$.value=!$.value,disabled:Y.value,class:`text-xs text-content-muted dark:text-content-muted hover:text-content-secondary dark:hover:text-content-secondary transition-colors disabled:opacity-50 flex items-center gap-1`},[(w(),C(`svg`,{class:u([`w-3 h-3 transition-transform`,{"rotate-90":$.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...t[25]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)),t[26]||=y(` Advanced `,-1)],8,at),$.value?(w(),C(`div`,ot,[...t[27]||=[S(`p`,{class:`text-amber-600 dark:text-amber-400 text-xs font-medium`},` Extended prefix mode (up to 8 characters) `,-1),S(`p`,{class:`text-amber-600 dark:text-amber-500 text-xs mt-1`},` Prefixes longer than 4 characters require exponentially more attempts and can take a very long time or may not complete at all. The request may time out. `,-1)]])):g(``,!0)]),Y.value?(w(),C(`div`,st,[t[28]||=S(`svg`,{class:`animate-spin h-5 w-5 text-blue-500 flex-shrink-0`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[S(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),S(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1),S(`div`,null,[S(`p`,ct,` Searching for key with prefix "`+b(J.value.toUpperCase())+`"... `,1),S(`p`,lt,` Elapsed: `+b(ie.value)+`s `,1)])])):g(``,!0),Z.value?(w(),C(`div`,ut,[S(`p`,dt,b(Z.value),1)])):g(``,!0),X.value?(w(),C(`div`,ft,[S(`p`,pt,` Key found in `+b(X.value.attempts.toLocaleString())+` attempts `,1),S(`div`,null,[t[29]||=S(`span`,{class:`text-xs text-content-muted dark:text-content-muted`},`Public Key:`,-1),S(`p`,mt,b(X.value.public_hex),1)])])):g(``,!0),Q.value&&X.value?(w(),C(`div`,ht,[t[30]||=S(`p`,{class:`text-amber-600 dark:text-amber-400 text-sm font-medium`},` Warning: This will replace your current identity key. `,-1),t[31]||=S(`p`,{class:`text-amber-600 dark:text-amber-500 text-xs mt-1`},` Your node address and public key will change. Other nodes will need to re-discover you. This cannot be undone unless you have a backup. `,-1),S(`div`,gt,[S(`button`,{onClick:pe,disabled:re.value,class:`px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs transition-colors disabled:opacity-50`},b(re.value?`Applying...`:`Confirm Replace Key`),9,_t),S(`button`,{onClick:t[8]||=e=>Q.value=!1,disabled:re.value,class:`px-3 py-1.5 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 text-xs transition-colors`},` Cancel `,8,vt)])])):g(``,!0),S(`div`,yt,[S(`button`,{onClick:t[9]||=e=>q.value=!1,disabled:Y.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors`},` Close `,8,bt),X.value?(w(),C(x,{key:1},[S(`button`,{onClick:t[10]||=e=>{X.value=null,Z.value=null},class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 text-sm transition-colors`},` Try Again `),Q.value?g(``,!0):(w(),C(`button`,{key:0,onClick:t[11]||=e=>Q.value=!0,class:`px-4 py-2 bg-red-600/20 hover:bg-red-600/30 text-red-600 dark:text-red-400 rounded-lg border border-red-500/50 text-sm transition-colors`},` Apply Key `))],64)):(w(),C(`button`,{key:0,onClick:fe,disabled:!se.value||Y.value,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed`},b(Y.value?`Generating...`:`Generate`),9,xt))])])])):g(``,!0)]))]))}}),Ct={class:`space-y-4`},wt={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm`},Tt={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},Et={class:`flex justify-end gap-2`},Dt=[`disabled`],Ot=[`disabled`],kt={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},At={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},jt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Mt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Nt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Pt=f({__name:`DutyCycle`,setup(e){let t=j(),n=v(()=>t.stats?.config?.duty_cycle||{}),r=v(()=>{let e=n.value.max_airtime_percent;return typeof e==`number`?e.toFixed(1)+`%`:e&&typeof e==`object`&&`parsedValue`in e?(e.parsedValue||0).toFixed(1)+`%`:`Not set`}),i=v(()=>n.value.enforcement_enabled?`Enabled`:`Disabled`),a=E(!1),o=E(!1),s=E(``),c=E(``),l=E(0),u=E(!0),d=()=>{let e=n.value.max_airtime_percent;typeof e==`number`?l.value=e:e&&typeof e==`object`&&`parsedValue`in e?l.value=e.parsedValue||0:l.value=6,u.value=n.value.enforcement_enabled!==!1,a.value=!0,s.value=``,c.value=``},f=()=>{a.value=!1,s.value=``,c.value=``},p=async()=>{o.value=!0,c.value=``,s.value=``;try{let e=(await k.post(`/api/update_duty_cycle_config`,{max_airtime_percent:l.value,enforcement_enabled:u.value})).data;e.message||e.persisted?(s.value=e.message||`Settings saved successfully`,a.value=!1,await t.fetchStats(),setTimeout(()=>{s.value=``},3e3)):c.value=`Failed to save settings`}catch(e){console.error(`Failed to save duty cycle settings:`,e),c.value=e.response?.data?.error||`Failed to save settings`}finally{o.value=!1}};return(e,t)=>(w(),C(`div`,Ct,[s.value?(w(),C(`div`,wt,b(s.value),1)):g(``,!0),c.value?(w(),C(`div`,Tt,b(c.value),1)):g(``,!0),S(`div`,Et,[a.value?(w(),C(x,{key:1},[S(`button`,{onClick:f,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,Dt),S(`button`,{onClick:p,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},b(o.value?`Saving...`:`Save Changes`),9,Ot)],64)):(w(),C(`button`,{key:0,onClick:d,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Edit Settings `))]),S(`div`,kt,[S(`div`,At,[t[2]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Max Airtime %`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[0]||=e=>l.value=e,type:`number`,step:`0.1`,min:`0.1`,max:`100`,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,l.value,void 0,{number:!0}]]):(w(),C(`div`,jt,b(r.value),1))]),S(`div`,Mt,[t[4]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Enforcement`,-1),a.value?m((w(),C(`select`,{key:1,"onUpdate:modelValue":t[1]||=e=>u.value=e,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[3]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[P,u.value]]):(w(),C(`div`,Nt,b(i.value),1))])])]))}}),Ft={class:`space-y-4`},It={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm`},Lt={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},Rt={class:`flex justify-end gap-2`},zt=[`disabled`],Bt=[`disabled`],Vt={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},Ht={class:`flex flex-col py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},Ut={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1`},Wt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4`},Gt={class:`flex flex-col py-2 gap-2`},Kt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1`},qt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4`},Jt=f({__name:`TransmissionDelays`,setup(e){let t=j(),n=v(()=>t.stats?.config?.delays||{}),r=v(()=>{let e=n.value.tx_delay_factor;if(e&&typeof e==`object`&&e&&`parsedValue`in e){let t=e.parsedValue;if(typeof t==`number`)return t.toFixed(2)+`x`}return`Not set`}),i=v(()=>{let e=n.value.direct_tx_delay_factor;return typeof e==`number`?e.toFixed(2)+`s`:`Not set`}),a=E(!1),o=E(!1),s=E(``),c=E(``),l=E(0),u=E(0),d=()=>{let e=n.value.tx_delay_factor;e&&typeof e==`object`&&`parsedValue`in e?l.value=e.parsedValue||1:typeof e==`number`?l.value=e:l.value=1;let t=n.value.direct_tx_delay_factor;u.value=typeof t==`number`?t:.5,a.value=!0,s.value=``,c.value=``},f=()=>{a.value=!1,s.value=``,c.value=``},p=async()=>{o.value=!0,c.value=``,s.value=``;try{let e=(await k.post(`/api/update_radio_config`,{tx_delay_factor:l.value,direct_tx_delay_factor:u.value})).data;e.message||e.persisted?(s.value=e.message||`Settings saved successfully`,a.value=!1,await t.fetchStats(),setTimeout(()=>{s.value=``},3e3)):c.value=`Failed to save settings`}catch(e){console.error(`Failed to save delay settings:`,e),c.value=e.response?.data?.error||`Failed to save settings`}finally{o.value=!1}};return(e,t)=>(w(),C(`div`,Ft,[s.value?(w(),C(`div`,It,b(s.value),1)):g(``,!0),c.value?(w(),C(`div`,Lt,b(c.value),1)):g(``,!0),S(`div`,Rt,[a.value?(w(),C(x,{key:1},[S(`button`,{onClick:f,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,zt),S(`button`,{onClick:p,disabled:o.value,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},b(o.value?`Saving...`:`Save Changes`),9,Bt)],64)):(w(),C(`button`,{key:0,onClick:d,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Edit Settings `))]),S(`div`,Vt,[S(`div`,Ht,[S(`div`,Ut,[t[2]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Flood TX Delay Factor`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[0]||=e=>l.value=e,type:`number`,step:`0.1`,min:`0`,max:`5`,class:`w-full sm:w-32 px-3 py-1.5 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,l.value,void 0,{number:!0}]]):(w(),C(`div`,Wt,b(r.value),1))]),t[3]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`Multiplier for flood packet transmission delays (collision avoidance)`,-1)]),S(`div`,Gt,[S(`div`,Kt,[t[4]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Direct TX Delay Factor`,-1),a.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`number`,step:`0.1`,min:`0`,max:`5`,class:`w-full sm:w-32 px-3 py-1.5 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,u.value,void 0,{number:!0}]]):(w(),C(`div`,qt,b(i.value),1))]),t[5]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`Base delay for direct-routed packet transmission (seconds)`,-1)])])]))}}),Yt=D(`treeState`,()=>{let e=o(new Set),t=o({value:null}),n=t=>{e.add(t)},r=t=>{e.delete(t)};return{expandedNodes:e,selectedNodeId:t,addExpandedNode:n,removeExpandedNode:r,isNodeExpanded:t=>e.has(t),setSelectedNode:e=>{t.value=e},toggleExpanded:t=>{e.has(t)?r(t):n(t)}}}),Xt={class:`select-none`},Zt={class:`flex-shrink-0`},Qt={key:0,class:`w-3.5 h-3.5 sm:w-4 sm:h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},$t={key:1,class:`w-3.5 h-3.5 sm:w-4 sm:h-4 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},en={key:0,class:`hidden sm:flex items-center gap-1 ml-2`},tn={class:`relative group`},nn=[`title`],rn={key:0,class:`text-xs font-mono text-white/50 bg-white/5 px-1.5 py-0.5 rounded border border-white/10`},an={class:`flex justify-between items-start mb-4`},on={class:`bg-black/20 border border-white/10 rounded-md p-4 mb-4`},sn={class:`text-sm font-mono text-white/80 break-all leading-relaxed`},cn={class:`flex items-center gap-1 sm:gap-2 ml-auto flex-shrink-0`},ln={key:0,class:`hidden sm:flex items-center gap-1`},un=[`title`],dn={key:1,class:`hidden sm:flex items-center gap-1`},fn={key:2,class:`hidden sm:inline-block px-2 py-1 bg-white/10 text-white/60 text-xs rounded-full ml-1`},pn={key:0,class:`space-y-1`},mn=M(f({__name:`TreeNode`,props:{node:{},selectedNodeId:{},level:{},disabled:{type:Boolean}},emits:[`select`],setup(e,{emit:n}){let a=e,o=n,s=Yt(),c=E(!1),d=v({get:()=>s.isNodeExpanded(a.node.id),set:e=>{e?s.addExpandedNode(a.node.id):s.removeExpandedNode(a.node.id)}}),f=v(()=>a.node.children.length>0);function p(e){if(!e)return`Never`;let t=new Date().getTime()-e.getTime(),n=Math.floor(t/(1e3*60)),r=Math.floor(t/(1e3*60*60)),i=Math.floor(t/(1e3*60*60*24)),a=Math.floor(i/365);return n<60?`${n}m ago`:r<24?`${r}h ago`:i<365?`${i}d ago`:`${a}y ago`}function m(e){return e?e.length<=16?e:`${e.slice(0,8)}...${e.slice(-8)}`:`No key`}function h(){f.value&&(d.value=!d.value)}function T(){o(`select`,a.node.id)}function D(e){o(`select`,e)}function O(e){e.stopPropagation(),c.value=!c.value}function k(e){e.stopPropagation(),a.node.transport_key&&window.navigator?.clipboard&&window.navigator.clipboard.writeText(a.node.transport_key)}return(n,o)=>{let s=r(`TreeNode`,!0);return w(),C(`div`,Xt,[S(`div`,{class:u([`flex flex-wrap sm:flex-nowrap items-start sm:items-center gap-1 sm:gap-2 py-2 px-2 sm:px-3 rounded-lg cursor-pointer transition-all duration-200`,a.disabled?`opacity-50 cursor-not-allowed`:`hover:bg-white/5`,e.selectedNodeId===e.node.id&&!a.disabled?`bg-primary/20 text-primary`:`text-white/80 hover:text-white`,`ml-${e.level*4}`]),onClick:o[3]||=e=>!a.disabled&&T()},[S(`div`,{class:`flex-shrink-0 w-3 h-3 sm:w-4 sm:h-4 flex items-center justify-center`,onClick:I(h,[`stop`])},[f.value?(w(),C(`svg`,{key:0,class:u([`w-2.5 h-2.5 sm:w-3 sm:h-3 transition-transform duration-200`,d.value?`rotate-90`:`rotate-0`]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...o[4]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)):g(``,!0)]),S(`div`,Zt,[a.node.name.startsWith(`#`)?(w(),C(`svg`,Qt,[...o[5]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,$t,[...o[6]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`},null,-1)]]))]),S(`span`,{class:u([`font-mono text-xs sm:text-sm transition-colors duration-200 break-all`,e.selectedNodeId===e.node.id?`text-primary font-medium`:``])},b(e.node.name),3),e.node.transport_key?(w(),C(`div`,en,[S(`div`,tn,[S(`button`,{onClick:O,class:`p-1 rounded hover:bg-white/10 transition-colors`,title:c.value?`Hide full key`:`Show full key`},[...o[7]||=[S(`svg`,{class:`w-3 h-3 text-white/60 hover:text-white/80`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,nn),c.value?g(``,!0):(w(),C(`span`,rn,b(m(e.node.transport_key)),1)),c.value?(w(),C(`div`,{key:1,class:`fixed inset-0 z-[9998] flex items-center justify-center bg-black/70 backdrop-blur-md`,onClick:o[2]||=e=>c.value=!1},[S(`div`,{class:`bg-black/20 border border-white/20 rounded-lg shadow-lg p-6 max-w-2xl w-full mx-4`,onClick:o[1]||=I(()=>{},[`stop`])},[S(`div`,an,[o[9]||=S(`h3`,{class:`text-lg font-semibold text-white`},`Transport Key`,-1),S(`button`,{onClick:o[0]||=e=>c.value=!1,class:`text-white/60 hover:text-white transition-colors`},[...o[8]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`div`,on,[S(`div`,sn,b(e.node.transport_key),1)]),S(`div`,{class:`flex justify-end`},[S(`button`,{onClick:k,class:`px-4 py-2 bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green rounded-lg transition-colors flex items-center gap-2`,title:`Copy to clipboard`},[...o[10]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),y(` Copy Key `,-1)]])])])])):g(``,!0)])])):g(``,!0),S(`div`,cn,[e.node.last_used?(w(),C(`div`,ln,[o[11]||=S(`svg`,{class:`w-3 h-3 text-white/40`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`span`,{class:`text-xs text-white/50`,title:e.node.last_used.toLocaleString()},b(p(e.node.last_used)),9,un)])):(w(),C(`div`,dn,[...o[12]||=[S(`svg`,{class:`w-3 h-3 text-white/30`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`span`,{class:`text-xs text-white/30 italic`},`Never`,-1)]])),S(`span`,{class:u([`px-1.5 sm:px-2 py-0.5 text-[10px] sm:text-xs font-medium rounded-md transition-colors`,e.node.floodPolicy===`allow`?`bg-accent-green/10 text-accent-green/90 border border-accent-green/20`:`bg-accent-red/10 text-accent-red/90 border border-accent-red/20`])},b(e.node.floodPolicy===`allow`?`ALLOW`:`DENY`),3),f.value?(w(),C(`span`,fn,` > `+b(e.node.children.length),1)):g(``,!0)])],2),_(N,{"enter-active-class":`transition-all duration-300 ease-out`,"enter-from-class":`opacity-0 max-h-0 overflow-hidden`,"enter-to-class":`opacity-100 max-h-screen overflow-visible`,"leave-active-class":`transition-all duration-300 ease-in`,"leave-from-class":`opacity-100 max-h-screen overflow-visible`,"leave-to-class":`opacity-0 max-h-0 overflow-hidden`},{default:t(()=>[d.value&&e.node.children.length>0?(w(),C(`div`,pn,[(w(!0),C(x,null,i(e.node.children,t=>(w(),l(s,{key:t.id,node:t,"selected-node-id":e.selectedNodeId,level:e.level+1,disabled:a.disabled,onSelect:D},null,8,[`node`,`selected-node-id`,`level`,`disabled`]))),128))])):g(``,!0)]),_:1})])}}}),[[`__scopeId`,`data-v-ed9c8a11`]]),hn={class:`flex items-center justify-between mb-6`},gn={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},_n={key:0},vn={class:`text-primary font-mono`},yn={key:1},bn={for:`keyName`,class:`block text-sm font-medium text-white mb-2`},xn={class:`flex items-center gap-2`},Sn={key:0,class:`w-4 h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Cn={key:1,class:`w-4 h-4 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},wn={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},Tn={class:`flex items-center gap-3 mb-2`},En={class:`flex items-center gap-2`},Dn={key:0,class:`w-5 h-5 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},On={key:1,class:`w-5 h-5 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},kn={class:`text-content-secondary dark:text-content-muted text-sm`},An={class:`grid grid-cols-2 gap-3`},jn={class:`relative cursor-pointer group`},Mn={class:`relative cursor-pointer group`},Nn={class:`flex gap-3 pt-4`},Pn=[`disabled`],Fn=f({__name:`AddKeyModal`,props:{show:{type:Boolean},selectedNodeName:{},selectedNodeId:{}},emits:[`close`,`add`],setup(e,{emit:t}){let n=e,r=t,i=E(``),a=E(``),o=E(`allow`),s=v(()=>i.value.startsWith(`#`)),c=v(()=>({type:s.value?`Region`:`Private Key`,description:s.value?`Regional organizational key`:`Individual assigned key`}));h(s,e=>{e?a.value=`This will create a new region for organizing keys`:a.value=`This will create a new private key entry`},{immediate:!0});let l=v(()=>i.value.trim().length>0),f=()=>{l.value&&(r(`add`,{name:i.value.trim(),floodPolicy:o.value,parentId:n.selectedNodeId}),i.value=``,a.value=``,o.value=`allow`)},p=()=>{i.value=``,a.value=``,o.value=`allow`,r(`close`)},_=e=>{e.target===e.currentTarget&&p()};return(t,r)=>e.show?(w(),C(`div`,{key:0,onClick:_,class:`fixed inset-0 bg-black/40 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[S(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10`,onClick:r[3]||=I(()=>{},[`stop`])},[S(`div`,hn,[S(`div`,null,[r[5]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Add New Entry `,-1),S(`p`,gn,[n.selectedNodeName?(w(),C(`span`,_n,[r[4]||=y(` Add to: `,-1),S(`span`,vn,b(n.selectedNodeName),1)])):(w(),C(`span`,yn,` Add to root level (#uk) `))])]),S(`button`,{onClick:p,class:`text-white/60 hover:text-white transition-colors`},[...r[6]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`form`,{onSubmit:I(f,[`prevent`]),class:`space-y-4`},[S(`div`,null,[S(`label`,bn,[S(`div`,xn,[s.value?(w(),C(`svg`,Sn,[...r[7]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,Cn,[...r[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`},null,-1)]])),r[9]||=y(` Region/Key Name `,-1)])]),m(S(`input`,{id:`keyName`,"onUpdate:modelValue":r[0]||=e=>i.value=e,type:`text`,placeholder:`Enter name (prefix with # for regions)`,class:`w-full px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors`,autocomplete:`off`},null,512),[[F,i.value]])]),S(`div`,wn,[S(`div`,Tn,[S(`div`,En,[s.value?(w(),C(`svg`,Dn,[...r[10]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,On,[...r[11]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1221 9z`},null,-1)]])),S(`span`,{class:u([s.value?`text-secondary`:`text-accent-green`,`font-medium`])},b(c.value.type),3)]),S(`div`,{class:u([`flex-1 h-px`,s.value?`bg-secondary/20`:`bg-accent-green/20`])},null,2)]),S(`p`,kn,b(c.value.description),1)]),S(`div`,null,[r[14]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-3`},[S(`div`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})]),y(` Flood Policy `)])],-1),S(`div`,An,[S(`label`,jn,[m(S(`input`,{type:`radio`,"onUpdate:modelValue":r[1]||=e=>o.value=e,value:`allow`,class:`sr-only`},null,512),[[B,o.value]]),r[12]||=d(`
Allow

Permit flooding

`,1)]),S(`label`,Mn,[m(S(`input`,{type:`radio`,"onUpdate:modelValue":r[2]||=e=>o.value=e,value:`deny`,class:`sr-only`},null,512),[[B,o.value]]),r[13]||=d(`
Deny

Block flooding

`,1)])])]),S(`div`,Nn,[S(`button`,{type:`button`,onClick:p,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),S(`button`,{type:`submit`,disabled:!l.value,class:u([`flex-1 px-4 py-3 rounded-lg transition-colors font-medium`,l.value?`bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green`:`bg-background-mute dark:bg-stroke/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted cursor-not-allowed`])},` Add `+b(c.value.type),11,Pn)])],32)])])):g(``,!0)}}),In={class:`flex items-center justify-between mb-6`},Ln={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},Rn={class:`text-primary font-mono`},zn={for:`keyName`,class:`block text-sm font-medium text-content-secondary dark:text-content-primary mb-2`},Bn={class:`flex items-center gap-2`},Vn={key:0,class:`w-4 h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Hn={key:1,class:`w-4 h-4 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Un={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},Wn={class:`flex items-center gap-3 mb-2`},Gn={class:`flex items-center gap-2`},Kn={key:0,class:`w-5 h-5 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},qn={key:1,class:`w-5 h-5 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Jn={class:`text-content-secondary dark:text-content-muted text-sm`},Yn={key:0,class:`space-y-4`},Xn={key:0,class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},Zn={class:`bg-background-mute dark:bg-black/20 border border-stroke-subtle dark:border-stroke/10 rounded-md p-3`},Qn={class:`text-xs font-mono text-content-primary dark:text-content-primary/80 break-all`},$n={key:1,class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},er={class:`flex items-center justify-between`},tr={class:`text-sm text-content-secondary dark:text-content-muted`},nr={class:`text-xs text-content-muted dark:text-content-muted`},rr={class:`grid grid-cols-2 gap-3`},ir={class:`relative cursor-pointer group`},ar={class:`relative cursor-pointer group`},or={class:`flex gap-3 pt-4`},sr=[`disabled`],cr=f({__name:`EditKeyModal`,props:{show:{type:Boolean},node:{}},emits:[`close`,`save`,`request-delete`],setup(e,{emit:t}){let n=e,r=t,i=E(``),a=E(`allow`),o=v(()=>i.value.startsWith(`#`)),s=v(()=>({type:o.value?`Region`:`Private Key`,description:o.value?`Regional organizational key`:`Individual assigned key`}));h(()=>n.node,e=>{e?(i.value=e.name,a.value=e.floodPolicy):(i.value=``,a.value=`allow`)},{immediate:!0});let c=v(()=>i.value.trim().length>0&&n.node),l=e=>{let t=new Date().getTime()-e.getTime(),n=Math.floor(t/(1e3*60)),r=Math.floor(t/(1e3*60*60)),i=Math.floor(t/(1e3*60*60*24)),a=Math.floor(i/365);return n<60?`${n}m ago`:r<24?`${r}h ago`:i<365?`${i}d ago`:`${a}y ago`},f=e=>{window.navigator?.clipboard&&window.navigator.clipboard.writeText(e)},p=()=>{!c.value||!n.node||(r(`save`,{id:n.node.id,name:i.value.trim(),floodPolicy:a.value}),x())},_=()=>{n.node&&(r(`request-delete`,n.node),x())},x=()=>{r(`close`)},T=e=>{e.target===e.currentTarget&&x()};return(t,n)=>e.show?(w(),C(`div`,{key:0,onClick:T,class:`fixed inset-0 bg-black/50 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[S(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-lg border border-stroke-subtle dark:border-white/10`,onClick:n[4]||=I(()=>{},[`stop`])},[S(`div`,In,[S(`div`,null,[n[6]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Edit Entry `,-1),S(`p`,Ln,[n[5]||=y(` Modify `,-1),S(`span`,Rn,b(e.node?.name),1)])]),S(`button`,{onClick:x,class:`text-white/60 hover:text-white transition-colors`},[...n[7]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`form`,{onSubmit:I(p,[`prevent`]),class:`space-y-4`},[S(`div`,null,[S(`label`,zn,[S(`div`,Bn,[o.value?(w(),C(`svg`,Vn,[...n[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,Hn,[...n[9]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z`},null,-1)]])),n[10]||=y(` Region/Key Name `,-1)])]),m(S(`input`,{id:`keyName`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`text`,placeholder:`Enter name (prefix with # for regions)`,class:`w-full px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors`,autocomplete:`off`},null,512),[[F,i.value]])]),S(`div`,Un,[S(`div`,Wn,[S(`div`,Gn,[o.value?(w(),C(`svg`,Kn,[...n[11]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,qn,[...n[12]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z`},null,-1)]])),S(`span`,{class:u([o.value?`text-secondary`:`text-accent-green`,`font-medium`])},b(s.value.type),3)]),S(`div`,{class:u([`flex-1 h-px`,o.value?`bg-secondary/20`:`bg-accent-green/20`])},null,2)]),S(`p`,Jn,b(s.value.description),1)]),e.node?(w(),C(`div`,Yn,[e.node.transport_key?(w(),C(`div`,Xn,[n[14]||=d(`
Transport Key
`,1),S(`div`,Zn,[S(`div`,Qn,b(e.node.transport_key),1),S(`button`,{onClick:n[1]||=t=>f(e.node.transport_key||``),class:`mt-2 text-xs text-accent-green hover:text-accent-green/80 flex items-center gap-1`,title:`Copy to clipboard`},[...n[13]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),y(` Copy Key `,-1)]])])])):g(``,!0),e.node.last_used?(w(),C(`div`,$n,[n[15]||=S(`div`,{class:`flex items-center gap-2 mb-3`},[S(`svg`,{class:`w-4 h-4 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})]),S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Last Used`)],-1),S(`div`,er,[S(`div`,tr,b(e.node.last_used.toLocaleDateString())+` at `+b(e.node.last_used.toLocaleTimeString()),1),S(`div`,nr,b(l(e.node.last_used)),1)])])):g(``,!0)])):g(``,!0),S(`div`,null,[n[18]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary mb-3`},[S(`div`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})]),y(` Flood Policy `)])],-1),S(`div`,rr,[S(`label`,ir,[m(S(`input`,{type:`radio`,"onUpdate:modelValue":n[2]||=e=>a.value=e,value:`allow`,class:`sr-only`},null,512),[[B,a.value]]),n[16]||=d(`
Allow

Permit flooding

`,1)]),S(`label`,ar,[m(S(`input`,{type:`radio`,"onUpdate:modelValue":n[3]||=e=>a.value=e,value:`deny`,class:`sr-only`},null,512),[[B,a.value]]),n[17]||=d(`
Deny

Block flooding

`,1)])])]),S(`div`,or,[S(`button`,{type:`button`,onClick:_,class:`px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors`},` Delete `),S(`button`,{type:`button`,onClick:x,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),S(`button`,{type:`submit`,disabled:!c.value,class:u([`flex-1 px-4 py-3 rounded-lg transition-colors font-medium`,c.value?`bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green`:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted/70 cursor-not-allowed`])},` Save Changes `,10,sr)])],32)])])):g(``,!0)}}),lr={class:`flex items-center gap-3 mb-6`},ur={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},dr={class:`text-accent-red font-mono`},fr={key:0,class:`bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6`},pr={class:`flex items-start gap-3`},mr={class:`flex-1`},hr={class:`text-accent-red font-medium text-sm mb-2`},gr={class:`space-y-1 max-h-32 overflow-y-auto`},_r={key:0,class:`w-3 h-3 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},vr={key:1,class:`w-3 h-3 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},yr={class:`font-mono`},br={key:0,class:`text-content-secondary dark:text-content-muted text-xs`},xr={key:1,class:`mb-6`},Sr={class:`mb-3`},Cr={class:`relative`},wr={class:`space-y-2 max-h-40 overflow-y-auto border border-stroke-subtle dark:border-stroke/20 rounded-lg p-3 bg-gray-50 dark:bg-white/5`},Tr={key:0,class:`text-center py-4 text-content-secondary dark:text-content-muted text-sm`},Er={class:`relative`},Dr=[`value`],Or={class:`flex items-center gap-2 flex-1`},kr={class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ar={key:0,class:`ml-auto px-2 py-0.5 bg-background-mute dark:bg-stroke/10 text-content-secondary dark:text-content-muted text-xs rounded-full`},jr={class:`flex gap-3`},Mr=f({__name:`DeleteConfirmModal`,props:{show:{type:Boolean},node:{},allNodes:{}},emits:[`close`,`delete-all`,`move-children`],setup(e,{emit:t}){let n=e,r=t,a=E(null),o=E(``),s=e=>{let t=[],n=e=>{for(let r of e.children)t.push(r),n(r)};return n(e),t},c=v(()=>n.node?s(n.node):[]),l=v(()=>{if(!n.node)return[];let e=new Set([n.node.id,...c.value.map(e=>e.id)]),t=n=>{let r=[];for(let i of n)i.name.startsWith(`#`)&&!e.has(i.id)&&r.push(i),i.children.length>0&&r.push(...t(i.children));return r};return t(n.allNodes)}),d=v(()=>{if(!o.value.trim())return l.value;let e=o.value.toLowerCase();return l.value.filter(t=>t.name.toLowerCase().includes(e))}),f=()=>{n.node&&(r(`delete-all`,n.node.id),h())},p=()=>{!n.node||!a.value||(r(`move-children`,{nodeId:n.node.id,targetParentId:a.value}),h())},h=()=>{a.value=null,o.value=``,r(`close`)},_=e=>{e.target===e.currentTarget&&h()};return(t,n)=>e.show&&e.node?(w(),C(`div`,{key:0,onClick:_,class:`fixed inset-0 bg-black/80 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[S(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-lg border border-stroke-subtle dark:border-white/10`,onClick:n[2]||=I(()=>{},[`stop`])},[S(`div`,lr,[n[6]||=S(`svg`,{class:`w-6 h-6 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,null,[n[4]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Confirm Deletion `,-1),S(`p`,ur,[n[3]||=y(` Deleting `,-1),S(`span`,dr,b(e.node?.name),1)])]),S(`button`,{onClick:h,class:`ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...n[5]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),c.value.length>0?(w(),C(`div`,fr,[S(`div`,pr,[n[9]||=S(`svg`,{class:`w-5 h-5 text-accent-red flex-shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`div`,mr,[S(`h4`,hr,` This will affect `+b(c.value.length)+` child `+b(c.value.length===1?`entry`:`entries`)+`: `,1),S(`div`,gr,[(w(!0),C(x,null,i(c.value.slice(0,10),e=>(w(),C(`div`,{key:e.id,class:`flex items-center gap-2 text-xs text-content-secondary dark:text-content-primary/80`},[e.name.startsWith(`#`)?(w(),C(`svg`,_r,[...n[7]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(w(),C(`svg`,vr,[...n[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z`},null,-1)]])),S(`span`,yr,b(e.name),1),S(`span`,{class:u([`px-1 py-0.5 text-xs rounded`,e.floodPolicy===`allow`?`bg-accent-green/20 text-accent-green`:`bg-accent-red/20 text-accent-red`])},b(e.floodPolicy),3)]))),128)),c.value.length>10?(w(),C(`div`,br,` ...and `+b(c.value.length-10)+` more `,1)):g(``,!0)])])])])):g(``,!0),c.value.length>0&&l.value.length>0?(w(),C(`div`,xr,[n[13]||=S(`h4`,{class:`text-content-primary dark:text-content-primary font-medium text-sm mb-3`},` Move children to another region: `,-1),S(`div`,Sr,[S(`div`,Cr,[n[10]||=S(`svg`,{class:`absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-content-muted dark:text-content-muted`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1),m(S(`input`,{"onUpdate:modelValue":n[0]||=e=>o.value=e,type:`text`,placeholder:`Search regions...`,class:`w-full pl-9 pr-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors text-sm`},null,512),[[F,o.value]])])]),S(`div`,wr,[d.value.length===0?(w(),C(`div`,Tr,b(o.value?`No regions match your search`:`No available regions`),1)):g(``,!0),(w(!0),C(x,null,i(d.value,e=>(w(),C(`label`,{key:e.id,class:`flex items-center gap-3 p-2 rounded cursor-pointer hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors group`},[S(`div`,Er,[m(S(`input`,{type:`radio`,value:e.id,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`sr-only peer`},null,8,Dr),[[B,a.value]]),n[11]||=S(`div`,{class:`w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-hover:border-stroke dark:group-hover:border-stroke/50 peer-checked:border-primary peer-checked:bg-primary/20 transition-all`},[S(`div`,{class:`w-2 h-2 rounded-full bg-primary scale-0 peer-checked:scale-100 transition-transform absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2`})],-1)]),S(`div`,Or,[n[12]||=S(`svg`,{class:`w-4 h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`})],-1),S(`span`,kr,b(e.name),1),e.children.length>0?(w(),C(`span`,Ar,b(e.children.length),1)):g(``,!0)])]))),128))])])):g(``,!0),S(`div`,jr,[S(`button`,{onClick:h,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),c.value.length>0&&a.value?(w(),C(`button`,{key:0,onClick:p,class:`flex-1 px-4 py-3 bg-primary/20 hover:bg-primary/30 border border-primary/50 text-primary rounded-lg transition-colors`},` Move & Delete `)):g(``,!0),S(`button`,{onClick:f,class:`flex-1 px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors font-medium`},b(c.value.length>0?`Delete All`:`Delete`),1)])])])):g(``,!0)}}),Nr={class:`space-y-4 sm:space-y-6`},Pr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3`},Fr={class:`flex gap-2 flex-wrap`},Ir=[`disabled`],Lr=[`disabled`],Rr={class:`glass-card rounded-[15px] p-3 sm:p-4 border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5`},zr={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},Br={class:`flex items-center gap-2 sm:gap-3`},Vr={class:`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5 sm:p-1`},Hr={class:`glass-card rounded-[15px] p-3 sm:p-6 border border-stroke-subtle dark:border-stroke/10`},Ur={key:0,class:`flex items-center justify-center py-8`},Wr={key:1,class:`text-center py-8`},Gr={class:`text-content-secondary dark:text-content-muted text-sm`},Kr={key:2,class:`text-center py-8`},qr={key:3,class:`space-y-2`},Jr=f({name:`TransportKeys`,__name:`TransportKeys`,setup(e){let t=Yt(),n=j(),r=E(!1),o=E(!1),c=E(!1),d=E(null),f=E(null),p=E(`deny`);h(v(()=>n.stats?.config?.mesh?.unscoped_flood_allow??null),e=>{e!==null&&(p.value=e?`allow`:`deny`)},{immediate:!0});let m=E([]),g=E(!1),T=E(null),D=e=>{let t=new Map,n=[];return e.forEach(e=>{let n={id:e.id,name:e.name,floodPolicy:e.flood_policy,transport_key:e.transport_key,last_used:e.last_used?new Date(e.last_used*1e3):void 0,parent_id:e.parent_id,children:[]};t.set(e.id,n)}),t.forEach(e=>{e.parent_id&&t.has(e.parent_id)?t.get(e.parent_id).children.push(e):n.push(e)}),n},O=async()=>{try{g.value=!0,T.value=null;let e=await A.getTransportKeys();e.success&&e.data?m.value=D(e.data):T.value=e.error||`Failed to load transport keys`}catch(e){T.value=e instanceof Error?e.message:`Unknown error occurred`,console.error(`Error loading transport keys:`,e)}finally{g.value=!1}};s(()=>{O()});function k(e,t){for(let n of e){if(n.id===t)return n;if(n.children){let e=k(n.children,t);if(e)return e}}return null}function M(){let e=t.selectedNodeId.value;if(e)return k(m.value,e)?.name}function N(e){t.setSelectedNode(e)}function P(){r.value=!0}function F(){if(t.selectedNodeId.value){let e=k(m.value,t.selectedNodeId.value);e&&(f.value=e,c.value=!0)}}function I(){if(t.selectedNodeId.value){let e=k(m.value,t.selectedNodeId.value);e&&(d.value=e,o.value=!0)}}let L=async e=>{try{let t=await A.createTransportKey(e.name,e.floodPolicy,void 0,e.parentId,void 0);t.success?await O():(console.error(`Failed to add transport key:`,t.error),T.value=t.error||`Failed to add transport key`)}catch(e){console.error(`Error adding transport key:`,e),T.value=e instanceof Error?e.message:`Unknown error occurred`}finally{r.value=!1}};function R(){r.value=!1}async function z(e){try{let t=e===`allow`,r=await A.updateUnscopedFloodPolicy(t);r.success?(p.value=e,await n.fetchStats()):(console.error(`Failed to update unscoped flood policy:`,r.error),T.value=r.error||`Failed to update unscoped flood policy`)}catch(e){console.error(`Error updating unscoped flood policy:`,e),T.value=e instanceof Error?e.message:`Failed to update unscoped flood policy`}}function B(){o.value=!1,d.value=null}async function V(e){try{let t=await A.updateTransportKey(e.id,e.name,e.floodPolicy);t.success?await O():(console.error(`Failed to update transport key:`,t.error),T.value=t.error||`Failed to update transport key`)}catch(e){console.error(`Error updating transport key:`,e),T.value=e instanceof Error?e.message:`Unknown error occurred`}finally{B()}}function ee(e){o.value=!1,d.value=null,f.value=e,c.value=!0}function H(){c.value=!1,f.value=null}async function U(e){try{let n=await A.deleteTransportKey(e);n.success?(await O(),t.setSelectedNode(null)):(console.error(`Failed to delete transport key:`,n.error),T.value=n.error||`Failed to delete transport key`)}catch(e){console.error(`Error deleting transport key:`,e),T.value=e instanceof Error?e.message:`Unknown error occurred`}finally{H()}}async function W(e){try{let n=await A.deleteTransportKey(e.nodeId);n.success?(await O(),t.setSelectedNode(null)):(console.error(`Failed to delete transport key:`,n.error),T.value=n.error||`Failed to delete transport key`)}catch(e){console.error(`Error deleting transport key:`,e),T.value=e instanceof Error?e.message:`Unknown error occurred`}finally{H()}}return(e,n)=>(w(),C(`div`,Nr,[S(`div`,Pr,[n[3]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},` Regions/Keys `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Manage regional key hierarchy `)],-1),S(`div`,Fr,[S(`button`,{onClick:P,class:`flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm bg-accent-green/10 hover:bg-accent-green/20 text-accent-green border-accent-green/30`},[...n[2]||=[S(`svg`,{class:`w-3.5 h-3.5 sm:w-4 sm:h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),y(` Add `,-1)]]),S(`button`,{onClick:I,disabled:!a(t).selectedNodeId.value,class:u([`px-2.5 sm:px-4 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm`,a(t).selectedNodeId.value?`bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border-accent-green/50`:`bg-background-mute dark:bg-stroke/10 text-content-muted dark:text-content-muted/70 border-stroke-subtle dark:border-stroke/20 cursor-not-allowed`])},` Edit `,10,Ir),S(`button`,{onClick:F,disabled:!a(t).selectedNodeId.value,class:u([`px-2.5 sm:px-4 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm`,a(t).selectedNodeId.value?`bg-accent-red/20 hover:bg-accent-red/30 text-accent-red border-accent-red/50`:`bg-background-mute dark:bg-stroke/10 text-content-muted dark:text-content-muted/70 border-stroke-subtle dark:border-stroke/20 cursor-not-allowed`])},` Delete `,10,Lr)])]),S(`div`,Rr,[S(`div`,zr,[n[4]||=S(`div`,null,[S(`h4`,{class:`text-xs sm:text-sm font-medium text-content-primary dark:text-content-primary mb-1`},` Unscoped Flood Policy (*) `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-[10px] sm:text-xs`},` Allow or Deny unscoped flood packets `)],-1),S(`div`,Br,[S(`div`,Vr,[S(`button`,{onClick:n[0]||=e=>z(`deny`),class:u([`px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors`,p.value===`deny`?`bg-accent-red/20 text-accent-red border border-accent-red/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` DENY `,2),S(`button`,{onClick:n[1]||=e=>z(`allow`),class:u([`px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors`,p.value===`allow`?`bg-accent-green/20 text-accent-green border border-accent-green/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` ALLOW `,2)])])])]),S(`div`,Hr,[g.value?(w(),C(`div`,Ur,[...n[5]||=[S(`div`,{class:`animate-spin rounded-full h-8 w-8 border-b-2 border-accent-green`},null,-1),S(`span`,{class:`ml-2 text-content-secondary dark:text-content-muted`},`Loading transport keys...`,-1)]])):T.value?(w(),C(`div`,Wr,[n[6]||=S(`div`,{class:`text-accent-red mb-2`},`⚠️ Error loading transport keys`,-1),S(`div`,Gr,b(T.value),1),S(`button`,{onClick:O,class:`mt-4 px-4 py-2 bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/50 rounded-lg transition-colors`},` Retry `)])):m.value.length===0?(w(),C(`div`,Kr,[...n[7]||=[S(`div`,{class:`text-content-muted dark:text-content-muted mb-2`},` 📝 No transport keys found `,-1),S(`div`,{class:`text-content-muted dark:text-content-muted/60 text-sm`},` Add your first transport key to get started `,-1)]])):(w(),C(`div`,qr,[(w(!0),C(x,null,i(m.value,e=>(w(),l(mn,{key:e.id,node:e,"selected-node-id":a(t).selectedNodeId.value,level:0,onSelect:N},null,8,[`node`,`selected-node-id`]))),128))]))]),_(Fn,{show:r.value,"selected-node-name":M(),"selected-node-id":a(t).selectedNodeId.value||void 0,onClose:R,onAdd:L},null,8,[`show`,`selected-node-name`,`selected-node-id`]),_(cr,{show:o.value,node:d.value,onClose:B,onSave:V,onRequestDelete:ee},null,8,[`show`,`node`]),_(Mr,{show:c.value,node:f.value,"all-nodes":m.value,onClose:H,onDeleteAll:U,onMoveChildren:W},null,8,[`show`,`node`,`all-nodes`])]))}}),Yr={class:`space-y-4 sm:space-y-6`},Xr={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},Zr={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-4`},Qr={class:`flex items-center gap-2 text-red-600 dark:text-red-400`},$r={key:1,class:`flex items-center justify-center py-12`},ei={key:2,class:`space-y-3`},ti={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},ni={class:`flex-1`},ri={class:`flex items-center gap-2 sm:gap-3`},ii={class:`min-w-0 flex-1`},ai={class:`text-content-primary dark:text-content-primary font-medium text-sm sm:text-base break-all`},oi={class:`flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-1 text-xs text-content-secondary dark:text-content-muted`},si={class:`truncate`},ci={class:`truncate`},li=[`onClick`,`disabled`],ui={key:3,class:`text-center py-12`},di={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-md w-full shadow-2xl`},fi={class:`space-y-4`},pi={class:`flex justify-end gap-3 mt-6`},mi=[`disabled`],hi=[`disabled`],gi={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-lg w-full shadow-2xl`},_i={class:`space-y-4`},vi={class:`flex gap-2`},yi=[`value`],bi={class:`bg-blue-500/10 border border-blue-500/30 rounded-lg p-4`},xi={class:`block bg-blue-500/20 px-3 py-2 rounded text-xs text-blue-100 font-mono overflow-x-auto`},Si=f({name:`APITokens`,__name:`APITokens`,setup(e){let t=E([]),n=E(!1),r=E(null),a=E(!1),o=E(``),c=E(null),l=E(!1),u=E(!1),f=E(null),p=async()=>{n.value=!0,r.value=null;try{let e=await A.get(`/auth/tokens`);t.value=(e.data||e).tokens||[]}catch(e){console.error(`Failed to fetch API tokens:`,e),r.value=e instanceof Error?e.message:`Failed to fetch tokens`}finally{n.value=!1}},h=async()=>{if(!o.value.trim()){r.value=`Token name is required`;return}n.value=!0,r.value=null;try{let e=await A.post(`/auth/tokens`,{name:o.value.trim()});c.value=(e.data||e).token||null,a.value=!1,l.value=!0,o.value=``,await p()}catch(e){console.error(`Failed to create API token:`,e),r.value=e instanceof Error?e.message:`Failed to create token`}finally{n.value=!1}},T=(e,t)=>{f.value={id:e,name:t},u.value=!0},D=async()=>{if(f.value){n.value=!0,r.value=null;try{await A.delete(`/auth/tokens/${f.value.id}`),await p(),u.value=!1,f.value=null}catch(e){console.error(`Failed to revoke API token:`,e),r.value=e instanceof Error?e.message:`Failed to revoke token`}finally{n.value=!1}}},O=()=>{a.value=!1,o.value=``,r.value=null},k=()=>{l.value=!1,c.value=null},j=()=>{c.value&&navigator.clipboard.writeText(c.value)},M=e=>e?new Date(e*1e3).toLocaleString():`Never`,N=v(()=>`${window.location.origin}/api/stats`);return s(()=>{p()}),(e,s)=>(w(),C(x,null,[S(`div`,Yr,[S(`div`,Xr,[s[5]||=S(`div`,null,[S(`h2`,{class:`text-lg sm:text-xl font-semibold text-content-primary dark:text-content-primary`},` API Tokens `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm mt-1`},` Manage API tokens for machine-to-machine authentication `)],-1),S(`button`,{onClick:s[0]||=e=>a.value=!0,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors flex items-center justify-center gap-2 text-sm sm:text-base`},[...s[4]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),y(` Create Token `,-1)]])]),s[20]||=d(`

API tokens are used for machine-to-machine authentication. Include the token in the X-API-Key header when making API requests.

Tokens are only shown once at creation. Store them securely.

`,1),r.value?(w(),C(`div`,Zr,[S(`div`,Qr,[s[6]||=S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),y(` `+b(r.value),1)])])):g(``,!0),n.value&&t.value.length===0?(w(),C(`div`,$r,[...s[7]||=[S(`div`,{class:`text-center`},[S(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full mx-auto mb-4`}),S(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading tokens...`)],-1)]])):t.value.length>0?(w(),C(`div`,ei,[(w(!0),C(x,null,i(t.value,e=>(w(),C(`div`,{key:e.id,class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-3 sm:p-4 hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors`},[S(`div`,ti,[S(`div`,ni,[S(`div`,ri,[s[8]||=S(`svg`,{class:`w-4 h-4 sm:w-5 sm:h-5 text-primary flex-shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})],-1),S(`div`,ii,[S(`h3`,ai,b(e.name),1),S(`div`,oi,[S(`span`,si,`Created: `+b(M(e.created_at)),1),S(`span`,ci,`Last used: `+b(M(e.last_used)),1)])])])]),S(`button`,{onClick:t=>T(e.id,e.name),disabled:n.value,class:`w-full sm:w-auto px-3 py-1.5 bg-red-100 dark:bg-red-500/20 hover:bg-red-500/30 text-red-600 dark:text-red-400 rounded-lg border border-red-500/50 transition-colors disabled:opacity-50 text-sm`},` Revoke `,8,li)])]))),128))])):(w(),C(`div`,ui,[s[9]||=S(`svg`,{class:`w-16 h-16 text-content-muted dark:text-content-muted/40 mx-auto mb-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})],-1),s[10]||=S(`h3`,{class:`text-content-primary dark:text-content-primary font-medium mb-2`},`No API Tokens`,-1),s[11]||=S(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mb-4`},` Create a token to enable API access `,-1),S(`button`,{onClick:s[1]||=e=>a.value=!0,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Create Your First Token `)])),a.value?(w(),C(`div`,{key:4,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:I(O,[`self`])},[S(`div`,di,[s[14]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-4`},` Create API Token `,-1),S(`div`,fi,[S(`div`,null,[s[12]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Token Name`,-1),m(S(`input`,{"onUpdate:modelValue":s[2]||=e=>o.value=e,type:`text`,placeholder:`e.g., Production Server, CI/CD Pipeline`,class:`w-full px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-400 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,onKeydown:R(h,[`enter`])},null,544),[[F,o.value]]),s[13]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted mt-1`},` Give your token a descriptive name to identify its purpose `,-1)]),S(`div`,pi,[S(`button`,{onClick:O,disabled:n.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors disabled:opacity-50`},` Cancel `,8,mi),S(`button`,{onClick:h,disabled:n.value||!o.value.trim(),class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors disabled:opacity-50`},b(n.value?`Creating...`:`Create Token`),9,hi)])])])])):g(``,!0),l.value&&c.value?(w(),C(`div`,{key:5,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:I(k,[`self`])},[S(`div`,gi,[s[19]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-4`},` Token Created Successfully `,-1),S(`div`,_i,[s[18]||=d(`
Save this token now! For security reasons, it will not be shown again.
`,1),S(`div`,null,[s[16]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Your API Token`,-1),S(`div`,vi,[S(`input`,{value:c.value,readonly:``,class:`flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary font-mono text-sm`},null,8,yi),S(`button`,{onClick:j,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors flex items-center gap-2`,title:`Copy to clipboard`},[...s[15]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),y(` Copy `,-1)]])])]),S(`div`,bi,[s[17]||=S(`p`,{class:`text-sm text-blue-200 mb-2`},[S(`strong`,null,`Usage Example:`)],-1),S(`code`,xi,` curl -H "X-API-Key: `+b(c.value)+`" `+b(N.value),1)]),S(`div`,{class:`flex justify-end mt-6`},[S(`button`,{onClick:k,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Done `)])])])])):g(``,!0)]),_(V,{show:u.value,title:`Revoke API Token`,message:`Are you sure you want to revoke the token '${f.value?.name}'? This action cannot be undone.`,"confirm-text":`Revoke`,"cancel-text":`Cancel`,variant:`danger`,onConfirm:D,onClose:s[3]||=e=>u.value=!1},null,8,[`show`,`message`])],64))}}),Ci={class:`space-y-6`},wi={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Ti={class:`space-y-4`},Ei={class:`flex items-center justify-between`},Di=[`disabled`],Oi={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},ki={class:`space-y-4`},Ai={class:`space-y-3`},ji=[`checked`,`disabled`],Mi=[`checked`,`disabled`],Ni={class:`flex items-start gap-3`},Pi={key:0,class:`w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Fi={key:1,class:`w-5 h-5 text-accent-cyan flex-shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Ii={class:`flex-1`},Li={class:`text-sm font-medium text-content-primary dark:text-content-primary`},Ri={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-1`},zi={key:1,class:`p-4 bg-amber-500/10 border border-amber-500/30 rounded-lg`},Bi={class:`flex items-start justify-between gap-3`},Vi=[`disabled`],Hi={key:0,class:`animate-spin h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},Ui={key:1,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Wi={class:`flex items-center space-x-2`},Gi={key:0,class:`w-5 h-5 text-green-600 dark:text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Ki={key:1,class:`w-5 h-5 text-red-600 dark:text-red-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},qi=f({name:`WebSettings`,__name:`WebSettings`,setup(e){let t=E(!1),n=E(``),r=E(!1),i=E(!1),a=E(!1),c=E(!1),l=E(!0),f=o({cors_enabled:!1,use_default_frontend:!0}),p=v(()=>r.value?`bg-green-500/10 border-green-600/40 dark:border-green-500/30`:`bg-red-500/10 border-red-500/30`);async function m(){try{l.value=!0;let e=await A.get(`/check_pymc_console`);e.success&&e.data&&(c.value=e.data.exists,console.log(`PyMC Console exists:`,c.value))}catch(e){console.error(`Failed to check PyMC Console:`,e),c.value=!1}finally{l.value=!1}}async function h(){try{let e=await A.get(`/stats`);console.log(`WebSettings: Full response:`,e);let t=null;if(e.success&&e.data?t=e.data:e&&`version`in e&&(t=e),t){let e=t.config?.web||{};console.log(`WebSettings: webConfig:`,e),f.cors_enabled=e.cors_enabled===!0,console.log(`WebSettings: Set cors_enabled to:`,f.cors_enabled);let n=e.web_path;f.use_default_frontend=!n||n===``,console.log(`WebSettings: Set use_default_frontend to:`,f.use_default_frontend,`from web_path:`,n)}}catch(e){console.error(`Failed to load web settings:`,e),k(`Failed to load settings`,!1)}}async function _(){t.value=!0,n.value=``;try{let e={web:{cors_enabled:f.cors_enabled}};f.use_default_frontend?e.web.web_path=null:e.web.web_path=`/opt/pymc_console/web/html`;let t=await A.post(`/update_web_config`,e);t.success?(k(`Settings saved successfully`,!0),i.value=!0):k(t.error||`Failed to save settings`,!1)}catch(e){console.error(`Failed to save web settings:`,e),k(e.message||`Failed to save settings`,!1)}finally{t.value=!1}}async function T(){f.cors_enabled=!f.cors_enabled,await _()}async function D(){f.use_default_frontend=!0,await _()}async function O(){f.use_default_frontend=!1,await _()}function k(e,t){n.value=e,r.value=t,setTimeout(()=>{n.value=``},5e3)}async function j(){a.value=!0,n.value=``;try{let e=await A.post(`/restart_service`,{});e.success?(k(`Service restart initiated. Page will reload...`,!0),i.value=!1,setTimeout(()=>{window.location.reload()},2e3)):k(e.error||`Failed to restart service`,!1)}catch(e){e.code===`ERR_NETWORK`||e.message?.includes(`Network error`)?(k(`Service restarting... Page will reload`,!0),i.value=!1,setTimeout(()=>{window.location.reload()},3e3)):(console.error(`Failed to restart service:`,e),k(e.message||`Failed to restart service`,!1))}finally{a.value=!1}}return s(()=>{h(),m()}),(e,o)=>(w(),C(`div`,Ci,[S(`div`,wi,[o[1]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` CORS Settings `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Control cross-origin resource sharing for API access `)])],-1),S(`div`,Ti,[S(`div`,Ei,[o[0]||=S(`div`,null,[S(`label`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Enable CORS`),S(`p`,{class:`text-xs text-content-secondary dark:text-content-muted mt-1`},` Allow web frontends from different origins to access the API `)],-1),S(`button`,{onClick:T,disabled:t.value,class:u([`relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2`,f.cors_enabled?`bg-cyan-600 dark:bg-teal-500 border-cyan-600 dark:border-teal-500`:`bg-gray-400 dark:bg-gray-600 border-gray-400 dark:border-gray-600`,t.value?`opacity-50 cursor-not-allowed`:`cursor-pointer`])},[S(`span`,{class:u([`inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg`,f.cors_enabled?`translate-x-5`:`translate-x-0.5`])},null,2)],10,Di)])])]),S(`div`,Oi,[o[11]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Web Frontend `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Choose which web interface to use `)])],-1),S(`div`,ki,[S(`div`,Ai,[S(`label`,{class:u([`flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 cursor-pointer transition-all`,f.use_default_frontend?`border-accent-cyan bg-accent-cyan/10`:`border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50`])},[S(`input`,{type:`radio`,name:`frontend`,checked:f.use_default_frontend,onChange:D,disabled:t.value,class:`mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background`},null,40,ji),o[2]||=S(`div`,{class:`flex-1`},[S(`div`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},` Default Frontend `),S(`div`,{class:`text-xs text-content-secondary dark:text-content-muted mt-1`},` Built-in pyMC Repeater web interface `),S(`div`,{class:`text-xs text-content-muted dark:text-content-muted/60 mt-1 font-mono`},` Built-in `)],-1)],2),S(`label`,{class:u([`flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 cursor-pointer transition-all`,f.use_default_frontend?`border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50`:`border-accent-cyan bg-accent-cyan/10`])},[S(`input`,{type:`radio`,name:`frontend`,checked:!f.use_default_frontend,onChange:O,disabled:t.value,class:`mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background`},null,40,Mi),o[3]||=d(`
PyMC Console
@Treehouse⚡
Alternative web interface for pyMC Repeater
/opt/pymc_console/web/html
`,1)],2)]),l.value?g(``,!0):(w(),C(`div`,{key:0,class:u([`p-4 rounded-lg border`,c.value?`bg-green-500/5 border-green-500/20`:`bg-accent-cyan/5 border-accent-cyan/20`])},[S(`div`,Ni,[c.value?(w(),C(`svg`,Pi,[...o[4]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(w(),C(`svg`,Fi,[...o[5]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])),S(`div`,Ii,[S(`h4`,Li,b(c.value?`PyMC Console has been detected`:`PyMC Console Not Installed`),1),c.value?(w(),C(`p`,Ri,[...o[6]||=[y(` PyMC Console is installed at `,-1),S(`code`,{class:`text-green-700 dark:text-green-300`},`/opt/pymc_console/web/html`,-1)]])):(w(),C(x,{key:1},[o[7]||=d(`

PyMC Console must be installed at /opt/pymc_console/web/html before selecting this option.

PyMC Console Install Instructions `,2)],64))])])],2)),i.value?(w(),C(`div`,zi,[S(`div`,Bi,[o[10]||=d(`

Service restart required

Web frontend changes will take effect after restarting the pymc-repeater service.

`,1),S(`button`,{onClick:j,disabled:a.value,class:`px-4 py-2 bg-amber-500 hover:bg-amber-600 disabled:bg-amber-500/50 text-white font-medium rounded-lg transition-colors disabled:cursor-not-allowed flex items-center gap-2 whitespace-nowrap`},[a.value?(w(),C(`svg`,Hi,[...o[8]||=[S(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),S(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):(w(),C(`svg`,Ui,[...o[9]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`},null,-1)]])),y(` `+b(a.value?`Restarting...`:`Restart Now`),1)],8,Vi)])])):g(``,!0)])]),n.value?(w(),C(`div`,{key:0,class:u([`p-4 rounded-lg border`,p.value])},[S(`div`,Wi,[r.value?(w(),C(`svg`,Gi,[...o[12]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`},null,-1)]])):(w(),C(`svg`,Ki,[...o[13]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])),S(`span`,{class:u(r.value?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`)},b(n.value),3)])],2)):g(``,!0)]))}}),Ji={class:`space-y-4`},Yi={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm`},Xi={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},Zi={class:`flex justify-between items-center`},Qi={class:`flex gap-2`},$i=[`disabled`],ea={class:`flex gap-2`},ta=[`disabled`],na=[`disabled`],ra={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},ia={key:0,class:`flex items-center justify-center py-4`},aa={key:1,class:`text-center py-4`},oa={class:`grid grid-cols-2 sm:grid-cols-4 gap-3`},sa={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},ca={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},la={class:`text-lg font-mono text-content-primary dark:text-content-primary`},ua={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},da={class:`text-lg font-mono text-green-600 dark:text-green-400`},fa={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},pa={class:`text-lg font-mono text-red-600 dark:text-red-400`},ma={key:0,class:`mt-2 p-2 bg-red-50 dark:bg-red-500/10 rounded-lg border border-red-200 dark:border-red-500/30`},ha={key:1,class:`mt-2 p-2 bg-orange-50 dark:bg-orange-500/10 rounded-lg border border-orange-200 dark:border-orange-500/30`},ga={class:`font-medium`},_a={class:`font-mono text-[10px] opacity-70`},va={class:`text-[10px]`},ya={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},ba={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},xa={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Sa={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ca={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},wa={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ta={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ea={key:1,class:`flex items-center gap-2`},Da={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Oa={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},ka={key:1,class:`flex items-center gap-2`},Aa={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},ja={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ma={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Na={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Pa={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Fa={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ia={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},La={key:1,class:`flex items-center gap-2`},Ra={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},za={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ba={key:1,class:`flex items-center gap-2`},Va={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Ha={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ua={key:1,class:`flex items-center gap-2`},Wa={class:`bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3`},Ga={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ka={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},qa={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ja={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ya={key:1,class:`flex items-center gap-2`},Xa={class:`py-2`},Za={class:`grid grid-cols-3 gap-2 mt-2`},Qa={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},$a={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},eo={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},to={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},no={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg`},ro={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},io={class:`p-6 space-y-4`},ao={class:`flex justify-between items-start`},oo={class:`flex justify-end pt-4 border-t border-stroke-subtle dark:border-stroke/20`},so=f({__name:`AdvertSettings`,setup(e){let t=j(),n=v(()=>t.stats?.config?.repeater||{}),r=v(()=>n.value.advert_rate_limit||{}),a=v(()=>n.value.advert_penalty_box||{}),o=v(()=>n.value.advert_adaptive||{}),l=v(()=>o.value.thresholds||{}),f=E(!1),p=E(!1),_=E(``),T=E(``),D=E(!1),O=E(!1),A=E(null),M=E(!0),N=E(2),L=E(1),R=E(10),z=E(60),B=E(!0),V=E(2),ee=E(12),H=E(6),U=E(2),W=E(24),G=E(!0),te=E(.1),K=E(5),ne=E(.05),q=E(.2),J=E(.5),Y=async()=>{O.value=!0;try{let e=await k.get(`/api/advert_rate_limit_stats`);e.data?.success&&(A.value=e.data.data)}catch(e){console.error(`Failed to fetch rate limit stats:`,e)}finally{O.value=!1}};h([r,a,o],()=>{f.value||(M.value=r.value.enabled??!1,N.value=r.value.bucket_capacity??2,L.value=r.value.refill_tokens??1,R.value=Math.round((r.value.refill_interval_seconds??36e3)/3600),z.value=Math.round((r.value.min_interval_seconds??0)/60),B.value=a.value.enabled??!1,V.value=a.value.violation_threshold??2,ee.value=Math.round((a.value.violation_decay_seconds??43200)/3600),H.value=Math.round((a.value.base_penalty_seconds??21600)/3600),U.value=a.value.penalty_multiplier??2,W.value=Math.round((a.value.max_penalty_seconds??86400)/3600),G.value=o.value.enabled??!1,te.value=o.value.ewma_alpha??.1,K.value=Math.round((o.value.hysteresis_seconds??300)/60),ne.value=l.value.quiet_max??.05,q.value=l.value.normal_max??.2,J.value=l.value.busy_max??.5)},{immediate:!0}),s(()=>{Y()});let X=()=>{M.value=r.value.enabled??!1,N.value=r.value.bucket_capacity??2,L.value=r.value.refill_tokens??1,R.value=Math.round((r.value.refill_interval_seconds??36e3)/3600),z.value=Math.round((r.value.min_interval_seconds??0)/60),B.value=a.value.enabled??!1,V.value=a.value.violation_threshold??2,ee.value=Math.round((a.value.violation_decay_seconds??43200)/3600),H.value=Math.round((a.value.base_penalty_seconds??21600)/3600),U.value=a.value.penalty_multiplier??2,W.value=Math.round((a.value.max_penalty_seconds??86400)/3600),G.value=o.value.enabled??!1,te.value=o.value.ewma_alpha??.1,K.value=Math.round((o.value.hysteresis_seconds??300)/60),ne.value=l.value.quiet_max??.05,q.value=l.value.normal_max??.2,J.value=l.value.busy_max??.5},Z=()=>{f.value=!0,_.value=``,T.value=``},Q=()=>{f.value=!1,_.value=``,T.value=``,X()},re=async()=>{p.value=!0,T.value=``,_.value=``;try{let e={rate_limit_enabled:M.value,bucket_capacity:N.value,refill_tokens:L.value,refill_interval_seconds:R.value*3600,min_interval_seconds:z.value*60,penalty_enabled:B.value,violation_threshold:V.value,violation_decay_seconds:ee.value*3600,base_penalty_seconds:H.value*3600,penalty_multiplier:U.value,max_penalty_seconds:W.value*3600,adaptive_enabled:G.value,ewma_alpha:te.value,hysteresis_seconds:K.value*60,quiet_max:ne.value,normal_max:q.value,busy_max:J.value},n=(await k.post(`/api/update_advert_rate_limit_config`,e)).data;n.success?(_.value=n.data?.message||`Settings saved successfully`,await t.fetchStats(),await Y(),await c(),X(),f.value=!1,setTimeout(()=>{_.value=``},3e3)):(T.value=n.error||`Failed to save settings`,console.error(`[AdvertSettings] Save failed:`,n.error))}catch(e){console.error(`Failed to save advert settings:`,e),T.value=e.response?.data?.error||`Failed to save settings`}finally{p.value=!1}},$=v(()=>A.value?.adaptive?.current_tier||`unknown`),ie=v(()=>{switch($.value){case`quiet`:return`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-500`;case`normal`:return`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-500`;case`busy`:return`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-500`;case`congested`:return`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-500`;default:return`bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-400 border-gray-500`}});return(e,t)=>(w(),C(`div`,Ji,[_.value?(w(),C(`div`,Yi,b(_.value),1)):g(``,!0),T.value?(w(),C(`div`,Xi,b(T.value),1)):g(``,!0),S(`div`,Zi,[S(`div`,Qi,[S(`button`,{onClick:Y,disabled:O.value,class:`px-3 py-1.5 text-xs bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-secondary dark:text-content-muted rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors disabled:opacity-50`},b(O.value?`Loading...`:`Refresh Stats`),9,$i),S(`button`,{onClick:t[0]||=e=>D.value=!0,class:`px-3 py-1.5 text-xs bg-blue-100 dark:bg-blue-500/20 hover:bg-blue-200 dark:hover:bg-blue-500/30 text-blue-700 dark:text-blue-400 rounded-lg border border-blue-500/50 transition-colors`,title:`How rate limiting works`},[...t[19]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1)]])]),S(`div`,ea,[f.value?(w(),C(x,{key:1},[S(`button`,{onClick:Q,disabled:p.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,ta),S(`button`,{onClick:re,disabled:p.value,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},b(p.value?`Saving...`:`Save Changes`),9,na)],64)):(w(),C(`button`,{key:0,onClick:Z,class:`px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Edit Settings `))])]),S(`div`,ra,[t[28]||=S(`h3`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},` Current Status `,-1),O.value&&!A.value?(w(),C(`div`,ia,[...t[20]||=[S(`div`,{class:`animate-spin w-5 h-5 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full`},null,-1),S(`span`,{class:`ml-2 text-sm text-content-muted`},`Loading stats...`,-1)]])):A.value?(w(),C(x,{key:2},[S(`div`,oa,[S(`div`,sa,[t[22]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Mesh Tier`,-1),S(`div`,{class:u([`mt-1 px-2 py-0.5 rounded border text-xs font-medium inline-block`,ie.value])},b($.value.toUpperCase()),3)]),S(`div`,ca,[t[23]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Adverts/min`,-1),S(`div`,la,b(A.value.metrics?.adverts_per_min_ewma?.toFixed(2)||`0.00`),1)]),S(`div`,ua,[t[24]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Allowed`,-1),S(`div`,da,b(A.value.stats?.adverts_allowed||0),1)]),S(`div`,fa,[t[25]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Dropped`,-1),S(`div`,pa,b(A.value.stats?.adverts_dropped||0),1)])]),Object.keys(A.value.active_penalties||{}).length>0?(w(),C(`div`,ma,[t[26]||=S(`div`,{class:`text-xs font-medium text-red-700 dark:text-red-400 mb-1`},` Active Penalties `,-1),(w(!0),C(x,null,i(A.value.active_penalties,(e,t)=>(w(),C(`div`,{key:t,class:`text-xs font-mono text-red-600 dark:text-red-400`},b(t)+`... - `+b(Math.round(e))+`s remaining `,1))),128))])):g(``,!0),A.value.recent_drops&&A.value.recent_drops.length>0?(w(),C(`div`,ha,[t[27]||=S(`div`,{class:`text-xs font-medium text-orange-700 dark:text-orange-400 mb-1`},` Recently Dropped Adverts `,-1),(w(!0),C(x,null,i(A.value.recent_drops,(e,t)=>(w(),C(`div`,{key:t,class:`text-xs text-orange-600 dark:text-orange-400 py-0.5`},[S(`span`,ga,b(e.name),1),S(`span`,_a,`(`+b(e.pubkey)+`...)`,1),S(`span`,va,` - `+b(e.reason)+` (`+b(e.seconds_ago)+`s ago)`,1)]))),128))])):g(``,!0)],64)):(w(),C(`div`,aa,[...t[21]||=[S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Stats not available. Click "Refresh Stats" to load. `,-1)]]))]),S(`div`,ya,[t[36]||=S(`h3`,{class:`text-sm font-medium text-content-primary dark:text-content-primary flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})]),y(` Token Bucket Rate Limiting `)],-1),t[37]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Controls how many adverts each pubkey can send in a given time period. `,-1),S(`div`,ba,[t[30]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Rate Limiting`,-1),f.value?m((w(),C(`select`,{key:1,"onUpdate:modelValue":t[1]||=e=>M.value=e,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[29]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[P,M.value]]):(w(),C(`div`,xa,b(M.value?`Enabled`:`Disabled`),1))]),S(`div`,Sa,[t[31]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Bucket Capacity`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Max burst size (adverts)`)],-1),f.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[2]||=e=>N.value=e,type:`number`,min:`1`,max:`10`,class:`w-full sm:w-24 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,N.value,void 0,{number:!0}]]):(w(),C(`div`,Ca,b(N.value),1))]),S(`div`,wa,[t[33]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Refill Interval`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Time between token refills `)],-1),f.value?(w(),C(`div`,Ea,[m(S(`input`,{"onUpdate:modelValue":t[3]||=e=>R.value=e,type:`number`,min:`1`,max:`48`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,R.value,void 0,{number:!0}]]),t[32]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(w(),C(`div`,Ta,b(R.value)+` hours `,1))]),S(`div`,Da,[t[35]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Minimum Interval`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Hard minimum between adverts `)],-1),f.value?(w(),C(`div`,ka,[m(S(`input`,{"onUpdate:modelValue":t[4]||=e=>z.value=e,type:`number`,min:`0`,max:`1440`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,z.value,void 0,{number:!0}]]),t[34]||=S(`span`,{class:`text-content-muted text-sm`},`min`,-1)])):(w(),C(`div`,Oa,b(z.value)+` min `,1))])]),S(`div`,Aa,[t[47]||=S(`h3`,{class:`text-sm font-medium text-content-primary dark:text-content-primary flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})]),y(` Penalty Box (Repeat Offenders) `)],-1),t[48]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Applies escalating cooldowns to pubkeys that repeatedly violate limits. `,-1),S(`div`,ja,[t[39]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Penalty Box`,-1),f.value?m((w(),C(`select`,{key:1,"onUpdate:modelValue":t[5]||=e=>B.value=e,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[38]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[P,B.value]]):(w(),C(`div`,Ma,b(B.value?`Enabled`:`Disabled`),1))]),S(`div`,Na,[t[40]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Violation Threshold`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Violations before penalty `)],-1),f.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[6]||=e=>V.value=e,type:`number`,min:`1`,max:`10`,class:`w-full sm:w-24 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512)),[[F,V.value,void 0,{number:!0}]]):(w(),C(`div`,Pa,b(V.value),1))]),S(`div`,Fa,[t[42]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Base Penalty Duration`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`First penalty duration`)],-1),f.value?(w(),C(`div`,La,[m(S(`input`,{"onUpdate:modelValue":t[7]||=e=>H.value=e,type:`number`,min:`1`,max:`48`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,H.value,void 0,{number:!0}]]),t[41]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(w(),C(`div`,Ia,b(H.value)+` hours `,1))]),S(`div`,Ra,[t[44]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Penalty Multiplier`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Escalation factor`)],-1),f.value?(w(),C(`div`,Ba,[m(S(`input`,{"onUpdate:modelValue":t[8]||=e=>U.value=e,type:`number`,min:`1`,max:`5`,step:`0.5`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,U.value,void 0,{number:!0}]]),t[43]||=S(`span`,{class:`text-content-muted text-sm`},`x`,-1)])):(w(),C(`div`,za,b(U.value)+`x `,1))]),S(`div`,Va,[t[46]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Max Penalty Duration`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Maximum cooldown cap`)],-1),f.value?(w(),C(`div`,Ua,[m(S(`input`,{"onUpdate:modelValue":t[9]||=e=>W.value=e,type:`number`,min:`1`,max:`168`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,W.value,void 0,{number:!0}]]),t[45]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(w(),C(`div`,Ha,b(W.value)+` hours `,1))])]),S(`div`,Wa,[t[58]||=d(`

Adaptive Rate Limiting

How the three systems work together: Each layer can be enabled/disabled independently and the others will still function.

  • Rate Limiting OFF: All limiting disabled — adverts pass through freely
  • Adaptive OFF: Token bucket uses fixed limits (no tier scaling), penalty box still works
  • Penalty Box OFF: Token bucket still applies, but no escalating cooldowns for repeat offenders

Decision flow when all enabled: Adaptive tier check → Penalty box check → Token bucket check → Violation recording (triggers penalty box)

Activity tiers:Quiet (bypass limiting) → Normal (lighter: 0.5x intervals) → Busy (base: 1.0x intervals) → Congested (stricter: 2.0x intervals)

Note: Adaptive mode scales refill/min-interval timing; bucket capacity stays at the configured base value.

`,2),S(`div`,Ga,[t[50]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Adaptive Mode`,-1),f.value?m((w(),C(`select`,{key:1,"onUpdate:modelValue":t[10]||=e=>G.value=e,class:`w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},[...t[49]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[P,G.value]]):(w(),C(`div`,Ka,b(G.value?`Enabled`:`Disabled`),1))]),S(`div`,qa,[t[52]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Tier Change Delay`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Prevents tier flapping`)],-1),f.value?(w(),C(`div`,Ya,[m(S(`input`,{"onUpdate:modelValue":t[11]||=e=>K.value=e,type:`number`,min:`0`,max:`60`,class:`w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary`},null,512),[[F,K.value,void 0,{number:!0}]]),t[51]||=S(`span`,{class:`text-content-muted text-sm`},`min`,-1)])):(w(),C(`div`,Ja,b(K.value)+` min `,1))]),S(`div`,Xa,[t[56]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm mb-2 block`},`Activity Tier Thresholds (adverts/min)`,-1),S(`div`,Za,[S(`div`,Qa,[t[53]||=S(`div`,{class:`text-xs text-green-600 dark:text-green-400 mb-1`},`Quiet Max`,-1),f.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[12]||=e=>ne.value=e,type:`number`,min:`0`,max:`1`,step:`0.01`,class:`w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary`},null,512)),[[F,ne.value,void 0,{number:!0}]]):(w(),C(`div`,$a,b(ne.value),1))]),S(`div`,eo,[t[54]||=S(`div`,{class:`text-xs text-blue-600 dark:text-blue-400 mb-1`},`Normal Max`,-1),f.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[13]||=e=>q.value=e,type:`number`,min:`0`,max:`5`,step:`0.01`,class:`w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary`},null,512)),[[F,q.value,void 0,{number:!0}]]):(w(),C(`div`,to,b(q.value),1))]),S(`div`,no,[t[55]||=S(`div`,{class:`text-xs text-yellow-600 dark:text-yellow-400 mb-1`},`Busy Max`,-1),f.value?m((w(),C(`input`,{key:1,"onUpdate:modelValue":t[14]||=e=>J.value=e,type:`number`,min:`0`,max:`10`,step:`0.01`,class:`w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary`},null,512)),[[F,J.value,void 0,{number:!0}]]):(w(),C(`div`,ro,b(J.value),1))])]),t[57]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted mt-2`},` Above Busy Max = Congested tier (strictest limiting) `,-1)])]),D.value?(w(),C(`div`,{key:2,class:`fixed inset-0 bg-black/50 flex items-start justify-center z-50 p-4 overflow-y-auto`,onClick:t[18]||=I(e=>D.value=!1,[`self`])},[S(`div`,{class:`bg-background dark:bg-background-dark rounded-lg shadow-xl max-w-3xl w-full my-8`,onClick:t[17]||=I(()=>{},[`stop`])},[S(`div`,io,[S(`div`,ao,[t[60]||=S(`h2`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` How Advert Rate Limiting Works `,-1),S(`button`,{onClick:t[15]||=e=>D.value=!1,class:`text-content-muted hover:text-content-primary dark:text-content-muted dark:hover:text-content-primary`},[...t[59]||=[S(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),t[61]||=d(`

Why you may see the same advert more than once

Mesh traffic can reach your repeater through different paths, so duplicate advert packets are expected.

  • First copy arrives and is forwarded
  • Second copy arrives through another repeater path
  • Later copies may be dropped once limits are hit

This is normal behavior and helps prevent repeated rebroadcasts from flooding the mesh.

Token Bucket Rate Limiting

Each sender has a token bucket. Every forwarded advert uses one token.

  • Bucket Capacity: How many adverts can pass in a burst.
  • Refill Rate: How quickly tokens come back over time.
  • Min Interval: Optional gap between adverts from the same sender (usually set to 0).
Example (capacity 2):
- Copy 1 forwarded (2 → 1 tokens)
- Copy 2 forwarded (1 → 0 tokens)
- Copy 3 dropped (no tokens left)

Penalty Box (Repeat Offenders)

If a sender keeps hitting the limit, it is temporarily blocked.

  • Violation Threshold: How many hits before penalty starts.
  • Base Penalty: First block duration.
  • Multiplier: Repeated penalties get longer.
  • Decay Time: Violations age out after stable behavior.

Adaptive Mesh Activity Tiers

Adaptive mode adjusts limits based on recent advert activity.

How Congestion is Measured:
  • What is counted: Advert packets only (not chat/data traffic)
  • Smoothing: 60-second EWMA to avoid reacting to short spikes
  • Score: Tier is based on adverts per minute
  • Hysteresis: Tier changes must hold for 5 minutes
QUIET
Activity < 0.05/min
No rate limiting
NORMAL
Activity 0.05-0.20/min
Light limiting (50%)
BUSY
Activity 0.20-0.50/min
Standard limiting (100%)
CONGESTED
Activity > 0.50/min
Aggressive (200%)
Quick examples:
- 0.02 adverts/min → QUIET (bypass)
- 0.35 adverts/min → BUSY (tighter limits)
- 0.68 adverts/min → CONGESTED (strict limits)

Recommended starting settings

  • Min Interval: 0 (disabled), let adaptive mode do the work
  • Bucket Capacity: 2-3 tokens for normal mesh propagation
  • Adaptive Mode: On
  • Penalty Box: On
`,5),S(`div`,oo,[S(`button`,{onClick:t[16]||=e=>D.value=!1,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Got it! `)])])])])):g(``,!0)]))}}),co=[{name:`US West only (US v1)`,website:`letsmesh.net`,brokers:[{enabled:!0,name:`MeshMapper`,host:`mqtt-us-v1.letsmesh.net`,port:443,audience:`mqtt-us-v1.letsmesh.net`,use_jwt_auth:!0,format:`letsmesh`,transport:`websockets`,retain_status:!1,tls:{enabled:!0,insecure:!1}}]},{name:`Europe only (EU v1)`,website:`letsmesh.net`,brokers:[{enabled:!0,name:`MeshMapper`,host:`mqtt-eu-v1.letsmesh.net`,port:443,audience:`mqtt-eu-v1.letsmesh.net`,use_jwt_auth:!0,format:`letsmesh`,transport:`websockets`,retain_status:!1,tls:{enabled:!0,insecure:!1}}]},{name:`MeshMapper`,website:`https://meshmapper.net`,brokers:[{enabled:!0,name:`MeshMapper`,host:`mqtt.meshmapper.cc`,port:443,audience:`mqtt.meshmapper.cc`,use_jwt_auth:!0,format:`letsmesh`,transport:`websockets`,retain_status:!1,tls:{enabled:!0,insecure:!1}}]}],lo={class:`space-y-6`},uo={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},fo={class:`flex items-center justify-between mb-4`},po=[`disabled`],mo={key:0},ho={key:1},go={key:0,class:`text-sm text-content-secondary dark:text-content-muted`},_o={key:1,class:`space-y-3`},vo={class:`flex items-center gap-2`},yo={key:0,class:`space-y-2`},bo=[`title`],xo={key:1,class:`text-sm text-content-muted dark:text-content-muted/60 italic`},So={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Co={class:`flex items-start justify-between mb-6`},wo={key:0,class:`space-y-4`},To={class:`grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3`},Eo={class:`mt-1 text-sm text-content-primary dark:text-content-primary font-mono`},Do={class:`mt-1 text-sm text-content-primary dark:text-content-primary`},Oo={class:`mt-1 text-sm text-content-primary dark:text-content-primary`},ko={class:`mt-1 text-sm text-content-primary dark:text-content-primary`},Ao={key:0,class:`mt-2 text-sm text-content-muted dark:text-content-muted/60 italic`},jo={key:1,class:`mt-2 space-y-1.5`},Mo={class:`min-w-0 flex-1`},No={class:u([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`])},Po={key:0,class:`w-4 h-4 text-green-600 dark:text-green-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Fo={class:`text-sm font-medium text-content-primary dark:text-content-primary`},Io={class:`text-xs text-content-secondary dark:text-content-muted ml-2 font-mono`},Lo=[`title`],Ro={key:1,class:`space-y-5`},zo={class:`grid grid-cols-1 sm:grid-cols-2 gap-4`},Bo={class:`grid grid-cols-1 sm:grid-cols-2 gap-4`},Vo={class:`grid grid-cols-1 sm:grid-cols-2 gap-4`},Ho={class:`flex items-start justify-between mb-3 gap-3`},Uo={class:`flex items-center gap-2 flex-shrink-0`},Wo={class:`relative`},Go={key:0,class:`absolute right-0 top-full mt-1 z-20 w-64 rounded-lg shadow-lg border border-stroke-subtle dark:border-stroke/20 bg-white dark:bg-[var(--color-surface)] overflow-hidden`},Ko={class:`py-1`},qo=[`onClick`],Jo={class:`min-w-0 flex-1`},Yo={class:`text-sm font-medium text-content-primary dark:text-content-primary group-hover:text-cyan-700 dark:group-hover:text-primary transition-colors`},Xo={class:`text-xs text-content-secondary dark:text-content-muted`},Zo=[`href`],Qo={key:0,class:`flex flex-col items-center justify-center py-7 rounded-lg border-2 border-dashed border-stroke-subtle dark:border-stroke/20 text-content-secondary dark:text-content-muted`},$o={key:1,class:`space-y-2`},es={key:0,class:`flex items-center gap-3 px-4 py-2.5`},ts={class:`min-w-0 flex-1`},ns={class:`text-sm font-medium text-content-primary dark:text-content-primary`},rs={class:`text-xs font-mono text-content-secondary dark:text-content-muted ml-2`},is={key:0,class:`ml-2 text-xs text-red-500 dark:text-red-400`},as={class:`flex items-center gap-0.5 flex-shrink-0`},os=[`onClick`],ss=[`onClick`],cs={key:1,class:`p-4 space-y-3 bg-background-mute/60 dark:bg-background/20`},ls={class:`grid grid-cols-1 sm:grid-cols-2 gap-3`},us={class:`grid grid-cols-1 sm:grid-cols-2 gap-3`},ds={class:`sm:col-span-2`},fs={key:0},ps={key:1},ms={class:`grid grid-cols-1 sm:grid-cols-2 gap-3`},hs={class:`sm:col-span-2`},gs={class:`sm:col-span-2`},_s={key:2},vs={class:`col-span-full`},ys={class:`flex flex-wrap gap-2`},bs=[`onClick`],xs={class:`flex items-center gap-2 pt-1`},Ss=[`disabled`],Cs=[`onClick`],ws={key:0,class:`p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-700/30 text-green-700 dark:text-green-400 text-sm`},Ts={key:1,class:`p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-700/30 text-red-700 dark:text-red-400 text-sm`},Es={class:`flex items-center gap-3 pt-2`},Ds=[`disabled`],Os={key:0},ks={key:1},As=[`disabled`],js=M(f({__name:`LetsMeshSettings`,setup(e){let n=j(),r=v(()=>n.stats?.config?.mqtt_brokers||{}),o=[`REQ`,`RESPONSE`,`TXT_MSG`,`ACK`,`ADVERT`,`GRP_TXT`,`GRP_DATA`,`ANON_REQ`,`PATH`,`TRACE`,`RAW_CUSTOM`],c=co,l=E(!1),d=E(!1),f=E(``),p=E(``),T=E(``),D=E(300),O=E(``),A=E(``),M=E([]),R=E(null),z=E({_id:0,enabled:!0,name:``,host:``,port:443,format:`letsmesh`,use_jwt_auth:!1,transport:`websockets`,disallowedInput:[],retain_status:!1,tls:{enabled:!0,insecure:!1}}),B=E(!1);function V(e){B.value=!1,R.value!==null&&K(),e.brokers.forEach(e=>{let t=H(e);M.value.push(t)})}let ee=1;function H(e={}){return{_id:ee++,enabled:e.enabled??!0,name:e.name??``,host:e.host??``,port:e.port??0,audience:e.audience??``,format:e.format??`letsmesh`,use_jwt_auth:e.use_jwt_auth??!1,username:e.username??``,password:e.password??``,transport:e.transport??`websockets`,disallowedInput:Array.isArray(e.disallowedInput)?[...e.disallowedInput]:[],retain_status:e.retain_status??!1,base_topic:e.base_topic??``,tls:{enabled:e.tls?.enabled??!1,insecure:e.tls?.insecure??!1}}}function U(){let e=H();M.value.push(e),z.value={...e},R.value=e._id}function W(e){M.value=M.value.filter(t=>t._id!==e),R.value===e&&(R.value=null)}function G(e){z.value={...e},R.value=e._id}function te(){R.value=null}function K(){let e=z.value;if(!e.name.trim()||!e.host.trim()||e.use_jwt_auth&&!e.audience?.trim())return;let t=M.value.findIndex(t=>t._id===e._id);t!==-1&&M.value.splice(t,1,{...e}),R.value=null}function ne(){let e=z.value;(!e.audience||e.audience===e.host)&&(e.audience=e.host)}let q=v(()=>{let e={};return M.value.forEach(t=>{t.name.trim()?t.host.trim()?t.use_jwt_auth&&!t.audience?.trim()?e[t._id]=`Audience required for JWT auth`:(t.port<1||t.port>65535)&&(e[t._id]=`Port must be 1–65535`):e[t._id]=`Host required`:e[t._id]=`Name required`}),e}),J=v(()=>Object.keys(q.value).length>0),Y=E(null),X=E(!1);async function Z(){X.value=!0;try{let e=await k.get(`/api/mqtt_status`);e.data?.success&&(Y.value=e.data.data)}catch{}finally{X.value=!1}}function Q(){let e=r.value;T.value=e.iata_code??``,D.value=e.status_interval??300,O.value=e.owner??``,A.value=e.email??``,M.value=Array.isArray(e.brokers)?e.brokers.map(e=>H(e)):[]}h(r,()=>{l.value||Q()},{immediate:!0});function re(){Q(),R.value=null,l.value=!0,f.value=``,p.value=``}function $(){R.value=null,l.value=!1,f.value=``,p.value=``}function ie(e,t){e.disallowedInput||=[];let n=e.disallowedInput.indexOf(t);n===-1?e.disallowedInput.push(t):e.disallowedInput.splice(n,1)}async function ae(){if(R.value!==null&&K(),J.value){p.value=`Please fix broker errors before saving.`;return}d.value=!0,p.value=``,f.value=``;try{let e=(await k.post(`/api/update_mqtt_config`,{iata_code:T.value,status_interval:D.value,owner:O.value,email:A.value,brokers:M.value.map(e=>{let t={name:e.name,enabled:e.enabled,transport:e.transport,host:e.host,port:e.port,use_jwt_auth:e.use_jwt_auth,format:e.format,disallowed_packet_types:e.disallowedInput,base_topic:e.base_topic,retain_status:e.retain_status,tls:{enabled:e.tls?.enabled??!1,insecure:e.tls?.insecure??!1}};return e.use_jwt_auth?{...t,audience:e.audience}:{...t,username:e.username,password:e.password}})})).data;e?.success?(f.value=e.data?.message||`Settings saved`,l.value=!1,await n.fetchStats(),await Z(),setTimeout(()=>{f.value=``},5e3)):p.value=e?.error||`Save failed`}catch(e){let t=e;p.value=t?.response?.data?.error||t?.message||`Request failed`}finally{d.value=!1}}return s(Z),(e,n)=>(w(),C(`div`,lo,[S(`div`,uo,[S(`div`,fo,[n[21]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Observer Status `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Live LetsMesh broker connection state `)],-1),S(`button`,{onClick:Z,disabled:X.value,class:`px-3 py-1.5 text-xs rounded-lg bg-cyan-500/10 dark:bg-primary/10 hover:bg-cyan-500/20 dark:hover:bg-primary/20 text-cyan-700 dark:text-primary border border-cyan-400/30 dark:border-primary/30 transition-colors disabled:opacity-50`},[X.value?(w(),C(`span`,mo,`Refreshing…`)):(w(),C(`span`,ho,`↻ Refresh`))],8,po)]),Y.value?(w(),C(`div`,_o,[S(`div`,vo,[n[22]||=S(`span`,{class:`text-sm text-content-secondary dark:text-content-muted w-36`},`Handler`,-1),S(`span`,{class:u([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`,Y.value.handler_active?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-gray-800/50 text-gray-500 dark:text-gray-400`])},[S(`span`,{class:u([`w-1.5 h-1.5 rounded-full`,Y.value.handler_active?`bg-green-500`:`bg-gray-400`])},null,2),y(` `+b(Y.value.handler_active?`Active`:`Inactive`),1)],2)]),Y.value.brokers.length?(w(),C(`div`,yo,[(w(!0),C(x,null,i(Y.value.brokers,e=>(w(),C(`div`,{key:e.host,class:`flex items-center gap-2`},[S(`span`,{class:`text-sm text-content-secondary dark:text-content-muted w-36 truncate`,title:e.name},b(e.name),9,bo),S(`span`,{class:u([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`,e.status.connected?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:e.status.reconnecting?`bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400`:`bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400`])},[S(`span`,{class:u([`w-1.5 h-1.5 rounded-full`,e.status.connected?`bg-green-500`:e.status.reconnecting?`bg-amber-500`:`bg-red-500`])},null,2),y(` `+b(e.status.connected?`Connected`:e.status.reconnecting?`Reconnecting…`:`Disconnected`),1)],2)]))),128))])):(w(),C(`div`,xo,` No broker connections configured. `))])):(w(),C(`div`,go,` Status unavailable — service may not be running. `))]),S(`div`,So,[S(`div`,Co,[n[23]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Observer Configuration `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Configure MQTT observer settings `)],-1),l.value?g(``,!0):(w(),C(`button`,{key:0,onClick:re,class:`px-4 py-2 text-sm rounded-lg bg-cyan-500/10 dark:bg-primary/10 hover:bg-cyan-500/20 dark:hover:bg-primary/20 text-cyan-700 dark:text-primary border border-cyan-400/30 dark:border-primary/30 transition-colors`},` Edit `))]),l.value?(w(),C(`div`,Ro,[S(`div`,zo,[S(`div`,null,[n[30]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-1.5`},[y(` IATA Code `),S(`span`,{class:`text-content-secondary dark:text-content-muted font-normal text-xs ml-1`},`(e.g. SFO, LHR)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[0]||=e=>T.value=e,type:`text`,maxlength:`10`,placeholder:`TEST`,class:`w-full px-3 py-2 text-sm rounded-lg bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[F,T.value]])])]),S(`div`,Bo,[S(`div`,null,[n[31]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-1.5`},`Owner / Callsign`,-1),m(S(`input`,{"onUpdate:modelValue":n[1]||=e=>O.value=e,type:`text`,placeholder:`Optional`,class:`w-full px-3 py-2 text-sm rounded-lg bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[F,O.value]])]),S(`div`,null,[n[32]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-1.5`},`Email`,-1),m(S(`input`,{"onUpdate:modelValue":n[2]||=e=>A.value=e,type:`email`,placeholder:`Optional`,class:`w-full px-3 py-2 text-sm rounded-lg bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[F,A.value]])])]),S(`div`,Vo,[n[33]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-1.5`},[y(` Status Heartbeat Interval `),S(`span`,{class:`text-content-secondary dark:text-content-muted font-normal text-xs ml-1`},`(seconds, min 60)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[3]||=e=>D.value=e,type:`number`,min:`60`,max:`3600`,class:`w-32 px-3 py-2 text-sm rounded-lg bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[F,D.value,void 0,{number:!0}]])]),S(`div`,null,[S(`div`,Ho,[n[40]||=S(`div`,{class:`min-w-0`},[S(`label`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Brokers`),S(`p`,{class:`text-xs text-content-secondary dark:text-content-muted mt-0.5`},` MQTT brokers `)],-1),S(`div`,Uo,[S(`div`,Wo,[S(`button`,{onClick:n[4]||=e=>B.value=!B.value,class:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-background-mute dark:bg-background/30 hover:bg-stroke-subtle dark:hover:bg-stroke/10 text-content-secondary dark:text-content-muted border border-stroke-subtle dark:border-stroke/20 transition-colors`},[n[35]||=S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 11H5m14 0l-4-4m4 4l-4 4`})],-1),n[36]||=y(` From Template `,-1),(w(),C(`svg`,{class:u([`w-3 h-3 ml-0.5 transition-transform`,B.value?`rotate-180`:``]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...n[34]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]],2))]),_(N,{name:`dropdown`},{default:t(()=>[B.value?(w(),C(`div`,Go,[n[38]||=S(`div`,{class:`px-3 py-2 border-b border-stroke-subtle dark:border-stroke/10`},[S(`p`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},` Known Networks `)],-1),S(`div`,Ko,[(w(!0),C(x,null,i(a(c),e=>(w(),C(`div`,{key:e.name,class:`flex items-center gap-2 px-3 py-2.5 hover:bg-background-mute dark:hover:bg-background/30 cursor-pointer group`,onClick:t=>V(e)},[S(`div`,Jo,[S(`p`,Yo,b(e.name),1),S(`p`,Xo,b(e.brokers.length)+` broker`+b(e.brokers.length===1?``:`s`),1)]),S(`a`,{href:e.website,target:`_blank`,rel:`noopener noreferrer`,title:`Visit website`,class:`flex-shrink-0 p-1 rounded hover:bg-cyan-500/10 dark:hover:bg-primary/10 text-content-secondary dark:text-content-muted hover:text-cyan-700 dark:hover:text-primary transition-colors`,onClick:n[5]||=I(()=>{},[`stop`])},[...n[37]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14`})],-1)]],8,Zo)],8,qo))),128))])])):g(``,!0)]),_:1}),B.value?(w(),C(`div`,{key:0,class:`fixed inset-0 z-10`,onClick:n[6]||=e=>B.value=!1})):g(``,!0)]),S(`button`,{onClick:U,class:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-cyan-500/10 dark:bg-primary/10 hover:bg-cyan-500/20 dark:hover:bg-primary/20 text-cyan-700 dark:text-primary border border-cyan-400/30 dark:border-primary/30 transition-colors`},[...n[39]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),y(` Add `,-1)]])])]),M.value.length?(w(),C(`div`,$o,[(w(!0),C(x,null,i(M.value,e=>(w(),C(`div`,{key:e._id,class:u([`rounded-lg border overflow-hidden transition-colors`,q.value[e._id]?`border-red-300 dark:border-red-700/50`:`border-stroke-subtle dark:border-stroke/10`])},[R.value===e._id?(w(),C(`div`,cs,[S(`div`,ls,[S(`div`,null,[n[44]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Enabled `),S(`span`,{class:`text-red-500`},`*`)],-1),m(S(`input`,{"onUpdate:modelValue":n[7]||=e=>z.value.enabled=e,type:`checkbox`,class:`w-4 h-4 text-cyan-600 bg-background-mute border-stroke-subtle dark:border-stroke/20 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[L,z.value.enabled]])]),S(`div`,null,[n[45]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Retain Status`),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},[y(` (Enable MQTT `),S(`a`,{href:`https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/`,class:`w-4 h-4 text-cyan-600 border-stroke-subtle dark:border-stroke/20 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},`Retained`),y(` for status messages) `)])],-1),m(S(`input`,{"onUpdate:modelValue":n[8]||=e=>z.value.retain_status=e,type:`checkbox`,class:`w-4 h-4 text-cyan-600 bg-background-mute border-stroke-subtle dark:border-stroke/20 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[L,z.value.retain_status]])]),S(`div`,null,[n[46]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Name `),S(`span`,{class:`text-red-500`},`*`)],-1),m(S(`input`,{"onUpdate:modelValue":n[9]||=e=>z.value.name=e,type:`text`,placeholder:`Broker Name`,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[F,z.value.name]])]),S(`div`,null,[n[48]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Transport `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`})],-1),m(S(`select`,{"onUpdate:modelValue":n[10]||=e=>z.value.transport=e,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},[...n[47]||=[S(`option`,{value:`websockets`},`Websockets`,-1),S(`option`,{value:`tcp`},`TCP`,-1)]],512),[[P,z.value.transport]])]),S(`div`,null,[n[49]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Host `),S(`span`,{class:`text-red-500`},`*`)],-1),m(S(`input`,{"onUpdate:modelValue":n[11]||=e=>z.value.host=e,type:`text`,placeholder:`mqtt.myserver.com`,onBlur:ne,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,544),[[F,z.value.host]])]),S(`div`,us,[S(`div`,ds,[n[50]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Port `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(Usually 443 for Websockets, 1883 for TCP)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[12]||=e=>z.value.port=e,type:`number`,min:`0`,max:`65535`,placeholder:`0`,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[F,z.value.port,void 0,{number:!0}]])]),S(`div`,null,[n[51]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` TLS - Enabled `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(Enable TLS)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[13]||=e=>z.value.tls.enabled=e,type:`checkbox`,class:`px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[L,z.value.tls.enabled,void 0,{number:!0}]])]),S(`div`,null,[n[52]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` TLS - Insecure`),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(Allow insecure TLS connections)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[14]||=e=>z.value.tls.insecure=e,type:`checkbox`,class:`px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[L,z.value.tls.insecure,void 0,{number:!0}]])])]),S(`div`,null,[n[53]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Use JWT Auth `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`})],-1),m(S(`input`,{"onUpdate:modelValue":n[15]||=e=>z.value.use_jwt_auth=e,type:`checkbox`,placeholder:`true`,class:`px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[L,z.value.use_jwt_auth]])]),z.value.use_jwt_auth?(w(),C(`div`,fs,[n[54]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Audience `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(JWT aud — usually same as host)`)],-1),m(S(`input`,{"onUpdate:modelValue":n[16]||=e=>z.value.audience=e,type:`text`,placeholder:`mqtt.myserver.com`,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40 font-mono`},null,512),[[F,z.value.audience]])])):(w(),C(`div`,ps,[S(`div`,ms,[n[57]||=S(`input`,{type:`text`,autocomplete:`username`,style:{display:`none`}},null,-1),n[58]||=S(`input`,{type:`password`,autocomplete:`current-password`,style:{display:`none`}},null,-1),S(`div`,hs,[n[55]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Username `),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},` (Leave blank for anonymous auth) `)],-1),m(S(`input`,{autocomplete:`username`,"onUpdate:modelValue":n[17]||=e=>z.value.username=e,type:`text`,placeholder:`username`,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[F,z.value.username]])]),S(`div`,gs,[n[56]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},` Password `,-1),m(S(`input`,{autocomplete:`new-password`,"onUpdate:modelValue":n[18]||=e=>z.value.password=e,type:`password`,placeholder:``,readonly:``,onfocus:`this.removeAttribute('readonly');`,onblur:`this.setAttribute('readonly', true);`,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-content-muted dark:placeholder-content-muted/50 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},null,512),[[F,z.value.password]])])])])),S(`div`,null,[n[60]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` Format `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`})],-1),m(S(`select`,{"onUpdate:modelValue":n[19]||=e=>z.value.format=e,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`},[...n[59]||=[S(`option`,{value:`letsmesh`},`LetsMesh MQTT format`,-1),S(`option`,{value:`mqtt`},`pyMC MQTT format`,-1)]],512),[[P,z.value.format]])]),z.value.format===`mqtt`?(w(),C(`div`,_s,[n[61]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},[y(` MQTT base topic `),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(Messages are sent to topics under this path. Example: /advert) `)],-1),m(S(`input`,{"onUpdate:modelValue":n[20]||=e=>z.value.base_topic=e,class:`w-full px-3 py-1.5 text-sm rounded-md bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-cyan-500/40 dark:focus:ring-primary/40`,placeholder:`meshcore/repeater`},null,512),[[F,z.value.base_topic]])])):g(``,!0),S(`div`,vs,[n[62]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},[y(` Block Packet Types `),S(`span`,{class:`text-content-secondary dark:text-content-muted font-normal text-xs ml-1`},` (prevent publishing to LetsMesh) `)],-1),S(`div`,ys,[(w(),C(x,null,i(o,e=>S(`button`,{key:e,onClick:t=>ie(z.value,e),class:u([`px-2.5 py-1 rounded text-xs font-mono font-medium border transition-colors`,z.value.disallowedInput?.includes(e)?`bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-700 dark:text-red-400`:`bg-background-mute dark:bg-background/30 border-stroke-subtle dark:border-stroke/20 text-content-secondary dark:text-content-muted hover:border-cyan-400/50 dark:hover:border-primary/40`])},b(e),11,bs)),64))]),n[63]||=S(`p`,{class:`mt-1.5 text-xs text-content-secondary dark:text-content-muted`},[S(`span`,{class:`text-red-600 dark:text-red-400 font-medium`},`Red = blocked.`),y(` Leave all unselected to publish all packet types. `)],-1)])]),S(`div`,xs,[S(`button`,{onClick:K,disabled:!z.value.name.trim()||!z.value.host.trim()||z.value.port<=0||z.value.port>65535||z.value.use_jwt_auth&&!z.value.audience?.trim(),class:`px-3 py-1.5 text-xs font-medium rounded-md bg-cyan-600 dark:bg-teal-600 hover:bg-cyan-700 dark:hover:bg-teal-700 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed`},` Done `,8,Ss),S(`button`,{onClick:te,class:`px-3 py-1.5 text-xs rounded-md border border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-stroke/10 text-content-secondary dark:text-content-muted transition-colors`},` Cancel `),S(`button`,{onClick:t=>W(e._id),class:`ml-auto px-3 py-1.5 text-xs rounded-md border border-red-300/60 dark:border-red-700/30 hover:bg-red-50 dark:hover:bg-red-900/20 text-red-600 dark:text-red-400 transition-colors`},` Remove `,8,Cs)])])):(w(),C(`div`,es,[S(`div`,ts,[S(`span`,{class:u([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`,e.enabled?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400`])},[S(`span`,{class:u([`w-1.5 h-1.5 rounded-full`,e.enabled?`bg-green-500`:`bg-red-500`])},null,2),y(` `+b(e.enabled?`Enabled`:`Disabled`),1)],2),S(`span`,ns,b(e.name||`(unnamed)`),1),S(`span`,rs,b(e.host||`—`)+`:`+b(e.port),1),q.value[e._id]?(w(),C(`span`,is,b(q.value[e._id]),1)):g(``,!0)]),S(`div`,as,[S(`button`,{onClick:t=>G(e),title:`Edit`,class:`p-1.5 rounded hover:bg-cyan-500/10 dark:hover:bg-primary/10 text-content-secondary dark:text-content-muted hover:text-cyan-700 dark:hover:text-primary transition-colors`},[...n[42]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,os),S(`button`,{onClick:t=>W(e._id),title:`Remove`,class:`p-1.5 rounded hover:bg-red-500/10 dark:hover:bg-red-900/20 text-content-secondary dark:text-content-muted hover:text-red-600 dark:hover:text-red-400 transition-colors`},[...n[43]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,ss)])]))],2))),128))])):(w(),C(`div`,Qo,[...n[41]||=[S(`svg`,{class:`w-7 h-7 mb-2 opacity-40`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1.5`,d:`M5 12h14M5 12l4-4m-4 4l4 4`})],-1),S(`p`,{class:`text-sm`},`No brokers`,-1),S(`p`,{class:`text-xs mt-0.5 opacity-70`},`Add a MQTT broker`,-1)]]))]),n[64]||=S(`div`,{class:`flex items-start gap-2 p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700/30 text-amber-700 dark:text-amber-400 text-xs`},[S(`svg`,{class:`w-4 h-4 mt-0.5 flex-shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})]),y(` A service restart is required for MQTT broker changes to take effect. `)],-1),f.value?(w(),C(`div`,ws,b(f.value),1)):g(``,!0),p.value?(w(),C(`div`,Ts,b(p.value),1)):g(``,!0),S(`div`,Es,[S(`button`,{onClick:ae,disabled:d.value||J.value,class:`px-5 py-2 text-sm font-medium rounded-lg bg-cyan-600 dark:bg-teal-600 hover:bg-cyan-700 dark:hover:bg-teal-700 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed`},[d.value?(w(),C(`span`,Os,`Saving…`)):(w(),C(`span`,ks,`Save Settings`))],8,Ds),S(`button`,{onClick:$,disabled:d.value,class:`px-4 py-2 text-sm rounded-lg bg-background-mute dark:bg-background/30 hover:bg-stroke-subtle dark:hover:bg-stroke/10 text-content-secondary dark:text-content-muted border border-stroke-subtle dark:border-stroke/20 transition-colors disabled:opacity-50`},` Cancel `,8,As)])])):(w(),C(`div`,wo,[S(`div`,To,[S(`div`,null,[n[24]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`IATA Code`,-1),S(`p`,Eo,b(r.value.iata_code||`—`),1)]),S(`div`,null,[n[25]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`Status Interval`,-1),S(`p`,Do,b(r.value.status_interval??300)+`s `,1)]),S(`div`,null,[n[26]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`Owner`,-1),S(`p`,Oo,b(r.value.owner||`—`),1)]),S(`div`,null,[n[27]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`Email`,-1),S(`p`,ko,b(r.value.email||`—`),1)])]),S(`div`,null,[n[29]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`Brokers`,-1),r.value.brokers?.length?(w(),C(`div`,jo,[(w(!0),C(x,null,i(r.value.brokers,e=>(w(),C(`div`,{key:e.host,class:`flex items-center gap-3 px-3 py-2 rounded-lg bg-background-mute dark:bg-background/30 border border-stroke-subtle dark:border-stroke/10`},[S(`div`,Mo,[S(`span`,No,[e.enabled?(w(),C(`svg`,Po,[...n[28]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`},null,-1)]])):g(``,!0)]),S(`span`,Fo,b(e.name),1),S(`span`,Io,`Host: `+b(e.host)+`:`+b(e.port),1)]),S(`span`,{class:`text-xs text-content-secondary dark:text-content-muted font-mono truncate max-w-[140px]`,title:e.format},b(e.format),9,Lo)]))),128))])):(w(),C(`div`,Ao,` None configured `))])]))])]))}}),[[`__scopeId`,`data-v-45835eb1`]]),Ms={class:`space-y-6`},Ns={key:0,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-100 dark:bg-red-500/10 p-4`},Ps={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Fs=[`disabled`],Is={key:0,class:`flex items-center gap-2`},Ls={key:1,class:`flex items-center gap-2`},Rs={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-2`},zs={key:1,class:`text-xs text-red-500 dark:text-red-400 mt-2`},Bs={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Vs={key:0},Hs={key:1,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-50 dark:bg-red-500/10 p-4`},Us={class:`flex items-start gap-3`},Ws={class:`flex-1`},Gs={class:`text-xs text-red-600 dark:text-red-400/80 mt-1`},Ks={class:`flex gap-2 mt-3`},qs=[`disabled`],Js=[`disabled`],Ys={key:2,class:`text-xs text-green-600 dark:text-green-400 mt-2`},Xs={key:3,class:`text-xs text-red-500 dark:text-red-400 mt-2`},Zs={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Qs={class:`space-y-3`},$s={class:`flex items-center gap-3 cursor-pointer px-4 py-3 bg-background-mute dark:bg-background/30 rounded-lg border-2 border-dashed border-stroke-subtle dark:border-stroke/20 hover:border-cyan-500/50 dark:hover:border-primary/50 transition-colors`},ec={class:`text-sm text-content-secondary dark:text-content-muted`},tc={key:0,class:`bg-background-mute dark:bg-background/30 rounded-lg p-4 border border-stroke-subtle dark:border-stroke/10`},nc={key:0,class:`text-xs text-content-secondary dark:text-content-muted space-y-1 mb-3`},rc={class:`font-mono`},ic={class:`font-mono`},ac={key:0,class:`text-amber-600 dark:text-amber-400 font-medium`},oc={key:1,class:`text-content-muted`},sc={class:`text-xs text-content-secondary dark:text-content-muted`},cc={class:`font-mono`},lc={key:1},uc={key:2,class:`rounded-lg border-2 border-amber-500/50 dark:border-amber-400/40 bg-amber-50 dark:bg-amber-500/10 p-4`},dc={class:`flex items-start gap-3`},fc={class:`flex-1`},pc={class:`text-xs text-amber-700 dark:text-amber-300/80 mt-1`},mc={class:`flex gap-2 mt-3`},hc=[`disabled`],gc=[`disabled`],_c={key:3,class:`text-xs text-green-600 dark:text-green-400 mt-2`},vc={key:4,class:`text-xs text-red-500 dark:text-red-400 mt-2`},yc={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},bc={key:0},xc={key:1,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-50 dark:bg-red-500/10 p-4`},Sc={class:`flex items-start gap-3`},Cc={class:`flex-1`},wc={class:`text-xs text-red-600 dark:text-red-400/80 mt-1`},Tc={class:`flex gap-2 mt-3`},Ec=[`disabled`],Dc=[`disabled`],Oc={key:2,class:`bg-background-mute dark:bg-background/30 rounded-lg p-4 border border-stroke-subtle dark:border-stroke/10 space-y-2`},kc={class:`flex items-center justify-between`},Ac={class:`text-xs text-content-secondary dark:text-content-muted space-y-1`},jc={class:`font-mono`},Mc={key:0},Nc={class:`font-mono`},Pc={key:1},Fc={class:`font-mono text-[10px] break-all`},Ic={key:3,class:`text-xs text-red-500 dark:text-red-400 mt-2`},Lc=f({__name:`BackupRestore`,setup(e){let t=v(()=>window.location.protocol===`http:`),n=E(!1),r=E(``),i=E(``);async function a(){n.value=!0,r.value=``,i.value=``;try{let e=await A.exportConfig(!1);if(!e.success||!e.data){i.value=e.error||`Export failed`;return}let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),a=document.createElement(`a`);a.href=n,a.download=`pymc-repeater-settings-${(e.data.meta?.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`)}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n),r.value=`Settings exported successfully (secrets redacted).`}catch(e){i.value=e instanceof Error?e.message:`Export failed`}finally{n.value=!1}}let o=E(!1),s=E(!1),c=E(``),l=E(``);async function u(){s.value=!0,c.value=``,l.value=``;try{let e=await A.exportConfig(!0);if(!e.success||!e.data){l.value=e.error||`Export failed`;return}let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pymc-repeater-full-backup-${(e.data.meta?.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),c.value=`Full backup exported (includes all secrets).`,o.value=!1}catch(e){l.value=e instanceof Error?e.message:`Export failed`}finally{s.value=!1}}let f=E(null),p=E(null),m=E(!1),h=E(!1),_=E(``),T=E(``),D=E(null),O=v(()=>p.value?.config?Object.keys(p.value.config).join(`, `):``),k=v(()=>{let e=p.value?.meta?.includes_secrets;return e===!0||e===`true`});function j(e){let t=e.target.files?.[0];if(!t)return;f.value=t,p.value=null,m.value=!1,_.value=``,T.value=``;let n=new FileReader;n.onload=e=>{try{let t=JSON.parse(e.target?.result);t.config&&typeof t.config==`object`?p.value={meta:t.meta,config:t.config}:typeof t==`object`&&!Array.isArray(t)?p.value={config:t}:T.value=`Invalid file format — expected a JSON config object.`}catch{T.value=`Invalid JSON file.`}},n.readAsText(t)}function M(){m.value=!1,p.value=null,f.value=null,D.value&&(D.value.value=``)}async function N(){if(p.value?.config){h.value=!0,_.value=``,T.value=``;try{let e=await A.importConfig(p.value.config);if(e.success){let t=e.data,n=e.message||t?.message||`Configuration imported.`;t?.restart_required&&(n+=` A service restart is required for radio changes to take effect.`),_.value=n,m.value=!1,p.value=null,f.value=null,D.value&&(D.value.value=``)}else T.value=e.error||`Import failed`}catch(e){T.value=e instanceof Error?e.message:`Import failed`}finally{h.value=!1}}}let P=E(!1),F=E(!1),I=E(null),L=E(``);async function R(){F.value=!0,L.value=``;try{let e=await A.exportIdentityKey();if(!e.success||!e.data){L.value=e.error||`Export failed`;return}I.value=e.data;let t=new Blob([e.data.identity_key_hex],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pymc-identity-${e.data.node_address||`key`}.hex`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(e){L.value=e instanceof Error?e.message:`Export failed`}finally{F.value=!1}}return(e,v)=>(w(),C(`div`,Ms,[t.value?(w(),C(`div`,Ns,[...v[6]||=[d(`

Unencrypted Connection

This page is served over HTTP, not HTTPS. Exported data (including identity keys) will be transmitted in plain text. Only use these features on a trusted local network.

`,1)]])):g(``,!0),S(`div`,Ps,[v[9]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Export Settings `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},[y(` Download the current configuration as a JSON file. Passwords, JWT secrets, and identity keys are `),S(`strong`,null,`redacted`),y(`. Safe to share or use as a template for other devices. `)])])],-1),S(`button`,{onClick:a,disabled:n.value,class:`px-4 py-2 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm`},[n.value?(w(),C(`span`,Is,[...v[7]||=[S(`span`,{class:`animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full inline-block`},null,-1),y(` Exporting… `,-1)]])):(w(),C(`span`,Ls,[...v[8]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4`})],-1),y(` Export Settings `,-1)]]))],8,Fs),r.value?(w(),C(`p`,Rs,b(r.value),1)):g(``,!0),i.value?(w(),C(`p`,zs,b(i.value),1)):g(``,!0)]),S(`div`,Bs,[v[15]||=d(`

Full Backup

Download a complete backup including all passwords, JWT secrets, and identity keys. Required for restoring to a new device or recovering from a failed SD card.

Contains sensitive data. The backup file will include plain-text passwords and private keys. Store it securely and never share it.

`,2),o.value?g(``,!0):(w(),C(`div`,Vs,[S(`button`,{onClick:v[0]||=e=>o.value=!0,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm`},[...v[10]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z`})]),y(` Full Backup `)],-1)]])])),o.value?(w(),C(`div`,Hs,[S(`div`,Us,[v[14]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,Ws,[v[13]||=S(`h4`,{class:`text-sm font-semibold text-red-700 dark:text-red-400`},` Confirm Full Backup `,-1),S(`p`,Gs,[v[11]||=y(` This will export `,-1),v[12]||=S(`strong`,null,`all secrets in plain text`,-1),y(` including admin/guest passwords, JWT secret, and your repeater's private identity key`+b(t.value?` over an unencrypted HTTP connection`:``)+`. `,1)]),S(`div`,Ks,[S(`button`,{onClick:u,disabled:s.value,class:`px-4 py-2 bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},b(s.value?`Exporting…`:`Yes, Export Full Backup`),9,qs),S(`button`,{onClick:v[1]||=e=>o.value=!1,disabled:s.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,Js)])])])])):g(``,!0),c.value?(w(),C(`p`,Ys,b(c.value),1)):g(``,!0),l.value?(w(),C(`p`,Xs,b(l.value),1)):g(``,!0)]),S(`div`,Zs,[v[29]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Import Configuration `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},[y(` Restore configuration from a previously exported JSON file. Importing a `),S(`strong`,null,`full backup`),y(` will also restore passwords and identity keys. Importing a `),S(`strong`,null,`settings export`),y(` will only update non-sensitive settings. `)])])],-1),S(`div`,Qs,[S(`label`,$s,[v[16]||=S(`svg`,{class:`w-5 h-5 text-content-secondary dark:text-content-muted`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12`})],-1),S(`span`,ec,b(f.value?f.value.name:`Choose a config JSON file…`),1),S(`input`,{ref_key:`fileInputRef`,ref:D,type:`file`,accept:`.json,application/json`,class:`hidden`,onChange:j},null,544)]),p.value?(w(),C(`div`,tc,[v[20]||=S(`h4`,{class:`text-sm font-medium text-content-primary dark:text-content-primary mb-2`},` Import Preview `,-1),p.value.meta?(w(),C(`div`,nc,[S(`p`,null,[v[17]||=y(` Exported: `,-1),S(`span`,rc,b(p.value.meta.exported_at),1)]),S(`p`,null,[v[18]||=y(` Version: `,-1),S(`span`,ic,b(p.value.meta.version),1)]),p.value.meta.includes_secrets===`true`||p.value.meta.includes_secrets===!0?(w(),C(`p`,ac,` ⚠ Full backup — will restore passwords and identity keys `)):(w(),C(`p`,oc,` Settings only — existing secrets will not be changed `))])):g(``,!0),S(`p`,sc,[v[19]||=y(` Sections: `,-1),S(`span`,cc,b(O.value),1)])])):g(``,!0),p.value&&!m.value?(w(),C(`div`,lc,[S(`button`,{onClick:v[2]||=e=>m.value=!0,class:`px-4 py-2 bg-amber-500/20 dark:bg-amber-400/20 hover:bg-amber-500/30 dark:hover:bg-amber-400/30 text-amber-900 dark:text-amber-200 rounded-lg border border-amber-500/50 dark:border-amber-400/40 transition-colors text-sm`},` Review & Import `)])):g(``,!0),m.value?(w(),C(`div`,uc,[S(`div`,dc,[v[28]||=S(`svg`,{class:`w-5 h-5 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,fc,[v[27]||=S(`h4`,{class:`text-sm font-semibold text-amber-800 dark:text-amber-300`},` Confirm Import `,-1),S(`p`,pc,[v[24]||=y(` This will overwrite current settings for: `,-1),S(`strong`,null,b(O.value),1),v[25]||=y(`. `,-1),k.value?(w(),C(x,{key:0},[v[21]||=y(` This is a full backup — `,-1),v[22]||=S(`strong`,null,`passwords, JWT secrets, and identity keys will also be overwritten`,-1),v[23]||=y(`. `,-1)],64)):(w(),C(x,{key:1},[y(` Passwords and identity keys will not be changed. `)],64)),v[26]||=y(` Some changes (radio settings) require a service restart. `,-1)]),S(`div`,mc,[S(`button`,{onClick:N,disabled:h.value,class:`px-4 py-2 bg-amber-600 hover:bg-amber-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},b(h.value?`Importing…`:`Yes, Import`),9,hc),S(`button`,{onClick:M,disabled:h.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,gc)])])])])):g(``,!0),_.value?(w(),C(`p`,_c,b(_.value),1)):g(``,!0),T.value?(w(),C(`p`,vc,b(T.value),1)):g(``,!0)])]),S(`div`,yc,[v[38]||=d(`

Export Identity Key

Download the repeater's private identity key for backup. This key determines the node's address and cryptographic identity on the mesh.

Sensitive data. The identity key is the repeater's private key. Anyone with this key can impersonate your node. Store the exported file securely and never share it.

`,2),P.value?g(``,!0):(w(),C(`div`,bc,[S(`button`,{onClick:v[3]||=e=>P.value=!0,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm`},[...v[30]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})]),y(` Export Identity Key `)],-1)]])])),P.value&&!I.value?(w(),C(`div`,xc,[S(`div`,Sc,[v[32]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,Cc,[v[31]||=S(`h4`,{class:`text-sm font-semibold text-red-700 dark:text-red-400`},`Are you sure?`,-1),S(`p`,wc,` This will transmit your private key `+b(t.value?`over an unencrypted HTTP connection. `:``)+` and download it as a file. `,1),S(`div`,Tc,[S(`button`,{onClick:R,disabled:F.value,class:`px-4 py-2 bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},b(F.value?`Exporting…`:`Yes, Export Key`),9,Ec),S(`button`,{onClick:v[4]||=e=>P.value=!1,disabled:F.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,Dc)])])])])):g(``,!0),I.value?(w(),C(`div`,Oc,[S(`div`,kc,[v[33]||=S(`h4`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},` Key Exported `,-1),S(`button`,{onClick:v[5]||=e=>{I.value=null,P.value=!1},class:`text-xs text-content-muted hover:text-content-secondary transition-colors`},` Dismiss `)]),S(`div`,Ac,[S(`p`,null,[v[34]||=y(` Key length: `,-1),S(`span`,jc,b(I.value.key_length_bytes)+` bytes`,1)]),I.value.node_address?(w(),C(`p`,Mc,[v[35]||=y(` Node address: `,-1),S(`span`,Nc,b(I.value.node_address),1)])):g(``,!0),I.value.public_key_hex?(w(),C(`p`,Pc,[v[36]||=y(` Public key: `,-1),S(`span`,Fc,b(I.value.public_key_hex),1)])):g(``,!0)]),v[37]||=S(`p`,{class:`text-xs text-green-600 dark:text-green-400`},`File downloaded successfully.`,-1)])):g(``,!0),L.value?(w(),C(`p`,Ic,b(L.value),1)):g(``,!0)])]))}}),Rc={class:`space-y-6`},zc={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Bc={class:`flex items-start justify-between mb-4`},Vc=[`disabled`],Hc={key:0,class:`flex items-center gap-1.5`},Uc={key:1},Wc={key:0,class:`grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6`},Gc={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Kc={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},qc={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Jc={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Yc={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Xc={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Zc={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Qc={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},$c={key:1,class:`flex items-center justify-center py-12`},el={key:2,class:`rounded-lg border border-red-500/30 dark:border-red-400/30 bg-red-50 dark:bg-red-500/10 p-3 mb-4`},tl={class:`text-xs text-red-700 dark:text-red-400`},nl={key:3},rl={class:`overflow-x-auto`},il={class:`w-full text-sm`},al={class:`py-2.5 pr-4`},ol={class:`font-mono text-content-primary dark:text-content-primary`},sl={class:`py-2.5 pr-4 text-right`},cl={class:`font-mono text-content-secondary dark:text-content-muted`},ll={class:`py-2.5 pr-4 text-right hidden sm:table-cell`},ul={key:0,class:`text-xs text-content-muted`},dl={class:`text-content-muted/60 ml-1`},fl={key:1,class:`text-xs text-content-muted/50`},pl={key:2,class:`text-xs text-content-muted/50`},ml={class:`py-2.5 text-right`},hl=[`onClick`,`disabled`],gl={key:0,class:`flex items-center gap-1`},_l={key:1},vl={key:1,class:`text-xs text-content-muted/50`},yl={key:0,class:`glass-card rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-50 dark:bg-red-500/10 p-6`},bl={class:`flex items-start gap-3`},xl={class:`flex-1`},Sl={class:`text-sm font-semibold text-red-700 dark:text-red-400`},Cl={class:`text-xs text-red-600 dark:text-red-400/80 mt-1`},wl={class:`flex gap-2 mt-3`},Tl=[`disabled`],El=[`disabled`],Dl={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Ol={class:`flex flex-wrap gap-3`},kl=[`disabled`],Al=[`disabled`],jl={class:`flex items-center gap-2`},Ml={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-3`},Nl={key:1,class:`text-xs text-green-600 dark:text-green-400 mt-3`},Pl=f({__name:`DatabaseManagement`,setup(e){let t=new Set([`packets`,`adverts`,`noise_floor`,`crc_errors`,`room_messages`,`room_client_sync`,`companion_contacts`,`companion_channels`,`companion_messages`,`companion_prefs`]),n=E(!1),r=E(``),a=E(null),o=E({}),c=E(null),l=E(``),u=E(!1),d=E(``),f=v(()=>a.value?a.value.tables.reduce((e,t)=>e+t.row_count,0):0);function p(e){return t.has(e)}function m(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r<10?r.toFixed(1):Math.round(r)} ${t[n]}`}function h(e){return e?new Date(e*1e3).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`}):`—`}function _(e,t){return!e||!t?0:Math.max(1,Math.round((t-e)/86400))}async function T(){n.value=!0,r.value=``;try{let e=await A.getDbStats();e.success&&e.data?a.value=e.data:r.value=e.error||`Failed to load database stats`}catch(e){r.value=e instanceof Error?e.message:`Failed to load database stats`}finally{n.value=!1}}function D(e,t){l.value=``,c.value={table:e,rowCount:t,executing:!1}}async function O(){if(!c.value)return;let{table:e}=c.value;c.value.executing=!0,l.value=``;try{let t=e===`all`?`all`:[e];e!==`all`&&(o.value[e]=!0);let n=await A.purgeTable(t);if(n.success){let t=n.data||{};l.value=`Deleted ${Object.values(t).reduce((e,t)=>e+(t.deleted||0),0).toLocaleString()} rows${e===`all`?` from all tables`:` from ${e}`}.`,c.value=null,await T()}else r.value=n.error||`Purge failed`,c.value=null}catch(e){r.value=e instanceof Error?e.message:`Purge failed`,c.value=null}finally{e!==`all`&&(o.value[e]=!1)}}async function k(){u.value=!0,d.value=``,r.value=``;try{let e=await A.vacuumDb();if(e.success&&e.data){let t=e.data.freed_bytes;d.value=t>0?`Compacted database — freed ${m(t)} (${m(e.data.size_before)} → ${m(e.data.size_after)}).`:`Database already compact (${m(e.data.size_after)}).`,await T()}else r.value=e.error||`Vacuum failed`}catch(e){r.value=e instanceof Error?e.message:`Vacuum failed`}finally{u.value=!1}}return s(T),(e,t)=>(w(),C(`div`,Rc,[S(`div`,zc,[S(`div`,Bc,[t[3]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Database Overview `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Storage usage and table statistics for the repeater database. `)],-1),S(`button`,{onClick:T,disabled:n.value,class:`px-3 py-1.5 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors text-sm disabled:opacity-50`},[n.value?(w(),C(`span`,Hc,[...t[2]||=[S(`span`,{class:`animate-spin w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full inline-block`},null,-1),y(` Loading… `,-1)]])):(w(),C(`span`,Uc,`Refresh`))],8,Vc)]),a.value?(w(),C(`div`,Wc,[S(`div`,Gc,[t[4]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Database Size`,-1),S(`p`,Kc,b(m(a.value.database_size_bytes)),1)]),S(`div`,qc,[t[5]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`RRD Metrics`,-1),S(`p`,Jc,b(m(a.value.rrd_size_bytes)),1)]),S(`div`,Yc,[t[6]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Size`,-1),S(`p`,Xc,b(m(a.value.database_size_bytes+a.value.rrd_size_bytes)),1)]),S(`div`,Zc,[t[7]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Rows`,-1),S(`p`,Qc,b(f.value.toLocaleString()),1)])])):g(``,!0),n.value&&!a.value?(w(),C(`div`,$c,[...t[8]||=[S(`div`,{class:`text-center`},[S(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full mx-auto mb-4`}),S(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading database info…`)],-1)]])):g(``,!0),r.value?(w(),C(`div`,el,[S(`p`,tl,b(r.value),1)])):g(``,!0),a.value&&a.value.tables.length>0?(w(),C(`div`,nl,[S(`div`,rl,[S(`table`,il,[t[10]||=S(`thead`,null,[S(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[S(`th`,{class:`text-left py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider`},` Table `),S(`th`,{class:`text-right py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider`},` Rows `),S(`th`,{class:`text-right py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider hidden sm:table-cell`},` Date Range `),S(`th`,{class:`text-right py-2 text-xs font-medium text-content-muted uppercase tracking-wider`},` Actions `)])],-1),S(`tbody`,null,[(w(!0),C(x,null,i(a.value.tables,e=>(w(),C(`tr`,{key:e.name,class:`border-b border-stroke-subtle/50 dark:border-stroke/5`},[S(`td`,al,[S(`span`,ol,b(e.name),1)]),S(`td`,sl,[S(`span`,cl,b(e.row_count.toLocaleString()),1)]),S(`td`,ll,[e.has_timestamp&&e.row_count>0?(w(),C(`span`,ul,[y(b(h(e.oldest_timestamp))+` — `+b(h(e.newest_timestamp))+` `,1),S(`span`,dl,`(`+b(_(e.oldest_timestamp,e.newest_timestamp))+`d)`,1)])):e.row_count===0?(w(),C(`span`,fl,`—`)):(w(),C(`span`,pl,`n/a`))]),S(`td`,ml,[p(e.name)&&e.row_count>0?(w(),C(`button`,{key:0,onClick:t=>D(e.name,e.row_count),disabled:o.value[e.name],class:`px-2.5 py-1 bg-red-500/10 dark:bg-red-400/10 hover:bg-red-500/20 dark:hover:bg-red-400/20 text-red-700 dark:text-red-400 rounded border border-red-500/30 dark:border-red-400/20 transition-colors text-xs disabled:opacity-50`},[o.value[e.name]?(w(),C(`span`,gl,[...t[9]||=[S(`span`,{class:`animate-spin w-3 h-3 border border-current border-t-transparent rounded-full inline-block`},null,-1),y(` Purging… `,-1)]])):(w(),C(`span`,_l,`Empty`))],8,hl)):p(e.name)?g(``,!0):(w(),C(`span`,vl,`—`))])]))),128))])])])])):g(``,!0)]),c.value?(w(),C(`div`,yl,[S(`div`,bl,[t[16]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,xl,[S(`h4`,Sl,b(c.value.table===`all`?`Confirm Purge All Tables`:`Confirm Purge "${c.value.table}"`),1),S(`p`,Cl,[c.value.table===`all`?(w(),C(x,{key:0},[t[11]||=y(` This will permanently delete `,-1),t[12]||=S(`strong`,null,`all data`,-1),y(` from every data table (`+b(f.value.toLocaleString())+` rows total). This cannot be undone. `,1)],64)):(w(),C(x,{key:1},[t[13]||=y(` This will permanently delete `,-1),S(`strong`,null,b(c.value.rowCount.toLocaleString())+` rows`,1),t[14]||=y(` from `,-1),S(`strong`,null,b(c.value.table),1),t[15]||=y(`. This cannot be undone. `,-1)],64))]),S(`div`,wl,[S(`button`,{onClick:O,disabled:c.value.executing,class:`px-4 py-2 bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},b(c.value.executing?`Purging…`:`Yes, Delete Data`),9,Tl),S(`button`,{onClick:t[0]||=e=>c.value=null,disabled:c.value.executing,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,El)])])])])):g(``,!0),S(`div`,Dl,[t[19]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Maintenance `,-1),S(`div`,Ol,[S(`button`,{onClick:t[1]||=e=>D(`all`,f.value),disabled:!a.value||f.value===0,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},[...t[17]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})]),y(` Purge All Data `)],-1)]],8,kl),S(`button`,{onClick:k,disabled:u.value||!a.value,class:`px-4 py-2 bg-amber-500/20 dark:bg-amber-400/20 hover:bg-amber-500/30 dark:hover:bg-amber-400/30 text-amber-900 dark:text-amber-200 rounded-lg border border-amber-500/50 dark:border-amber-400/40 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},[S(`span`,jl,[t[18]||=S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`})],-1),y(` `+b(u.value?`Compacting…`:`Compact Database`),1)])],8,Al)]),d.value?(w(),C(`p`,Ml,b(d.value),1)):g(``,!0),l.value?(w(),C(`p`,Nl,b(l.value),1)):g(``,!0)])]))}}),Fl={class:`space-y-6`},Il={class:`glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6`},Ll={class:`flex items-start justify-between mb-4`},Rl={class:`flex items-center gap-2`},zl=[`disabled`],Bl={key:0,class:`flex items-center gap-1.5`},Vl={key:1},Hl=[`disabled`],Ul={key:0,class:`flex items-center gap-1.5`},Wl={key:1},Gl={key:0,class:`mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400 text-sm`},Kl={key:1,class:`mb-4`},ql={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10 inline-block`},Jl={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Yl={key:2,class:`p-4 rounded-lg bg-cyan-500/10 dark:bg-primary/10 border border-cyan-400/30 dark:border-primary/30`},Xl={key:3},Zl=[`innerHTML`],Ql={class:`font-semibold text-sm`},$l={class:`text-sm mt-0.5 opacity-80`},eu={class:`grid grid-cols-2 sm:grid-cols-3 gap-3 mb-6`},tu={key:0,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},nu={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},ru={key:1,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},iu={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},au={key:2,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},ou={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},su={key:0,class:`mb-6`},cu={class:`space-y-2`},lu={class:`flex items-start justify-between gap-3`},uu={class:`flex items-center gap-2 min-w-0`},du={class:`shrink-0 text-xs font-medium text-content-muted w-5 text-right`},fu={class:`text-right shrink-0`},pu={class:`text-xs text-content-muted`},mu={class:`mt-1.5 ml-7`},hu={class:`text-xs font-mono text-content-secondary dark:text-content-muted break-all`},gu={key:0,class:`text-xs text-content-muted mt-0.5`},_u={key:1,class:`mb-6 p-4 rounded-lg bg-green-500/10 border border-green-500/30 text-sm flex items-center gap-3`},vu={key:2},yu={key:0,class:`overflow-x-auto rounded-lg border border-stroke-subtle dark:border-stroke/10`},bu={class:`w-full text-sm`},xu={class:`px-3 py-2 text-content-muted font-mono text-xs`},Su={class:`px-3 py-2 text-content-primary dark:text-content-primary font-mono text-xs break-all`},Cu={class:`px-3 py-2 text-right font-mono text-xs text-content-secondary dark:text-content-muted whitespace-nowrap`},wu={class:`px-3 py-2 text-right font-mono text-xs text-content-secondary dark:text-content-muted`},Tu={key:4,class:`py-8 text-center text-content-muted text-sm`},Eu=M(f({__name:`MemoryDebug`,setup(e){let n=E(!1),r=E(!1),a=E(``),o=E(null),c=E(!1),l=E(null),f=E(!1),p=v(()=>o.value&&(o.value.current_top_20||o.value.growth_since_baseline));async function m(){n.value=!0,a.value=``;try{let e=await A.get(`memory_debug`);e.success&&e.data?(c.value=!!e.data.tracing,l.value=e.data.rss_mb??null,(e.data.current_top_20||e.data.growth_since_baseline)&&(o.value=e.data)):a.value=e.error||`Failed to fetch memory status`}catch(e){a.value=e instanceof Error?e.message:`Failed to fetch memory status`}finally{n.value=!1}}async function h(){r.value=!0,a.value=``;let e=c.value?`stop`:`start`;try{let t=await A.post(`memory_debug`,{action:e});t.success&&t.data?(c.value=!!t.data.tracing,e===`stop`&&(o.value=null,l.value=null)):a.value=t.error||`Failed to ${e} tracing`}catch(t){a.value=t instanceof Error?t.message:`Failed to ${e} tracing`}finally{r.value=!1,c.value&&await m()}}function T(e){return e.size_diff_kb>=100?`critical`:e.size_diff_kb>=10?`warning`:e.size_diff_kb>=1?`low`:`ok`}function D(e){let t=T(e);return t===`critical`?`Investigate`:t===`warning`?`Watch`:t===`low`?`Minor`:`Normal`}function O(e){let t=T(e);return t===`critical`?`bg-red-500/20 text-red-700 dark:text-red-400 border border-red-500/30`:t===`warning`?`bg-amber-500/20 text-amber-700 dark:text-amber-400 border border-amber-500/30`:t===`low`?`bg-blue-500/15 text-blue-600 dark:text-blue-400 border border-blue-500/20`:`bg-green-500/15 text-green-700 dark:text-green-400 border border-green-500/20`}function k(e){let t=T(e);return t===`critical`?`border-red-500/40 dark:border-red-500/30 bg-red-500/5 dark:bg-red-500/5`:t===`warning`?`border-amber-500/40 dark:border-amber-500/30 bg-amber-500/5 dark:bg-amber-500/5`:t===`low`?`border-stroke-subtle dark:border-stroke/10 bg-background-mute/50 dark:bg-background/20`:`border-stroke-subtle/50 dark:border-stroke/5 bg-background-mute/30 dark:bg-background/10 opacity-60`}function j(e){let t=T(e);return t===`critical`?`text-red-600 dark:text-red-400`:t===`warning`?`text-amber-600 dark:text-amber-400`:t===`low`?`text-blue-600 dark:text-blue-400`:`text-green-600 dark:text-green-500`}function M(e){return e>=1024?`${(e/1024).toFixed(1)} MB`:e>=10?`${Math.round(e)} KB`:`${e.toFixed(1)} KB`}function P(e){return e.replace(/.*\/site-packages\//,``).replace(/.*\/lib\/python[^/]*\//,``).replace(/.*\/repeater\//,`repeater/`)}let F=v(()=>o.value?.growth_since_baseline?o.value.growth_since_baseline.reduce((e,t)=>e+t.size_diff_kb,0):0),I=v(()=>F.value>=500?`critical`:F.value>=50?`warning`:F.value>=5?`low`:`ok`),L=v(()=>{let e=I.value;return e===`critical`?`border-red-500/40 dark:border-red-500/30 bg-red-500/10 dark:bg-red-500/10 text-red-800 dark:text-red-300`:e===`warning`?`border-amber-500/40 dark:border-amber-500/30 bg-amber-500/10 dark:bg-amber-500/10 text-amber-800 dark:text-amber-300`:e===`low`?`border-blue-500/30 bg-blue-500/10 dark:bg-blue-500/10 text-blue-800 dark:text-blue-300`:`border-green-500/30 bg-green-500/10 dark:bg-green-500/10 text-green-800 dark:text-green-300`}),R=v(()=>{let e=I.value;return e===`critical`?``:e===`warning`?``:e===`low`?``:``}),z=v(()=>{let e=I.value;return e===`critical`?`Significant memory growth detected`:e===`warning`?`Some memory growth detected`:e===`low`?`Minor memory growth — likely normal`:`Memory looks healthy`}),B=v(()=>{let e=M(F.value),t=I.value;return t===`critical`?`Total growth: ${e}. Red items below need attention.`:t===`warning`?`Total growth: ${e}. Orange items below may need attention over time.`:t===`low`?`Total growth: ${e}. Nothing to worry about right now.`:`No significant growth since tracing started.`});return s(m),(e,s)=>(w(),C(`div`,Fl,[S(`div`,Il,[S(`div`,Ll,[s[3]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Memory Diagnostics `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Trace memory allocations to find leaks. Tracing adds overhead — only enable when needed. `)],-1),S(`div`,Rl,[c.value&&p.value?(w(),C(`button`,{key:0,onClick:m,disabled:n.value,class:`px-3 py-1.5 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors text-sm disabled:opacity-50`},[n.value?(w(),C(`span`,Bl,[...s[1]||=[S(`span`,{class:`animate-spin w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full inline-block`},null,-1),y(` Checking… `,-1)]])):(w(),C(`span`,Vl,`Check Again`))],8,zl)):g(``,!0),S(`button`,{onClick:h,disabled:r.value,class:u([`px-3 py-1.5 rounded-lg border text-sm transition-colors disabled:opacity-50`,c.value?`bg-red-500/20 hover:bg-red-500/30 text-red-700 dark:text-red-400 border-red-500/50`:`bg-green-500/20 hover:bg-green-500/30 text-green-700 dark:text-green-400 border-green-500/50`])},[r.value?(w(),C(`span`,Ul,[s[2]||=S(`span`,{class:`animate-spin w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full inline-block`},null,-1),y(` `+b(c.value?`Stopping…`:`Starting…`),1)])):(w(),C(`span`,Wl,b(c.value?`Stop Tracing`:`Start Tracing`),1))],10,Hl)])]),a.value?(w(),C(`div`,Gl,b(a.value),1)):g(``,!0),!c.value&&l.value!==null&&!n.value?(w(),C(`div`,Kl,[S(`div`,ql,[s[4]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Current Memory (RSS)`,-1),S(`p`,Jl,b(l.value)+` MB`,1)])])):g(``,!0),c.value&&!p.value&&!n.value?(w(),C(`div`,Yl,[...s[5]||=[d(`
Tracing active

Memory tracing is running. Let the repeater run for a few minutes, then click Check Again to see which parts of the code are using more memory.

`,2)]])):g(``,!0),o.value&&p.value?(w(),C(`div`,Xl,[S(`div`,{class:u([`mb-5 p-4 rounded-lg border flex items-start gap-3`,L.value])},[S(`div`,{class:`mt-0.5`,innerHTML:R.value},null,8,Zl),S(`div`,null,[S(`p`,Ql,b(z.value),1),S(`p`,$l,b(B.value),1)])],2),S(`div`,eu,[o.value.rss_mb===void 0?g(``,!0):(w(),C(`div`,tu,[s[6]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Memory Used`,-1),S(`p`,nu,b(o.value.rss_mb)+` MB`,1)])),o.value.traced_current_mb===void 0?g(``,!0):(w(),C(`div`,ru,[s[7]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Tracked Now`,-1),S(`p`,iu,b(o.value.traced_current_mb)+` MB`,1)])),o.value.traced_peak_mb===void 0?g(``,!0):(w(),C(`div`,au,[s[8]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Peak Tracked`,-1),S(`p`,ou,b(o.value.traced_peak_mb)+` MB`,1)]))]),o.value.growth_since_baseline&&o.value.growth_since_baseline.length>0?(w(),C(`div`,su,[s[9]||=S(`h4`,{class:`text-sm font-semibold text-content-primary dark:text-content-primary mb-1`},`Memory Growth Breakdown`,-1),s[10]||=S(`p`,{class:`text-xs text-content-muted mb-3`},` Items at the top with red/orange tags are the most likely cause of memory issues. Green items are normal and can be ignored. `,-1),S(`div`,cu,[(w(!0),C(x,null,i(o.value.growth_since_baseline,(e,t)=>(w(),C(`div`,{key:t,class:u([`rounded-lg border p-3 transition-colors`,k(e)])},[S(`div`,lu,[S(`div`,uu,[S(`span`,du,b(t+1),1),S(`span`,{class:u([`shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold`,O(e)])},b(D(e)),3)]),S(`div`,fu,[S(`span`,{class:u([`font-mono text-sm font-semibold`,j(e)])},`+`+b(M(e.size_diff_kb)),3),S(`p`,pu,b(M(e.current_size_kb))+` total`,1)])]),S(`div`,mu,[S(`p`,hu,b(P(e.file)),1),e.count_diff===0?g(``,!0):(w(),C(`p`,gu,b(e.count_diff>0?`+`:``)+b(e.count_diff)+` new allocation`+b(Math.abs(e.count_diff)===1?``:`s`),1))])],2))),128))])])):o.value.growth_since_baseline&&o.value.growth_since_baseline.length===0?(w(),C(`div`,_u,[...s[11]||=[S(`svg`,{class:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`span`,{class:`text-green-700 dark:text-green-400`},`No memory growth detected. Everything looks healthy.`,-1)]])):g(``,!0),o.value.current_top_20&&o.value.current_top_20.length>0?(w(),C(`div`,vu,[S(`button`,{onClick:s[0]||=e=>f.value=!f.value,class:`flex items-center gap-2 text-sm font-semibold text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors mb-3`},[(w(),C(`svg`,{class:u([`w-4 h-4 transition-transform`,{"rotate-90":f.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...s[12]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)),s[13]||=y(` Advanced: Current Top Allocations `,-1)]),_(N,{name:`expand`},{default:t(()=>[f.value?(w(),C(`div`,yu,[S(`table`,bu,[s[14]||=S(`thead`,null,[S(`tr`,{class:`bg-background-mute dark:bg-background/30 text-left`},[S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted`},`#`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted`},`Location`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted text-right`},`Size`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted text-right`},`Count`)])],-1),S(`tbody`,null,[(w(!0),C(x,null,i(o.value.current_top_20,(e,t)=>(w(),C(`tr`,{key:t,class:`border-t border-stroke-subtle/50 dark:border-stroke/5 hover:bg-background-mute/50 dark:hover:bg-background/20 transition-colors`},[S(`td`,xu,b(t+1),1),S(`td`,Su,b(P(e.file)),1),S(`td`,Cu,b(M(e.size_kb)),1),S(`td`,wu,b(e.count),1)]))),128))])])])):g(``,!0)]),_:1})])):g(``,!0)])):g(``,!0),!n.value&&!r.value&&!c.value&&!p.value&&!a.value&&l.value===null?(w(),C(`div`,Tu,[...s[15]||=[y(` Click `,-1),S(`strong`,null,`Start Tracing`,-1),y(` to enable memory diagnostics. `,-1),S(`br`,null,null,-1),S(`span`,{class:`text-xs`},`Tracing uses extra memory — remember to stop it when done.`,-1)]])):g(``,!0)])]))}}),[[`__scopeId`,`data-v-50d93367`]]),Du={class:`p-3 sm:p-6 space-y-4 sm:space-y-6`},Ou={class:`glass-card rounded-[15px] z-10 p-3 sm:p-4 border border-cyan-400 dark:border-primary/30 bg-cyan-500/10 dark:bg-primary/10`},ku={class:`text-cyan-700 dark:text-primary text-sm sm:text-base`},Au={class:`mt-1 sm:mt-2 text-cyan-600 dark:text-primary/80`},ju={class:`glass-card rounded-[15px] p-3 sm:p-6`},Mu={class:`relative -mx-3 sm:mx-0 mb-4 sm:mb-6`},Nu={key:0,class:`absolute left-0 top-0 bottom-[1px] w-12 z-10 flex items-center`},Pu={key:0,class:`absolute right-0 top-0 bottom-[1px] w-12 z-10 flex items-center justify-end`},Fu=[`onClick`],Iu={class:`flex items-center gap-1 sm:gap-2`},Lu={key:0,class:`w-3.5 h-3.5 sm:w-4 sm:h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ru={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},zu={key:2,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Bu={key:3,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Vu={key:4,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Hu={key:5,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Uu={key:6,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Wu={key:7,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Gu={key:8,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ku={key:9,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},qu={key:10,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ju={key:11,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Yu={class:`min-h-[400px]`},Xu={key:0,class:`flex items-center justify-center py-12`},Zu={key:1,class:`flex items-center justify-center py-12`},Qu={class:`text-center`},$u={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},ed={key:2},td=M(f({name:`ConfigurationView`,__name:`Configuration`,setup(e){let n=j(),o=E(H(`configuration_activeTab`,`radio`)),l=E(!1),d=E(null),f=E(!1),p=E(!1);function v(){if(!d.value)return;let e=d.value;p.value=e.scrollLeft>4,f.value=e.scrollLeftee(`configuration_activeTab`,e));let D=[{id:`radio`,label:`Radio Settings`,icon:`radio`},{id:`repeater`,label:`Repeater Settings`,icon:`repeater`},{id:`advert`,label:`Advert Limits`,icon:`advert`},{id:`duty`,label:`Duty Cycle`,icon:`duty`},{id:`delays`,label:`TX Delays`,icon:`delays`},{id:`transport`,label:`Regions/Keys`,icon:`keys`},{id:`api-tokens`,label:`API Tokens`,icon:`tokens`},{id:`web`,label:`Web Options`,icon:`web`},{id:`observer`,label:`Observer`,icon:`observer`},{id:`backup`,label:`Backup`,icon:`backup`},{id:`database`,label:`Database`,icon:`database`},{id:`memory`,label:`Memory`,icon:`memory`}];s(async()=>{try{await n.fetchStats(),l.value=!0}catch(e){console.error(`Failed to load configuration data:`,e),l.value=!0}c(()=>v())});function O(e){o.value=e}return(e,s)=>{let c=r(`router-link`);return w(),C(`div`,Du,[s[24]||=S(`div`,null,[S(`h1`,{class:`text-xl sm:text-2xl font-bold text-content-primary dark:text-content-primary`},` Configuration `),S(`p`,{class:`text-content-secondary dark:text-content-muted mt-1 sm:mt-2 text-sm sm:text-base`},` System configuration and settings `)],-1),S(`div`,Ou,[S(`div`,ku,[s[5]||=S(`strong`,null,`CAD Calibration Tool Available`,-1),S(`p`,Au,[s[4]||=y(` Optimize your Channel Activity Detection settings. `,-1),_(c,{to:`/cad-calibration`,class:`underline hover:text-cyan-800 dark:hover:text-primary transition-colors`},{default:t(()=>[...s[3]||=[y(` Launch CAD Calibration Tool → `,-1)]]),_:1})])])]),S(`div`,ju,[S(`div`,Mu,[_(N,{name:`tab-fade`},{default:t(()=>[p.value?(w(),C(`div`,Nu,[s[7]||=S(`div`,{class:`tab-fade-left absolute inset-0 pointer-events-none`},null,-1),S(`button`,{onClick:s[0]||=e=>T(`left`),class:`relative z-10 ml-1.5 w-6 h-6 flex items-center justify-center rounded-full bg-white dark:bg-zinc-900 shadow-md border border-gray-200 dark:border-white/10 text-gray-500 dark:text-gray-300`},[...s[6]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M15 19l-7-7 7-7`})],-1)]])])):g(``,!0)]),_:1}),_(N,{name:`tab-fade`},{default:t(()=>[f.value?(w(),C(`div`,Pu,[s[9]||=S(`div`,{class:`tab-fade-right absolute inset-0 pointer-events-none`},null,-1),S(`button`,{onClick:s[1]||=e=>T(`right`),class:`relative z-10 mr-1.5 w-6 h-6 flex items-center justify-center rounded-full bg-white dark:bg-zinc-900 shadow-md border border-gray-200 dark:border-white/10 text-gray-500 dark:text-gray-300`},[...s[8]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1)]])])):g(``,!0)]),_:1}),S(`div`,{ref_key:`tabsContainer`,ref:d,onScroll:v,class:`flex overflow-x-auto border-b border-stroke-subtle dark:border-stroke/10 px-3 sm:px-0 scrollbar-hide`},[(w(),C(x,null,i(D,e=>S(`button`,{key:e.id,onClick:t=>O(e.id),class:u([`px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors duration-200 border-b-2 mr-3 sm:mr-6 whitespace-nowrap flex-shrink-0`,o.value===e.id?`text-cyan-500 dark:text-primary border-cyan-500 dark:border-primary`:`text-content-secondary dark:text-content-muted border-transparent hover:text-content-primary dark:hover:text-content-primary hover:border-stroke-subtle dark:hover:border-stroke/30`])},[S(`div`,Iu,[e.icon===`radio`?(w(),C(`svg`,Lu,[...s[10]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.822c5.716-5.716 14.976-5.716 20.692 0`},null,-1)]])):e.icon===`repeater`?(w(),C(`svg`,Ru,[...s[11]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14M5 12l4-4m-4 4l4 4`},null,-1)]])):e.icon===`advert`?(w(),C(`svg`,zu,[...s[12]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`},null,-1)]])):e.icon===`duty`?(w(),C(`svg`,Bu,[...s[13]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):e.icon===`delays`?(w(),C(`svg`,Vu,[...s[14]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`},null,-1)]])):e.icon===`keys`?(w(),C(`svg`,Hu,[...s[15]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`},null,-1)]])):e.icon===`tokens`?(w(),C(`svg`,Uu,[...s[16]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`},null,-1)]])):e.icon===`web`?(w(),C(`svg`,Wu,[...s[17]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9`},null,-1)]])):e.icon===`observer`?(w(),C(`svg`,Gu,[...s[18]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):e.icon===`backup`?(w(),C(`svg`,Ku,[...s[19]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4`},null,-1)]])):e.icon===`database`?(w(),C(`svg`,qu,[...s[20]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`},null,-1)]])):e.icon===`memory`?(w(),C(`svg`,Ju,[...s[21]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z`},null,-1)]])):g(``,!0),y(` `+b(e.label),1)])],10,Fu)),64))],544)]),S(`div`,Yu,[!l.value&&a(n).isLoading?(w(),C(`div`,Xu,[...s[22]||=[S(`div`,{class:`text-center`},[S(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full mx-auto mb-4`}),S(`div`,{class:`text-content-secondary dark:text-content-muted`},` Loading configuration... `)],-1)]])):a(n).error&&!l.value?(w(),C(`div`,Zu,[S(`div`,Qu,[s[23]||=S(`div`,{class:`text-red-500 dark:text-red-400 mb-2`},`Failed to load configuration`,-1),S(`div`,$u,b(a(n).error),1),S(`button`,{onClick:s[2]||=e=>a(n).fetchStats(),class:`px-4 py-2 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors`},` Retry `)])])):(w(),C(`div`,ed,[m(S(`div`,null,[_(ye,{key:`radio-settings`})],512),[[z,o.value===`radio`]]),m(S(`div`,null,[_(St,{key:`repeater-settings`})],512),[[z,o.value===`repeater`]]),m(S(`div`,null,[_(so,{key:`advert-settings`})],512),[[z,o.value===`advert`]]),m(S(`div`,null,[_(Pt,{key:`duty-cycle`})],512),[[z,o.value===`duty`]]),m(S(`div`,null,[_(Jt,{key:`transmission-delays`})],512),[[z,o.value===`delays`]]),m(S(`div`,null,[_(Jr,{key:`transport-keys`})],512),[[z,o.value===`transport`]]),m(S(`div`,null,[_(Si,{key:`api-tokens`})],512),[[z,o.value===`api-tokens`]]),m(S(`div`,null,[_(qi,{key:`web-settings`})],512),[[z,o.value===`web`]]),m(S(`div`,null,[_(js,{key:`letsmesh-settings`})],512),[[z,o.value===`observer`]]),m(S(`div`,null,[_(Lc,{key:`backup-restore`})],512),[[z,o.value===`backup`]]),m(S(`div`,null,[_(Pl,{key:`database-management`})],512),[[z,o.value===`database`]]),m(S(`div`,null,[_(Eu,{key:`memory-debug`})],512),[[z,o.value===`memory`]])]))])])])}}}),[[`__scopeId`,`data-v-e8f5e632`]]);export{td as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Configuration-C7dIc7Ik.css b/repeater/web/html/assets/Configuration-C7dIc7Ik.css new file mode 100644 index 00000000..bf61a158 --- /dev/null +++ b/repeater/web/html/assets/Configuration-C7dIc7Ik.css @@ -0,0 +1 @@ +.ml-0[data-v-dad29312]{margin-left:0}.ml-4[data-v-dad29312]{margin-left:1rem}.ml-8[data-v-dad29312]{margin-left:2rem}.ml-12[data-v-dad29312]{margin-left:3rem}.ml-16[data-v-dad29312]{margin-left:4rem}.ml-20[data-v-dad29312]{margin-left:5rem}.ml-24[data-v-dad29312]{margin-left:6rem}.ml-28[data-v-dad29312]{margin-left:7rem}.ml-32[data-v-dad29312]{margin-left:8rem}.dropdown-enter-active[data-v-de709eb9],.dropdown-leave-active[data-v-de709eb9]{transition:opacity .12s,transform .12s}.dropdown-enter-from[data-v-de709eb9],.dropdown-leave-to[data-v-de709eb9]{opacity:0;transform:translateY(-4px)}.expand-enter-active[data-v-00e540ed],.expand-leave-active[data-v-00e540ed]{transition:all .2s;overflow:hidden}.expand-enter-from[data-v-00e540ed],.expand-leave-to[data-v-00e540ed]{opacity:0;max-height:0}.expand-enter-to[data-v-00e540ed],.expand-leave-from[data-v-00e540ed]{opacity:1;max-height:2000px}.tab-fade-left[data-v-ff4fb67b]{background:linear-gradient(to right, var(--color-surface) 30%, transparent)}.tab-fade-right[data-v-ff4fb67b]{background:linear-gradient(to left, var(--color-surface) 30%, transparent)}.tab-fade-enter-active[data-v-ff4fb67b],.tab-fade-leave-active[data-v-ff4fb67b]{transition:opacity .2s}.tab-fade-enter-from[data-v-ff4fb67b],.tab-fade-leave-to[data-v-ff4fb67b]{opacity:0} diff --git a/repeater/web/html/assets/Configuration-DqetrFgk.js b/repeater/web/html/assets/Configuration-DqetrFgk.js new file mode 100644 index 00000000..d27587ae --- /dev/null +++ b/repeater/web/html/assets/Configuration-DqetrFgk.js @@ -0,0 +1 @@ +import{B as e,Ct as t,D as n,E as r,J as i,N as a,R as o,S as s,V as c,Y as l,c as u,f as d,g as f,i as p,j as m,k as h,l as g,m as _,nt as v,o as y,p as b,r as x,s as S,u as C,w,xt as T,z as E}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{a as D,i as O,l as k,o as A,s as j,t as M,u as N}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{_ as P,h as F,p as I,r as L,t as R,v as z}from"./api-3gMnsCKh.js";import{t as ee}from"./system-DbBvxitf.js";import{t as B}from"./dataService-DelZA92b.js";import{t as V}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as H}from"./Spinner-CcYauG9D.js";import{n as te}from"./index-DTUpsCzx.js";import{t as ne}from"./ConfirmDialog-DBlDmP2I.js";import{r as U,t as W}from"./TxPowerNoticeModal-DLQEpbGj.js";import{t as G}from"./LocationPicker-KRjSN9TZ.js";import{c as K,d as re,n as ie,t as q}from"./formatters-CHyWlnnq.js";import{n as J,t as Y}from"./preferences-CkCjR0CQ.js";var X={key:0,class:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`},Z={class:`modal-card max-w-md`},Q={class:`flex items-start gap-3 mb-4`},ae={class:`mt-1 text-sm text-content-secondary dark:text-content-muted`},oe={class:`modal-actions`},se=[`disabled`],$=[`disabled`],ce=[`disabled`],le=f({__name:`UnsavedChangesModal`,props:{show:{type:Boolean},isSaving:{type:Boolean},label:{}},emits:[`discard`,`save`,`cancel`],setup(n){return(r,i)=>(h(),u(p,{to:`body`},[_(M,{"enter-active-class":`transition-opacity duration-200`,"enter-from-class":`opacity-0`,"leave-active-class":`transition-opacity duration-200`,"leave-to-class":`opacity-0`},{default:e(()=>[n.show?(h(),C(`div`,X,[S(`div`,Z,[S(`div`,Q,[i[4]||=S(`div`,{class:`flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center`},[S(`svg`,{class:`w-5 h-5 text-amber-600 dark:text-amber-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})])],-1),S(`div`,null,[i[3]||=S(`h3`,{class:`text-base font-semibold text-content-primary dark:text-content-primary`},` Unsaved Changes `,-1),S(`p`,ae,t(n.label?n.label:`Settings`)+` have not been saved. What would you like to do? `,1)])]),S(`div`,oe,[S(`button`,{onClick:i[0]||=e=>r.$emit(`cancel`),disabled:n.isSaving,class:`modal-btn-cancel`},` Keep Editing `,8,se),S(`button`,{onClick:i[1]||=e=>r.$emit(`discard`),disabled:n.isSaving,class:`modal-btn-danger`},` Discard `,8,$),S(`button`,{onClick:i[2]||=e=>r.$emit(`save`),disabled:n.isSaving,class:`modal-btn-primary`},t(n.isSaving?`Saving…`:`Save Settings`),9,ce)])])])):g(``,!0)]),_:1})]))}});function ue(e,t,n,r){let i=l(!1),a=l(null),o=l(null);I((t,n,r)=>{e.value?(i.value=!0,a.value=()=>r(),o.value=()=>r(!1)):r()});function s(t){e.value?(i.value=!0,a.value=t,o.value=null):t()}function c(){n(),i.value=!1,o.value=null,a.value&&=(a.value(),null)}async function u(){await r()&&(i.value=!1,o.value=null,a.value&&=(a.value(),null))}function d(){i.value=!1,o.value&&=(o.value(),null),a.value=null}return{showUnsavedModal:i,requestLeave:s,handleDiscard:c,handleSave:u,handleCancel:d}}var de={class:`space-y-12`},fe={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},pe={class:`flex items-center gap-2 shrink-0`},me=[`disabled`],he=[`disabled`],ge={key:0,class:`bg-red-100 dark:bg-red-500/20 border border-red-500/50 rounded-lg p-3`},_e={class:`text-red-600 dark:text-red-400 text-sm`},ve={class:`cfg-section space-y-3`},ye={class:`w-full max-w-3xl rounded-3xl border border-stroke-subtle dark:border-white/10 bg-white dark:bg-surface-elevated shadow-[0_20px_80px_rgba(0,0,0,0.35)] overflow-hidden`},be={class:`flex items-start justify-between gap-3 p-5 border-b border-stroke-subtle dark:border-white/10`},xe={class:`p-5`},Se={class:`space-y-2 max-h-[60vh] overflow-y-auto pr-1`},Ce=[`onClick`],we={class:`min-w-0`},Te={class:`flex flex-wrap items-center gap-2`},Ee={class:`text-content-primary dark:text-content-primary font-semibold text-sm truncate`},De={key:0,class:`inline-flex items-center rounded-full bg-primary/15 text-primary text-[10px] font-semibold px-2 py-0.5`},Oe={class:`text-content-secondary dark:text-content-muted text-xs mt-1 line-clamp-2`},ke={class:`flex flex-wrap justify-end gap-2 shrink-0 text-[11px] font-mono`},Ae={class:`rounded-full bg-background-mute dark:bg-black/20 px-2 py-1 text-content-secondary dark:text-content-muted`},je={class:`rounded-full bg-background-mute dark:bg-black/20 px-2 py-1 text-content-secondary dark:text-content-muted`},Me={class:`rounded-full bg-background-mute dark:bg-black/20 px-2 py-1 text-content-secondary dark:text-content-muted`},Ne={class:`rounded-full bg-background-mute dark:bg-black/20 px-2 py-1 text-content-secondary dark:text-content-muted`},Pe={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Fe={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ie={key:1,class:`flex items-center gap-2`},Le={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Re={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},ze={key:1},Be=[`value`],Ve={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},He={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ue={key:1},We=[`value`],Ge={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ke={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},qe={key:1,class:`flex items-center gap-2`},Je={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Ye={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Xe={key:1},Ze={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Qe={class:`text-content-primary dark:text-content-primary font-mono text-sm`},$e={class:`cfg-section space-y-3`},et={class:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},tt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},nt={class:`text-content-primary dark:text-content-primary font-mono text-sm`},rt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},it={class:`text-content-primary dark:text-content-primary font-mono text-sm`},at=f({__name:`RadioSettings`,setup(n,{expose:r}){let i=F(),a=ee(),s=U(),u=y(()=>a.stats?.config?.radio||{}),d=y(()=>a.stats?.config?.radio?.cad??{}),f=l(!1),p=l(!1),b=l(null),w=l(!1),E=l(``),D=l(!1),O=l(!1),k=l(!1),P=l(0),I=l(0),L=l(0),z=l(0),B=l(0),V=l(0),H=l(0),ne=[{value:7.8,label:`7.8 kHz`},{value:10.4,label:`10.4 kHz`},{value:15.6,label:`15.6 kHz`},{value:20.8,label:`20.8 kHz`},{value:31.25,label:`31.25 kHz`},{value:41.7,label:`41.7 kHz`},{value:62.5,label:`62.5 kHz`},{value:125,label:`125 kHz`},{value:250,label:`250 kHz`},{value:500,label:`500 kHz`}];o(u,e=>{e&&!f.value&&(I.value=e.frequency?Number((e.frequency/1e6).toFixed(3)):0,L.value=e.spreading_factor??0,z.value=e.bandwidth?Number((e.bandwidth/1e3).toFixed(1)):0,B.value=e.tx_power??0,V.value=e.coding_rate??0,H.value=e.preamble_length??0)},{immediate:!0});let G=y(()=>{let e=u.value.frequency;return e?(e/1e6).toFixed(3)+` MHz`:`Not set`}),K=y(()=>{let e=u.value.bandwidth;return e?(e/1e3).toFixed(1)+` kHz`:`Not set`}),re=y(()=>{let e=u.value.tx_power;return e===void 0?`Not set`:e+` dBm`}),ie=y(()=>{let e=u.value.coding_rate;return e?`4/`+e:`Not set`}),q=y(()=>{let e=u.value.preamble_length;return e?e+` symbols`:`Not set`}),J=y(()=>u.value.spreading_factor??`Not set`),Y=async()=>{s.radioPresets.length===0&&await s.fetchRadioPresets(),f.value=!0,b.value=null,k.value=!1,P.value=B.value},X=e=>{I.value=e.frequency?Number(Number(e.frequency).toFixed(3)):0,L.value=e.spreading_factor?Number(e.spreading_factor):0,z.value=e.bandwidth?Number(Number(e.bandwidth).toFixed(1)):0,V.value=e.coding_rate?Number(e.coding_rate):0},Z=e=>e.frequency?`${Number(e.frequency).toFixed(3)} MHz`:`Not set`,Q=e=>e.bandwidth?`${Number(e.bandwidth).toFixed(1)} kHz`:`Not set`,ae=e=>e.spreading_factor||`Not set`,oe=e=>e.coding_rate?`4/${e.coding_rate}`:`Not set`,se=()=>{b.value=null;let e=s.radioPresets.find(e=>e.title===E.value);e&&X(e)};o(E,e=>{!f.value||!e||se()});let $=e=>{E.value=e;let t=s.radioPresets.find(t=>t.title===e);t&&(X(t),D.value=!1)},ce=()=>{f.value=!1,b.value=null,E.value=``,D.value=!1,O.value=!1,k.value=!1;let e=u.value;I.value=e.frequency?Number((e.frequency/1e6).toFixed(3)):0,L.value=e.spreading_factor??0,z.value=e.bandwidth?Number((e.bandwidth/1e3).toFixed(1)):0,B.value=e.tx_power??0,V.value=e.coding_rate??0,H.value=e.preamble_length??0},at=async({silent:e=!1}={})=>{p.value=!0,b.value=null;try{if(B.value<-9||B.value>22)return b.value=`TX Power must be between -9 and +22 dBm for SX1262`,!1;let t={};I.value&&(t.frequency=I.value*1e6),L.value&&(t.spreading_factor=L.value),z.value&&(t.bandwidth=z.value*1e3),(B.value||B.value===0)&&(t.tx_power=B.value),V.value&&(t.coding_rate=V.value);let n=(await R.post(`/update_radio_config`,t)).data;if(n.message||n.persisted)return f.value=!1,k.value=!1,await a.fetchStats(),e||(w.value=!0),!0;n.error?b.value=n.error:b.value=`Unknown response from server`}catch(e){console.error(`Failed to update radio settings:`,e),b.value=e.response?.data?.error||`Failed to update settings`}finally{p.value=!1}return!1},ot=y(()=>B.value!==P.value),st=async({silent:e=!1}={})=>f.value&&ot.value&&!k.value?(O.value=!0,!1):at({silent:e}),ct=async()=>{k.value&&(O.value=!1,await at())},lt=()=>{O.value=!1,k.value=!1},{showUnsavedModal:ut,requestLeave:dt,handleDiscard:ft,handleSave:pt,handleCancel:mt}=ue(f,p,ce,()=>st());return r({requestLeave:dt,isEditing:f}),(n,r)=>(h(),C(x,null,[_(te,{modelValue:w.value,"onUpdate:modelValue":r[0]||=e=>w.value=e,title:`Radio Settings Changes require a restart.`,message:`Restart Now?`},null,8,[`modelValue`]),_(le,{show:v(ut),"is-saving":p.value,label:`Radio Settings`,onDiscard:v(ft),onSave:v(pt),onCancel:v(mt)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),_(W,{show:O.value,confirmed:k.value,busy:p.value,"action-label":`I Understand, Save Changes`,"onUpdate:show":r[1]||=e=>e?O.value=!0:lt(),"onUpdate:confirmed":r[2]||=e=>k.value=e,onConfirm:ct},null,8,[`show`,`confirmed`,`busy`]),S(`div`,de,[S(`div`,fe,[r[13]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Radio Settings`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure LoRa radio parameters and frequency presets`)],-1),S(`div`,pe,[f.value?(h(),C(x,{key:1},[S(`button`,{onClick:r[3]||=e=>D.value=!D.value,class:`cfg-btn-secondary`},` Prefill Preset `),S(`button`,{onClick:ce,disabled:p.value,class:`cfg-btn-secondary`},` Cancel `,8,me),S(`button`,{onClick:r[4]||=e=>st(),disabled:p.value,class:`cfg-btn-primary`},t(p.value?`Saving...`:`Save Changes`),9,he)],64)):(h(),C(`button`,{key:0,onClick:Y,class:`cfg-btn-primary`},` Edit Settings `))])]),b.value?(h(),C(`div`,ge,[S(`p`,_e,t(b.value),1)])):g(``,!0),S(`div`,ve,[_(M,{name:`fade`},{default:e(()=>[f.value&&D.value?(h(),C(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm`,onClick:r[6]||=N(e=>D.value=!1,[`self`])},[S(`div`,ye,[S(`div`,be,[r[14]||=S(`div`,null,[S(`div`,{class:`text-content-primary dark:text-content-primary font-semibold text-base`},` Prefill from preset `),S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mt-1`},` Pick a preset to load its radio values into the form. `)],-1),S(`button`,{type:`button`,class:`cfg-btn-secondary`,onClick:r[5]||=e=>D.value=!1},` Close `)]),S(`div`,xe,[S(`div`,Se,[(h(!0),C(x,null,m(v(s).radioPresets,e=>(h(),C(`button`,{key:e.title,type:`button`,onClick:t=>$(e.title),class:T([`w-full text-left rounded-[18px] border px-4 py-3 transition-all duration-200 flex items-center justify-between gap-4`,E.value===e.title?`border-primary/60 bg-primary/10 shadow-sm shadow-primary/10`:`border-stroke-subtle dark:border-white/10 bg-white/60 dark:bg-white/5 hover:border-primary/30 hover:bg-stroke-subtle/60 dark:hover:bg-white/10`])},[S(`div`,we,[S(`div`,Te,[S(`div`,Ee,t(e.title),1),E.value===e.title?(h(),C(`span`,De,` Selected `)):g(``,!0)]),S(`div`,Oe,t(e.description),1)]),S(`div`,ke,[S(`span`,Ae,` Freq `+t(Z(e)),1),S(`span`,je,` SF `+t(ae(e)),1),S(`span`,Me,` BW `+t(Q(e)),1),S(`span`,Ne,` CR `+t(oe(e)),1)])],10,Ce))),128))])])])])):g(``,!0)]),_:1}),S(`div`,Pe,[r[16]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Frequency`,-1),f.value?(h(),C(`div`,Ie,[c(S(`input`,{"onUpdate:modelValue":r[7]||=e=>I.value=e,type:`number`,step:`0.001`,min:`100`,max:`1000`,class:`cfg-input w-32`},null,512),[[j,I.value,void 0,{number:!0}]]),r[15]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`MHz`,-1)])):(h(),C(`div`,Fe,t(G.value),1))]),S(`div`,Le,[r[17]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Spreading Factor`,-1),f.value?(h(),C(`div`,ze,[c(S(`select`,{"onUpdate:modelValue":r[8]||=e=>L.value=e,class:`cfg-select`},[(h(),C(x,null,m([5,6,7,8,9,10,11,12],e=>S(`option`,{key:e,value:e},t(e),9,Be)),64))],512),[[A,L.value,void 0,{number:!0}]])])):(h(),C(`div`,Re,t(J.value),1))]),S(`div`,Ve,[r[18]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Bandwidth`,-1),f.value?(h(),C(`div`,Ue,[c(S(`select`,{"onUpdate:modelValue":r[9]||=e=>z.value=e,class:`cfg-select`},[(h(),C(x,null,m(ne,e=>S(`option`,{key:e.value,value:e.value},t(e.label),9,We)),64))],512),[[A,z.value,void 0,{number:!0}]])])):(h(),C(`div`,He,t(K.value),1))]),S(`div`,Ge,[r[20]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`TX Power`,-1),f.value?(h(),C(`div`,qe,[c(S(`input`,{"onUpdate:modelValue":r[10]||=e=>B.value=e,type:`number`,min:`-9`,max:`22`,class:`cfg-input w-20`},null,512),[[j,B.value,void 0,{number:!0}]]),r[19]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`dBm`,-1)])):(h(),C(`div`,Ke,t(re.value),1))]),S(`div`,Je,[r[22]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Coding Rate`,-1),f.value?(h(),C(`div`,Xe,[c(S(`select`,{"onUpdate:modelValue":r[11]||=e=>V.value=e,class:`cfg-select`},[...r[21]||=[S(`option`,{value:5},`4/5`,-1),S(`option`,{value:6},`4/6`,-1),S(`option`,{value:7},`4/7`,-1),S(`option`,{value:8},`4/8`,-1)]],512),[[A,V.value,void 0,{number:!0}]])])):(h(),C(`div`,Ye,t(ie.value),1))]),S(`div`,Ze,[r[23]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Preamble Length`,-1),S(`span`,Qe,t(q.value),1)])]),S(`div`,$e,[S(`div`,et,[r[24]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`CAD Calibration`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Channel Activity Detection: Run Calibration to update`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm mt-1`},`These settings tune the receivers ability to detect channel status prior to transmission`)],-1),S(`button`,{onClick:r[12]||=e=>v(i).push(`/cad-calibration`),class:`cfg-btn-secondary shrink-0`},` Run Calibration `)]),r[27]||=S(`div`,{class:`pt-2`},null,-1),S(`div`,tt,[r[25]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Peak Threshold`,-1),S(`span`,nt,t(d.value.peak_threshold??`Not calibrated`),1)]),S(`div`,rt,[r[26]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Min Threshold`,-1),S(`span`,it,t(d.value.min_threshold??`Not calibrated`),1)])])])],64))}}),ot={class:`space-y-12`},st={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},ct={class:`flex items-center gap-2 shrink-0`},lt=[`disabled`],ut=[`disabled`],dt={key:0,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},ft={class:`cfg-section space-y-3`},pt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},mt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},ht={key:1,class:`w-full sm:w-80`},gt=[`value`],_t={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},vt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm break-all`},yt={key:1,class:`w-full sm:w-80 space-y-2`},bt={class:`flex gap-2`},xt=[`disabled`],St=[`value`],Ct=[`value`],wt=[`disabled`],Tt=[`value`],Et=[`value`],Dt=[`disabled`],Ot={class:`flex items-center gap-2 text-xs text-content-secondary dark:text-content-muted`},kt={key:2,class:`text-xs text-red-600 dark:text-red-400`},At={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},jt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Mt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},Nt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm break-all`},Pt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},Ft={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},It={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},Lt={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Rt={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2`},zt={class:`w-full sm:w-96 space-y-2`},Bt={class:`flex gap-2`},Vt=[`value`],Ht=[`disabled`],Ut={key:0,class:`text-xs text-red-600 dark:text-red-400`},Wt={class:`grid grid-cols-1 sm:grid-cols-2 gap-3 py-2 border-b border-stroke-subtle dark:border-stroke/10`},Gt={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Kt={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},qt={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Jt={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},Yt={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Xt={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},Zt={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Qt={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},$t={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},en={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},tn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},nn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},rn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},an={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},on={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},sn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},cn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},ln={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},un={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},dn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},fn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},pn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},mn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},hn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},gn={key:3,class:`grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm`},_n={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},vn={class:`text-content-primary dark:text-content-primary font-mono`},yn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},bn={class:`text-content-primary dark:text-content-primary font-mono`},xn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},Sn={class:`text-content-primary dark:text-content-primary font-mono`},Cn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},wn={class:`text-content-primary dark:text-content-primary font-mono`},Tn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},En={class:`text-content-primary dark:text-content-primary font-mono`},Dn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},On={class:`text-content-primary dark:text-content-primary font-mono`},kn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},An={class:`text-content-primary dark:text-content-primary font-mono`},jn={class:`rounded-lg border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5 p-3`},Mn={class:`text-content-primary dark:text-content-primary font-mono`},Nn={class:`grid grid-cols-1 sm:grid-cols-2 gap-3 py-2 border-b border-stroke-subtle dark:border-stroke/10`},Pn={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Fn={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},In={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Ln={key:1,class:`block text-content-primary dark:text-content-primary font-mono text-sm mt-1`},Rn=f({__name:`RadioHardwareSettings`,setup(e,{expose:n}){let i=ee(),a=[{value:`sx1262`,label:`sx1262`,detail:`Linux spidev + system GPIO`},{value:`sx1262_ch341`,label:`sx1262_ch341`,detail:`CH341 USB-to-SPI`},{value:`kiss`,label:`kiss`,detail:`KISS-modem over serial`},{value:`pymc_tcp`,label:`pymc_tcp`,detail:`pymc_tcp firmware modem over Wi-Fi/TCP`},{value:`pymc_usb`,label:`pymc_usb`,detail:`pymc_usb firmware modem over USB-CDC`},{value:`none`,label:`none`,detail:`Disable radio hardware (no RF I/O)`}],s=y(()=>{let e=i.stats;if(!e)return{};let t=e.config??{};return{...e,...t}}),u=l(!1),d=l(!1),f=l(``),p=l(!1),w=l(`none`),T=l([]),E=l(!1),D=l(``),k=l(!1),M=l([]),N=l(!1),P=l(``),F=l(``),I=l(``),L=l(9600),z=l(``),B=l(921600),V=l(``),H=l(5055),ne=l(``),U=l(0),W=l(0),G=l(21),K=l(18),re=l(20),ie=l(16),q=l(-1),J=l(-1),Y=l(-1),X=l(``),Z=l(-1),Q=l(-1),ae=l(6790),oe=l(21778);function se(e,t=``){return e==null?t:String(e)}function $(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function ce(e){if(e==null)return`none`;let t=String(e).trim().toLowerCase();return!t||[`none`,`null`,`disabled`,`off`,`no_radio`].includes(t)?`none`:t===`kiss-modem`?`kiss`:t===`sx1262`?`sx1262`:t===`sx1262_ch341`?`sx1262_ch341`:t===`kiss`?`kiss`:t===`pymc_tcp`?`pymc_tcp`:t===`pymc_usb`?`pymc_usb`:`none`}function de(e){let t=e.config?.radio_type;return t==null||t===``?`sx1262`:ce(t)}let fe=y(()=>w.value!==`sx1262`&&w.value!==`sx1262_ch341`?[]:M.value.filter(e=>de(e)===w.value));function pe(e){let t=M.value.find(t=>t.key===e);if(!t||!t.config)return;let n=t.config;U.value=$(n.bus_id,U.value),W.value=$(n.cs_id,W.value),G.value=$(n.cs_pin,G.value),K.value=$(n.reset_pin,K.value),re.value=$(n.busy_pin,re.value),ie.value=$(n.irq_pin,ie.value),q.value=$(n.txen_pin,q.value),J.value=$(n.rxen_pin,J.value),Y.value=$(n.en_pin,Y.value),Array.isArray(n.en_pins)?X.value=n.en_pins.map(e=>Number(e)).filter(e=>Number.isFinite(e)).join(`, `):X.value=``,Z.value=$(n.txled_pin,Z.value),Q.value=$(n.rxled_pin,Q.value),w.value===`sx1262_ch341`&&(ae.value=$(n.vid,ae.value),oe.value=$(n.pid,oe.value))}o(s,e=>{if(!u.value){w.value=ce(e.radio_type);let t=e.kiss??{},n=e.pymc_usb??{},r=e.pymc_tcp??{},i=e.sx1262??{},a=e.ch341??{};I.value=se(t.port,`/dev/ttyUSB0`),L.value=$(t.baud_rate,9600),z.value=se(n.port,`/dev/ttyACM0`),B.value=$(n.baudrate,921600),V.value=se(r.host,``),H.value=$(r.port,5055),ne.value=se(r.token,``),U.value=$(i.bus_id,0),W.value=$(i.cs_id,0),G.value=$(i.cs_pin,21),K.value=$(i.reset_pin,18),re.value=$(i.busy_pin,20),ie.value=$(i.irq_pin,16),q.value=$(i.txen_pin,-1),J.value=$(i.rxen_pin,-1),Y.value=$(i.en_pin,-1),Array.isArray(i.en_pins)?X.value=i.en_pins.map(e=>Number(e)).filter(e=>Number.isFinite(e)).join(`, `):X.value=``,Z.value=$(i.txled_pin,-1),Q.value=$(i.rxled_pin,-1),ae.value=$(a.vid,6790),oe.value=$(a.pid,21778),F.value=``}},{immediate:!0});let me=y(()=>ce(s.value.radio_type)),he=y(()=>{let e=a.find(e=>e.value===me.value);return e?`${e.label} - ${e.detail}`:`none - Disable radio hardware (no RF I/O)`});function ge(){w.value=me.value,u.value=!0,f.value=``}function _e(){w.value=me.value,u.value=!1,f.value=``,k.value=!1,F.value=``}function ve(e){return e.split(`,`).map(e=>Number(e.trim())).filter(e=>Number.isFinite(e))}async function ye(){N.value=!0,P.value=``;try{let e=await R.get(`hardware_options`),t=e.hardware;if(Array.isArray(t)){M.value=t;return}if(e.success&&Array.isArray(e.data)){M.value=e.data;return}M.value=[],P.value=e.error||`Could not load hardware presets`}catch(e){let t=e;M.value=[],P.value=t.message||`Could not load hardware presets`}finally{N.value=!1}}async function be(){E.value=!0,D.value=``;try{let e=await R.getSerialPorts();e.success&&Array.isArray(e.data)?T.value=e.data:(T.value=[],D.value=e.error||`Could not load USB serial devices`)}catch(e){let t=e;T.value=[],D.value=t.message||`Could not load USB serial devices`}finally{E.value=!1}}async function xe(){d.value=!0,f.value=``;try{if(w.value===`pymc_tcp`&&!V.value.trim())return f.value=`TCP modem host is required for pymc_tcp`,!1;let e={radio_type:w.value===`none`?null:w.value};if(w.value===`kiss`&&(e.kiss={port:I.value.trim()||`/dev/ttyUSB0`,baud_rate:$(L.value,9600)}),w.value===`pymc_usb`&&(e.pymc_usb={port:z.value.trim()||`/dev/ttyACM0`,baudrate:$(B.value,921600)}),w.value===`pymc_tcp`&&(e.pymc_tcp={host:V.value.trim(),port:$(H.value,5055),token:ne.value}),w.value===`sx1262`||w.value===`sx1262_ch341`){let t=ve(X.value);e.sx1262={bus_id:$(U.value,0),cs_id:$(W.value,0),cs_pin:$(G.value,21),reset_pin:$(K.value,18),busy_pin:$(re.value,20),irq_pin:$(ie.value,16),txen_pin:$(q.value,-1),rxen_pin:$(J.value,-1),...t.length>0?{en_pins:t}:{en_pin:$(Y.value,-1)},txled_pin:$(Z.value,-1),rxled_pin:$(Q.value,-1)}}w.value===`sx1262_ch341`&&(e.ch341={vid:$(ae.value,6790),pid:$(oe.value,21778)});let t=await R.importConfig(e);return t.success?(u.value=!1,await i.fetchStats(),p.value=!0,!0):(f.value=t.error||`Failed to save settings`,!1)}catch(e){let t=e;return f.value=t.response?.data?.error||t.message||`Failed to save settings`,!1}finally{d.value=!1}}let Se=y(()=>w.value===`kiss`||w.value===`pymc_usb`),Ce=y(()=>w.value===`pymc_tcp`),we=y(()=>w.value===`sx1262`||w.value===`sx1262_ch341`),Te=y(()=>w.value===`sx1262_ch341`),{showUnsavedModal:Ee,requestLeave:De,handleDiscard:Oe,handleSave:ke,handleCancel:Ae}=ue(u,d,_e,async()=>xe());return n({requestLeave:De,isEditing:u}),r(()=>{be(),ye()}),o([u,w],([e,t])=>{e&&(t===`kiss`||t===`pymc_usb`)&&be(),e&&(t===`sx1262`||t===`sx1262_ch341`)&&ye(),F.value=``},{immediate:!1}),(e,n)=>(h(),C(x,null,[_(te,{modelValue:p.value,"onUpdate:modelValue":n[0]||=e=>p.value=e,title:`Radio Hardware change requires a restart.`,message:`Restart now?`},null,8,[`modelValue`]),_(le,{show:v(Ee),"is-saving":d.value,label:`Radio Hardware settings`,onDiscard:v(Oe),onSave:v(ke),onCancel:v(Ae)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,ot,[S(`div`,st,[n[28]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},` Radio Hardware `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Select which radio hardware backend this repeater should use `)],-1),S(`div`,ct,[u.value?(h(),C(x,{key:1},[S(`button`,{onClick:_e,disabled:d.value,class:`cfg-btn-secondary`},` Cancel `,8,lt),S(`button`,{onClick:xe,disabled:d.value,class:`cfg-btn-primary`},t(d.value?`Saving...`:`Save Changes`),9,ut)],64)):(h(),C(`button`,{key:0,onClick:ge,class:`cfg-btn-primary`},` Edit Settings `))])]),f.value?(h(),C(`div`,dt,t(f.value),1)):g(``,!0),S(`div`,ft,[S(`div`,pt,[n[29]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Radio Type`,-1),u.value?(h(),C(`div`,ht,[c(S(`select`,{"onUpdate:modelValue":n[1]||=e=>w.value=e,class:`cfg-select`},[(h(),C(x,null,m(a,e=>S(`option`,{key:e.value,value:e.value},t(e.label)+` - `+t(e.detail),9,gt)),64))],512),[[A,w.value]])])):(h(),C(`div`,mt,t(he.value),1))]),Se.value?(h(),C(x,{key:0},[S(`div`,_t,[n[31]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Serial Port `,-1),u.value?(h(),C(`div`,yt,[S(`div`,bt,[w.value===`kiss`?c((h(),C(`select`,{key:0,"onUpdate:modelValue":n[2]||=e=>I.value=e,class:`cfg-select flex-1`,disabled:k.value},[I.value&&!T.value.some(e=>e.device===I.value)?(h(),C(`option`,{key:0,value:I.value},t(I.value)+` (current) `,9,St)):g(``,!0),(h(!0),C(x,null,m(T.value,e=>(h(),C(`option`,{key:`kiss-${e.device}`,value:e.device},t(e.description||e.device),9,Ct))),128))],8,xt)),[[A,I.value]]):c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[3]||=e=>z.value=e,class:`cfg-select flex-1`,disabled:k.value},[z.value&&!T.value.some(e=>e.device===z.value)?(h(),C(`option`,{key:0,value:z.value},t(z.value)+` (current) `,9,Tt)):g(``,!0),(h(!0),C(x,null,m(T.value,e=>(h(),C(`option`,{key:`usb-${e.device}`,value:e.device},t(e.description||e.device),9,Et))),128))],8,wt)),[[A,z.value]]),S(`button`,{type:`button`,class:`cfg-btn-secondary`,disabled:E.value,onClick:be},t(E.value?`...`:`Refresh`),9,Dt)]),S(`label`,Ot,[c(S(`input`,{"onUpdate:modelValue":n[4]||=e=>k.value=e,type:`checkbox`},null,512),[[O,k.value]]),n[30]||=b(` Enter custom device path `,-1)]),k.value&&w.value===`kiss`?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[5]||=e=>I.value=e,type:`text`,class:`cfg-input`,placeholder:`/dev/ttyUSB0`},null,512)),[[j,I.value]]):g(``,!0),k.value&&w.value!==`kiss`?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[6]||=e=>z.value=e,type:`text`,class:`cfg-input`,placeholder:`/dev/ttyACM0`},null,512)),[[j,z.value]]):g(``,!0),D.value?(h(),C(`p`,kt,t(D.value),1)):g(``,!0)])):(h(),C(`div`,vt,t(w.value===`kiss`?I.value:z.value),1))]),S(`div`,At,[n[32]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Baud Rate `,-1),u.value?(h(),C(x,{key:1},[w.value===`kiss`?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[7]||=e=>L.value=e,type:`number`,min:`1`,class:`cfg-input w-full sm:w-40`},null,512)),[[j,L.value,void 0,{number:!0}]]):c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[8]||=e=>B.value=e,type:`number`,min:`1`,class:`cfg-input w-full sm:w-40`},null,512)),[[j,B.value,void 0,{number:!0}]])],64)):(h(),C(`div`,jt,t(w.value===`kiss`?L.value:B.value),1))])],64)):g(``,!0),Ce.value?(h(),C(x,{key:1},[S(`div`,Mt,[n[33]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`TCP Host`,-1),u.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[9]||=e=>V.value=e,type:`text`,class:`cfg-input w-full sm:w-72`,placeholder:`pymc-3e2834.local`},null,512)),[[j,V.value]]):(h(),C(`div`,Nt,t(V.value||`Not set`),1))]),S(`div`,Pt,[n[34]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`TCP Port`,-1),u.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[10]||=e=>H.value=e,type:`number`,min:`1`,max:`65535`,class:`cfg-input w-full sm:w-40`},null,512)),[[j,H.value,void 0,{number:!0}]]):(h(),C(`div`,Ft,t(H.value),1))]),S(`div`,It,[n[35]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`TCP Token`,-1),u.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[11]||=e=>ne.value=e,type:`text`,class:`cfg-input w-full sm:w-72`,placeholder:`Optional`},null,512)),[[j,ne.value]]):(h(),C(`div`,Lt,t(ne.value?`Configured`:`Not set`),1))])],64)):g(``,!0),we.value&&u.value?(h(),C(x,{key:2},[S(`div`,Rt,[n[38]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Board Preset (Quick Apply)`,-1),S(`div`,zt,[S(`div`,Bt,[c(S(`select`,{"onUpdate:modelValue":n[12]||=e=>F.value=e,class:`cfg-select flex-1`,onChange:n[13]||=e=>pe(F.value)},[n[36]||=S(`option`,{value:``},`Leave current pin values unchanged`,-1),(h(!0),C(x,null,m(fe.value,e=>(h(),C(`option`,{key:e.key,value:e.key},t(e.name||e.key),9,Vt))),128))],544),[[A,F.value]]),S(`button`,{type:`button`,class:`cfg-btn-secondary`,disabled:N.value,onClick:ye},t(N.value?`...`:`Refresh`),9,Ht)]),P.value?(h(),C(`p`,Ut,t(P.value),1)):g(``,!0),n[37]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Optional: selecting a preset fills the pin fields below for quick setup changes. `,-1)])]),n[51]||=S(`div`,{class:`pt-2 text-xs text-content-muted dark:text-content-muted`},`SX1262 Board Pin Configuration`,-1),S(`div`,Wt,[S(`label`,Gt,[n[39]||=b(`SPI Bus ID `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[14]||=e=>U.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,U.value,void 0,{number:!0}]]):(h(),C(`span`,Kt,t(U.value),1))]),S(`label`,qt,[n[40]||=b(`SPI CS ID `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[15]||=e=>W.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,W.value,void 0,{number:!0}]]):(h(),C(`span`,Jt,t(W.value),1))]),S(`label`,Yt,[n[41]||=b(`CS Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[16]||=e=>G.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,G.value,void 0,{number:!0}]]):(h(),C(`span`,Xt,t(G.value),1))]),S(`label`,Zt,[n[42]||=b(`Reset Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[17]||=e=>K.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,K.value,void 0,{number:!0}]]):(h(),C(`span`,Qt,t(K.value),1))]),S(`label`,$t,[n[43]||=b(`Busy Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[18]||=e=>re.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,re.value,void 0,{number:!0}]]):(h(),C(`span`,en,t(re.value),1))]),S(`label`,tn,[n[44]||=b(`IRQ Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[19]||=e=>ie.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,ie.value,void 0,{number:!0}]]):(h(),C(`span`,nn,t(ie.value),1))]),S(`label`,rn,[n[45]||=b(`TX Enable Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[20]||=e=>q.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,q.value,void 0,{number:!0}]]):(h(),C(`span`,an,t(q.value),1))]),S(`label`,on,[n[46]||=b(`RX Enable Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[21]||=e=>J.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,J.value,void 0,{number:!0}]]):(h(),C(`span`,sn,t(J.value),1))]),S(`label`,cn,[n[47]||=b(`Power Enable Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[22]||=e=>Y.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,Y.value,void 0,{number:!0}]]):(h(),C(`span`,ln,t(Y.value),1))]),S(`label`,un,[n[48]||=b(`Power Enable Pins (array) `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[23]||=e=>X.value=e,type:`text`,class:`cfg-input mt-1`,placeholder:`26, 23`},null,512)),[[j,X.value]]):(h(),C(`span`,dn,t(X.value||`Not set`),1))]),S(`label`,fn,[n[49]||=b(`TX LED Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[24]||=e=>Z.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,Z.value,void 0,{number:!0}]]):(h(),C(`span`,pn,t(Z.value),1))]),S(`label`,mn,[n[50]||=b(`RX LED Pin `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[25]||=e=>Q.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,Q.value,void 0,{number:!0}]]):(h(),C(`span`,hn,t(Q.value),1))])])],64)):we.value?(h(),C(`div`,gn,[S(`div`,_n,[n[52]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current SPI bus`,-1),S(`div`,vn,t(U.value),1)]),S(`div`,yn,[n[53]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current SPI CS`,-1),S(`div`,bn,t(W.value),1)]),S(`div`,xn,[n[54]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current CS pin`,-1),S(`div`,Sn,t(G.value),1)]),S(`div`,Cn,[n[55]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current reset pin`,-1),S(`div`,wn,t(K.value),1)]),S(`div`,Tn,[n[56]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current busy pin`,-1),S(`div`,En,t(re.value),1)]),S(`div`,Dn,[n[57]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current IRQ pin`,-1),S(`div`,On,t(ie.value),1)]),S(`div`,kn,[n[58]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current power enable pin`,-1),S(`div`,An,t(Y.value),1)]),S(`div`,jn,[n[59]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs mb-1`},`Current power enable pins`,-1),S(`div`,Mn,t(X.value||`Not set`),1)])])):g(``,!0),Te.value?(h(),C(x,{key:4},[n[62]||=S(`div`,{class:`pt-2 text-xs text-content-muted dark:text-content-muted`},`CH341 Adapter Configuration`,-1),S(`div`,Nn,[S(`label`,Pn,[n[60]||=b(`CH341 VID `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[26]||=e=>ae.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,ae.value,void 0,{number:!0}]]):(h(),C(`span`,Fn,t(ae.value),1))]),S(`label`,In,[n[61]||=b(`CH341 PID `,-1),u.value?c((h(),C(`input`,{key:0,"onUpdate:modelValue":n[27]||=e=>oe.value=e,type:`number`,class:`cfg-input mt-1`},null,512)),[[j,oe.value,void 0,{number:!0}]]):(h(),C(`span`,Ln,t(oe.value),1))])])],64)):g(``,!0),n[63]||=S(`div`,{class:`py-2 text-xs text-content-muted dark:text-content-muted`},` Switching hardware saves immediately and requires a service restart to apply. `,-1)])])],64))}}),zn={class:`space-y-12`},Bn={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},Vn={class:`flex items-center gap-2 flex-shrink-0`},Hn=[`disabled`],Un=[`disabled`],Wn={key:0,class:`bg-green-100 dark:bg-green-500/10 border border-green-300 dark:border-green-500/30 rounded-lg p-3`},Gn={class:`text-green-700 dark:text-green-400 text-sm`},Kn={key:1,class:`bg-red-100 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30 rounded-lg p-3`},qn={class:`text-red-700 dark:text-red-400 text-sm`},Jn={class:`cfg-section space-y-3`},Yn={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Xn={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm break-all`},Zn={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Qn={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all`},$n={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},er={class:`flex items-center gap-2 min-w-0 sm:justify-end`},tr={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all sm:text-right min-w-0`},nr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},rr={class:`text-content-primary dark:text-content-primary font-mono text-sm`},ir={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},ar={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},or={class:`flex flex-col py-2 gap-2`},sr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1`},cr={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4`},lr={key:1,class:`flex items-center gap-2`},ur={class:`cfg-section space-y-3`},dr={class:`pb-2`},fr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},pr={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},mr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},hr={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},gr={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] shadow-2xl w-full max-w-md p-6 space-y-4`},_r={class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},vr=[`maxlength`,`disabled`],yr={key:0,class:`text-red-500 text-xs mt-1`},br={key:1,class:`text-content-muted dark:text-content-muted text-xs mt-1`},xr=[`disabled`],Sr={key:0,class:`mt-2 bg-amber-500/10 border border-amber-500/30 rounded-lg p-3`},Cr={key:0,class:`flex items-center gap-3 bg-blue-500/10 border border-blue-500/30 rounded-lg p-3`},wr={class:`text-blue-700 dark:text-blue-400 text-xs font-medium`},Tr={class:`text-blue-600 dark:text-blue-500 text-xs mt-0.5`},Er={key:1,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`},Dr={class:`text-red-600 dark:text-red-400 text-sm`},Or={key:2,class:`bg-green-500/10 border border-green-600/40 dark:border-green-500/30 rounded-lg p-3 space-y-2`},kr={class:`text-green-600 dark:text-green-400 text-sm font-medium`},Ar={class:`font-mono text-xs break-all text-content-primary dark:text-content-primary`},jr={key:3,class:`bg-amber-500/10 border border-amber-500/30 rounded-lg p-3`},Mr={class:`flex gap-2 mt-3`},Nr=[`disabled`],Pr=[`disabled`],Fr={class:`flex justify-end gap-3 mt-6`},Ir=[`disabled`],Lr=[`disabled`],Rr=f({__name:`RepeaterSettings`,setup(e,{expose:n}){let r=ee(),i=y(()=>r.stats?.config||{}),a=y(()=>i.value.repeater||{}),s=y(()=>r.stats),d=l(!1),f=l(!1),m=l(null),E=l(null),D=l(!1),O=l(``),k=l(0),M=l(0),P=l(0),F=l(1),I=y(()=>i.value.mesh||{});o([i,a,I],()=>{if(!d.value){O.value=i.value.node_name||``,k.value=a.value.latitude||0,M.value=a.value.longitude||0,P.value=a.value.send_advert_interval_hours||0;let e=I.value.path_hash_mode;F.value=e===0||e===1||e===2?e+1:1}},{immediate:!0});let L=y(()=>i.value.node_name||`Not set`),z=y(()=>s.value?.local_hash||`Not available`),B=y(()=>{let e=s.value?.public_key;return!e||e===`Not set`?`Not set`:e}),V=y(()=>{let e=a.value.latitude;return e&&e!==0?e.toFixed(6):`Not set`}),H=y(()=>{let e=a.value.longitude;return e&&e!==0?e.toFixed(6):`Not set`}),te=y(()=>{let e=a.value.mode;return e?e===`no_tx`?`No TX`:e.charAt(0).toUpperCase()+e.slice(1):`Not set`}),ne=y(()=>{let e=a.value.send_advert_interval_hours;return e===void 0?`Not set`:e===0?`Disabled`:e+` hour`+(e===1?``:`s`)}),U=y(()=>{let e=I.value.path_hash_mode;return e===0||e===1||e===2?e+1+(e===0?` byte`:` bytes`):`Not set`}),W=()=>{d.value=!0,m.value=null,E.value=null},K=()=>{d.value=!1,m.value=null,O.value=i.value.node_name||``,k.value=a.value.latitude||0,M.value=a.value.longitude||0,P.value=a.value.send_advert_interval_hours||0;let e=I.value.path_hash_mode;F.value=e===0||e===1||e===2?e+1:1},re=async()=>{f.value=!0,m.value=null,E.value=null;try{let e={};O.value&&(e.node_name=O.value),e.latitude=k.value,e.longitude=M.value,e.flood_advert_interval_hours=P.value,e.path_hash_mode=F.value-1;let t=(await R.post(`/update_radio_config`,e)).data;t.message||t.persisted?(E.value=t.message||`Settings saved successfully`,d.value=!1,await r.fetchStats(),setTimeout(()=>{E.value=null},3e3)):t.error?m.value=t.error:m.value=`Unknown response from server`}catch(e){console.error(`Failed to update repeater settings:`,e),m.value=e.response?.data?.error||`Failed to update settings`}finally{f.value=!1}},ie=()=>{D.value=!0},q=e=>{k.value=e.latitude,M.value=e.longitude},J=l(!1),Y=l(``),X=l(!1),Z=l(null),Q=l(null),ae=l(!1),oe=l(!1),se=l(!1),$=l(0),ce=null,de=y(()=>se.value?8:4),fe=y(()=>{let e=Y.value.trim();return!e||e.length>de.value?!1:/^[0-9a-fA-F]+$/.test(e)}),pe=y(()=>{let e=Y.value.trim().length;return e===0?``:e===1?`Very fast — ~16 attempts on average`:e===2?`Fast — ~256 attempts on average`:e===3?`Moderate — ~4,096 attempts, a few seconds`:e===4?`Slow — ~65,536 attempts, may take 10-30 seconds`:e===5?`Very slow — ~1 million attempts, could take minutes`:e===6?`Extremely slow — ~16 million attempts, could take a very long time`:e===7?`Extreme — ~268 million attempts, may not complete`:`Extreme — ~4 billion attempts, extremely unlikely to complete`}),me=()=>{$.value=0,ce=setInterval(()=>{$.value++},1e3)},he=()=>{ce&&=(clearInterval(ce),null)};w(()=>he());let ge=()=>{Y.value=``,Z.value=null,Q.value=null,ae.value=!1,se.value=!1,J.value=!0},_e=async()=>{X.value=!0,Q.value=null,Z.value=null,me();try{let e=await R.generateVanityKey(Y.value.trim());e.success&&e.data?Z.value=e.data:Q.value=e.error||`Generation failed`}catch(e){let t=e;Q.value=t.response?.data?.error||t.message||`Generation failed`}finally{he(),X.value=!1}},ve=async()=>{if(Z.value){oe.value=!0,Q.value=null;try{let e=await R.generateVanityKey(Y.value.trim(),!0);e.success&&e.data?(Z.value=e.data,ae.value=!1,J.value=!1,E.value=`New identity key applied. Restart the repeater for the change to take effect.`,await r.fetchStats(),setTimeout(()=>{E.value=null},8e3)):Q.value=e.error||`Failed to apply key`}catch(e){let t=e;Q.value=t.response?.data?.error||t.message||`Failed to apply key`}finally{oe.value=!1}}},{showUnsavedModal:ye,requestLeave:be,handleDiscard:xe,handleSave:Se,handleCancel:Ce}=ue(d,f,K,async()=>(await re(),!d.value));return n({requestLeave:be,isEditing:d}),(e,n)=>(h(),C(x,null,[_(le,{show:v(ye),"is-saving":f.value,label:`Repeater Settings`,onDiscard:v(xe),onSave:v(Se),onCancel:v(Ce)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,zn,[S(`div`,Bn,[n[13]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Repeater Settings`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure repeater identity, location, and network settings`)],-1),S(`div`,Vn,[d.value?(h(),C(x,{key:1},[S(`button`,{onClick:K,disabled:f.value,class:`cfg-btn-secondary`},` Cancel `,8,Hn),S(`button`,{onClick:re,disabled:f.value,class:`cfg-btn-primary`},t(f.value?`Saving...`:`Save Changes`),9,Un)],64)):(h(),C(`button`,{key:0,onClick:W,class:`cfg-btn-primary`},` Edit Settings `))])]),E.value?(h(),C(`div`,Wn,[S(`p`,Gn,t(E.value),1)])):g(``,!0),m.value?(h(),C(`div`,Kn,[S(`p`,qn,t(m.value),1)])):g(``,!0),S(`div`,Jn,[n[23]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary pb-2`},`General Settings`,-1),S(`div`,Yn,[n[14]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Node Name`,-1),d.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[0]||=e=>O.value=e,type:`text`,maxlength:`50`,class:`cfg-input w-full sm:w-64`,placeholder:`Enter node name`},null,512)),[[j,O.value]]):(h(),C(`div`,Xn,t(L.value),1))]),S(`div`,Zn,[n[15]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Local Hash`,-1),S(`span`,Qn,t(z.value),1)]),S(`div`,$n,[n[16]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm flex-shrink-0`},`Public Key`,-1),S(`div`,er,[S(`span`,tr,t(B.value),1),d.value?(h(),C(`button`,{key:0,onClick:ge,class:`flex-shrink-0 px-2 py-1 text-xs bg-primary/10 hover:bg-primary/20 text-content-secondary dark:text-content-muted rounded border border-primary/30 transition-colors whitespace-nowrap`},` Generate New Key `)):g(``,!0)])]),S(`div`,nr,[n[17]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Mode`,-1),S(`span`,rr,t(te.value),1)]),S(`div`,ir,[n[19]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Path hash length`,-1),d.value?c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[1]||=e=>F.value=e,class:`cfg-select w-full sm:w-32`},[...n[18]||=[S(`option`,{value:1},`1 byte`,-1),S(`option`,{value:2},`2 bytes`,-1),S(`option`,{value:3},`3 bytes`,-1)]],512)),[[A,F.value,void 0,{number:!0}]]):(h(),C(`div`,ar,t(U.value),1))]),S(`div`,or,[S(`div`,sr,[n[21]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Periodic Advertisement Interval`,-1),d.value?(h(),C(`div`,lr,[c(S(`input`,{"onUpdate:modelValue":n[2]||=e=>P.value=e,type:`number`,min:`0`,max:`48`,class:`cfg-input w-20`},null,512),[[j,P.value,void 0,{number:!0}]]),n[20]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-sm`},`hours`,-1)])):(h(),C(`div`,cr,t(ne.value),1))]),n[22]||=S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`How often the repeater sends an advertisement packet (0 = disabled, 3-48 hours)`,-1)])]),S(`div`,ur,[S(`div`,dr,[n[25]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-3`},`Location Settings`,-1),d.value?(h(),C(`button`,{key:0,onClick:ie,class:`btn-primary flex items-center gap-2`,title:`Pick location on map`},[...n[24]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),b(` Pick Location on Map `,-1)]])):g(``,!0)]),S(`div`,fr,[n[26]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Manual Latitude`,-1),d.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[3]||=e=>k.value=e,type:`number`,step:`0.000001`,min:`-90`,max:`90`,class:`cfg-input w-full sm:w-48`},null,512)),[[j,k.value,void 0,{number:!0}]]):(h(),C(`div`,pr,t(V.value),1))]),S(`div`,mr,[n[27]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Manual Longitude`,-1),d.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[4]||=e=>M.value=e,type:`number`,step:`0.000001`,min:`-180`,max:`180`,class:`cfg-input w-full sm:w-48`},null,512)),[[j,M.value,void 0,{number:!0}]]):(h(),C(`div`,hr,t(H.value),1))])]),_(G,{"is-open":D.value,latitude:k.value,longitude:M.value,onClose:n[5]||=e=>D.value=!1,onSelect:q},null,8,[`is-open`,`latitude`,`longitude`]),(h(),u(p,{to:`body`},[J.value?(h(),C(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:n[12]||=N(e=>J.value=!1,[`self`])},[S(`div`,gr,[n[35]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Generate Vanity Identity Key `,-1),n[36]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Generate a new Ed25519 identity key whose public key starts with your chosen hex prefix (0-9, A-F). Longer prefixes take more time to find. `,-1),S(`div`,null,[S(`label`,_r,`Hex Prefix (1-`+t(de.value)+` characters)`,1),c(S(`input`,{"onUpdate:modelValue":n[6]||=e=>Y.value=e,type:`text`,maxlength:de.value,placeholder:`e.g. F8A1`,disabled:X.value,class:`cfg-input py-2 placeholder-gray-400 dark:placeholder-white/40 font-mono uppercase disabled:opacity-50`},null,8,vr),[[j,Y.value]]),Y.value&&!fe.value?(h(),C(`p`,yr,` Enter 1-`+t(de.value)+` valid hex characters (0-9, A-F) `,1)):pe.value?(h(),C(`p`,br,t(pe.value),1)):g(``,!0)]),S(`div`,null,[S(`button`,{onClick:n[7]||=e=>se.value=!se.value,disabled:X.value,class:`text-xs text-content-muted dark:text-content-muted hover:text-content-secondary dark:hover:text-content-secondary transition-colors disabled:opacity-50 flex items-center gap-1`},[(h(),C(`svg`,{class:T([`w-3 h-3 transition-transform`,{"rotate-90":se.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...n[28]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)),n[29]||=b(` Advanced `,-1)],8,xr),se.value?(h(),C(`div`,Sr,[...n[30]||=[S(`p`,{class:`text-amber-600 dark:text-amber-400 text-xs font-medium`},` Extended prefix mode (up to 8 characters) `,-1),S(`p`,{class:`text-amber-600 dark:text-amber-500 text-xs mt-1`},` Prefixes longer than 4 characters require exponentially more attempts and can take a very long time or may not complete at all. The request may time out. `,-1)]])):g(``,!0)]),X.value?(h(),C(`div`,Cr,[n[31]||=S(`svg`,{class:`animate-spin h-5 w-5 text-blue-500 flex-shrink-0`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[S(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),S(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1),S(`div`,null,[S(`p`,wr,` Searching for key with prefix "`+t(Y.value.toUpperCase())+`"... `,1),S(`p`,Tr,` Elapsed: `+t($.value)+`s `,1)])])):g(``,!0),Q.value?(h(),C(`div`,Er,[S(`p`,Dr,t(Q.value),1)])):g(``,!0),Z.value?(h(),C(`div`,Or,[S(`p`,kr,` Key found in `+t(Z.value.attempts.toLocaleString())+` attempts `,1),S(`div`,null,[n[32]||=S(`span`,{class:`text-xs text-content-muted dark:text-content-muted`},`Public Key:`,-1),S(`p`,Ar,t(Z.value.public_hex),1)])])):g(``,!0),ae.value&&Z.value?(h(),C(`div`,jr,[n[33]||=S(`p`,{class:`text-amber-600 dark:text-amber-400 text-sm font-medium`},` Warning: This will replace your current identity key. `,-1),n[34]||=S(`p`,{class:`text-amber-600 dark:text-amber-500 text-xs mt-1`},` Your node address and public key will change. Other nodes will need to re-discover you. This cannot be undone unless you have a backup. `,-1),S(`div`,Mr,[S(`button`,{onClick:ve,disabled:oe.value,class:`px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs transition-colors disabled:opacity-50`},t(oe.value?`Applying...`:`Confirm Replace Key`),9,Nr),S(`button`,{onClick:n[8]||=e=>ae.value=!1,disabled:oe.value,class:`px-3 py-1.5 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 text-xs transition-colors`},` Cancel `,8,Pr)])])):g(``,!0),S(`div`,Fr,[S(`button`,{onClick:n[9]||=e=>J.value=!1,disabled:X.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors`},` Close `,8,Ir),Z.value?(h(),C(x,{key:1},[S(`button`,{onClick:n[10]||=e=>{Z.value=null,Q.value=null},class:`btn-primary`},` Try Again `),ae.value?g(``,!0):(h(),C(`button`,{key:0,onClick:n[11]||=e=>ae.value=!0,class:`px-4 py-2 bg-red-600/20 hover:bg-red-600/30 text-red-600 dark:text-red-400 rounded-lg border border-red-500/50 text-sm transition-colors`},` Apply Key `))],64)):(h(),C(`button`,{key:0,onClick:_e,disabled:!fe.value||X.value,class:`btn-primary`},t(X.value?`Generating...`:`Generate`),9,Lr))])])])):g(``,!0)]))])],64))}}),zr={class:`space-y-12`},Br={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},Vr={class:`flex items-center gap-2 flex-shrink-0`},Hr=[`disabled`],Ur=[`disabled`],Wr={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm`},Gr={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},Kr={class:`cfg-section`},qr={class:`space-y-3`},Jr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Yr={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Xr={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Zr={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Qr=f({__name:`DutyCycle`,setup(e,{expose:n}){let r=ee(),i=y(()=>r.stats?.config?.duty_cycle||{}),a=y(()=>{let e=i.value.max_airtime_percent;return typeof e==`number`?e.toFixed(1)+`%`:e&&typeof e==`object`&&`parsedValue`in e?(e.parsedValue||0).toFixed(1)+`%`:`Not set`}),o=y(()=>i.value.enforcement_enabled?`Enabled`:`Disabled`),s=l(!1),u=l(!1),d=l(``),f=l(``),p=l(0),m=l(!0),b=()=>{let e=i.value.max_airtime_percent;typeof e==`number`?p.value=e:e&&typeof e==`object`&&`parsedValue`in e?p.value=e.parsedValue||0:p.value=6,m.value=i.value.enforcement_enabled!==!1,s.value=!0,d.value=``,f.value=``},w=()=>{s.value=!1,d.value=``,f.value=``},{showUnsavedModal:T,requestLeave:E,handleDiscard:D,handleSave:O,handleCancel:k}=ue(s,u,w,async()=>(await M(),!s.value));n({requestLeave:E,isEditing:s});let M=async()=>{u.value=!0,f.value=``,d.value=``;try{let e=(await L.post(`/api/update_duty_cycle_config`,{max_airtime_percent:p.value,enforcement_enabled:m.value})).data;e.message||e.persisted?(d.value=e.message||`Settings saved successfully`,s.value=!1,await r.fetchStats(),setTimeout(()=>{d.value=``},3e3)):f.value=`Failed to save settings`}catch(e){console.error(`Failed to save duty cycle settings:`,e),f.value=e.response?.data?.error||`Failed to save settings`}finally{u.value=!1}};return(e,n)=>(h(),C(x,null,[_(le,{show:v(T),"is-saving":u.value,label:`Duty Cycle settings`,onDiscard:v(D),onSave:v(O),onCancel:v(k)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,zr,[S(`div`,Br,[n[2]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Duty Cycle`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure duty cycle limits for channel activity`)],-1),S(`div`,Vr,[s.value?(h(),C(x,{key:1},[S(`button`,{onClick:w,disabled:u.value,class:`cfg-btn-secondary`},` Cancel `,8,Hr),S(`button`,{onClick:M,disabled:u.value,class:`cfg-btn-primary`},t(u.value?`Saving...`:`Save Changes`),9,Ur)],64)):(h(),C(`button`,{key:0,onClick:b,class:`cfg-btn-primary`},` Edit Settings `))])]),d.value?(h(),C(`div`,Wr,t(d.value),1)):g(``,!0),f.value?(h(),C(`div`,Gr,t(f.value),1)):g(``,!0),S(`div`,Kr,[S(`div`,qr,[S(`div`,Jr,[n[3]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Max Airtime %`,-1),s.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[0]||=e=>p.value=e,type:`number`,step:`0.1`,min:`0.1`,max:`100`,class:`cfg-input w-full sm:w-32`},null,512)),[[j,p.value,void 0,{number:!0}]]):(h(),C(`div`,Yr,t(a.value),1))]),S(`div`,Xr,[n[5]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Enforcement`,-1),s.value?c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[1]||=e=>m.value=e,class:`cfg-select w-full sm:w-32`},[...n[4]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[A,m.value]]):(h(),C(`div`,Zr,t(o.value),1))])])])])],64))}}),$r={class:`space-y-12`},ei={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},ti={class:`flex items-center gap-2 flex-shrink-0`},ni=[`disabled`],ri=[`disabled`],ii={key:0,class:`bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm`},ai={key:1,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},oi={class:`cfg-section space-y-3`},si={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-3`},ci={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm flex-shrink-0`},li={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between py-2 gap-3`},ui={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm flex-shrink-0`},di=f({__name:`TransmissionDelays`,setup(e,{expose:n}){let r=ee(),i=y(()=>r.stats?.config?.delays||{}),a=y(()=>{let e=i.value.tx_delay_factor;if(typeof e==`number`)return e.toFixed(2)+`x`;if(e&&typeof e==`object`&&`parsedValue`in e){let t=e.parsedValue;if(typeof t==`number`)return t.toFixed(2)+`x`}return`Not set`}),o=y(()=>{let e=i.value.direct_tx_delay_factor;return typeof e==`number`?e.toFixed(2)+`s`:`Not set`}),s=l(!1),u=l(!1),d=l(``),f=l(``),p=l(0),m=l(0),b=()=>{let e=i.value.tx_delay_factor;e&&typeof e==`object`&&`parsedValue`in e?p.value=e.parsedValue||1:typeof e==`number`?p.value=e:p.value=1;let t=i.value.direct_tx_delay_factor;m.value=typeof t==`number`?t:.5,s.value=!0,d.value=``,f.value=``},w=()=>{s.value=!1,d.value=``,f.value=``},T=async()=>{u.value=!0,f.value=``,d.value=``;try{let e=(await L.post(`/api/update_radio_config`,{tx_delay_factor:p.value,direct_tx_delay_factor:m.value})).data,t=e?.data??e;e.success||t.persisted||t.message?(d.value=t.message||`Settings saved successfully`,s.value=!1,await r.fetchStats(),setTimeout(()=>{d.value=``},3e3)):f.value=`Failed to save settings`}catch(e){console.error(`Failed to save delay settings:`,e),f.value=e.response?.data?.error||`Failed to save settings`}finally{u.value=!1}},{showUnsavedModal:E,requestLeave:D,handleDiscard:O,handleSave:k,handleCancel:A}=ue(s,u,w,async()=>(await T(),!s.value));return n({requestLeave:D,isEditing:s}),(e,n)=>(h(),C(x,null,[_(le,{show:v(E),"is-saving":u.value,label:`TX Delay settings`,onDiscard:v(O),onSave:v(k),onCancel:v(A)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,$r,[S(`div`,ei,[n[2]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`TX Delays`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure transmission delay factors for flood and direct packets`)],-1),S(`div`,ti,[s.value?(h(),C(x,{key:1},[S(`button`,{onClick:w,disabled:u.value,class:`cfg-btn-secondary`},` Cancel `,8,ni),S(`button`,{onClick:T,disabled:u.value,class:`cfg-btn-primary`},t(u.value?`Saving...`:`Save Changes`),9,ri)],64)):(h(),C(`button`,{key:0,onClick:b,class:`cfg-btn-primary`},` Edit Settings `))])]),d.value?(h(),C(`div`,ii,t(d.value),1)):g(``,!0),f.value?(h(),C(`div`,ai,t(f.value),1)):g(``,!0),S(`div`,oi,[S(`div`,si,[n[3]||=S(`div`,{class:`flex flex-col gap-1`},[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Flood TX Delay Factor`),S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`Scales the airtime-based random transmit window for flood packets. Higher values increase delay spread for collision avoidance.`)],-1),s.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[0]||=e=>p.value=e,type:`number`,step:`0.1`,min:`0`,max:`5`,class:`cfg-input w-full sm:w-32 flex-shrink-0`},null,512)),[[j,p.value,void 0,{number:!0}]]):(h(),C(`div`,ci,t(a.value),1))]),S(`div`,li,[n[4]||=S(`div`,{class:`flex flex-col gap-1`},[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Direct TX Delay Factor`),S(`span`,{class:`text-content-muted dark:text-content-muted text-xs`},`Fixed delay in seconds before transmitting direct-routed packets. Applied as-is with no randomisation.`)],-1),s.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[1]||=e=>m.value=e,type:`number`,step:`0.1`,min:`0`,max:`5`,class:`cfg-input w-full sm:w-32 flex-shrink-0`},null,512)),[[j,m.value,void 0,{number:!0}]]):(h(),C(`div`,ui,t(o.value),1))])])])],64))}}),fi=P(`treeState`,()=>{let e=i(new Set),t=i({value:null}),n=t=>{e.add(t)},r=t=>{e.delete(t)};return{expandedNodes:e,selectedNodeId:t,addExpandedNode:n,removeExpandedNode:r,isNodeExpanded:t=>e.has(t),setSelectedNode:e=>{t.value=e},toggleExpanded:t=>{e.has(t)?r(t):n(t)}}}),pi={class:`select-none`},mi={class:`flex-shrink-0`},hi={key:0,class:`w-3.5 h-3.5 sm:w-4 sm:h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},gi={key:1,class:`w-3.5 h-3.5 sm:w-4 sm:h-4 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},_i={key:0,class:`hidden sm:flex items-center gap-1 ml-2`},vi={class:`relative group`},yi=[`title`],bi={key:0,class:`text-xs font-mono text-content-secondary dark:text-white/50 bg-stroke-subtle/40 dark:bg-white/5 px-1.5 py-0.5 rounded border border-stroke-subtle dark:border-white/10`},xi={class:`flex justify-between items-start mb-4`},Si={class:`bg-black/20 border border-white/10 rounded-md p-4 mb-4`},Ci={class:`text-sm font-mono text-white/80 break-all leading-relaxed`},wi={class:`flex items-center gap-2 sm:gap-3 ml-auto flex-shrink-0`},Ti={key:0,class:`hidden sm:flex items-center gap-1`},Ei=[`title`],Di={key:1,class:`hidden sm:flex items-center gap-1`},Oi={key:3,class:`hidden sm:inline-block px-2 py-1 bg-stroke-subtle dark:bg-white/10 text-content-secondary dark:text-white/60 text-xs rounded-full ml-1`},ki={key:0,class:`space-y-1`},Ai=V(f({__name:`TreeNode`,props:{node:{},selectedNodeId:{},level:{},disabled:{type:Boolean},unlocked:{type:Boolean}},emits:[`select`,`edit`,`delete`],setup(n,{emit:r}){let i=n,o=r,s=fi(),c=l(!1),d=y({get:()=>s.isNodeExpanded(i.node.id),set:e=>{e?s.addExpandedNode(i.node.id):s.removeExpandedNode(i.node.id)}}),f=y(()=>i.node.children.length>0);function p(){i.unlocked&&E(),f.value&&w()}function w(){f.value&&(d.value=!d.value)}function E(){o(`select`,i.node.id)}function D(e){o(`select`,e)}function O(e){o(`edit`,e)}function k(e){o(`delete`,e)}function A(e){e.stopPropagation(),c.value=!c.value}function j(e){e.stopPropagation(),i.node.transport_key&&window.navigator?.clipboard&&window.navigator.clipboard.writeText(i.node.transport_key)}return(r,s)=>{let l=a(`TreeNode`,!0);return h(),C(`div`,pi,[S(`div`,{class:T([`flex flex-wrap sm:flex-nowrap items-start sm:items-center gap-1 sm:gap-2 py-2 px-2 sm:px-3 rounded-lg border transition-colors duration-150`,i.disabled?`opacity-50`:``,i.unlocked&&n.selectedNodeId===n.node.id?`bg-primary/10 border-primary/30 text-content-primary dark:text-white`:`cfg-card text-content-primary dark:text-white/80`,i.unlocked&&n.selectedNodeId!==n.node.id?`hover:bg-stroke-subtle/40 dark:hover:bg-white/5 hover:border-stroke dark:hover:border-white/15`:``,f.value&&!i.disabled?`cursor-pointer`:``,`ml-${n.level*4}`]),onClick:s[5]||=N(e=>!i.disabled&&p(),[`stop`])},[S(`div`,{class:`flex-shrink-0 w-3 h-3 sm:w-4 sm:h-4 flex items-center justify-center`,onClick:N(w,[`stop`])},[f.value?(h(),C(`svg`,{key:0,class:T([`w-2.5 h-2.5 sm:w-3 sm:h-3 transition-transform duration-200`,d.value?`rotate-90`:`rotate-0`]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...s[6]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)):g(``,!0)]),S(`div`,mi,[i.node.name.startsWith(`#`)?(h(),C(`svg`,hi,[...s[7]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(h(),C(`svg`,gi,[...s[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`},null,-1)]]))]),S(`span`,{class:T([`font-mono text-xs sm:text-sm transition-colors duration-200 break-all`,n.selectedNodeId===n.node.id?`text-primary font-medium`:``])},t(n.node.name.startsWith(`#`)?n.node.name.slice(1):n.node.name),3),n.node.transport_key?(h(),C(`div`,_i,[S(`div`,vi,[S(`button`,{onClick:A,class:`p-1 rounded hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors`,title:c.value?`Hide full key`:`Show full key`},[...s[9]||=[S(`svg`,{class:`w-3 h-3 text-content-muted dark:text-white/60 hover:text-content-secondary dark:hover:text-white/80`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,yi),c.value?g(``,!0):(h(),C(`span`,bi,t(v(re)(n.node.transport_key)),1)),c.value?(h(),C(`div`,{key:1,class:`fixed inset-0 z-[300] flex items-center justify-center bg-black/70 backdrop-blur-md`,onClick:s[2]||=e=>c.value=!1},[S(`div`,{class:`bg-black/20 border border-white/20 rounded-lg shadow-lg p-6 max-w-2xl w-full mx-4`,onClick:s[1]||=N(()=>{},[`stop`])},[S(`div`,xi,[s[11]||=S(`h3`,{class:`text-lg font-semibold text-white`},`Transport Key`,-1),S(`button`,{onClick:s[0]||=e=>c.value=!1,class:`text-white/60 hover:text-white transition-colors`},[...s[10]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`div`,Si,[S(`div`,Ci,t(n.node.transport_key),1)]),S(`div`,{class:`flex justify-end`},[S(`button`,{onClick:j,class:`btn-success flex items-center gap-2`,title:`Copy to clipboard`},[...s[12]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),b(` Copy Key `,-1)]])])])])):g(``,!0)])])):g(``,!0),S(`div`,wi,[n.node.last_used?(h(),C(`div`,Ti,[s[13]||=S(`span`,{class:`text-xs text-content-muted dark:text-white/40`},`Last Heard:`,-1),S(`span`,{class:`text-xs text-content-secondary dark:text-white/50`,title:n.node.last_used.toLocaleString()},t(v(K)(n.node.last_used)),9,Ei)])):(h(),C(`div`,Di,[...s[14]||=[S(`span`,{class:`text-xs text-content-muted dark:text-white/30`},`Last Heard:`,-1),S(`span`,{class:`text-xs text-content-muted dark:text-white/30 italic`},`Never`,-1)]])),S(`span`,{class:T([`text-[10px] sm:text-xs`,n.node.floodPolicy===`allow`?`text-accent-green/80`:`text-accent-red/80`])},` Flood: `+t(n.node.floodPolicy===`allow`?`Allow`:`Deny`),3),i.unlocked?(h(),C(x,{key:2},[S(`button`,{onClick:s[3]||=N(e=>o(`edit`,n.node.id),[`stop`]),class:`px-2 py-0.5 text-[10px] sm:text-xs bg-primary/10 hover:bg-primary/20 text-content-secondary dark:text-content-muted rounded border border-primary/30 transition-colors whitespace-nowrap`},` Edit `),S(`button`,{onClick:s[4]||=N(e=>o(`delete`,n.node.id),[`stop`]),class:`p-1 text-accent-red/50 hover:text-accent-red transition-colors`,title:`Delete`},[...s[15]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]])],64)):g(``,!0),f.value&&!i.unlocked?(h(),C(`span`,Oi,t(n.node.children.length),1)):g(``,!0)])],2),_(M,{"enter-active-class":`transition-all duration-300 ease-out`,"enter-from-class":`opacity-0 max-h-0 overflow-hidden`,"enter-to-class":`opacity-100 max-h-screen overflow-visible`,"leave-active-class":`transition-all duration-300 ease-in`,"leave-from-class":`opacity-100 max-h-screen overflow-visible`,"leave-to-class":`opacity-0 max-h-0 overflow-hidden`},{default:e(()=>[d.value&&n.node.children.length>0?(h(),C(`div`,ki,[(h(!0),C(x,null,m(n.node.children,e=>(h(),u(l,{key:e.id,node:e,"selected-node-id":n.selectedNodeId,level:n.level+1,disabled:i.disabled,unlocked:i.unlocked,onSelect:D,onEdit:O,onDelete:k},null,8,[`node`,`selected-node-id`,`level`,`disabled`,`unlocked`]))),128))])):g(``,!0)]),_:1})])}}}),[[`__scopeId`,`data-v-dad29312`]]),ji={class:`modal-card max-w-md`},Mi={class:`flex items-center justify-between mb-6`},Ni={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},Pi={key:0},Fi={class:`text-primary font-mono`},Ii={key:1},Li={class:`pb-2`},Ri={class:`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5`},zi={for:`keyName`,class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},Bi={class:`flex items-center`},Vi={key:0,class:`px-3 py-3 bg-secondary/10 border border-r-0 border-secondary/30 rounded-l-lg text-secondary text-sm font-mono`},Hi=[`placeholder`],Ui={key:0,class:`text-content-muted dark:text-content-muted text-xs mt-1`},Wi={class:`pt-1 border-t border-stroke-subtle dark:border-stroke/10`},Gi={class:`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5`},Ki={class:`flex gap-3 pt-4`},qi=[`disabled`],Ji=f({__name:`AddKeyModal`,props:{show:{type:Boolean},selectedNodeName:{},selectedNodeId:{}},emits:[`close`,`add`],setup(e,{emit:n}){let r=e,i=n,a=l(``),o=l(`allow`),s=l(`region`),d=y(()=>s.value===`region`),f=y(()=>({type:d.value?`Region`:`Private Key`,description:d.value?`Regional organisational key`:`Individual assigned key`})),m=y(()=>a.value.trim().length>0),_=()=>{m.value&&(i(`add`,{name:d.value?`#${a.value.trim()}`:a.value.trim(),floodPolicy:o.value,parentId:r.selectedNodeId}),a.value=``,o.value=`allow`,s.value=`region`)},v=()=>{a.value=``,o.value=`allow`,s.value=`region`,i(`close`)};return(n,i)=>(h(),u(p,{to:`body`},[e.show?(h(),C(`div`,{key:0,onClick:i[5]||=N(e=>v(),[`self`]),class:`modal-backdrop`},[S(`div`,ji,[S(`div`,Mi,[S(`div`,null,[i[7]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Add New Entry `,-1),S(`p`,Ni,[r.selectedNodeName?(h(),C(`span`,Pi,[i[6]||=b(` Add to: `,-1),S(`span`,Fi,t(r.selectedNodeName),1)])):(h(),C(`span`,Ii,` Add to root level (#uk) `))])]),S(`button`,{onClick:v,class:`text-white/60 hover:text-white transition-colors`},[...i[8]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`form`,{onSubmit:N(_,[`prevent`]),class:`space-y-5`},[S(`div`,Li,[i[9]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},` Entry Type `,-1),S(`div`,Ri,[S(`button`,{type:`button`,onClick:i[0]||=e=>s.value=`region`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,s.value===`region`?`bg-secondary/20 text-secondary border border-secondary/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` REGION `,2),S(`button`,{type:`button`,onClick:i[1]||=e=>s.value=`privateKey`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,s.value===`privateKey`?`bg-accent-green/20 text-accent-green border border-accent-green/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` PRIVATE KEY `,2)])]),S(`div`,null,[S(`label`,zi,t(f.value.type)+` Name `,1),S(`div`,Bi,[d.value?(h(),C(`span`,Vi,`#`)):g(``,!0),c(S(`input`,{id:`keyName`,"onUpdate:modelValue":i[2]||=e=>a.value=e,type:`text`,placeholder:d.value?`e.g., uk, au, us`:`Enter key name`,class:T([`flex-1 px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors`,d.value?`rounded-r-lg`:`rounded-lg`]),autocomplete:`off`},null,10,Hi),[[j,a.value]])]),d.value?(h(),C(`p`,Ui,` The # prefix is added automatically for regions. `)):g(``,!0)]),S(`div`,Wi,[i[10]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-3 pt-4`},` Flood Policy `,-1),S(`div`,Gi,[S(`button`,{type:`button`,onClick:i[3]||=e=>o.value=`allow`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,o.value===`allow`?`bg-accent-green/10 text-accent-green border border-accent-green/20`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` ALLOW `,2),S(`button`,{type:`button`,onClick:i[4]||=e=>o.value=`deny`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,o.value===`deny`?`bg-accent-red/10 text-accent-red border border-accent-red/20`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` DENY `,2)])]),S(`div`,Ki,[S(`button`,{type:`button`,onClick:v,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),S(`button`,{type:`submit`,disabled:!m.value,class:T([`flex-1 px-4 py-3 rounded-lg transition-colors font-medium`,m.value?`bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green`:`bg-background-mute dark:bg-stroke/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted cursor-not-allowed`])},` Add `+t(f.value.type),11,qi)])],32)])])):g(``,!0)]))}});function Yi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function Xi(e,t,n=``){let r=Yi(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function Zi(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Qi(e,t){Xi(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length=`+n)}function $i(...e){for(let t=0;t>>t}new Uint8Array(new Uint32Array([287454020]).buffer)[0],typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function na(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var ra=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ia(e,t,n){return e&t^~e&n}function aa(e,t,n){return e&t^e&n^t&n}var oa=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ea(this.buffer)}update(e){Zi(this),Xi(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;ar-a&&(this.process(n,0),a=0);for(let e=a;el.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e>la&ca)}:{h:Number(e>>la&ca)|0,l:Number(e&ca)|0}}function da(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a>>3;pa[e]=(ta(n,17)^ta(n,19)^n>>>10)+pa[e-7]+r+pa[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=ta(o,6)^ta(o,11)^ta(o,25),u=l+t+ia(o,s,c)+fa[e]+pa[e]|0,d=(ta(n,2)^ta(n,13)^ta(n,22))+aa(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){$i(pa)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),$i(this.buffer)}},ha=class extends ma{A=sa[0]|0;B=sa[1]|0;C=sa[2]|0;D=sa[3]|0;E=sa[4]|0;F=sa[5]|0;G=sa[6]|0;H=sa[7]|0;constructor(){super(32)}},ga=da(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e)));ga[0],ga[1];var _a=na(()=>new ha,ra(1)),va={class:`modal-card max-w-lg`},ya={class:`flex items-center justify-between mb-6`},ba={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},xa={class:`text-primary font-mono`},Sa={class:`pb-2`},Ca={class:`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5`},wa={for:`keyName`,class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},Ta={class:`flex items-center`},Ea={key:0,class:`px-3 py-3 bg-secondary/10 border border-r-0 border-secondary/30 rounded-l-lg text-secondary text-sm font-mono`},Da=[`placeholder`],Oa={key:0,class:`text-content-muted dark:text-content-muted text-xs mt-1`},ka={key:1,class:`mt-3 bg-background-mute dark:bg-black/20 border border-stroke-subtle dark:border-stroke/10 rounded-md p-3`},Aa={class:`flex items-center justify-between mb-1.5`},ja={class:`text-xs font-mono text-content-primary dark:text-content-primary/80 break-all`},Ma={key:0,class:`text-xs text-amber-500 dark:text-amber-400 mt-1`},Na={key:0,class:`mt-1 bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-3`},Pa={class:`flex items-center justify-between`},Fa={class:`text-right`},Ia={class:`text-sm text-content-secondary dark:text-content-muted`},La={class:`text-xs text-content-muted dark:text-content-muted`},Ra={class:`pt-1 border-t border-stroke-subtle dark:border-stroke/10`},za={class:`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5`},Ba={class:`flex gap-3 pt-4`},Va=[`disabled`],Ha=f({__name:`EditKeyModal`,props:{show:{type:Boolean},node:{}},emits:[`close`,`save`],setup(e,{emit:n}){let r=e,i=n,a=l(``),s=l(`allow`),d=l(`region`),f=y(()=>d.value===`region`),m=y(()=>({type:f.value?`Region`:`Private Key`,description:f.value?`Regional organisational key`:`Individual assigned key`}));o(()=>r.node,e=>{if(e){let t=e.name.startsWith(`#`);d.value=t?`region`:`privateKey`,a.value=t?e.name.slice(1):e.name,s.value=e.floodPolicy}else a.value=``,s.value=`allow`,d.value=`region`},{immediate:!0});let _=y(()=>a.value.trim().length>0&&r.node),x=y(()=>{let e=a.value.trim();return e?f.value?`#${e}`:e:r.node?.name||``}),w=y(()=>r.node?r.node.name.startsWith(`#`)?r.node.name.slice(1):r.node.name:``),D=y(()=>a.value.trim()!==w.value);function O(e){let t=e.startsWith(`#`)?e:`#${e}`,n=_a(new TextEncoder().encode(t)).slice(0,16),r=``;return n.forEach(e=>{r+=String.fromCharCode(e)}),btoa(r)}let k=l(null);E(()=>{let e=a.value.trim();if(!f.value||!e){k.value=null;return}k.value=O(e)});let A=e=>{window.navigator?.clipboard&&window.navigator.clipboard.writeText(e)},M=()=>{if(!_.value||!r.node)return;let e=f.value?`#${a.value.trim()}`:a.value.trim(),t=f.value&&D.value?k.value??O(a.value.trim()):void 0;i(`save`,{id:r.node.id,name:e,floodPolicy:s.value,transportKey:t}),P()},P=()=>{i(`close`)};return(n,r)=>(h(),u(p,{to:`body`},[e.show?(h(),C(`div`,{key:0,onClick:r[6]||=N(e=>P(),[`self`]),class:`modal-backdrop`},[S(`div`,va,[S(`div`,ya,[S(`div`,null,[r[8]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Edit Entry `,-1),S(`p`,ba,[r[7]||=b(` Modify `,-1),S(`span`,xa,t(x.value),1)])]),S(`button`,{onClick:P,class:`text-white/60 hover:text-white transition-colors`},[...r[9]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`form`,{onSubmit:N(M,[`prevent`]),class:`space-y-5`},[S(`div`,Sa,[r[10]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},` Entry Type `,-1),S(`div`,Ca,[S(`button`,{type:`button`,onClick:r[0]||=e=>d.value=`region`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,d.value===`region`?`bg-secondary/20 text-secondary border border-secondary/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` REGION `,2),S(`button`,{type:`button`,onClick:r[1]||=e=>d.value=`privateKey`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,d.value===`privateKey`?`bg-accent-green/20 text-accent-green border border-accent-green/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` PRIVATE KEY `,2)])]),S(`div`,null,[S(`label`,wa,t(m.value.type)+` Name `,1),S(`div`,Ta,[f.value?(h(),C(`span`,Ea,`#`)):g(``,!0),c(S(`input`,{id:`keyName`,"onUpdate:modelValue":r[2]||=e=>a.value=e,type:`text`,placeholder:f.value?`e.g., uk, au, us`:`Enter key name`,class:T([`flex-1 px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors`,f.value?`rounded-r-lg`:`rounded-lg`]),autocomplete:`off`},null,10,Da),[[j,a.value]])]),f.value?(h(),C(`p`,Oa,` The # prefix is added automatically for regions. `)):g(``,!0),f.value&&e.node?.transport_key?(h(),C(`div`,ka,[S(`div`,Aa,[r[12]||=S(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted`},`Transport Key`,-1),D.value?g(``,!0):(h(),C(`button`,{key:0,type:`button`,onClick:r[3]||=t=>A(e.node.transport_key||``),class:`text-xs text-accent-green hover:text-accent-green/80 flex items-center gap-1`,title:`Copy to clipboard`},[...r[11]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),b(` Copy `,-1)]]))]),S(`div`,ja,t(k.value??e.node.transport_key),1),D.value?(h(),C(`div`,Ma,` Updated for "`+t(x.value)+`" `,1)):g(``,!0)])):g(``,!0)]),e.node?.last_used?(h(),C(`div`,Na,[S(`div`,Pa,[r[13]||=S(`div`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})]),S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Last Used`)],-1),S(`div`,Fa,[S(`div`,Ia,t(e.node.last_used.toLocaleDateString())+` at `+t(e.node.last_used.toLocaleTimeString()),1),S(`div`,La,t(v(K)(e.node.last_used)),1)])])])):g(``,!0),S(`div`,Ra,[r[14]||=S(`label`,{class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-3 pt-4`},` Flood Policy `,-1),S(`div`,za,[S(`button`,{type:`button`,onClick:r[4]||=e=>s.value=`allow`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,s.value===`allow`?`bg-accent-green/10 text-accent-green border border-accent-green/20`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` ALLOW `,2),S(`button`,{type:`button`,onClick:r[5]||=e=>s.value=`deny`,class:T([`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors`,s.value===`deny`?`bg-accent-red/10 text-accent-red border border-accent-red/20`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` DENY `,2)])]),S(`div`,Ba,[S(`button`,{type:`button`,onClick:P,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),S(`button`,{type:`submit`,disabled:!_.value,class:T([`flex-1 px-4 py-3 rounded-lg transition-colors font-medium`,_.value?`bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green`:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted/70 cursor-not-allowed`])},` Done `,10,Va)])],32)])])):g(``,!0)]))}}),Ua={class:`modal-card max-w-lg`},Wa={class:`flex items-center gap-3 mb-6`},Ga={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},Ka={class:`text-accent-red font-mono`},qa={key:0,class:`bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6`},Ja={class:`flex items-start gap-3`},Ya={class:`flex-1`},Xa={class:`text-accent-red font-medium text-sm mb-2`},Za={class:`space-y-1 max-h-32 overflow-y-auto`},Qa={key:0,class:`w-3 h-3 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},$a={key:1,class:`w-3 h-3 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},eo={class:`font-mono`},to={key:0,class:`text-content-secondary dark:text-content-muted text-xs`},no={key:1,class:`mb-6`},ro={class:`mb-3`},io={class:`relative`},ao={class:`space-y-2 max-h-40 overflow-y-auto border border-stroke-subtle dark:border-stroke/20 rounded-lg p-3 bg-gray-50 dark:bg-white/5`},oo={key:0,class:`text-center py-4 text-content-secondary dark:text-content-muted text-sm`},so={class:`relative`},co=[`value`],lo={class:`flex items-center gap-2 flex-1`},uo={class:`text-content-primary dark:text-content-primary font-mono text-sm`},fo={key:0,class:`ml-auto px-2 py-0.5 bg-background-mute dark:bg-stroke/10 text-content-secondary dark:text-content-muted text-xs rounded-full`},po={class:`flex gap-3`},mo=f({__name:`DeleteConfirmModal`,props:{show:{type:Boolean},node:{},allNodes:{}},emits:[`close`,`delete-all`,`move-children`],setup(e,{emit:n}){let r=e,i=n,a=l(null),o=l(``),s=e=>{let t=[],n=e=>{for(let r of e.children)t.push(r),n(r)};return n(e),t},d=y(()=>r.node?s(r.node):[]),f=y(()=>{if(!r.node)return[];let e=new Set([r.node.id,...d.value.map(e=>e.id)]),t=n=>{let r=[];for(let i of n)i.name.startsWith(`#`)&&!e.has(i.id)&&r.push(i),i.children.length>0&&r.push(...t(i.children));return r};return t(r.allNodes)}),_=y(()=>{if(!o.value.trim())return f.value;let e=o.value.toLowerCase();return f.value.filter(t=>t.name.toLowerCase().includes(e))}),v=()=>{r.node&&(i(`delete-all`,r.node.id),E())},w=()=>{!r.node||!a.value||(i(`move-children`,{nodeId:r.node.id,targetParentId:a.value}),E())},E=()=>{a.value=null,o.value=``,i(`close`)};return(n,r)=>(h(),u(p,{to:`body`},[e.show&&e.node?(h(),C(`div`,{key:0,onClick:r[2]||=N(e=>E(),[`self`]),class:`modal-backdrop-heavy`},[S(`div`,Ua,[S(`div`,Wa,[r[6]||=S(`svg`,{class:`w-6 h-6 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,null,[r[4]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Confirm Deletion `,-1),S(`p`,Ga,[r[3]||=b(` Deleting `,-1),S(`span`,Ka,t(e.node?.name),1)])]),S(`button`,{onClick:E,class:`ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...r[5]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),d.value.length>0?(h(),C(`div`,qa,[S(`div`,Ja,[r[9]||=S(`svg`,{class:`w-5 h-5 text-accent-red flex-shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`div`,Ya,[S(`h4`,Xa,` This will affect `+t(d.value.length)+` child `+t(d.value.length===1?`entry`:`entries`)+`: `,1),S(`div`,Za,[(h(!0),C(x,null,m(d.value.slice(0,10),e=>(h(),C(`div`,{key:e.id,class:`flex items-center gap-2 text-xs text-content-secondary dark:text-content-primary/80`},[e.name.startsWith(`#`)?(h(),C(`svg`,Qa,[...r[7]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`},null,-1)]])):(h(),C(`svg`,$a,[...r[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z`},null,-1)]])),S(`span`,eo,t(e.name),1),S(`span`,{class:T([`px-1 py-0.5 text-xs rounded`,e.floodPolicy===`allow`?`bg-accent-green/20 text-accent-green`:`bg-accent-red/20 text-accent-red`])},t(e.floodPolicy),3)]))),128)),d.value.length>10?(h(),C(`div`,to,` ...and `+t(d.value.length-10)+` more `,1)):g(``,!0)])])])])):g(``,!0),d.value.length>0&&f.value.length>0?(h(),C(`div`,no,[r[13]||=S(`h4`,{class:`text-content-primary dark:text-content-primary font-medium text-sm mb-3`},` Move children to another region: `,-1),S(`div`,ro,[S(`div`,io,[r[10]||=S(`svg`,{class:`absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-content-muted dark:text-content-muted`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1),c(S(`input`,{"onUpdate:modelValue":r[0]||=e=>o.value=e,type:`text`,placeholder:`Search regions...`,class:`w-full pl-9 pr-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors text-sm`},null,512),[[j,o.value]])])]),S(`div`,ao,[_.value.length===0?(h(),C(`div`,oo,t(o.value?`No regions match your search`:`No available regions`),1)):g(``,!0),(h(!0),C(x,null,m(_.value,e=>(h(),C(`label`,{key:e.id,class:`flex items-center gap-3 p-2 rounded cursor-pointer hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors group`},[S(`div`,so,[c(S(`input`,{type:`radio`,value:e.id,"onUpdate:modelValue":r[1]||=e=>a.value=e,class:`sr-only peer`},null,8,co),[[D,a.value]]),r[11]||=S(`div`,{class:`w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-hover:border-stroke dark:group-hover:border-stroke/50 peer-checked:border-primary peer-checked:bg-primary/20 transition-all`},[S(`div`,{class:`w-2 h-2 rounded-full bg-primary scale-0 peer-checked:scale-100 transition-transform absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2`})],-1)]),S(`div`,lo,[r[12]||=S(`svg`,{class:`w-4 h-4 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 20l4-16m2 16l4-16M6 9h14M4 15h14`})],-1),S(`span`,uo,t(e.name),1),e.children.length>0?(h(),C(`span`,fo,t(e.children.length),1)):g(``,!0)])]))),128))])])):g(``,!0),S(`div`,po,[S(`button`,{onClick:E,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),d.value.length>0&&a.value?(h(),C(`button`,{key:0,onClick:w,class:`modal-btn-primary`},` Move & Delete `)):g(``,!0),S(`button`,{onClick:v,class:`modal-btn-danger`},t(d.value.length>0?`Delete All`:`Delete`),1)])])])):g(``,!0)]))}}),ho={class:`space-y-12`},go={class:`cfg-page-heading flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3`},_o={class:`flex items-center gap-2 flex-shrink-0`},vo=[`disabled`],yo=[`disabled`],bo=[`disabled`],xo={key:0,class:`bg-red-100 dark:bg-red-500/20 border border-red-500/50 rounded-lg p-3`},So={class:`text-red-600 dark:text-red-400 text-sm`},Co={class:`cfg-section`},wo={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},To={key:0,class:`text-xs text-content-muted dark:text-content-muted pb-1`},Eo={key:1,class:`flex items-center justify-center py-8`},Do={key:2,class:`text-center py-8`},Oo={class:`text-content-secondary dark:text-content-muted text-sm`},ko={key:3,class:`text-center py-8`},Ao={key:4,class:`space-y-2`},jo=f({name:`TransportKeys`,__name:`TransportKeys`,setup(e,{expose:n}){let i=fi(),a=ee(),s=l(!1),c=l(!1),d=l(null),f=-1;function p(){return f--}let w=l(`deny`),E=`deny`;o(y(()=>a.stats?.config?.mesh?.unscoped_flood_allow??null),e=>{e!==null&&!s.value&&(w.value=e?`allow`:`deny`)},{immediate:!0});let D=l([]),O=null,k=l(!1),A=l(null),j=l(!1),M=l(!1),N=l(!1),P=l(null),F=l(null);function I(e){return e.map(e=>({...e,children:I(e.children)}))}function L(e,t){let n=[];for(let r of e)n.push({node:r,parentId:t}),n.push(...L(r.children,r.id));return n}function z(e,t){for(let n of e){if(n.id===t)return n;let e=z(n.children,t);if(e)return e}return null}function B(e,t){let n=e.findIndex(e=>e.id===t);if(n!==-1)return e.splice(n,1),!0;for(let n of e)if(B(n.children,t))return!0;return!1}let V=e=>{let t=new Map,n=[];return e.forEach(e=>{t.set(e.id,{id:e.id,name:e.name,floodPolicy:e.flood_policy,transport_key:e.transport_key,last_used:e.last_used?new Date(e.last_used*1e3):void 0,parent_id:e.parent_id,children:[]})}),t.forEach(e=>{e.parent_id&&t.has(e.parent_id)?t.get(e.parent_id).children.push(e):n.push(e)}),n},te=async()=>{k.value=!0,A.value=null;try{let e=await R.getTransportKeys();e.success&&e.data?D.value=V(e.data):A.value=e.error||`Failed to load regions`}catch(e){A.value=e instanceof Error?e.message:`Unknown error occurred`}finally{k.value=!1}};r(te);function ne(){O=I(D.value),E=w.value,s.value=!0,d.value=null}function U(){O&&(D.value=I(O)),w.value=E,O=null,s.value=!1,d.value=null,i.setSelectedNode(null)}async function W(){c.value=!0,d.value=null;try{let e=L(D.value),t=O?L(O):[],n=new Map(t.map(({node:e})=>[e.id,e])),r=e.filter(({node:e})=>e.id>0),o=e.filter(({node:e})=>e.id<0),c=new Set(r.map(({node:e})=>e.id));for(let{node:e}of t)c.has(e.id)||await R.deleteTransportKey(e.id);let l=new Map,u=[...o],d=u.length*2;for(;u.length&&d-- >0;){let e=u.findIndex(({parentId:e})=>e===void 0||e>0||e<0&&l.has(e));if(e===-1)break;let{node:t,parentId:n}=u.splice(e,1)[0],r=n===void 0?void 0:n>0?n:l.get(n),i=await R.createTransportKey(t.name,t.floodPolicy,t.transport_key,r);i.success&&i.data?.id&&l.set(t.id,i.data.id)}for(let{node:e}of r){let t=n.get(e.id);t&&(e.name!==t.name||e.floodPolicy!==t.floodPolicy||e.transport_key!==t.transport_key)&&await R.updateTransportKey(e.id,e.name,e.floodPolicy,e.transport_key)}w.value!==E&&await R.updateUnscopedFloodPolicy(w.value===`allow`),await te(),await a.fetchStats(),O=null,s.value=!1,i.setSelectedNode(null)}catch(e){d.value=e instanceof Error?e.message:`Save failed`}finally{c.value=!1}}function G(e){i.setSelectedNode(e)}function K(){let e=i.selectedNodeId.value;return e?z(D.value,e)?.name:void 0}function re(){j.value=!0}function ie(e){let t={id:p(),name:e.name,floodPolicy:e.floodPolicy,children:[]};if(e.parentId){let n=z(D.value,e.parentId);n?n.children.push(t):D.value.push(t)}else D.value.push(t);j.value=!1}function q(e){let t=z(D.value,e);t&&(P.value=t,M.value=!0)}function J(e){let t=z(D.value,e.id);t&&(t.name=e.name,t.floodPolicy=e.floodPolicy,e.transportKey!==void 0&&(t.transport_key=e.transportKey)),M.value=!1,P.value=null}function Y(){M.value=!1,P.value=null}function X(e){let t=z(D.value,e);t&&(F.value=t,N.value=!0)}function Z(e){B(D.value,e),i.setSelectedNode(null),N.value=!1,F.value=null}function Q(e){let t=z(D.value,e.nodeId);if(t?.children.length){let n=z(D.value,e.targetParentId);n?n.children.push(...t.children):D.value.push(...t.children)}B(D.value,e.nodeId),i.setSelectedNode(null),N.value=!1,F.value=null}function ae(e){w.value=e}let{showUnsavedModal:oe,requestLeave:se,handleDiscard:$,handleSave:ce,handleCancel:de}=ue(s,c,U,async()=>(await W(),!s.value));return n({requestLeave:se,isEditing:s}),(e,n)=>(h(),C(x,null,[_(le,{show:v(oe),"is-saving":c.value,label:`Region Configuration`,onDiscard:v($),onSave:v(ce),onCancel:v(de)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,ho,[S(`div`,go,[n[6]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},` Region Configuration `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Manage regional key hierarchy `)],-1),S(`div`,_o,[s.value?(h(),C(`button`,{key:0,onClick:re,class:`cfg-btn-secondary flex items-center gap-1.5`,disabled:c.value},[...n[5]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),b(` Add Region `,-1)]],8,vo)):g(``,!0),s.value?(h(),C(x,{key:2},[S(`button`,{onClick:U,disabled:c.value,class:`cfg-btn-secondary`},`Cancel`,8,yo),S(`button`,{onClick:W,disabled:c.value,class:`cfg-btn-primary`},t(c.value?`Saving…`:`Save Changes`),9,bo)],64)):(h(),C(`button`,{key:1,onClick:ne,class:`cfg-btn-primary`},`Edit Settings`))])]),d.value?(h(),C(`div`,xo,[S(`p`,So,t(d.value),1)])):g(``,!0),S(`div`,Co,[S(`div`,wo,[n[7]||=S(`div`,null,[S(`h4`,{class:`text-xs sm:text-sm font-medium text-content-primary dark:text-content-primary mb-1`},` Unscoped Flood Policy (*) `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-[10px] sm:text-xs`},` Allow or Deny unscoped flood packets `)],-1),S(`div`,{class:T([`flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5 sm:p-1`,s.value?``:`opacity-50 pointer-events-none`])},[S(`button`,{onClick:n[0]||=e=>ae(`deny`),class:T([`px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors`,w.value===`deny`?`bg-accent-red/20 text-accent-red border border-accent-red/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` DENY `,2),S(`button`,{onClick:n[1]||=e=>ae(`allow`),class:T([`px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors`,w.value===`allow`?`bg-accent-green/20 text-accent-green border border-accent-green/50`:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary`])},` ALLOW `,2)],2)])]),S(`div`,{class:`cfg-section space-y-4`,onClick:n[2]||=e=>s.value&&v(i).setSelectedNode(null)},[n[11]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary`},`Regions`,-1),s.value?(h(),C(`p`,To,` To add a child region, click on a region to select it, then click "Add Region". `)):g(``,!0),k.value?(h(),C(`div`,Eo,[_(H),n[8]||=S(`span`,{class:`ml-2 text-content-secondary dark:text-content-muted`},`Loading regions…`,-1)])):A.value?(h(),C(`div`,Do,[n[9]||=S(`div`,{class:`text-accent-red mb-2`},`⚠️ Error loading regions`,-1),S(`div`,Oo,t(A.value),1),S(`button`,{onClick:te,class:`btn-success mt-4`},` Retry `)])):D.value.length===0?(h(),C(`div`,ko,[...n[10]||=[S(`div`,{class:`text-content-muted dark:text-content-muted mb-2`},`No regions found`,-1),S(`div`,{class:`text-content-muted dark:text-content-muted/60 text-sm`},` Click "Edit Settings" then "Add Region" to get started `,-1)]])):(h(),C(`div`,Ao,[(h(!0),C(x,null,m(D.value,e=>(h(),u(Ai,{key:e.id,node:e,"selected-node-id":v(i).selectedNodeId.value,level:0,unlocked:s.value,onSelect:G,onEdit:q,onDelete:X},null,8,[`node`,`selected-node-id`,`unlocked`]))),128))]))]),_(Ji,{show:j.value,"selected-node-name":K(),"selected-node-id":v(i).selectedNodeId.value||void 0,onClose:n[3]||=e=>j.value=!1,onAdd:ie},null,8,[`show`,`selected-node-name`,`selected-node-id`]),_(Ha,{show:M.value,node:P.value,onClose:Y,onSave:J},null,8,[`show`,`node`]),_(mo,{show:N.value,node:F.value,"all-nodes":D.value,onClose:n[4]||=e=>{N.value=!1,F.value=null},onDeleteAll:Z,onMoveChildren:Q},null,8,[`show`,`node`,`all-nodes`])])],64))}}),Mo={class:`space-y-12`},No={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},Po={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-4`},Fo={class:`flex items-center gap-2 text-red-600 dark:text-red-400`},Io={key:1,class:`flex items-center justify-center py-12`},Lo={class:`text-center`},Ro={key:2,class:`space-y-3`},zo={class:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`},Bo={class:`flex-1`},Vo={class:`flex items-center gap-2 sm:gap-3`},Ho={class:`min-w-0 flex-1`},Uo={class:`text-content-primary dark:text-content-primary font-medium text-sm sm:text-base break-all`},Wo={class:`flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-1 text-xs text-content-secondary dark:text-content-muted`},Go={class:`truncate`},Ko={class:`truncate`},qo=[`onClick`,`disabled`],Jo={key:3,class:`text-center py-12`},Yo={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-md w-full shadow-2xl`},Xo={class:`space-y-4`},Zo={class:`flex justify-end gap-3 mt-6`},Qo=[`disabled`],$o=[`disabled`],es={class:`bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-lg w-full shadow-2xl`},ts={class:`space-y-4`},ns={class:`flex gap-2`},rs=[`value`],is={class:`bg-blue-500/10 border border-blue-500/30 rounded-lg p-4`},as={class:`block bg-blue-500/20 px-3 py-2 rounded text-xs text-blue-100 font-mono overflow-x-auto`},os=f({name:`APITokens`,__name:`APITokens`,setup(e){let n=l([]),i=l(!1),a=l(null),o=l(!1),s=l(``),u=l(null),f=l(!1),p=l(!1),v=l(null),w=async()=>{i.value=!0,a.value=null;try{let e=await R.get(`/auth/tokens`);n.value=(e.data||e).tokens||[]}catch(e){console.error(`Failed to fetch API tokens:`,e),a.value=e instanceof Error?e.message:`Failed to fetch tokens`}finally{i.value=!1}},T=async()=>{if(!s.value.trim()){a.value=`Token name is required`;return}i.value=!0,a.value=null;try{let e=await R.post(`/auth/tokens`,{name:s.value.trim()});u.value=(e.data||e).token||null,o.value=!1,f.value=!0,s.value=``,await w()}catch(e){console.error(`Failed to create API token:`,e),a.value=e instanceof Error?e.message:`Failed to create token`}finally{i.value=!1}},E=(e,t)=>{v.value={id:e,name:t},p.value=!0},D=async()=>{if(v.value){i.value=!0,a.value=null;try{await R.delete(`/auth/tokens/${v.value.id}`),await w(),p.value=!1,v.value=null}catch(e){console.error(`Failed to revoke API token:`,e),a.value=e instanceof Error?e.message:`Failed to revoke token`}finally{i.value=!1}}},O=()=>{o.value=!1,s.value=``,a.value=null},A=()=>{f.value=!1,u.value=null},M=()=>{u.value&&navigator.clipboard.writeText(u.value)},P=e=>e?new Date(e*1e3).toLocaleString():`Never`,F=y(()=>`${window.location.origin}/api/stats`);return r(()=>{w()}),(e,r)=>(h(),C(x,null,[S(`div`,Mo,[S(`div`,No,[r[5]||=S(`div`,null,[S(`h2`,{class:`text-lg sm:text-xl font-semibold text-content-primary dark:text-content-primary`},` API Tokens `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm mt-1`},` Manage API tokens for machine-to-machine authentication `)],-1),S(`button`,{onClick:r[0]||=e=>o.value=!0,class:`cfg-btn-primary flex items-center justify-center gap-2`},[...r[4]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),b(` Create Token `,-1)]])]),r[20]||=d(`

API tokens are used for machine-to-machine authentication. Include the token in the X-API-Key header when making API requests.

Tokens are only shown once at creation. Store them securely.

`,1),a.value?(h(),C(`div`,Po,[S(`div`,Fo,[r[6]||=S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),b(` `+t(a.value),1)])])):g(``,!0),i.value&&n.value.length===0?(h(),C(`div`,Io,[S(`div`,Lo,[_(H,{class:`mx-auto mb-4`}),r[7]||=S(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading tokens...`,-1)])])):n.value.length>0?(h(),C(`div`,Ro,[(h(!0),C(x,null,m(n.value,e=>(h(),C(`div`,{key:e.id,class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-3 sm:p-4 hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors`},[S(`div`,zo,[S(`div`,Bo,[S(`div`,Vo,[r[8]||=S(`svg`,{class:`w-4 h-4 sm:w-5 sm:h-5 text-primary flex-shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})],-1),S(`div`,Ho,[S(`h3`,Uo,t(e.name),1),S(`div`,Wo,[S(`span`,Go,`Created: `+t(P(e.created_at)),1),S(`span`,Ko,`Last used: `+t(P(e.last_used)),1)])])])]),S(`button`,{onClick:t=>E(e.id,e.name),disabled:i.value,class:`w-full sm:w-auto px-3 py-1.5 bg-red-100 dark:bg-red-500/20 hover:bg-red-500/30 text-red-600 dark:text-red-400 rounded-lg border border-red-500/50 transition-colors disabled:opacity-50 text-sm`},` Revoke `,8,qo)])]))),128))])):(h(),C(`div`,Jo,[r[9]||=S(`svg`,{class:`w-16 h-16 text-content-muted dark:text-content-muted/40 mx-auto mb-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})],-1),r[10]||=S(`h3`,{class:`text-content-primary dark:text-content-primary font-medium mb-2`},`No API Tokens`,-1),r[11]||=S(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mb-4`},` Create a token to enable API access `,-1),S(`button`,{onClick:r[1]||=e=>o.value=!0,class:`cfg-btn-primary`},` Create Your First Token `)])),o.value?(h(),C(`div`,{key:4,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:N(O,[`self`])},[S(`div`,Yo,[r[14]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-4`},` Create API Token `,-1),S(`div`,Xo,[S(`div`,null,[r[12]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Token Name`,-1),c(S(`input`,{"onUpdate:modelValue":r[2]||=e=>s.value=e,type:`text`,placeholder:`e.g., Production Server, CI/CD Pipeline`,class:`cfg-input placeholder-gray-400 dark:placeholder-white/40`,onKeydown:k(T,[`enter`])},null,544),[[j,s.value]]),r[13]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted mt-1`},` Give your token a descriptive name to identify its purpose `,-1)]),S(`div`,Zo,[S(`button`,{onClick:O,disabled:i.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors disabled:opacity-50`},` Cancel `,8,Qo),S(`button`,{onClick:T,disabled:i.value||!s.value.trim(),class:`btn-primary`},t(i.value?`Creating...`:`Create Token`),9,$o)])])])])):g(``,!0),f.value&&u.value?(h(),C(`div`,{key:5,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:N(A,[`self`])},[S(`div`,es,[r[19]||=S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-4`},` Token Created Successfully `,-1),S(`div`,ts,[r[18]||=d(`
Save this token now! For security reasons, it will not be shown again.
`,1),S(`div`,null,[r[16]||=S(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Your API Token`,-1),S(`div`,ns,[S(`input`,{value:u.value,readonly:``,class:`flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary font-mono text-sm`},null,8,rs),S(`button`,{onClick:M,class:`btn-primary flex items-center gap-2`,title:`Copy to clipboard`},[...r[15]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),b(` Copy `,-1)]])])]),S(`div`,is,[r[17]||=S(`p`,{class:`text-sm text-blue-200 mb-2`},[S(`strong`,null,`Usage Example:`)],-1),S(`code`,as,` curl -H "X-API-Key: `+t(u.value)+`" `+t(F.value),1)]),S(`div`,{class:`flex justify-end mt-6`},[S(`button`,{onClick:A,class:`btn-primary`},` Done `)])])])])):g(``,!0)]),_(ne,{show:p.value,title:`Revoke API Token`,message:`Are you sure you want to revoke the token '${v.value?.name}'? This action cannot be undone.`,"confirm-text":`Revoke`,"cancel-text":`Cancel`,variant:`danger`,onConfirm:D,onClose:r[3]||=e=>p.value=!1},null,8,[`show`,`message`])],64))}}),ss={class:`space-y-12`},cs={class:`cfg-section`},ls={class:`space-y-4`},us=[`disabled`],ds={class:`cfg-section`},fs={class:`space-y-4`},ps={class:`flex items-center justify-between`},ms=[`disabled`],hs={class:`cfg-section`},gs={class:`space-y-4`},_s={class:`space-y-3`},vs=[`checked`,`disabled`],ys=[`checked`,`disabled`],bs={class:`flex items-start gap-3`},xs={key:0,class:`w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Ss={key:1,class:`w-5 h-5 text-accent-cyan flex-shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Cs={class:`flex-1`},ws={class:`text-sm font-medium text-content-primary dark:text-content-primary`},Ts={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-1`},Es={key:1,class:`p-4 bg-amber-500/10 border border-amber-500/30 rounded-lg`},Ds={class:`flex items-start justify-between gap-3`},Os=[`disabled`],ks={key:0,class:`animate-spin h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},As={key:1,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},js={class:`flex items-center space-x-2`},Ms={key:0,class:`w-5 h-5 text-green-600 dark:text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Ns={key:1,class:`w-5 h-5 text-red-600 dark:text-red-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},Ps=f({name:`WebSettings`,__name:`WebSettings`,setup(e){let{stats:n}=z(ee()),a=l(!1),o=l(``),s=l(!1),u=l(!1),f=l(!1),p=l(!1),m=l(!0),_=i({cors_enabled:!1,use_default_frontend:!0,site_name:``}),v=y(()=>s.value?`bg-green-500/10 border-green-600/40 dark:border-green-500/30`:`bg-red-500/10 border-red-500/30`);async function w(){try{m.value=!0;let e=await R.get(`/check_pymc_console`);e.success&&e.data&&(p.value=e.data.exists)}catch(e){console.error(`Failed to check PyMC Console:`,e),p.value=!1}finally{m.value=!1}}function E(){let e=n.value?.config?.web||{};_.cors_enabled=e.cors_enabled===!0;let t=e.web_path;_.use_default_frontend=!t||t===``,_.site_name=typeof n.value?.site_name==`string`?n.value.site_name:``}async function D(){a.value=!0,o.value=``;try{let e={web:{cors_enabled:_.cors_enabled,site_name:_.site_name.trim()}};_.use_default_frontend?e.web.web_path=null:e.web.web_path=`/opt/pymc_console/web/html`;let t=await R.post(`/update_web_config`,e);t.success?(M(`Settings saved successfully`,!0),u.value=!0):M(t.error||`Failed to save settings`,!1)}catch(e){console.error(`Failed to save web settings:`,e),M(e.message||`Failed to save settings`,!1)}finally{a.value=!1}}async function O(){_.cors_enabled=!_.cors_enabled,await D()}async function k(){_.use_default_frontend=!0,await D()}async function A(){if(!p.value){M(`PyMC Console is not installed. Please install it before switching.`,!1);return}_.use_default_frontend=!1,await D()}function M(e,t){o.value=e,s.value=t,setTimeout(()=>{o.value=``},5e3)}async function N(){f.value=!0,o.value=``;try{let e=await R.post(`/restart_service`,{});e.success?(M(`Service restart initiated. Page will reload...`,!0),u.value=!1,setTimeout(()=>{window.location.reload()},2e3)):M(e.error||`Failed to restart service`,!1)}catch(e){e.code===`ERR_NETWORK`||e.message?.includes(`Network error`)?(M(`Service restarting... Page will reload`,!0),u.value=!1,setTimeout(()=>{window.location.reload()},3e3)):(console.error(`Failed to restart service:`,e),M(e.message||`Failed to restart service`,!1))}finally{f.value=!1}}return r(()=>{E(),w()}),(e,n)=>(h(),C(`div`,ss,[n[18]||=S(`div`,{class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},[S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Web Options`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure site identification, CORS policy and web frontend selection`)])],-1),S(`div`,cs,[n[3]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Site Identification `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Customise the browser tab title and login page caption `)])],-1),S(`div`,ls,[S(`div`,null,[n[1]||=S(`label`,{for:`site-name`,class:`block text-sm font-medium text-content-primary dark:text-content-primary mb-2`},` Site Name `,-1),c(S(`input`,{id:`site-name`,"onUpdate:modelValue":n[0]||=e=>_.site_name=e,type:`text`,maxlength:`80`,placeholder:`e.g. Base Station Alpha`,class:`w-full px-3 py-2 rounded-lg bg-background-mute dark:bg-background/40 border border-stroke-subtle dark:border-stroke/20 text-sm text-content-primary dark:text-content-primary placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 transition-colors`,onChange:D,disabled:a.value},null,40,us),[[j,_.site_name]]),n[2]||=S(`p`,{class:`text-xs text-content-secondary dark:text-content-muted mt-1.5`},` Shown in the browser tab and above the login form. Leave blank to use the default title. `,-1)])])]),S(`div`,ds,[n[5]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` CORS Settings `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Control cross-origin resource sharing for API access `)])],-1),S(`div`,fs,[S(`div`,ps,[n[4]||=S(`div`,null,[S(`label`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Enable CORS`),S(`p`,{class:`text-xs text-content-secondary dark:text-content-muted mt-1`},` Allow web frontends from different origins to access the API `)],-1),S(`button`,{onClick:O,disabled:a.value,class:T([`relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2`,_.cors_enabled?`bg-cyan-600 dark:bg-teal-500 border-cyan-600 dark:border-teal-500`:`bg-gray-400 dark:bg-gray-600 border-gray-400 dark:border-gray-600`,a.value?`opacity-50 cursor-not-allowed`:`cursor-pointer`])},[S(`span`,{class:T([`inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg`,_.cors_enabled?`translate-x-5`:`translate-x-0.5`])},null,2)],10,ms)])])]),S(`div`,hs,[n[15]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Web Frontend `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Choose which web interface to use `)])],-1),S(`div`,gs,[S(`div`,_s,[S(`label`,{class:T([`flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 cursor-pointer transition-all`,_.use_default_frontend?`border-accent-cyan bg-accent-cyan/10`:`border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50`])},[S(`input`,{type:`radio`,name:`frontend`,checked:_.use_default_frontend,onChange:k,disabled:a.value,class:`mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background`},null,40,vs),n[6]||=S(`div`,{class:`flex-1`},[S(`div`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},` Default Frontend `),S(`div`,{class:`text-xs text-content-secondary dark:text-content-muted mt-1`},` Built-in pyMC Repeater web interface `),S(`div`,{class:`text-xs text-content-muted dark:text-content-muted/60 mt-1 font-mono`},` Built-in `)],-1)],2),S(`label`,{class:T([`flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 transition-all`,p.value?`cursor-pointer`:`opacity-50 cursor-not-allowed`,_.use_default_frontend?`border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50`:`border-accent-cyan bg-accent-cyan/10`])},[S(`input`,{type:`radio`,name:`frontend`,checked:!_.use_default_frontend,onChange:A,disabled:a.value||!p.value,class:`mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background`},null,40,ys),n[7]||=d(`
PyMC Console
@Treehouse⚡
Alternative web interface for pyMC Repeater
/opt/pymc_console/web/html
`,1)],2)]),m.value?g(``,!0):(h(),C(`div`,{key:0,class:T([`p-4 rounded-lg border`,p.value?`bg-green-500/5 border-green-500/20`:`bg-accent-cyan/5 border-accent-cyan/20`])},[S(`div`,bs,[p.value?(h(),C(`svg`,xs,[...n[8]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(h(),C(`svg`,Ss,[...n[9]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])),S(`div`,Cs,[S(`h4`,ws,t(p.value?`PyMC Console has been detected`:`PyMC Console Not Installed`),1),p.value?(h(),C(`p`,Ts,[...n[10]||=[b(` PyMC Console is installed at `,-1),S(`code`,{class:`text-green-700 dark:text-green-300`},`/opt/pymc_console/web/html`,-1)]])):(h(),C(x,{key:1},[n[11]||=d(`

PyMC Console must be installed at /opt/pymc_console/web/html before selecting this option.

PyMC Console Install Instructions `,2)],64))])])],2)),u.value?(h(),C(`div`,Es,[S(`div`,Ds,[n[14]||=d(`

Service restart required

Web frontend changes will take effect after restarting the pymc-repeater service.

`,1),S(`button`,{onClick:N,disabled:f.value,class:`px-4 py-2 bg-amber-500 hover:bg-amber-600 disabled:bg-amber-500/50 text-white font-medium rounded-lg transition-colors disabled:cursor-not-allowed flex items-center gap-2 whitespace-nowrap`},[f.value?(h(),C(`svg`,ks,[...n[12]||=[S(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),S(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):(h(),C(`svg`,As,[...n[13]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`},null,-1)]])),b(` `+t(f.value?`Restarting...`:`Restart Now`),1)],8,Os)])])):g(``,!0)])]),o.value?(h(),C(`div`,{key:0,class:T([`p-4 rounded-lg border`,v.value])},[S(`div`,js,[s.value?(h(),C(`svg`,Ms,[...n[16]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`},null,-1)]])):(h(),C(`svg`,Ns,[...n[17]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])),S(`span`,{class:T(s.value?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`)},t(o.value),3)])],2)):g(``,!0)]))}}),Fs={ref:`rootEl`,class:`space-y-12`},Is={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},Ls={class:`flex items-center gap-2 flex-shrink-0`},Rs=[`disabled`],zs=[`disabled`],Bs={key:0,class:`bg-accent-green/20 border border-accent-green/50 rounded-lg p-3 text-accent-green text-sm`},Vs={key:1,class:`bg-accent-red/20 border border-accent-red/50 rounded-lg p-3 text-accent-red text-sm`},Hs={class:`cfg-section space-y-3`},Us={key:0,class:`flex items-center justify-center py-4`},Ws={key:1,class:`text-center py-4`},Gs={class:`grid grid-cols-2 sm:grid-cols-4 gap-3`},Ks={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},qs={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Js={class:`text-lg font-mono text-content-primary dark:text-content-primary`},Ys={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Xs={class:`text-lg font-mono text-accent-green`},Zs={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Qs={class:`text-lg font-mono text-accent-red`},$s={key:0,class:`mt-2 p-2 bg-accent-red/10 rounded-lg border border-accent-red/20`},ec={key:1,class:`mt-2 p-2 bg-secondary/10 rounded-lg border border-secondary/20`},tc={class:`font-medium`},nc={class:`font-mono text-[10px] opacity-70`},rc={class:`text-[10px]`},ic={class:`cfg-section space-y-3`},ac={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},oc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},sc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},cc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},lc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},uc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},dc={key:1,class:`flex items-center gap-2`},fc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},pc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},mc={key:1,class:`flex items-center gap-2`},hc={class:`cfg-section space-y-3`},gc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},_c={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},vc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},yc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},bc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},xc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Sc={key:1,class:`flex items-center gap-2`},Cc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},wc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Tc={key:1,class:`flex items-center gap-2`},Ec={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1`},Dc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Oc={key:1,class:`flex items-center gap-2`},kc={class:`cfg-section space-y-3`},Ac={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},jc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Mc={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1`},Nc={key:0,class:`text-content-primary dark:text-content-primary font-mono text-sm`},Pc={key:1,class:`flex items-center gap-2`},Fc={class:`py-2`},Ic={class:`grid grid-cols-3 gap-2 mt-2`},Lc={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Rc={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},zc={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Bc={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},Vc={class:`text-center p-2 bg-white dark:bg-white/5 rounded-lg border border-stroke-subtle dark:border-white/10`},Hc={key:0,class:`font-mono text-sm text-content-primary dark:text-content-primary`},Uc={class:`p-6 space-y-4`},Wc={class:`flex justify-between items-start`},Gc={class:`flex justify-end pt-4 border-t border-stroke-subtle dark:border-stroke/20`},Kc=f({__name:`AdvertSettings`,setup(e,{expose:n}){let i=ee(),a=y(()=>i.stats?.config?.repeater||{}),u=y(()=>a.value.advert_rate_limit||{}),f=y(()=>a.value.advert_penalty_box||{}),p=y(()=>a.value.advert_adaptive||{}),w=y(()=>p.value.thresholds||{}),E=l(!1),D=l(!1),O=l(``),k=l(``),M=l(!1),P=l(!1),F=l(null),I=l(!0),R=l(2),z=l(1),B=l(10),V=l(60),te=l(!0),ne=l(2),U=l(12),W=l(6),G=l(2),K=l(24),re=l(!0),ie=l(.1),q=l(5),J=l(.05),Y=l(.2),X=l(.5),Z=async()=>{P.value=!0;try{let e=await L.get(`/api/advert_rate_limit_stats`);e.data?.success&&(F.value=e.data.data)}catch(e){console.error(`Failed to fetch rate limit stats:`,e)}finally{P.value=!1}};o([u,f,p],()=>{E.value||(I.value=u.value.enabled??!1,R.value=u.value.bucket_capacity??2,z.value=u.value.refill_tokens??1,B.value=Math.round((u.value.refill_interval_seconds??36e3)/3600),V.value=Math.round((u.value.min_interval_seconds??0)/60),te.value=f.value.enabled??!1,ne.value=f.value.violation_threshold??2,U.value=Math.round((f.value.violation_decay_seconds??43200)/3600),W.value=Math.round((f.value.base_penalty_seconds??21600)/3600),G.value=f.value.penalty_multiplier??2,K.value=Math.round((f.value.max_penalty_seconds??86400)/3600),re.value=p.value.enabled??!1,ie.value=p.value.ewma_alpha??.1,q.value=Math.round((p.value.hysteresis_seconds??300)/60),J.value=w.value.quiet_max??.05,Y.value=w.value.normal_max??.2,X.value=w.value.busy_max??.5)},{immediate:!0}),r(()=>{Z()});let Q=()=>{I.value=u.value.enabled??!1,R.value=u.value.bucket_capacity??2,z.value=u.value.refill_tokens??1,B.value=Math.round((u.value.refill_interval_seconds??36e3)/3600),V.value=Math.round((u.value.min_interval_seconds??0)/60),te.value=f.value.enabled??!1,ne.value=f.value.violation_threshold??2,U.value=Math.round((f.value.violation_decay_seconds??43200)/3600),W.value=Math.round((f.value.base_penalty_seconds??21600)/3600),G.value=f.value.penalty_multiplier??2,K.value=Math.round((f.value.max_penalty_seconds??86400)/3600),re.value=p.value.enabled??!1,ie.value=p.value.ewma_alpha??.1,q.value=Math.round((p.value.hysteresis_seconds??300)/60),J.value=w.value.quiet_max??.05,Y.value=w.value.normal_max??.2,X.value=w.value.busy_max??.5},ae=()=>{E.value=!0,O.value=``,k.value=``},oe=()=>{E.value=!1,O.value=``,k.value=``,Q()},se=async()=>{D.value=!0,k.value=``,O.value=``;try{let e={rate_limit_enabled:I.value,bucket_capacity:R.value,refill_tokens:z.value,refill_interval_seconds:B.value*3600,min_interval_seconds:V.value*60,penalty_enabled:te.value,violation_threshold:ne.value,violation_decay_seconds:U.value*3600,base_penalty_seconds:W.value*3600,penalty_multiplier:G.value,max_penalty_seconds:K.value*3600,adaptive_enabled:re.value,ewma_alpha:ie.value,hysteresis_seconds:q.value*60,quiet_max:J.value,normal_max:Y.value,busy_max:X.value},t=(await L.post(`/api/update_advert_rate_limit_config`,e)).data;t.success?(O.value=t.data?.message||`Settings saved successfully`,await i.fetchStats(),await Z(),await s(),Q(),E.value=!1,setTimeout(()=>{O.value=``},3e3)):(k.value=t.error||`Failed to save settings`,console.error(`[AdvertSettings] Save failed:`,t.error))}catch(e){console.error(`Failed to save advert settings:`,e),k.value=e.response?.data?.error||`Failed to save settings`}finally{D.value=!1}},{showUnsavedModal:$,requestLeave:ce,handleDiscard:de,handleSave:fe,handleCancel:pe}=ue(E,D,oe,async()=>(await se(),!E.value));n({requestLeave:ce,isEditing:E});let me=y(()=>F.value?.adaptive?.current_tier||`unknown`),he=y(()=>{switch(me.value){case`quiet`:return`bg-accent-green/20 text-accent-green border-accent-green/50`;case`normal`:return`bg-accent-cyan/20 text-accent-cyan border-accent-cyan/50`;case`busy`:return`bg-secondary/20 text-secondary border-secondary/50`;case`congested`:return`bg-accent-red/20 text-accent-red border-accent-red/50`;default:return`bg-background-mute text-content-muted border-stroke-subtle`}});return(e,n)=>(h(),C(x,null,[_(le,{show:v($),"is-saving":D.value,label:`Advert Limit settings`,onDiscard:v(de),onSave:v(fe),onCancel:v(pe)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,Fs,[S(`div`,Is,[n[20]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Advert Limits`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Configure advertisement rate limiting and adaptive controls`)],-1),S(`div`,Ls,[S(`button`,{onClick:n[0]||=e=>M.value=!0,class:`self-stretch flex items-center justify-center px-3 text-xs bg-primary/10 hover:bg-primary/20 text-primary rounded-lg border border-primary/30 transition-colors`,title:`How rate limiting works`},[...n[19]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1)]]),E.value?(h(),C(x,{key:1},[S(`button`,{onClick:oe,disabled:D.value,class:`cfg-btn-secondary`},` Cancel `,8,Rs),S(`button`,{onClick:se,disabled:D.value,class:`cfg-btn-primary`},t(D.value?`Saving...`:`Save Changes`),9,zs)],64)):(h(),C(`button`,{key:0,onClick:ae,class:`cfg-btn-primary`},` Edit Settings `))])]),O.value?(h(),C(`div`,Bs,t(O.value),1)):g(``,!0),k.value?(h(),C(`div`,Vs,t(k.value),1)):g(``,!0),S(`div`,Hs,[n[29]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary`},` Current Status `,-1),P.value&&!F.value?(h(),C(`div`,Us,[_(H,{size:`sm`}),n[21]||=S(`span`,{class:`ml-2 text-sm text-content-muted`},`Loading stats...`,-1)])):F.value?(h(),C(x,{key:2},[S(`div`,Gs,[S(`div`,Ks,[n[23]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Mesh Tier`,-1),S(`div`,{class:T([`mt-1 px-2 py-0.5 rounded border text-xs font-medium inline-block`,he.value])},t(me.value.toUpperCase()),3)]),S(`div`,qs,[n[24]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Adverts/min`,-1),S(`div`,Js,t(F.value.metrics?.adverts_per_min_ewma?.toFixed(2)||`0.00`),1)]),S(`div`,Ys,[n[25]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Allowed`,-1),S(`div`,Xs,t(F.value.stats?.adverts_allowed||0),1)]),S(`div`,Zs,[n[26]||=S(`div`,{class:`text-xs text-content-muted dark:text-content-muted`},`Dropped`,-1),S(`div`,Qs,t(F.value.stats?.adverts_dropped||0),1)])]),Object.keys(F.value.active_penalties||{}).length>0?(h(),C(`div`,$s,[n[27]||=S(`div`,{class:`text-xs font-medium text-accent-red mb-1`},` Active Penalties `,-1),(h(!0),C(x,null,m(F.value.active_penalties,(e,n)=>(h(),C(`div`,{key:n,class:`text-xs font-mono text-accent-red`},t(n)+`... - `+t(Math.round(e))+`s remaining `,1))),128))])):g(``,!0),F.value.recent_drops&&F.value.recent_drops.length>0?(h(),C(`div`,ec,[n[28]||=S(`div`,{class:`text-xs font-medium text-secondary mb-1`},` Recently Dropped Adverts `,-1),(h(!0),C(x,null,m(F.value.recent_drops,(e,n)=>(h(),C(`div`,{key:n,class:`text-xs text-secondary py-0.5`},[S(`span`,tc,t(e.name),1),S(`span`,nc,`(`+t(e.pubkey)+`...)`,1),S(`span`,rc,` - `+t(e.reason)+` (`+t(e.seconds_ago)+`s ago)`,1)]))),128))])):g(``,!0)],64)):(h(),C(`div`,Ws,[...n[22]||=[S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Stats not available. Click "Refresh Stats" to load. `,-1)]])),n[30]||=d(`

There are three layers of advert rate limit control: Each layer can be enabled/disabled independently and the others will still function.

  • Rate Limiting OFF: All limiting disabled — adverts pass through freely
  • Adaptive OFF: Token bucket uses fixed limits (no tier scaling), penalty box still works
  • Penalty Box OFF: Token bucket still applies, but no escalating cooldowns for repeat offenders

Decision flow when all enabled: Adaptive tier check → Penalty box check → Token bucket check → Violation recording (triggers penalty box)

Activity tiers:Quiet (bypass limiting) → Normal (lighter: 0.5x intervals) → Busy (base: 1.0x intervals) → Congested (stricter: 2.0x intervals)

Note: Adaptive mode scales refill/min-interval timing; bucket capacity stays at the configured base value.

`,1)]),S(`div`,ic,[n[38]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})]),b(` Token Bucket Rate Limiting `)],-1),n[39]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Controls how many adverts each pubkey can send in a given time period. `,-1),S(`div`,ac,[n[32]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Rate Limiting`,-1),E.value?c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[1]||=e=>I.value=e,class:`cfg-select w-full sm:w-32`},[...n[31]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[A,I.value]]):(h(),C(`div`,oc,t(I.value?`Enabled`:`Disabled`),1))]),S(`div`,sc,[n[33]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Bucket Capacity`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Max burst size (adverts)`)],-1),E.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[2]||=e=>R.value=e,type:`number`,min:`1`,max:`10`,class:`cfg-input w-full sm:w-24`},null,512)),[[j,R.value,void 0,{number:!0}]]):(h(),C(`div`,cc,t(R.value),1))]),S(`div`,lc,[n[35]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Refill Interval`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Time between token refills `)],-1),E.value?(h(),C(`div`,dc,[c(S(`input`,{"onUpdate:modelValue":n[3]||=e=>B.value=e,type:`number`,min:`1`,max:`48`,class:`cfg-input w-20`},null,512),[[j,B.value,void 0,{number:!0}]]),n[34]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(h(),C(`div`,uc,t(B.value)+` hours `,1))]),S(`div`,fc,[n[37]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Minimum Interval`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Hard minimum between adverts `)],-1),E.value?(h(),C(`div`,mc,[c(S(`input`,{"onUpdate:modelValue":n[4]||=e=>V.value=e,type:`number`,min:`0`,max:`1440`,class:`cfg-input w-20`},null,512),[[j,V.value,void 0,{number:!0}]]),n[36]||=S(`span`,{class:`text-content-muted text-sm`},`min`,-1)])):(h(),C(`div`,pc,t(V.value)+` min `,1))])]),S(`div`,hc,[n[49]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})]),b(` Penalty Box (Repeat Offenders) `)],-1),n[50]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Applies escalating cooldowns to pubkeys that repeatedly violate limits. `,-1),S(`div`,gc,[n[41]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Penalty Box`,-1),E.value?c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[5]||=e=>te.value=e,class:`cfg-select w-full sm:w-32`},[...n[40]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[A,te.value]]):(h(),C(`div`,_c,t(te.value?`Enabled`:`Disabled`),1))]),S(`div`,vc,[n[42]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Violation Threshold`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Violations before penalty `)],-1),E.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[6]||=e=>ne.value=e,type:`number`,min:`1`,max:`10`,class:`cfg-input w-full sm:w-24`},null,512)),[[j,ne.value,void 0,{number:!0}]]):(h(),C(`div`,yc,t(ne.value),1))]),S(`div`,bc,[n[44]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Base Penalty Duration`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`First penalty duration`)],-1),E.value?(h(),C(`div`,Sc,[c(S(`input`,{"onUpdate:modelValue":n[7]||=e=>W.value=e,type:`number`,min:`1`,max:`48`,class:`cfg-input w-20`},null,512),[[j,W.value,void 0,{number:!0}]]),n[43]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(h(),C(`div`,xc,t(W.value)+` hours `,1))]),S(`div`,Cc,[n[46]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Penalty Multiplier`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Escalation factor`)],-1),E.value?(h(),C(`div`,Tc,[c(S(`input`,{"onUpdate:modelValue":n[8]||=e=>G.value=e,type:`number`,min:`1`,max:`5`,step:`0.5`,class:`cfg-input w-20`},null,512),[[j,G.value,void 0,{number:!0}]]),n[45]||=S(`span`,{class:`text-content-muted text-sm`},`x`,-1)])):(h(),C(`div`,wc,t(G.value)+`x `,1))]),S(`div`,Ec,[n[48]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Max Penalty Duration`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Maximum cooldown cap`)],-1),E.value?(h(),C(`div`,Oc,[c(S(`input`,{"onUpdate:modelValue":n[9]||=e=>K.value=e,type:`number`,min:`1`,max:`168`,class:`cfg-input w-20`},null,512),[[j,K.value,void 0,{number:!0}]]),n[47]||=S(`span`,{class:`text-content-muted text-sm`},`hours`,-1)])):(h(),C(`div`,Dc,t(K.value)+` hours `,1))])]),S(`div`,kc,[n[60]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z`})]),b(` Adaptive Rate Limiting `)],-1),S(`div`,Ac,[n[52]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Adaptive Mode`,-1),E.value?c((h(),C(`select`,{key:1,"onUpdate:modelValue":n[10]||=e=>re.value=e,class:`cfg-select w-full sm:w-32`},[...n[51]||=[S(`option`,{value:!0},`Enabled`,-1),S(`option`,{value:!1},`Disabled`,-1)]],512)),[[A,re.value]]):(h(),C(`div`,jc,t(re.value?`Enabled`:`Disabled`),1))]),S(`div`,Mc,[n[54]||=S(`div`,null,[S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Tier Change Delay`),S(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},`Prevents tier flapping`)],-1),E.value?(h(),C(`div`,Pc,[c(S(`input`,{"onUpdate:modelValue":n[11]||=e=>q.value=e,type:`number`,min:`0`,max:`60`,class:`cfg-input w-20`},null,512),[[j,q.value,void 0,{number:!0}]]),n[53]||=S(`span`,{class:`text-content-muted text-sm`},`min`,-1)])):(h(),C(`div`,Nc,t(q.value)+` min `,1))]),S(`div`,Fc,[n[58]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm mb-2 block`},`Activity Tier Thresholds (adverts/min)`,-1),S(`div`,Ic,[S(`div`,Lc,[n[55]||=S(`div`,{class:`text-xs text-accent-green mb-1`},`Quiet Max`,-1),E.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[12]||=e=>J.value=e,type:`number`,min:`0`,max:`1`,step:`0.01`,class:`cfg-input w-full py-1 text-center`},null,512)),[[j,J.value,void 0,{number:!0}]]):(h(),C(`div`,Rc,t(J.value),1))]),S(`div`,zc,[n[56]||=S(`div`,{class:`text-xs text-accent-cyan mb-1`},`Normal Max`,-1),E.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[13]||=e=>Y.value=e,type:`number`,min:`0`,max:`5`,step:`0.01`,class:`cfg-input w-full py-1 text-center`},null,512)),[[j,Y.value,void 0,{number:!0}]]):(h(),C(`div`,Bc,t(Y.value),1))]),S(`div`,Vc,[n[57]||=S(`div`,{class:`text-xs text-secondary mb-1`},`Busy Max`,-1),E.value?c((h(),C(`input`,{key:1,"onUpdate:modelValue":n[14]||=e=>X.value=e,type:`number`,min:`0`,max:`10`,step:`0.01`,class:`cfg-input w-full py-1 text-center`},null,512)),[[j,X.value,void 0,{number:!0}]]):(h(),C(`div`,Hc,t(X.value),1))])]),n[59]||=S(`p`,{class:`text-xs text-content-muted dark:text-content-muted mt-2`},` Above Busy Max = Congested tier (strictest limiting) `,-1)])]),M.value?(h(),C(`div`,{key:2,class:`fixed inset-0 bg-black/50 flex items-start justify-center z-50 p-4 overflow-y-auto`,onClick:n[18]||=N(e=>M.value=!1,[`self`])},[S(`div`,{class:`bg-background dark:bg-background-dark rounded-lg shadow-xl max-w-3xl w-full my-8`,onClick:n[17]||=N(()=>{},[`stop`])},[S(`div`,Uc,[S(`div`,Wc,[n[62]||=S(`h2`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` How Advert Rate Limiting Works `,-1),S(`button`,{onClick:n[15]||=e=>M.value=!1,class:`text-content-muted hover:text-content-primary dark:text-content-muted dark:hover:text-content-primary`},[...n[61]||=[S(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),n[63]||=d(`

Why you may see the same advert more than once

Mesh traffic can reach your repeater through different paths, so duplicate advert packets are expected.

  • First copy arrives and is forwarded
  • Second copy arrives through another repeater path
  • Later copies may be dropped once limits are hit

This is normal behavior and helps prevent repeated rebroadcasts from flooding the mesh.

Token Bucket Rate Limiting

Each sender has a token bucket. Every forwarded advert uses one token.

  • Bucket Capacity: How many adverts can pass in a burst.
  • Refill Rate: How quickly tokens come back over time.
  • Min Interval: Optional gap between adverts from the same sender (usually set to 0).
Example (capacity 2):
- Copy 1 forwarded (2 → 1 tokens)
- Copy 2 forwarded (1 → 0 tokens)
- Copy 3 dropped (no tokens left)

Penalty Box (Repeat Offenders)

If a sender keeps hitting the limit, it is temporarily blocked.

  • Violation Threshold: How many hits before penalty starts.
  • Base Penalty: First block duration.
  • Multiplier: Repeated penalties get longer.
  • Decay Time: Violations age out after stable behavior.

Adaptive Mesh Activity Tiers

Adaptive mode adjusts limits based on recent advert activity.

How Congestion is Measured:
  • What is counted: Advert packets only (not chat/data traffic)
  • Smoothing: 60-second EWMA to avoid reacting to short spikes
  • Score: Tier is based on adverts per minute
  • Hysteresis: Tier changes must hold for 5 minutes
QUIET
Activity < 0.05/min
No rate limiting
NORMAL
Activity 0.05-0.20/min
Light limiting (50%)
BUSY
Activity 0.20-0.50/min
Standard limiting (100%)
CONGESTED
Activity > 0.50/min
Aggressive (200%)
Quick examples:
- 0.02 adverts/min → QUIET (bypass)
- 0.35 adverts/min → BUSY (tighter limits)
- 0.68 adverts/min → CONGESTED (strict limits)

Recommended starting settings

  • Min Interval: 0 (disabled), let adaptive mode do the work
  • Bucket Capacity: 2-3 tokens for normal mesh propagation
  • Adaptive Mode: On
  • Penalty Box: On
`,5),S(`div`,Gc,[S(`button`,{onClick:n[16]||=e=>M.value=!1,class:`btn-primary`},` Got it! `)])])])])):g(``,!0)],512)],64))}}),qc={class:`modal-card max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Jc={class:`flex items-center justify-between mb-7`},Yc={class:`text-xl font-semibold text-content-primary dark:text-content-primary`},Xc={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},Zc={class:`grid grid-cols-2 gap-5 items-end`},Qc={class:`flex items-center gap-3 pb-1.5`},$c={key:0,class:`grid grid-cols-2 gap-5`},el={class:`grid grid-cols-2 gap-5 items-end`},tl={class:`flex items-center gap-3 pb-1.5`},nl={class:`grid grid-cols-2 gap-x-5 gap-y-0`},rl=[`aria-hidden`],il={class:`grid grid-cols-2 gap-5 items-center pt-4`},al={class:`flex items-center gap-3`},ol={class:`flex items-center gap-6`},sl={class:`flex items-center gap-3`},cl={class:`flex items-center gap-3`},ll={class:`flex flex-wrap gap-2`},ul=[`onClick`],dl={class:`modal-actions`},fl=[`disabled`],pl=f({__name:`BrokerEditModal`,props:{show:{type:Boolean},broker:{},isNew:{type:Boolean}},emits:[`done`,`cancel`],setup(n,{emit:r}){let i=[`REQ`,`RESPONSE`,`TXT_MSG`,`ACK`,`ADVERT`,`GRP_TXT`,`GRP_DATA`,`ANON_REQ`,`PATH`,`TRACE`,`RAW_CUSTOM`],a=n,s=r;function d(e){return{...e,tls:{...e.tls},disallowedInput:[...e.disallowedInput??[]]}}let f=l({_id:0,enabled:!0,name:``,host:``,port:443,format:`letsmesh`,use_jwt_auth:!1,transport:`websockets`,disallowedInput:[],retain_status:!1,tls:{enabled:!0,insecure:!1}});o(()=>a.broker,e=>{e&&(f.value=d(e))},{immediate:!0});let v=y(()=>{let e=f.value;return e.name.trim()!==``&&e.host.trim()!==``&&e.port>=1&&e.port<=65535&&(!e.use_jwt_auth||(e.audience?.trim()??``)!==``)});function w(){let e=f.value;(!e.audience||e.audience===e.host)&&(e.audience=e.host)}function E(e){f.value.disallowedInput||(f.value.disallowedInput=[]);let t=f.value.disallowedInput.indexOf(e);t===-1?f.value.disallowedInput.push(e):f.value.disallowedInput.splice(t,1)}function D(){v.value&&s(`done`,d(f.value))}function O(){s(`cancel`)}return(r,a)=>(h(),u(p,{to:`body`},[_(M,{"enter-active-class":`transition-opacity duration-200`,"enter-from-class":`opacity-0`,"leave-active-class":`transition-opacity duration-200`,"leave-to-class":`opacity-0`},{default:e(()=>[n.show&&n.broker?(h(),C(`div`,{key:0,class:`modal-backdrop`,onClick:a[14]||=N(e=>O(),[`self`])},[S(`div`,qc,[S(`div`,Jc,[S(`div`,null,[S(`h3`,Yc,t(n.isNew?`Add Broker`:`Edit Broker`),1),S(`p`,Xc,t(n.isNew?`Configure a new MQTT broker`:`Editing ${n.broker.name||`(unnamed)`}`),1)]),S(`button`,{onClick:O,class:`text-content-secondary dark:text-white/60 hover:text-content-primary dark:hover:text-white transition-colors`},[...a[15]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`form`,{onSubmit:N(D,[`prevent`]),class:`modal-form`},[S(`div`,null,[a[16]||=S(`label`,{class:`modal-field-label`},[b(` Name `),S(`span`,{class:`text-red-500`},`*`)],-1),c(S(`input`,{"onUpdate:modelValue":a[0]||=e=>f.value.name=e,type:`text`,placeholder:`Broker Name`,class:`modal-input`},null,512),[[j,f.value.name]])]),S(`div`,Zc,[S(`div`,null,[a[18]||=S(`label`,{class:`modal-field-label`},[b(` Format `),S(`span`,{class:`text-red-500`},`*`)],-1),c(S(`select`,{"onUpdate:modelValue":a[1]||=e=>f.value.format=e,class:`modal-select`},[...a[17]||=[S(`option`,{value:`meshcoretomqtt`},`Meshcoretomqtt`,-1),S(`option`,{value:`letsmesh`},`Letsmesh`,-1),S(`option`,{value:`waev`},`Waev`,-1),S(`option`,{value:`mqtt`},`pyMC`,-1)]],512),[[A,f.value.format]])]),S(`div`,Qc,[S(`button`,{type:`button`,onClick:a[2]||=e=>f.value.enabled=!f.value.enabled,class:T([`relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full transition-colors duration-200 ease-in-out focus:outline-none`,f.value.enabled?`bg-primary`:`bg-gray-200 dark:bg-white/15`])},[S(`span`,{class:T([`pointer-events-none absolute top-0.5 left-0.5 inline-block h-4 w-4 transform rounded-full bg-white shadow transition duration-200 ease-in-out`,f.value.enabled?`translate-x-4`:`translate-x-0`])},null,2)],2),a[19]||=S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Enabled`,-1)])]),f.value.format===`mqtt`?(h(),C(`div`,$c,[S(`div`,null,[a[20]||=S(`label`,{class:`modal-field-label`},[b(` MQTT Base Topic `),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(e.g. meshcore/repeater)`)],-1),c(S(`input`,{"onUpdate:modelValue":a[3]||=e=>f.value.base_topic=e,placeholder:`meshcore/repeater`,class:`modal-input`},null,512),[[j,f.value.base_topic]])]),a[21]||=S(`div`,null,null,-1)])):g(``,!0),S(`div`,el,[S(`div`,null,[a[23]||=S(`label`,{class:`modal-field-label`},[b(` Transport `),S(`span`,{class:`text-red-500`},`*`)],-1),c(S(`select`,{"onUpdate:modelValue":a[4]||=e=>f.value.transport=e,class:`modal-select`},[...a[22]||=[S(`option`,{value:`websockets`},`Websockets`,-1),S(`option`,{value:`tcp`},`TCP`,-1)]],512),[[A,f.value.transport]])]),S(`div`,tl,[S(`button`,{type:`button`,onClick:a[5]||=e=>f.value.use_jwt_auth=!f.value.use_jwt_auth,class:T([`relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full transition-colors duration-200 ease-in-out focus:outline-none`,f.value.use_jwt_auth?`bg-primary`:`bg-gray-200 dark:bg-white/15`])},[S(`span`,{class:T([`pointer-events-none absolute top-0.5 left-0.5 inline-block h-4 w-4 transform rounded-full bg-white shadow transition duration-200 ease-in-out`,f.value.use_jwt_auth?`translate-x-4`:`translate-x-0`])},null,2)],2),a[24]||=S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Use JWT Auth`,-1)])]),S(`div`,nl,[S(`div`,null,[a[25]||=S(`label`,{class:`modal-field-label`},[b(` Host `),S(`span`,{class:`text-red-500`},`*`)],-1),c(S(`input`,{"onUpdate:modelValue":a[6]||=e=>f.value.host=e,type:`text`,placeholder:`mqtt.myserver.com`,onBlur:w,class:`modal-input font-mono`},null,544),[[j,f.value.host]])]),S(`div`,null,[f.value.use_jwt_auth?(h(),C(x,{key:0},[a[26]||=S(`label`,{class:`modal-field-label`},[b(` Audience `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(usually same as host)`)],-1),c(S(`input`,{"onUpdate:modelValue":a[7]||=e=>f.value.audience=e,type:`text`,placeholder:`mqtt.myserver.com`,class:`modal-input font-mono`},null,512),[[j,f.value.audience]])],64)):(h(),C(x,{key:1},[a[27]||=S(`label`,{class:`modal-field-label`},[b(` Username `),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(blank = anonymous)`)],-1),a[28]||=S(`input`,{type:`text`,autocomplete:`username`,style:{display:`none`}},null,-1),c(S(`input`,{autocomplete:`username`,"onUpdate:modelValue":a[8]||=e=>f.value.username=e,type:`text`,placeholder:`username`,class:`modal-input`},null,512),[[j,f.value.username]])],64))]),S(`div`,null,[a[29]||=S(`label`,{class:`modal-field-label`},[b(` Port `),S(`span`,{class:`text-red-500`},`*`),S(`span`,{class:`font-normal text-content-muted dark:text-content-muted/60 ml-1`},`(443 WS, 1883 TCP)`)],-1),c(S(`input`,{"onUpdate:modelValue":a[9]||=e=>f.value.port=e,type:`number`,min:`0`,max:`65535`,class:`modal-input font-mono`},null,512),[[j,f.value.port,void 0,{number:!0}]])]),S(`div`,{class:T(f.value.use_jwt_auth?`invisible pointer-events-none`:``),"aria-hidden":f.value.use_jwt_auth?`true`:void 0},[a[30]||=S(`label`,{class:`modal-field-label`},`Password`,-1),a[31]||=S(`input`,{type:`password`,autocomplete:`current-password`,style:{display:`none`}},null,-1),c(S(`input`,{autocomplete:`new-password`,"onUpdate:modelValue":a[10]||=e=>f.value.password=e,type:`password`,readonly:``,onfocus:`this.removeAttribute('readonly');`,onblur:`this.setAttribute('readonly', true);`,class:`modal-input`},null,512),[[j,f.value.password]])],10,rl)]),S(`div`,il,[S(`div`,al,[S(`button`,{type:`button`,onClick:a[11]||=e=>f.value.retain_status=!f.value.retain_status,class:T([`relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full transition-colors duration-200 ease-in-out focus:outline-none`,f.value.retain_status?`bg-primary`:`bg-gray-200 dark:bg-white/15`])},[S(`span`,{class:T([`pointer-events-none absolute top-0.5 left-0.5 inline-block h-4 w-4 transform rounded-full bg-white shadow transition duration-200 ease-in-out`,f.value.retain_status?`translate-x-4`:`translate-x-0`])},null,2)],2),a[32]||=S(`div`,null,[S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Retain Status`),S(`span`,{class:`text-xs text-content-muted dark:text-content-muted/60 ml-1`},`(MQTT retained)`)],-1)]),S(`div`,ol,[S(`div`,sl,[S(`button`,{type:`button`,onClick:a[12]||=e=>f.value.tls.enabled=!f.value.tls.enabled,class:T([`relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full transition-colors duration-200 ease-in-out focus:outline-none`,f.value.tls.enabled?`bg-primary`:`bg-gray-200 dark:bg-white/15`])},[S(`span`,{class:T([`pointer-events-none absolute top-0.5 left-0.5 inline-block h-4 w-4 transform rounded-full bg-white shadow transition duration-200 ease-in-out`,f.value.tls.enabled?`translate-x-4`:`translate-x-0`])},null,2)],2),a[33]||=S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`TLS`,-1)]),S(`div`,cl,[S(`button`,{type:`button`,onClick:a[13]||=e=>f.value.tls.insecure=!f.value.tls.insecure,class:T([`relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full transition-colors duration-200 ease-in-out focus:outline-none`,f.value.tls.insecure?`bg-amber-500`:`bg-gray-200 dark:bg-white/15`])},[S(`span`,{class:T([`pointer-events-none absolute top-0.5 left-0.5 inline-block h-4 w-4 transform rounded-full bg-white shadow transition duration-200 ease-in-out`,f.value.tls.insecure?`translate-x-4`:`translate-x-0`])},null,2)],2),a[34]||=S(`span`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},`Insecure`,-1)])])]),S(`div`,null,[a[35]||=S(`label`,{class:`modal-field-label`},[b(` Block Packet Types `),S(`span`,{class:`text-content-secondary dark:text-content-muted font-normal text-xs ml-1`},`(prevent publishing to broker)`)],-1),S(`div`,ll,[(h(),C(x,null,m(i,e=>S(`button`,{key:e,type:`button`,onClick:t=>E(e),class:T([`px-2.5 py-1 rounded text-xs font-mono font-medium border transition-colors`,f.value.disallowedInput?.includes(e)?`bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-700 dark:text-red-400`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 text-content-secondary dark:text-content-muted hover:border-primary/40`])},t(e),11,ul)),64))]),a[36]||=S(`p`,{class:`mt-2 text-xs text-content-secondary dark:text-content-muted`},[S(`span`,{class:`text-red-600 dark:text-red-400 font-medium`},`Red = blocked.`),b(` Leave all unselected to publish all packet types. `)],-1)]),S(`div`,dl,[S(`button`,{type:`button`,onClick:O,class:`modal-btn-cancel`},` Cancel `),S(`button`,{type:`submit`,disabled:!v.value,class:T([`flex-1 px-4 py-3 rounded-lg transition-colors font-medium`,v.value?`bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green`:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted/70 cursor-not-allowed`])},` Done `,10,fl)])],32)])])):g(``,!0)]),_:1})]))}}),ml={class:`space-y-12`},hl={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},gl={class:`flex items-center gap-2 flex-shrink-0`},_l=[`disabled`],vl=[`disabled`],yl={key:0,class:`bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm`},bl={class:`cfg-section`},xl={key:0,class:`text-sm text-content-secondary dark:text-content-muted`},Sl={key:1,class:`space-y-3`},Cl={class:`flex items-center gap-2`},wl={key:0,class:`space-y-2`},Tl=[`title`],El={key:1,class:`text-sm text-content-muted dark:text-content-muted/60 italic`},Dl={class:`cfg-card p-6`},Ol={key:0,class:`grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3`},kl={class:`flex flex-col py-1 border-b border-stroke-subtle dark:border-stroke/10`},Al={class:`text-content-primary dark:text-content-primary font-mono text-sm mt-0.5`},jl={class:`flex flex-col py-1 border-b border-stroke-subtle dark:border-stroke/10`},Ml={class:`text-content-primary dark:text-content-primary text-sm mt-0.5`},Nl={class:`flex flex-col py-1`},Pl={class:`text-content-primary dark:text-content-primary text-sm mt-0.5`},Fl={class:`flex flex-col py-1`},Il={class:`text-content-primary dark:text-content-primary text-sm mt-0.5`},Ll={key:1,class:`space-y-3`},Rl={class:`grid grid-cols-1 sm:grid-cols-2 gap-3`},zl={class:`cfg-card p-6`},Bl={class:`flex items-start justify-between mb-4`},Vl={key:0,class:`flex items-center gap-2 flex-shrink-0 ml-4`},Hl={class:`relative`},Ul={key:0,class:`absolute right-0 top-full mt-1 z-20 w-72 rounded-lg shadow-lg border border-stroke-subtle dark:border-stroke/20 bg-white dark:bg-[var(--color-surface)] overflow-hidden`},Wl={key:0,class:`px-3 py-3 text-xs text-content-secondary dark:text-content-muted italic`},Gl={key:1,class:`px-3 py-3 text-xs text-red-600 dark:text-red-400`},Kl={key:2,class:`px-3 py-3 text-xs text-content-secondary dark:text-content-muted italic`},ql={key:3,class:`py-1`},Jl=[`onClick`],Yl={class:`min-w-0 flex-1`},Xl={class:`text-sm font-medium text-content-primary dark:text-content-primary group-hover:text-primary transition-colors`},Zl={class:`text-xs text-content-secondary dark:text-content-muted`},Ql=[`onClick`,`title`],$l=[`href`],eu={key:0,class:`bg-background-mute/40 dark:bg-background/20 border-t border-stroke-subtle dark:border-stroke/10`},tu=[`onClick`],nu={class:`min-w-0 flex-1`},ru={class:`text-xs font-medium text-content-primary dark:text-content-primary truncate`},iu={class:`text-[11px] font-mono text-content-secondary dark:text-content-muted truncate`},au={key:0,class:`flex flex-col items-center justify-center py-8 rounded-lg border-2 border-dashed border-stroke-subtle dark:border-stroke/20 text-content-secondary dark:text-content-muted`},ou={key:0,class:`text-xs mt-0.5 opacity-70`},su={key:1,class:`space-y-2`},cu={class:`flex items-center gap-3 px-4 py-2.5`},lu={class:`min-w-0 flex-1 flex items-center gap-2 flex-wrap`},uu={class:`text-sm font-medium text-content-primary dark:text-content-primary`},du={class:`text-xs font-mono text-content-secondary dark:text-content-muted`},fu={key:0,class:`flex items-center gap-1.5 flex-shrink-0`},pu=[`onClick`],mu=[`onClick`],hu=V(f({__name:`LetsMeshSettings`,setup(i,{expose:a}){let s=ee(),u=y(()=>s.stats?.config?.mqtt_brokers||{}),d=l([]),f=l(!1),p=l(``),w=l(null);function E(e){return{...e,tls:{...e.tls},disallowedInput:[...e.disallowedInput??[]]}}let D=l(!1),O=l(!1),k=l(``),A=l(!1),P=l(null),F=l(!1),I=l(``),R=l(300),z=l(``),B=l(``),V=l([]),H=l(null),ne=l(!1),U=l(null),W=l({_id:0,enabled:!0,name:``,host:``,port:443,format:`letsmesh`,use_jwt_auth:!1,transport:`websockets`,disallowedInput:[],retain_status:!1,tls:{enabled:!0,insecure:!1}}),G=l(!1),K=l(null),re=l(!1);async function ie(){if(!re.value){re.value=!0;try{let e=await L.get(`/api/mqtt_status`);e.data?.success&&(K.value=e.data.data)}catch{}finally{re.value=!1}}}let q=1;function J(e={}){return{_id:q++,enabled:e.enabled??!0,name:e.name??``,host:e.host??``,port:e.port??0,audience:e.audience??``,format:e.format??`letsmesh`,use_jwt_auth:e.use_jwt_auth??!1,username:e.username??``,password:e.password??``,transport:e.transport??`websockets`,disallowedInput:Array.isArray(e.disallowedInput)?[...e.disallowedInput]:[],retain_status:e.retain_status??!1,base_topic:e.base_topic??``,tls:{enabled:e.tls?.enabled??!1,insecure:e.tls?.insecure??!1}}}function Y(){let e=u.value;I.value=e.iata_code??``,R.value=e.status_interval??300,z.value=e.owner??``,B.value=e.email??``,V.value=Array.isArray(e.brokers)?e.brokers.map(e=>J(e)):[]}o(u,()=>{D.value||Y()},{immediate:!0});function X(){return{iata_code:I.value,status_interval:R.value,owner:z.value,email:B.value,brokers:V.value.map(e=>{let t={name:e.name,enabled:e.enabled,transport:e.transport,host:e.host,port:e.port,use_jwt_auth:e.use_jwt_auth,format:e.format,disallowed_packet_types:e.disallowedInput,base_topic:e.base_topic,retain_status:e.retain_status,tls:{enabled:e.tls?.enabled??!1,insecure:e.tls?.insecure??!1}};return e.use_jwt_auth?{...t,audience:e.audience}:{...t,username:e.username,password:e.password}})}}async function Z(){try{let e=(await L.post(`/api/update_mqtt_config`,X())).data;return e?.success?(await s.fetchStats(),await ie(),{success:!0}):{success:!1,error:e?.error||`Save failed`}}catch(e){let t=e;return{success:!1,error:t?.response?.data?.error||t?.message||`Request failed`}}}function Q(){Y(),P.value={iata:I.value,interval:R.value,owner:z.value,email:B.value,brokers:V.value.map(E)},D.value=!0,k.value=``}function ae(){P.value&&(I.value=P.value.iata,R.value=P.value.interval,z.value=P.value.owner,B.value=P.value.email,V.value=P.value.brokers.map(E)),H.value=null,ne.value=!1,U.value=null,F.value=!1,D.value=!1,P.value=null,k.value=``}async function oe(){if(H.value!==null){let e=W.value;if(!e.name.trim()||!e.host.trim()){k.value=`Please complete or cancel the open broker edit before saving.`;return}de()}O.value=!0,k.value=``;let e=await Z();O.value=!1,e.success?(D.value=!1,F.value=!1,P.value=null,A.value=!0):k.value=e.error}function se(){H.value!==null&&ce();let e=J();V.value.push(e),U.value=null,ne.value=!0,W.value=E(e),H.value=e._id}function $(e){H.value!==null&&H.value!==e._id&&ce(),U.value=E(e),ne.value=!1,W.value=E(e),H.value=e._id}function ce(){if(ne.value&&H.value!==null)V.value=V.value.filter(e=>e._id!==H.value);else if(U.value){let e=V.value.findIndex(e=>e._id===U.value._id);e!==-1&&V.value.splice(e,1,E(U.value))}H.value=null,ne.value=!1,U.value=null}function de(){let e=W.value,t=V.value.findIndex(t=>t._id===e._id);t!==-1&&V.value.splice(t,1,E(e)),H.value=null,ne.value=!1,U.value=null}function fe(e){W.value=e,de()}function pe(e){V.value=V.value.filter(t=>t._id!==e),H.value===e&&(H.value=null,ne.value=!1,U.value=null)}function me(e){G.value=!1,w.value=null,H.value!==null&&ce(),e.brokers.forEach(e=>V.value.push(J(e)))}function he(e){G.value=!1,w.value=null,H.value!==null&&ce(),V.value.push(J(e))}function ge(e){w.value=w.value===e?null:e}async function _e(){f.value=!0,p.value=``;try{let e=(await L.get(`/api/broker_presets`)).data;e?.success&&Array.isArray(e.data)?d.value=e.data:(d.value=[],p.value=e?.error||`Failed to load broker presets`)}catch(e){d.value=[],e?.response?.status===404?p.value=``:p.value=`Could not reach repeater for broker presets`}finally{f.value=!1}}let ve=y(()=>{let e=W.value;return e.name.trim()!==``&&e.host.trim()!==``&&e.port>=1&&e.port<=65535&&(!e.use_jwt_auth||(e.audience?.trim()??``)!==``)});async function ye(){H.value!==null&&ve.value&&de(),O.value=!0,k.value=``;let e=await Z();return O.value=!1,e.success?(D.value=!1,F.value=!1,P.value=null,A.value=!0,!0):(k.value=e.error??`Save failed`,!1)}let{showUnsavedModal:be,requestLeave:xe,handleDiscard:Se,handleSave:Ce,handleCancel:we}=ue(D,O,ae,ye);a({requestLeave:xe,isEditing:D});let Te=null;return r(()=>{ie(),_e(),Te=setInterval(ie,5e3)}),n(()=>{Te&&clearInterval(Te)}),(n,r)=>(h(),C(x,null,[_(te,{modelValue:A.value,"onUpdate:modelValue":r[0]||=e=>A.value=e,message:`Broker settings have been saved. A service restart is required for the changes to take effect.`},null,8,[`modelValue`]),_(pl,{show:H.value!==null,broker:H.value===null?null:W.value,"is-new":ne.value,onDone:fe,onCancel:ce},null,8,[`show`,`broker`,`is-new`]),_(le,{show:v(be),"is-saving":O.value,label:`Broker settings`,onDiscard:v(Se),onSave:v(Ce),onCancel:v(we)},null,8,[`show`,`is-saving`,`onDiscard`,`onSave`,`onCancel`]),S(`div`,ml,[S(`div`,hl,[r[8]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},` Observer Configuration `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Configure LetsMesh observer settings, MQTT brokers, and connection status `)],-1),S(`div`,gl,[D.value?(h(),C(x,{key:1},[S(`button`,{onClick:ae,disabled:O.value,class:`px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},` Cancel `,8,_l),S(`button`,{onClick:oe,disabled:O.value,class:`btn-primary`},t(O.value?`Saving…`:`Save Settings`),9,vl)],64)):(h(),C(`button`,{key:0,onClick:Q,class:`btn-primary`},` Edit Settings `))])]),k.value?(h(),C(`div`,yl,t(k.value),1)):g(``,!0),S(`div`,bl,[r[10]||=S(`div`,{class:`mb-4`},[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},`Observer Status`),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},`Live LetsMesh broker connection state`)],-1),K.value?(h(),C(`div`,Sl,[S(`div`,Cl,[r[9]||=S(`span`,{class:`text-sm text-content-secondary dark:text-content-muted w-36`},`Handler`,-1),S(`span`,{class:T([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`,K.value.handler_active?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-gray-800/50 text-gray-500 dark:text-gray-400`])},[S(`span`,{class:T([`w-1.5 h-1.5 rounded-full`,K.value.handler_active?`bg-green-500`:`bg-gray-400`])},null,2),b(` `+t(K.value.handler_active?`Active`:`Inactive`),1)],2)]),K.value.brokers.length?(h(),C(`div`,wl,[(h(!0),C(x,null,m(K.value.brokers,e=>(h(),C(`div`,{key:e.host,class:`flex items-center gap-2`},[S(`span`,{class:`text-sm text-content-secondary dark:text-content-muted w-36 truncate`,title:e.name},t(e.name),9,Tl),S(`span`,{class:T([`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium`,e.status.connected?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:e.status.reconnecting?`bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400`:`bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400`])},[S(`span`,{class:T([`w-1.5 h-1.5 rounded-full`,e.status.connected?`bg-green-500`:e.status.reconnecting?`bg-amber-500`:`bg-red-500`])},null,2),b(` `+t(e.status.connected?`Connected`:e.status.reconnecting?`Reconnecting…`:`Disconnected`),1)],2)]))),128))])):(h(),C(`div`,El,`No broker connections configured.`))])):(h(),C(`div`,xl,` Status unavailable — service may not be running. `))]),S(`div`,Dl,[r[19]||=S(`div`,{class:`mb-4`},[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},`Observer Setup`),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},`IATA code, status interval, and owner details`)],-1),S(`div`,null,[D.value?g(``,!0):(h(),C(`div`,Ol,[S(`div`,kl,[r[11]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`IATA Code`,-1),S(`span`,Al,t(u.value.iata_code||`—`),1)]),S(`div`,jl,[r[12]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Status Interval`,-1),S(`span`,Ml,t(u.value.status_interval??300)+`s`,1)]),S(`div`,Nl,[r[13]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Owner`,-1),S(`span`,Pl,t(u.value.owner||`—`),1)]),S(`div`,Fl,[r[14]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Email`,-1),S(`span`,Il,t(u.value.email||`—`),1)])])),D.value?(h(),C(`div`,Ll,[S(`div`,Rl,[S(`div`,null,[r[15]||=S(`label`,{class:`block text-xs sm:text-sm text-content-secondary dark:text-content-muted mb-1`},[b(` IATA Code `),S(`span`,{class:`text-content-muted dark:text-content-muted/60 text-xs`},`(e.g. SFO, LHR)`)],-1),c(S(`input`,{"onUpdate:modelValue":r[1]||=e=>I.value=e,type:`text`,maxlength:`10`,placeholder:`TEST`,class:`cfg-input font-mono`},null,512),[[j,I.value]])]),S(`div`,null,[r[16]||=S(`label`,{class:`block text-xs sm:text-sm text-content-secondary dark:text-content-muted mb-1`},[b(` Status Interval `),S(`span`,{class:`text-content-muted dark:text-content-muted/60 text-xs`},`(seconds, min 60)`)],-1),c(S(`input`,{"onUpdate:modelValue":r[2]||=e=>R.value=e,type:`number`,min:`60`,max:`3600`,class:`cfg-input font-mono`},null,512),[[j,R.value,void 0,{number:!0}]])]),S(`div`,null,[r[17]||=S(`label`,{class:`block text-xs sm:text-sm text-content-secondary dark:text-content-muted mb-1`},`Owner Companion Pubkey`,-1),c(S(`input`,{"onUpdate:modelValue":r[3]||=e=>z.value=e,type:`text`,placeholder:`Optional`,class:`cfg-input`},null,512),[[j,z.value]])]),S(`div`,null,[r[18]||=S(`label`,{class:`block text-xs sm:text-sm text-content-secondary dark:text-content-muted mb-1`},`Email`,-1),c(S(`input`,{"onUpdate:modelValue":r[4]||=e=>B.value=e,type:`email`,placeholder:`Optional`,class:`cfg-input`},null,512),[[j,B.value]])])])])):g(``,!0)])]),S(`div`,zl,[S(`div`,Bl,[r[27]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},`Broker Settings`),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},`MQTT brokers for observer publishing`)],-1),D.value?(h(),C(`div`,Vl,[S(`div`,Hl,[S(`button`,{onClick:r[5]||=e=>G.value=!G.value,class:`inline-flex items-center gap-1.5 px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm`},[r[21]||=b(` From Template `,-1),(h(),C(`svg`,{class:T([`w-3 h-3 transition-transform`,G.value?`rotate-180`:``]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...r[20]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]],2))]),_(M,{name:`dropdown`},{default:e(()=>[G.value?(h(),C(`div`,Ul,[r[25]||=S(`div`,{class:`px-3 py-2 border-b border-stroke-subtle dark:border-stroke/10`},[S(`p`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted uppercase tracking-wide`},`Known Networks`)],-1),f.value?(h(),C(`div`,Wl,` Loading presets… `)):p.value?(h(),C(`div`,Gl,t(p.value),1)):d.value.length?(h(),C(`div`,ql,[(h(!0),C(x,null,m(d.value,e=>(h(),C(`div`,{key:e.id,class:`border-b border-stroke-subtle dark:border-stroke/10 last:border-b-0`},[S(`div`,{class:`flex items-center gap-2 px-3 py-2.5 hover:bg-background-mute dark:hover:bg-background/30 cursor-pointer group`,onClick:t=>me(e)},[S(`div`,Yl,[S(`p`,Xl,t(e.name),1),S(`p`,Zl,t(e.brokers.length)+` broker`+t(e.brokers.length===1?``:`s`),1)]),e.brokers.length>1?(h(),C(`button`,{key:0,onClick:N(t=>ge(e.id),[`stop`]),title:w.value===e.id?`Hide individual brokers`:`Pick individual brokers`,class:`flex-shrink-0 p-1 rounded hover:bg-primary/10 text-content-secondary dark:text-content-muted hover:text-primary transition-colors`},[(h(),C(`svg`,{class:T([`w-3.5 h-3.5 transition-transform`,w.value===e.id?`rotate-180`:``]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...r[22]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]],2))],8,Ql)):g(``,!0),e.website?(h(),C(`a`,{key:1,href:e.website,target:`_blank`,rel:`noopener noreferrer`,title:`Visit website`,class:`flex-shrink-0 p-1 rounded hover:bg-primary/10 text-content-secondary dark:text-content-muted hover:text-primary transition-colors`,onClick:r[6]||=N(()=>{},[`stop`])},[...r[23]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14`})],-1)]],8,$l)):g(``,!0)],8,Jl),w.value===e.id&&e.brokers.length>1?(h(),C(`div`,eu,[(h(!0),C(x,null,m(e.brokers,(n,i)=>(h(),C(`div`,{key:`${e.id}-${i}`,class:`flex items-center gap-2 pl-6 pr-3 py-2 hover:bg-background-mute dark:hover:bg-background/30 cursor-pointer`,onClick:e=>he(n)},[S(`div`,nu,[S(`p`,ru,t(n.name),1),S(`p`,iu,t(n.host)+`:`+t(n.port),1)]),r[24]||=S(`span`,{class:`flex-shrink-0 inline-flex items-center justify-center w-5 h-5 rounded bg-primary/10 text-primary text-xs font-bold`,title:`Add only this broker`},`+`,-1)],8,tu))),128))])):g(``,!0)]))),128))])):(h(),C(`div`,Kl,` No bundled presets. Use "Add" to configure manually. `))])):g(``,!0)]),_:1}),G.value?(h(),C(`div`,{key:0,class:`fixed inset-0 z-10`,onClick:r[7]||=e=>G.value=!1})):g(``,!0)]),S(`button`,{onClick:se,class:`btn-primary inline-flex items-center gap-1.5`},[...r[26]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),b(` Add `,-1)]])])):g(``,!0)]),V.value.length?(h(),C(`div`,su,[(h(!0),C(x,null,m(V.value,e=>(h(),C(`div`,{key:e._id,class:`cfg-card overflow-hidden`},[S(`div`,cu,[S(`div`,lu,[S(`span`,{class:T([`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,e.enabled?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400`])},[S(`span`,{class:T([`w-1.5 h-1.5 rounded-full`,e.enabled?`bg-green-500`:`bg-red-500`])},null,2),b(` `+t(e.enabled?`Enabled`:`Disabled`),1)],2),S(`span`,uu,t(e.name||`(unnamed)`),1),S(`span`,du,t(e.host||`—`)+`:`+t(e.port),1)]),D.value?(h(),C(`div`,fu,[S(`button`,{onClick:t=>$(e),class:`px-2.5 py-1 text-xs bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded border border-primary/50 transition-colors`},` Edit `,8,pu),S(`button`,{onClick:t=>pe(e._id),title:`Remove`,class:`p-1.5 rounded hover:bg-red-500/10 dark:hover:bg-red-900/20 text-content-secondary dark:text-content-muted hover:text-red-600 dark:hover:text-red-400 transition-colors`},[...r[30]||=[S(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,mu)])):g(``,!0)])]))),128))])):(h(),C(`div`,au,[r[28]||=S(`svg`,{class:`w-7 h-7 mb-2 opacity-40`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1.5`,d:`M5 12h14M5 12l4-4m-4 4l4 4`})],-1),r[29]||=S(`p`,{class:`text-sm`},`No brokers configured`,-1),D.value?(h(),C(`p`,ou,`Use Add or From Template above`)):g(``,!0)]))])])],64))}}),[[`__scopeId`,`data-v-de709eb9`]]),gu={class:`space-y-12`},_u={key:0,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-100 dark:bg-red-500/10 p-4`},vu={class:`cfg-section`},yu=[`disabled`],bu={key:0,class:`flex items-center gap-2`},xu={key:1,class:`flex items-center gap-2`},Su={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-2`},Cu={key:1,class:`text-xs text-red-500 dark:text-red-400 mt-2`},wu={class:`cfg-section`},Tu={key:0},Eu={key:1,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-50 dark:bg-red-500/10 p-4`},Du={class:`flex items-start gap-3`},Ou={class:`flex-1`},ku={class:`text-xs text-red-600 dark:text-red-400/80 mt-1`},Au={class:`flex gap-2 mt-3`},ju=[`disabled`],Mu=[`disabled`],Nu={key:2,class:`text-xs text-green-600 dark:text-green-400 mt-2`},Pu={key:3,class:`text-xs text-red-500 dark:text-red-400 mt-2`},Fu={class:`cfg-section`},Iu={class:`space-y-3`},Lu={class:`flex items-center gap-3 cursor-pointer px-4 py-3 bg-background-mute dark:bg-background/30 rounded-lg border-2 border-dashed border-stroke-subtle dark:border-stroke/20 hover:border-cyan-500/50 dark:hover:border-primary/50 transition-colors`},Ru={class:`text-sm text-content-secondary dark:text-content-muted`},zu={key:0,class:`bg-background-mute dark:bg-background/30 rounded-lg p-4 border border-stroke-subtle dark:border-stroke/10`},Bu={key:0,class:`text-xs text-content-secondary dark:text-content-muted space-y-1 mb-3`},Vu={class:`font-mono`},Hu={class:`font-mono`},Uu={key:0,class:`text-amber-600 dark:text-amber-400 font-medium`},Wu={key:1,class:`text-content-muted`},Gu={class:`text-xs text-content-secondary dark:text-content-muted`},Ku={class:`font-mono`},qu={key:1},Ju={key:2,class:`rounded-lg border-2 border-amber-500/50 dark:border-amber-400/40 bg-amber-50 dark:bg-amber-500/10 p-4`},Yu={class:`flex items-start gap-3`},Xu={class:`flex-1`},Zu={class:`text-xs text-amber-700 dark:text-amber-300/80 mt-1`},Qu={class:`flex gap-2 mt-3`},$u=[`disabled`],ed=[`disabled`],td={key:3,class:`text-xs text-green-600 dark:text-green-400 mt-2`},nd={key:4,class:`text-xs text-red-500 dark:text-red-400 mt-2`},rd={class:`cfg-section`},id={key:0},ad={key:1,class:`rounded-lg border-2 border-red-500/50 dark:border-red-400/40 bg-red-50 dark:bg-red-500/10 p-4`},od={class:`flex items-start gap-3`},sd={class:`flex-1`},cd={class:`text-xs text-red-600 dark:text-red-400/80 mt-1`},ld={class:`flex gap-2 mt-3`},ud=[`disabled`],dd=[`disabled`],fd={key:2,class:`bg-background-mute dark:bg-background/30 rounded-lg p-4 border border-stroke-subtle dark:border-stroke/10 space-y-2`},pd={class:`flex items-center justify-between`},md={class:`text-xs text-content-secondary dark:text-content-muted space-y-1`},hd={class:`font-mono`},gd={key:0},_d={class:`font-mono`},vd={key:1},yd={class:`font-mono text-[10px] break-all`},bd={key:3,class:`text-xs text-red-500 dark:text-red-400 mt-2`},xd=f({__name:`BackupRestore`,setup(e){let n=y(()=>window.location.protocol===`http:`),r=l(!1),i=l(``),a=l(``);async function o(){r.value=!0,i.value=``,a.value=``;try{let e=await R.exportConfig(!1);if(!e.success||!e.data){a.value=e.error||`Export failed`;return}let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pymc-repeater-settings-${(e.data.meta?.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),i.value=`Settings exported successfully (secrets redacted).`}catch(e){a.value=e instanceof Error?e.message:`Export failed`}finally{r.value=!1}}let s=l(!1),c=l(!1),u=l(``),f=l(``);async function p(){c.value=!0,u.value=``,f.value=``;try{let e=await R.exportConfig(!0);if(!e.success||!e.data){f.value=e.error||`Export failed`;return}let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pymc-repeater-full-backup-${(e.data.meta?.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),u.value=`Full backup exported (includes all secrets).`,s.value=!1}catch(e){f.value=e instanceof Error?e.message:`Export failed`}finally{c.value=!1}}let m=l(null),v=l(null),w=l(!1),T=l(!1),E=l(``),D=l(``),O=l(null),k=y(()=>v.value?.config?Object.keys(v.value.config).join(`, `):``),A=y(()=>{let e=v.value?.meta?.includes_secrets;return e===!0||e===`true`});function j(e){let t=e.target.files?.[0];if(!t)return;m.value=t,v.value=null,w.value=!1,E.value=``,D.value=``;let n=new FileReader;n.onload=e=>{try{let t=JSON.parse(e.target?.result);t.config&&typeof t.config==`object`?v.value={meta:t.meta,config:t.config}:typeof t==`object`&&!Array.isArray(t)?v.value={config:t}:D.value=`Invalid file format — expected a JSON config object.`}catch{D.value=`Invalid JSON file.`}},n.readAsText(t)}function M(){w.value=!1,v.value=null,m.value=null,O.value&&(O.value.value=``)}async function N(){if(v.value?.config){T.value=!0,E.value=``,D.value=``;try{let e=await R.importConfig(v.value.config);if(e.success){let t=e.data,n=e.message||t?.message||`Configuration imported.`;t?.restart_required&&(n+=` A service restart is required for radio changes to take effect.`),E.value=n,w.value=!1,v.value=null,m.value=null,O.value&&(O.value.value=``)}else D.value=e.error||`Import failed`}catch(e){D.value=e instanceof Error?e.message:`Import failed`}finally{T.value=!1}}}let P=l(!1),F=l(!1),I=l(null),L=l(``);async function z(){F.value=!0,L.value=``;try{let e=await R.exportIdentityKey();if(!e.success||!e.data){L.value=e.error||`Export failed`;return}I.value=e.data;let t=new Blob([e.data.identity_key_hex],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pymc-identity-${e.data.node_address||`key`}.hex`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(e){L.value=e instanceof Error?e.message:`Export failed`}finally{F.value=!1}}return(e,l)=>(h(),C(`div`,gu,[l[39]||=S(`div`,{class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},[S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Backup & Restore`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Export, import, and restore your repeater configuration`)])],-1),n.value?(h(),C(`div`,_u,[...l[6]||=[d(`

Unencrypted Connection

This page is served over HTTP, not HTTPS. Exported data (including identity keys) will be transmitted in plain text. Only use these features on a trusted local network.

`,1)]])):g(``,!0),S(`div`,vu,[l[9]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Export Settings `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},[b(` Download the current configuration as a JSON file. Passwords, JWT secrets, and identity keys are `),S(`strong`,null,`redacted`),b(`. Safe to share or use as a template for other devices. `)])])],-1),S(`button`,{onClick:o,disabled:r.value,class:`cfg-btn-primary`},[r.value?(h(),C(`span`,bu,[_(H,{size:`sm`,color:`current`,class:`inline-block`}),l[7]||=b(` Exporting… `,-1)])):(h(),C(`span`,xu,[...l[8]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4`})],-1),b(` Export Settings `,-1)]]))],8,yu),i.value?(h(),C(`p`,Su,t(i.value),1)):g(``,!0),a.value?(h(),C(`p`,Cu,t(a.value),1)):g(``,!0)]),S(`div`,wu,[l[15]||=d(`

Full Backup

Download a complete backup including all passwords, JWT secrets, and identity keys. Required for restoring to a new device or recovering from a failed SD card.

Contains sensitive data. The backup file will include plain-text passwords and private keys. Store it securely and never share it.

`,2),s.value?g(``,!0):(h(),C(`div`,Tu,[S(`button`,{onClick:l[0]||=e=>s.value=!0,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm`},[...l[10]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z`})]),b(` Full Backup `)],-1)]])])),s.value?(h(),C(`div`,Eu,[S(`div`,Du,[l[14]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,Ou,[l[13]||=S(`h4`,{class:`text-sm font-semibold text-red-700 dark:text-red-400`},` Confirm Full Backup `,-1),S(`p`,ku,[l[11]||=b(` This will export `,-1),l[12]||=S(`strong`,null,`all secrets in plain text`,-1),b(` including admin/guest passwords, JWT secret, and your repeater's private identity key`+t(n.value?` over an unencrypted HTTP connection`:``)+`. `,1)]),S(`div`,Au,[S(`button`,{onClick:p,disabled:c.value,class:`px-4 py-2 bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},t(c.value?`Exporting…`:`Yes, Export Full Backup`),9,ju),S(`button`,{onClick:l[1]||=e=>s.value=!1,disabled:c.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,Mu)])])])])):g(``,!0),u.value?(h(),C(`p`,Nu,t(u.value),1)):g(``,!0),f.value?(h(),C(`p`,Pu,t(f.value),1)):g(``,!0)]),S(`div`,Fu,[l[29]||=S(`div`,{class:`flex items-start justify-between mb-4`},[S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Import Configuration `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},[b(` Restore configuration from a previously exported JSON file. Importing a `),S(`strong`,null,`full backup`),b(` will also restore passwords and identity keys. Importing a `),S(`strong`,null,`settings export`),b(` will only update non-sensitive settings. `)])])],-1),S(`div`,Iu,[S(`label`,Lu,[l[16]||=S(`svg`,{class:`w-5 h-5 text-content-secondary dark:text-content-muted`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12`})],-1),S(`span`,Ru,t(m.value?m.value.name:`Choose a config JSON file…`),1),S(`input`,{ref_key:`fileInputRef`,ref:O,type:`file`,accept:`.json,application/json`,class:`hidden`,onChange:j},null,544)]),v.value?(h(),C(`div`,zu,[l[20]||=S(`h4`,{class:`text-sm font-medium text-content-primary dark:text-content-primary mb-2`},` Import Preview `,-1),v.value.meta?(h(),C(`div`,Bu,[S(`p`,null,[l[17]||=b(` Exported: `,-1),S(`span`,Vu,t(v.value.meta.exported_at),1)]),S(`p`,null,[l[18]||=b(` Version: `,-1),S(`span`,Hu,t(v.value.meta.version),1)]),v.value.meta.includes_secrets===`true`||v.value.meta.includes_secrets===!0?(h(),C(`p`,Uu,` ⚠ Full backup — will restore passwords and identity keys `)):(h(),C(`p`,Wu,` Settings only — existing secrets will not be changed `))])):g(``,!0),S(`p`,Gu,[l[19]||=b(` Sections: `,-1),S(`span`,Ku,t(k.value),1)])])):g(``,!0),v.value&&!w.value?(h(),C(`div`,qu,[S(`button`,{onClick:l[2]||=e=>w.value=!0,class:`px-4 py-2 bg-amber-500/20 dark:bg-amber-400/20 hover:bg-amber-500/30 dark:hover:bg-amber-400/30 text-amber-900 dark:text-amber-200 rounded-lg border border-amber-500/50 dark:border-amber-400/40 transition-colors text-sm`},` Review & Import `)])):g(``,!0),w.value?(h(),C(`div`,Ju,[S(`div`,Yu,[l[28]||=S(`svg`,{class:`w-5 h-5 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,Xu,[l[27]||=S(`h4`,{class:`text-sm font-semibold text-amber-800 dark:text-amber-300`},` Confirm Import `,-1),S(`p`,Zu,[l[24]||=b(` This will overwrite current settings for: `,-1),S(`strong`,null,t(k.value),1),l[25]||=b(`. `,-1),A.value?(h(),C(x,{key:0},[l[21]||=b(` This is a full backup — `,-1),l[22]||=S(`strong`,null,`passwords, JWT secrets, and identity keys will also be overwritten`,-1),l[23]||=b(`. `,-1)],64)):(h(),C(x,{key:1},[b(` Passwords and identity keys will not be changed. `)],64)),l[26]||=b(` Some changes (radio settings) require a service restart. `,-1)]),S(`div`,Qu,[S(`button`,{onClick:N,disabled:T.value,class:`px-4 py-2 bg-amber-600 hover:bg-amber-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},t(T.value?`Importing…`:`Yes, Import`),9,$u),S(`button`,{onClick:M,disabled:T.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,ed)])])])])):g(``,!0),E.value?(h(),C(`p`,td,t(E.value),1)):g(``,!0),D.value?(h(),C(`p`,nd,t(D.value),1)):g(``,!0)])]),S(`div`,rd,[l[38]||=d(`

Export Identity Key

Download the repeater's private identity key for backup. This key determines the node's address and cryptographic identity on the mesh.

Sensitive data. The identity key is the repeater's private key. Anyone with this key can impersonate your node. Store the exported file securely and never share it.

`,2),P.value?g(``,!0):(h(),C(`div`,id,[S(`button`,{onClick:l[3]||=e=>P.value=!0,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm`},[...l[30]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})]),b(` Export Identity Key `)],-1)]])])),P.value&&!I.value?(h(),C(`div`,ad,[S(`div`,od,[l[32]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,sd,[l[31]||=S(`h4`,{class:`text-sm font-semibold text-red-700 dark:text-red-400`},`Are you sure?`,-1),S(`p`,cd,` This will transmit your private key `+t(n.value?`over an unencrypted HTTP connection. `:``)+` and download it as a file. `,1),S(`div`,ld,[S(`button`,{onClick:z,disabled:F.value,class:`px-4 py-2 bg-red-600 hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600 text-white rounded-lg transition-colors text-sm disabled:opacity-50`},t(F.value?`Exporting…`:`Yes, Export Key`),9,ud),S(`button`,{onClick:l[4]||=e=>P.value=!1,disabled:F.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors text-sm`},` Cancel `,8,dd)])])])])):g(``,!0),I.value?(h(),C(`div`,fd,[S(`div`,pd,[l[33]||=S(`h4`,{class:`text-sm font-medium text-content-primary dark:text-content-primary`},` Key Exported `,-1),S(`button`,{onClick:l[5]||=e=>{I.value=null,P.value=!1},class:`text-xs text-content-muted hover:text-content-secondary transition-colors`},` Dismiss `)]),S(`div`,md,[S(`p`,null,[l[34]||=b(` Key length: `,-1),S(`span`,hd,t(I.value.key_length_bytes)+` bytes`,1)]),I.value.node_address?(h(),C(`p`,gd,[l[35]||=b(` Node address: `,-1),S(`span`,_d,t(I.value.node_address),1)])):g(``,!0),I.value.public_key_hex?(h(),C(`p`,vd,[l[36]||=b(` Public key: `,-1),S(`span`,yd,t(I.value.public_key_hex),1)])):g(``,!0)]),l[37]||=S(`p`,{class:`text-xs text-green-600 dark:text-green-400`},`File downloaded successfully.`,-1)])):g(``,!0),L.value?(h(),C(`p`,bd,t(L.value),1)):g(``,!0)])]))}}),Sd={class:`space-y-12`},Cd={class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},wd={class:`flex items-center gap-2 flex-shrink-0`},Td={class:`cfg-section`},Ed={class:`flex items-start justify-between mb-4`},Dd=[`disabled`],Od={key:0,class:`flex items-center gap-1.5`},kd={key:1},Ad={key:0,class:`grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6`},jd={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Md={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Nd={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Pd={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Fd={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Id={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Ld={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Rd={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},zd={key:1,class:`flex items-center justify-center py-12`},Bd={class:`text-center`},Vd={key:2,class:`rounded-lg border border-red-500/30 dark:border-red-400/30 bg-red-50 dark:bg-red-500/10 p-3 mb-4`},Hd={class:`text-xs text-red-700 dark:text-red-400`},Ud={key:3},Wd={class:`overflow-x-auto`},Gd={class:`w-full text-sm`},Kd={class:`py-2.5 pr-4`},qd={class:`font-mono text-content-primary dark:text-content-primary`},Jd={class:`py-2.5 pr-4 text-right`},Yd={class:`font-mono text-content-secondary dark:text-content-muted`},Xd={class:`py-2.5 pr-4 text-right hidden sm:table-cell`},Zd={key:0,class:`text-xs text-content-muted`},Qd={class:`text-content-muted/60 ml-1`},$d={key:1,class:`text-xs text-content-muted/50`},ef={key:2,class:`text-xs text-content-muted/50`},tf={class:`py-2.5 text-right`},nf=[`onClick`,`disabled`],rf={key:0,class:`flex items-center gap-1`},af={key:1},of={key:1,class:`text-xs text-content-muted/50`},sf={class:`flex items-start gap-3 mb-5`},cf={class:`flex-1 min-w-0`},lf={class:`text-lg font-semibold text-content-primary dark:text-content-primary`},uf={class:`text-sm text-content-secondary dark:text-content-muted mt-1`},df={class:`text-content-primary dark:text-content-primary`},ff={class:`text-content-primary dark:text-content-primary font-mono`},pf={class:`flex gap-3`},mf=[`disabled`],hf=[`disabled`],gf={class:`cfg-section`},_f={class:`flex flex-wrap gap-3`},vf=[`disabled`],yf=[`disabled`],bf={class:`flex items-center gap-2`},xf={key:0,class:`text-xs text-green-600 dark:text-green-400 mt-3`},Sf={key:1,class:`text-xs text-green-600 dark:text-green-400 mt-3`},Cf=f({__name:`DatabaseManagement`,setup(e){let n=new Set([`packets`,`adverts`,`noise_floor`,`crc_errors`,`room_messages`,`room_client_sync`,`companion_contacts`,`companion_channels`,`companion_messages`,`companion_prefs`]),i=l(!1),a=l(!1),o=l(``),s=l(null),c=l({}),d=l(null),f=l(``),w=l(!1),T=l(``),E=y(()=>s.value?s.value.tables.reduce((e,t)=>e+t.row_count,0):0);function D(e){return n.has(e)}function O(e,t){return!e||!t?0:Math.max(1,Math.round((t-e)/86400))}async function k(){a.value=!0,o.value=``;try{let e=await R.getDbStats();e.success&&e.data?s.value=e.data:o.value=e.error||`Failed to load database stats`}catch(e){o.value=e instanceof Error?e.message:`Failed to load database stats`}finally{a.value=!1}}function A(e,t){f.value=``,d.value={table:e,rowCount:t,executing:!1}}async function j(){if(!d.value)return;let{table:e}=d.value;d.value.executing=!0,f.value=``;try{let t=e===`all`?`all`:[e];e!==`all`&&(c.value[e]=!0);let n=await R.purgeTable(t);if(n.success){let t=n.data||{};f.value=`Deleted ${Object.values(t).reduce((e,t)=>e+(t.deleted||0),0).toLocaleString()} rows${e===`all`?` from all tables`:` from ${e}`}.`,d.value=null,await k()}else o.value=n.error||`Purge failed`,d.value=null}catch(e){o.value=e instanceof Error?e.message:`Purge failed`,d.value=null}finally{e!==`all`&&(c.value[e]=!1)}}async function M(){w.value=!0,T.value=``,o.value=``;try{let e=await R.vacuumDb();if(e.success&&e.data){let t=e.data.freed_bytes;T.value=t>0?`Compacted database — freed ${q(t)} (${q(e.data.size_before)} → ${q(e.data.size_after)}).`:`Database already compact (${q(e.data.size_after)}).`,await k()}else o.value=e.error||`Vacuum failed`}catch(e){o.value=e instanceof Error?e.message:`Vacuum failed`}finally{w.value=!1}}return r(k),(e,n)=>(h(),C(`div`,Sd,[S(`div`,Cd,[n[5]||=S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Database`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`View database statistics and perform maintenance`)],-1),S(`div`,wd,[S(`button`,{onClick:n[0]||=e=>i.value=!i.value,class:`cfg-btn-primary`},t(i.value?`Lock`:`Unlock`),1)])]),S(`div`,Td,[S(`div`,Ed,[n[7]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Database Overview `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Storage usage and table statistics for the repeater database. `)],-1),S(`button`,{onClick:k,disabled:a.value,class:`cfg-btn-secondary`},[a.value?(h(),C(`span`,Od,[_(H,{size:`xs`,color:`current`,class:`inline-block`}),n[6]||=b(` Loading… `,-1)])):(h(),C(`span`,kd,`Refresh`))],8,Dd)]),s.value?(h(),C(`div`,Ad,[S(`div`,jd,[n[8]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Database Size`,-1),S(`p`,Md,t(v(q)(s.value.database_size_bytes)),1)]),S(`div`,Nd,[n[9]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`RRD Metrics`,-1),S(`p`,Pd,t(v(q)(s.value.rrd_size_bytes)),1)]),S(`div`,Fd,[n[10]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Size`,-1),S(`p`,Id,t(v(q)(s.value.database_size_bytes+s.value.rrd_size_bytes)),1)]),S(`div`,Ld,[n[11]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Rows`,-1),S(`p`,Rd,t(E.value.toLocaleString()),1)])])):g(``,!0),a.value&&!s.value?(h(),C(`div`,zd,[S(`div`,Bd,[_(H,{class:`mx-auto mb-4`}),n[12]||=S(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading database info…`,-1)])])):g(``,!0),o.value?(h(),C(`div`,Vd,[S(`p`,Hd,t(o.value),1)])):g(``,!0),s.value&&s.value.tables.length>0?(h(),C(`div`,Ud,[S(`div`,Wd,[S(`table`,Gd,[n[14]||=S(`thead`,null,[S(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[S(`th`,{class:`text-left py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider`},` Table `),S(`th`,{class:`text-right py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider`},` Rows `),S(`th`,{class:`text-right py-2 pr-4 text-xs font-medium text-content-muted uppercase tracking-wider hidden sm:table-cell`},` Date Range `),S(`th`,{class:`text-right py-2 text-xs font-medium text-content-muted uppercase tracking-wider`},` Actions `)])],-1),S(`tbody`,null,[(h(!0),C(x,null,m(s.value.tables,e=>(h(),C(`tr`,{key:e.name,class:`border-b border-stroke-subtle/50 dark:border-stroke/5`},[S(`td`,Kd,[S(`span`,qd,t(e.name),1)]),S(`td`,Jd,[S(`span`,Yd,t(e.row_count.toLocaleString()),1)]),S(`td`,Xd,[e.has_timestamp&&e.row_count>0?(h(),C(`span`,Zd,[b(t(v(ie)(e.oldest_timestamp))+` — `+t(v(ie)(e.newest_timestamp))+` `,1),S(`span`,Qd,`(`+t(O(e.oldest_timestamp,e.newest_timestamp))+`d)`,1)])):e.row_count===0?(h(),C(`span`,$d,`—`)):(h(),C(`span`,ef,`n/a`))]),S(`td`,tf,[i.value&&D(e.name)&&e.row_count>0?(h(),C(`button`,{key:0,onClick:t=>A(e.name,e.row_count),disabled:c.value[e.name],class:`px-2.5 py-1 bg-red-500/10 dark:bg-red-400/10 hover:bg-red-500/20 dark:hover:bg-red-400/20 text-red-700 dark:text-red-400 rounded border border-red-500/30 dark:border-red-400/20 transition-colors text-xs disabled:opacity-50`},[c.value[e.name]?(h(),C(`span`,rf,[_(H,{size:`xs`,color:`current`,class:`inline-block`}),n[13]||=b(` Purging… `,-1)])):(h(),C(`span`,af,`Empty`))],8,nf)):D(e.name)?g(``,!0):(h(),C(`span`,of,`—`))])]))),128))])])])])):g(``,!0)]),(h(),u(p,{to:`body`},[d.value?(h(),C(`div`,{key:0,class:`modal-backdrop-heavy`,onClick:n[3]||=N(e=>!d.value.executing&&(d.value=null),[`self`])},[S(`div`,{class:`modal-card max-w-lg`,onClick:n[2]||=N(()=>{},[`stop`])},[S(`div`,sf,[n[20]||=S(`div`,{class:`flex-shrink-0 w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center`},[S(`svg`,{class:`w-5 h-5 text-red-500 dark:text-red-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})])],-1),S(`div`,cf,[S(`h3`,lf,t(d.value.table===`all`?`Purge All Tables`:`Purge "${d.value.table}"`),1),S(`p`,uf,[d.value.table===`all`?(h(),C(x,{key:0},[n[15]||=b(` This will permanently delete `,-1),n[16]||=S(`strong`,{class:`text-content-primary dark:text-content-primary`},`all data`,-1),b(` from every data table (`+t(E.value.toLocaleString())+` rows total). This cannot be undone. `,1)],64)):(h(),C(x,{key:1},[n[17]||=b(` This will permanently delete `,-1),S(`strong`,df,t(d.value.rowCount.toLocaleString())+` rows`,1),n[18]||=b(` from `,-1),S(`strong`,ff,t(d.value.table),1),n[19]||=b(`. This cannot be undone. `,-1)],64))])])]),S(`div`,pf,[S(`button`,{onClick:n[1]||=e=>d.value=null,disabled:d.value.executing,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `,8,mf),S(`button`,{onClick:j,disabled:d.value.executing,class:`flex-1 px-4 py-3 bg-red-500/20 hover:bg-red-500/30 border border-red-500/50 text-red-600 dark:text-red-400 rounded-lg transition-colors font-medium disabled:opacity-50`},t(d.value.executing?`Purging…`:`Yes, Delete Data`),9,hf)])])])):g(``,!0)])),S(`div`,gf,[n[23]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Maintenance `,-1),S(`div`,_f,[S(`button`,{onClick:n[4]||=e=>A(`all`,E.value),disabled:!s.value||E.value===0||!i.value,class:`px-4 py-2 bg-red-500/20 dark:bg-red-400/20 hover:bg-red-500/30 dark:hover:bg-red-400/30 text-red-900 dark:text-red-200 rounded-lg border border-red-500/50 dark:border-red-400/40 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed`},[...n[21]||=[S(`span`,{class:`flex items-center gap-2`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})]),b(` Purge All Data `)],-1)]],8,vf),S(`button`,{onClick:M,disabled:w.value||!s.value,class:`cfg-btn-primary`},[S(`span`,bf,[n[22]||=S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`})],-1),b(` `+t(w.value?`Compacting…`:`Compact Database`),1)])],8,yf)]),T.value?(h(),C(`p`,xf,t(T.value),1)):g(``,!0),f.value?(h(),C(`p`,Sf,t(f.value),1)):g(``,!0)])]))}}),wf={class:`space-y-12`},Tf={class:`cfg-section`},Ef={class:`flex items-start justify-between mb-4`},Df={class:`flex items-center gap-2`},Of=[`disabled`],kf={key:0,class:`flex items-center gap-1.5`},Af={key:1},jf=[`disabled`],Mf={key:0,class:`flex items-center gap-1.5`},Nf={key:1},Pf={key:0,class:`mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400 text-sm`},Ff={key:1,class:`mb-4`},If={class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10 inline-block`},Lf={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Rf={key:2,class:`p-4 rounded-lg bg-cyan-500/10 dark:bg-primary/10 border border-cyan-400/30 dark:border-primary/30`},zf={key:3},Bf=[`innerHTML`],Vf={class:`font-semibold text-sm`},Hf={class:`text-sm mt-0.5 opacity-80`},Uf={class:`grid grid-cols-2 sm:grid-cols-3 gap-3 mb-6`},Wf={key:0,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Gf={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Kf={key:1,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},qf={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Jf={key:2,class:`bg-background-mute dark:bg-background/30 rounded-lg p-3 border border-stroke-subtle dark:border-stroke/10`},Yf={class:`text-lg font-semibold text-content-primary dark:text-content-primary font-mono`},Xf={key:0,class:`mb-6`},Zf={class:`space-y-2`},Qf={class:`flex items-start justify-between gap-3`},$f={class:`flex items-center gap-2 min-w-0`},ep={class:`shrink-0 text-xs font-medium text-content-muted w-5 text-right`},tp={class:`text-right shrink-0`},np={class:`text-xs text-content-muted`},rp={class:`mt-1.5 ml-7`},ip={class:`text-xs font-mono text-content-secondary dark:text-content-muted break-all`},ap={key:0,class:`text-xs text-content-muted mt-0.5`},op={key:1,class:`mb-6 p-4 rounded-lg bg-green-500/10 border border-green-500/30 text-sm flex items-center gap-3`},sp={key:2},cp={key:0,class:`overflow-x-auto rounded-lg border border-stroke-subtle dark:border-stroke/10`},lp={class:`w-full text-sm`},up={class:`px-3 py-2 text-content-muted font-mono text-xs`},dp={class:`px-3 py-2 text-content-primary dark:text-content-primary font-mono text-xs break-all`},fp={class:`px-3 py-2 text-right font-mono text-xs text-content-secondary dark:text-content-muted whitespace-nowrap`},pp={class:`px-3 py-2 text-right font-mono text-xs text-content-secondary dark:text-content-muted`},mp={key:4,class:`py-8 text-center text-content-muted text-sm`},hp=V(f({__name:`MemoryDebug`,setup(n){let i=l(!1),a=l(!1),o=l(``),s=l(null),c=l(!1),u=l(null),f=l(!1),p=y(()=>s.value&&(s.value.current_top_20||s.value.growth_since_baseline));async function v(){i.value=!0,o.value=``;try{let e=await R.get(`memory_debug`);e.success&&e.data?(c.value=!!e.data.tracing,u.value=e.data.rss_mb??null,(e.data.current_top_20||e.data.growth_since_baseline)&&(s.value=e.data)):o.value=e.error||`Failed to fetch memory status`}catch(e){o.value=e instanceof Error?e.message:`Failed to fetch memory status`}finally{i.value=!1}}async function w(){a.value=!0,o.value=``;let e=c.value?`stop`:`start`;try{let t=await R.post(`memory_debug`,{action:e});t.success&&t.data?(c.value=!!t.data.tracing,e===`stop`&&(s.value=null,u.value=null)):o.value=t.error||`Failed to ${e} tracing`}catch(t){o.value=t instanceof Error?t.message:`Failed to ${e} tracing`}finally{a.value=!1,c.value&&await v()}}function E(e){return e.size_diff_kb>=100?`critical`:e.size_diff_kb>=10?`warning`:e.size_diff_kb>=1?`low`:`ok`}function D(e){let t=E(e);return t===`critical`?`Investigate`:t===`warning`?`Watch`:t===`low`?`Minor`:`Normal`}function O(e){let t=E(e);return t===`critical`?`bg-red-500/20 text-red-700 dark:text-red-400 border border-red-500/30`:t===`warning`?`bg-amber-500/20 text-amber-700 dark:text-amber-400 border border-amber-500/30`:t===`low`?`bg-blue-500/15 text-blue-600 dark:text-blue-400 border border-blue-500/20`:`bg-green-500/15 text-green-700 dark:text-green-400 border border-green-500/20`}function k(e){let t=E(e);return t===`critical`?`border-red-500/40 dark:border-red-500/30 bg-red-500/5 dark:bg-red-500/5`:t===`warning`?`border-amber-500/40 dark:border-amber-500/30 bg-amber-500/5 dark:bg-amber-500/5`:t===`low`?`border-stroke-subtle dark:border-stroke/10 bg-background-mute/50 dark:bg-background/20`:`border-stroke-subtle/50 dark:border-stroke/5 bg-background-mute/30 dark:bg-background/10 opacity-60`}function A(e){let t=E(e);return t===`critical`?`text-red-600 dark:text-red-400`:t===`warning`?`text-amber-600 dark:text-amber-400`:t===`low`?`text-blue-600 dark:text-blue-400`:`text-green-600 dark:text-green-500`}function j(e){return e>=1024?`${(e/1024).toFixed(1)} MB`:e>=10?`${Math.round(e)} KB`:`${e.toFixed(1)} KB`}function N(e){return e.replace(/.*\/site-packages\//,``).replace(/.*\/lib\/python[^/]*\//,``).replace(/.*\/repeater\//,`repeater/`)}let P=y(()=>s.value?.growth_since_baseline?s.value.growth_since_baseline.reduce((e,t)=>e+t.size_diff_kb,0):0),F=y(()=>P.value>=500?`critical`:P.value>=50?`warning`:P.value>=5?`low`:`ok`),I=y(()=>{let e=F.value;return e===`critical`?`border-red-500/40 dark:border-red-500/30 bg-red-500/10 dark:bg-red-500/10 text-red-800 dark:text-red-300`:e===`warning`?`border-amber-500/40 dark:border-amber-500/30 bg-amber-500/10 dark:bg-amber-500/10 text-amber-800 dark:text-amber-300`:e===`low`?`border-blue-500/30 bg-blue-500/10 dark:bg-blue-500/10 text-blue-800 dark:text-blue-300`:`border-green-500/30 bg-green-500/10 dark:bg-green-500/10 text-green-800 dark:text-green-300`}),L=y(()=>{let e=F.value;return e===`critical`?``:e===`warning`?``:e===`low`?``:``}),z=y(()=>{let e=F.value;return e===`critical`?`Significant memory growth detected`:e===`warning`?`Some memory growth detected`:e===`low`?`Minor memory growth — likely normal`:`Memory looks healthy`}),ee=y(()=>{let e=j(P.value),t=F.value;return t===`critical`?`Total growth: ${e}. Red items below need attention.`:t===`warning`?`Total growth: ${e}. Orange items below may need attention over time.`:t===`low`?`Total growth: ${e}. Nothing to worry about right now.`:`No significant growth since tracing started.`});return r(v),(n,r)=>(h(),C(`div`,wf,[r[15]||=S(`div`,{class:`cfg-page-heading flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},[S(`div`,null,[S(`h3`,{class:`text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2`},`Memory`),S(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Diagnose memory usage and trace allocations`)])],-1),S(`div`,Tf,[S(`div`,Ef,[r[2]||=S(`div`,null,[S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-1`},` Memory Diagnostics `),S(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Trace memory allocations to find leaks. Tracing adds overhead — only enable when needed. `)],-1),S(`div`,Df,[c.value&&p.value?(h(),C(`button`,{key:0,onClick:v,disabled:i.value,class:`cfg-btn-secondary`},[i.value?(h(),C(`span`,kf,[_(H,{size:`xs`,color:`current`,class:`inline-block`}),r[1]||=b(` Checking… `,-1)])):(h(),C(`span`,Af,`Check Again`))],8,Of)):g(``,!0),S(`button`,{onClick:w,disabled:a.value,class:T([`px-3 py-1.5 rounded-lg border text-sm transition-colors disabled:opacity-50`,c.value?`bg-red-500/20 hover:bg-red-500/30 text-red-700 dark:text-red-400 border-red-500/50`:`bg-green-500/20 hover:bg-green-500/30 text-green-700 dark:text-green-400 border-green-500/50`])},[a.value?(h(),C(`span`,Mf,[_(H,{size:`xs`,color:`current`,class:`inline-block`}),b(` `+t(c.value?`Stopping…`:`Starting…`),1)])):(h(),C(`span`,Nf,t(c.value?`Stop Tracing`:`Start Tracing`),1))],10,jf)])]),o.value?(h(),C(`div`,Pf,t(o.value),1)):g(``,!0),!c.value&&u.value!==null&&!i.value?(h(),C(`div`,Ff,[S(`div`,If,[r[3]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Current Memory (RSS)`,-1),S(`p`,Lf,t(u.value)+` MB`,1)])])):g(``,!0),c.value&&!p.value&&!i.value?(h(),C(`div`,Rf,[...r[4]||=[d(`
Tracing active

Memory tracing is running. Let the repeater run for a few minutes, then click Check Again to see which parts of the code are using more memory.

`,2)]])):g(``,!0),s.value&&p.value?(h(),C(`div`,zf,[S(`div`,{class:T([`mb-5 p-4 rounded-lg border flex items-start gap-3`,I.value])},[S(`div`,{class:`mt-0.5`,innerHTML:L.value},null,8,Bf),S(`div`,null,[S(`p`,Vf,t(z.value),1),S(`p`,Hf,t(ee.value),1)])],2),S(`div`,Uf,[s.value.rss_mb===void 0?g(``,!0):(h(),C(`div`,Wf,[r[5]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Total Memory Used`,-1),S(`p`,Gf,t(s.value.rss_mb)+` MB`,1)])),s.value.traced_current_mb===void 0?g(``,!0):(h(),C(`div`,Kf,[r[6]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Tracked Now`,-1),S(`p`,qf,t(s.value.traced_current_mb)+` MB`,1)])),s.value.traced_peak_mb===void 0?g(``,!0):(h(),C(`div`,Jf,[r[7]||=S(`p`,{class:`text-xs text-content-muted mb-1`},`Peak Tracked`,-1),S(`p`,Yf,t(s.value.traced_peak_mb)+` MB`,1)]))]),s.value.growth_since_baseline&&s.value.growth_since_baseline.length>0?(h(),C(`div`,Xf,[r[8]||=S(`h4`,{class:`text-sm font-semibold text-content-primary dark:text-content-primary mb-1`},`Memory Growth Breakdown`,-1),r[9]||=S(`p`,{class:`text-xs text-content-muted mb-3`},` Items at the top with red/orange tags are the most likely cause of memory issues. Green items are normal and can be ignored. `,-1),S(`div`,Zf,[(h(!0),C(x,null,m(s.value.growth_since_baseline,(e,n)=>(h(),C(`div`,{key:n,class:T([`rounded-lg border p-3 transition-colors`,k(e)])},[S(`div`,Qf,[S(`div`,$f,[S(`span`,ep,t(n+1),1),S(`span`,{class:T([`shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold`,O(e)])},t(D(e)),3)]),S(`div`,tp,[S(`span`,{class:T([`font-mono text-sm font-semibold`,A(e)])},`+`+t(j(e.size_diff_kb)),3),S(`p`,np,t(j(e.current_size_kb))+` total`,1)])]),S(`div`,rp,[S(`p`,ip,t(N(e.file)),1),e.count_diff===0?g(``,!0):(h(),C(`p`,ap,t(e.count_diff>0?`+`:``)+t(e.count_diff)+` new allocation`+t(Math.abs(e.count_diff)===1?``:`s`),1))])],2))),128))])])):s.value.growth_since_baseline&&s.value.growth_since_baseline.length===0?(h(),C(`div`,op,[...r[10]||=[S(`svg`,{class:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`span`,{class:`text-green-700 dark:text-green-400`},`No memory growth detected. Everything looks healthy.`,-1)]])):g(``,!0),s.value.current_top_20&&s.value.current_top_20.length>0?(h(),C(`div`,sp,[S(`button`,{onClick:r[0]||=e=>f.value=!f.value,class:`flex items-center gap-2 text-sm font-semibold text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors mb-3`},[(h(),C(`svg`,{class:T([`w-4 h-4 transition-transform`,{"rotate-90":f.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...r[11]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]],2)),r[12]||=b(` Advanced: Current Top Allocations `,-1)]),_(M,{name:`expand`},{default:e(()=>[f.value?(h(),C(`div`,cp,[S(`table`,lp,[r[13]||=S(`thead`,null,[S(`tr`,{class:`bg-background-mute dark:bg-background/30 text-left`},[S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted`},`#`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted`},`Location`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted text-right`},`Size`),S(`th`,{class:`px-3 py-2 text-xs font-medium text-content-muted text-right`},`Count`)])],-1),S(`tbody`,null,[(h(!0),C(x,null,m(s.value.current_top_20,(e,n)=>(h(),C(`tr`,{key:n,class:`border-t border-stroke-subtle/50 dark:border-stroke/5 hover:bg-background-mute/50 dark:hover:bg-background/20 transition-colors`},[S(`td`,up,t(n+1),1),S(`td`,dp,t(N(e.file)),1),S(`td`,fp,t(j(e.size_kb)),1),S(`td`,pp,t(e.count),1)]))),128))])])])):g(``,!0)]),_:1})])):g(``,!0)])):g(``,!0),!i.value&&!a.value&&!c.value&&!p.value&&!o.value&&u.value===null?(h(),C(`div`,mp,[...r[14]||=[b(` Click `,-1),S(`strong`,null,`Start Tracing`,-1),b(` to enable memory diagnostics. `,-1),S(`br`,null,null,-1),S(`span`,{class:`text-xs`},`Tracing uses extra memory — remember to stop it when done.`,-1)]])):g(``,!0)])]))}}),[[`__scopeId`,`data-v-00e540ed`]]),gp={class:`p-3 sm:p-6 space-y-4 sm:space-y-6`},_p={class:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`},vp={class:`glass-card rounded-[15px] p-3 sm:p-6 mt-4 sm:mt-6`},yp={class:`relative -mx-3 sm:mx-0 mb-4 sm:mb-6`},bp={key:0,class:`absolute left-0 top-0 bottom-[1px] w-12 z-10 flex items-center`},xp={key:0,class:`absolute right-0 top-0 bottom-[1px] w-12 z-10 flex items-center justify-end`},Sp=[`onClick`],Cp={class:`flex items-center gap-1 sm:gap-2`},wp={key:0,class:`w-3.5 h-3.5 sm:w-4 sm:h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Tp={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ep={key:2,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Dp={key:3,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Op={key:4,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},kp={key:5,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ap={key:6,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},jp={key:7,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Mp={key:8,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Np={key:9,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Pp={key:10,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Fp={key:11,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ip={key:12,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Lp={class:`min-h-[400px]`},Rp={key:0,class:`flex items-center justify-center py-12`},zp={class:`text-center`},Bp={key:1,class:`flex items-center justify-center py-12`},Vp={class:`text-center`},Hp={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},Up={key:2},Wp={key:0},Gp={key:1},Kp={key:2},qp={key:3},Jp={key:4},Yp={key:5},Xp={key:6},Zp={key:7},Qp={key:8},$p={key:9},em={key:10},tm={key:11},nm={key:12},rm=V(f({name:`ConfigurationView`,__name:`Configuration`,setup(n){let i=ee(),c=B(),d=l(Y(`configuration_activeTab`,`radio`)),f=l(!1),p=l(null),y=l(!1),w=l(!1),E=l(null),D=l(null),O=l(null),k=l(null),A=l(null),j=l(null),N=l(null),P=l(null),F={radio:E,"radio-hardware":D,repeater:O,advert:k,duty:A,delays:j,transport:N,observer:P};function I(){let e=F[d.value]?.value;if(!e)return!1;let t=e.isEditing;return typeof t==`boolean`?t:t.value}function L(e){let t=F[d.value]?.value;t?t.requestLeave(e):e()}function R(){if(!p.value)return;let e=p.value;w.value=e.scrollLeft>4,y.value=e.scrollLeftJ(`configuration_activeTab`,e));let V=[{id:`radio`,label:`Radio Settings`,icon:`radio`},{id:`radio-hardware`,label:`Radio Hardware`,icon:`hardware`},{id:`repeater`,label:`Repeater Settings`,icon:`repeater`},{id:`advert`,label:`Advert Limits`,icon:`advert`},{id:`duty`,label:`Duty Cycle`,icon:`duty`},{id:`delays`,label:`TX Delays`,icon:`delays`},{id:`transport`,label:`Region Configuration`,icon:`keys`},{id:`api-tokens`,label:`API Tokens`,icon:`tokens`},{id:`web`,label:`Web Options`,icon:`web`},{id:`observer`,label:`Observer`,icon:`observer`},{id:`backup`,label:`Backup`,icon:`backup`},{id:`database`,label:`Database`,icon:`database`},{id:`memory`,label:`Memory`,icon:`memory`}];r(async()=>{if(i.stats)f.value=!0;else try{await c.ensure(`stats`)}catch(e){console.error(`Failed to load configuration data:`,e)}finally{f.value=!0}s(()=>R())});function te(e){if(e!==d.value&&I()){L(()=>{d.value=e});return}d.value=e}return(n,r)=>{let o=a(`router-link`);return h(),C(`div`,gp,[S(`div`,_p,[r[4]||=S(`div`,null,[S(`h1`,{class:`text-xl sm:text-2xl font-bold text-content-primary dark:text-content-primary`},` Configuration `),S(`p`,{class:`text-content-secondary dark:text-content-muted mt-1 sm:mt-2 text-sm sm:text-base`},` System configuration and settings `)],-1),f.value&&!(v(i).stats?.config?.radio)?.cad?.peak_threshold?(h(),u(o,{key:0,to:`/cad-calibration`,class:`flex-shrink-0 flex items-center gap-4 px-5 py-3 min-w-[280px] rounded-xl border border-primary/30 bg-primary/10 text-primary hover:bg-primary/20 transition-colors`},{default:e(()=>[...r[3]||=[S(`svg`,{class:`w-5 h-5 flex-shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 10V3L4 14h7v7l9-11h-7z`})],-1),S(`div`,null,[S(`div`,{class:`text-sm font-semibold`},`CAD Calibration Available`),S(`div`,{class:`text-xs text-primary/70`},`Optimise CAD settings →`)],-1)]]),_:1})):g(``,!0)]),S(`div`,vp,[S(`div`,yp,[_(M,{name:`tab-fade`},{default:e(()=>[w.value?(h(),C(`div`,bp,[r[6]||=S(`div`,{class:`tab-fade-left absolute inset-0 pointer-events-none`},null,-1),S(`button`,{onClick:r[0]||=e=>z(`left`),class:`relative z-10 ml-1.5 w-6 h-6 flex items-center justify-center rounded-full bg-surface shadow-md border border-stroke-subtle dark:border-stroke/30 text-content-muted`},[...r[5]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M15 19l-7-7 7-7`})],-1)]])])):g(``,!0)]),_:1}),_(M,{name:`tab-fade`},{default:e(()=>[y.value?(h(),C(`div`,xp,[r[8]||=S(`div`,{class:`tab-fade-right absolute inset-0 pointer-events-none`},null,-1),S(`button`,{onClick:r[1]||=e=>z(`right`),class:`relative z-10 mr-1.5 w-6 h-6 flex items-center justify-center rounded-full bg-surface shadow-md border border-stroke-subtle dark:border-stroke/30 text-content-muted`},[...r[7]||=[S(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1)]])])):g(``,!0)]),_:1}),S(`div`,{ref_key:`tabsContainer`,ref:p,onScroll:R,class:`flex overflow-x-auto border-b border-stroke-subtle dark:border-stroke px-3 sm:px-0 scrollbar-hide`},[(h(),C(x,null,m(V,e=>S(`button`,{key:e.id,onClick:t=>te(e.id),class:T([`px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors duration-200 border-b-2 mr-3 sm:mr-6 whitespace-nowrap flex-shrink-0`,d.value===e.id?`text-primary border-primary`:`text-content-secondary dark:text-content-muted border-transparent hover:text-content-primary dark:hover:text-content-primary hover:border-stroke-subtle dark:hover:border-stroke/30`])},[S(`div`,Cp,[e.icon===`radio`?(h(),C(`svg`,wp,[...r[9]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.822c5.716-5.716 14.976-5.716 20.692 0`},null,-1)]])):e.icon===`hardware`?(h(),C(`svg`,Tp,[...r[10]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z`},null,-1)]])):e.icon===`repeater`?(h(),C(`svg`,Ep,[...r[11]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14M5 12l4-4m-4 4l4 4`},null,-1)]])):e.icon===`advert`?(h(),C(`svg`,Dp,[...r[12]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`},null,-1)]])):e.icon===`duty`?(h(),C(`svg`,Op,[...r[13]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):e.icon===`delays`?(h(),C(`svg`,kp,[...r[14]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`},null,-1)]])):e.icon===`keys`?(h(),C(`svg`,Ap,[...r[15]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`},null,-1)]])):e.icon===`tokens`?(h(),C(`svg`,jp,[...r[16]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`},null,-1)]])):e.icon===`web`?(h(),C(`svg`,Mp,[...r[17]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9`},null,-1)]])):e.icon===`observer`?(h(),C(`svg`,Np,[...r[18]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):e.icon===`backup`?(h(),C(`svg`,Pp,[...r[19]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4`},null,-1)]])):e.icon===`database`?(h(),C(`svg`,Fp,[...r[20]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`},null,-1)]])):e.icon===`memory`?(h(),C(`svg`,Ip,[...r[21]||=[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z`},null,-1)]])):g(``,!0),b(` `+t(e.label),1)])],10,Sp)),64))],544)]),S(`div`,Lp,[!f.value&&v(i).isLoading?(h(),C(`div`,Rp,[S(`div`,zp,[_(H,{class:`mx-auto mb-4`}),r[22]||=S(`div`,{class:`text-content-secondary dark:text-content-muted`},` Loading configuration... `,-1)])])):f.value&&!v(i).stats?(h(),C(`div`,Bp,[S(`div`,Vp,[r[23]||=S(`div`,{class:`text-accent-red mb-2`},`Failed to load configuration`,-1),S(`div`,Hp,t(v(i).error),1),S(`button`,{onClick:r[2]||=e=>v(i).fetchStats(),class:`btn-primary`},` Retry `)])])):(h(),C(`div`,Up,[d.value===`radio`?(h(),C(`div`,Wp,[_(at,{ref_key:`radioRef`,ref:E,key:`radio-settings`},null,512)])):g(``,!0),d.value===`repeater`?(h(),C(`div`,Gp,[_(Rr,{ref_key:`repeaterRef`,ref:O,key:`repeater-settings`},null,512)])):g(``,!0),d.value===`radio-hardware`?(h(),C(`div`,Kp,[_(Rn,{ref_key:`radioHardwareRef`,ref:D,key:`radio-hardware-settings`},null,512)])):g(``,!0),d.value===`advert`?(h(),C(`div`,qp,[_(Kc,{ref_key:`advertRef`,ref:k,key:`advert-settings`},null,512)])):g(``,!0),d.value===`duty`?(h(),C(`div`,Jp,[_(Qr,{ref_key:`dutyRef`,ref:A,key:`duty-cycle`},null,512)])):g(``,!0),d.value===`delays`?(h(),C(`div`,Yp,[_(di,{ref_key:`delaysRef`,ref:j,key:`transmission-delays`},null,512)])):g(``,!0),d.value===`transport`?(h(),C(`div`,Xp,[_(jo,{ref_key:`transportRef`,ref:N,key:`transport-keys`},null,512)])):g(``,!0),d.value===`api-tokens`?(h(),C(`div`,Zp,[_(os,{key:`api-tokens`})])):g(``,!0),d.value===`web`?(h(),C(`div`,Qp,[_(Ps,{key:`web-settings`})])):g(``,!0),d.value===`observer`?(h(),C(`div`,$p,[_(hu,{ref_key:`letsMeshRef`,ref:P,key:`letsmesh-settings`},null,512)])):g(``,!0),d.value===`backup`?(h(),C(`div`,em,[_(xd,{key:`backup-restore`})])):g(``,!0),d.value===`database`?(h(),C(`div`,tm,[_(Cf,{key:`database-management`})])):g(``,!0),d.value===`memory`?(h(),C(`div`,nm,[_(hp,{key:`memory-debug`})])):g(``,!0)]))])])])}}}),[[`__scopeId`,`data-v-ff4fb67b`]]);export{rm as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Configuration-zQuuYGWe.css b/repeater/web/html/assets/Configuration-zQuuYGWe.css deleted file mode 100644 index c29dff2b..00000000 --- a/repeater/web/html/assets/Configuration-zQuuYGWe.css +++ /dev/null @@ -1 +0,0 @@ -.leaflet-pane[data-v-fd94857e],.leaflet-tile[data-v-fd94857e],.leaflet-marker-icon[data-v-fd94857e],.leaflet-marker-shadow[data-v-fd94857e],.leaflet-tile-container[data-v-fd94857e],.leaflet-pane>svg[data-v-fd94857e],.leaflet-pane>canvas[data-v-fd94857e],.leaflet-zoom-box[data-v-fd94857e],.leaflet-image-layer[data-v-fd94857e],.leaflet-layer[data-v-fd94857e]{position:absolute;top:0;left:0}.leaflet-container[data-v-fd94857e]{overflow:hidden}.leaflet-tile[data-v-fd94857e],.leaflet-marker-icon[data-v-fd94857e],.leaflet-marker-shadow[data-v-fd94857e]{-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile[data-v-fd94857e]::selection{background:0 0}.leaflet-safari .leaflet-tile[data-v-fd94857e]{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container[data-v-fd94857e]{-webkit-transform-origin:0 0;width:1600px;height:1600px}.leaflet-marker-icon[data-v-fd94857e],.leaflet-marker-shadow[data-v-fd94857e]{display:block}.leaflet-container .leaflet-overlay-pane svg[data-v-fd94857e]{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img[data-v-fd94857e],.leaflet-container .leaflet-shadow-pane img[data-v-fd94857e],.leaflet-container .leaflet-tile-pane img[data-v-fd94857e],.leaflet-container img.leaflet-image-layer[data-v-fd94857e],.leaflet-container .leaflet-tile[data-v-fd94857e]{width:auto;padding:0;max-width:none!important;max-height:none!important}.leaflet-container img.leaflet-tile[data-v-fd94857e]{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom[data-v-fd94857e]{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag[data-v-fd94857e]{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom[data-v-fd94857e]{-ms-touch-action:none;touch-action:none}.leaflet-container[data-v-fd94857e]{-webkit-tap-highlight-color:transparent}.leaflet-container a[data-v-fd94857e]{-webkit-tap-highlight-color:#33b5e566}.leaflet-tile[data-v-fd94857e]{filter:inherit;visibility:hidden}.leaflet-tile-loaded[data-v-fd94857e]{visibility:inherit}.leaflet-zoom-box[data-v-fd94857e]{box-sizing:border-box;z-index:800;width:0;height:0}.leaflet-overlay-pane svg[data-v-fd94857e]{-moz-user-select:none}.leaflet-pane[data-v-fd94857e]{z-index:400}.leaflet-tile-pane[data-v-fd94857e]{z-index:200}.leaflet-overlay-pane[data-v-fd94857e]{z-index:400}.leaflet-shadow-pane[data-v-fd94857e]{z-index:500}.leaflet-marker-pane[data-v-fd94857e]{z-index:600}.leaflet-tooltip-pane[data-v-fd94857e]{z-index:650}.leaflet-popup-pane[data-v-fd94857e]{z-index:700}.leaflet-map-pane canvas[data-v-fd94857e]{z-index:100}.leaflet-map-pane svg[data-v-fd94857e]{z-index:200}.leaflet-vml-shape[data-v-fd94857e]{width:1px;height:1px}.lvml[data-v-fd94857e]{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control[data-v-fd94857e]{z-index:800;pointer-events:visiblePainted;pointer-events:auto;position:relative}.leaflet-top[data-v-fd94857e],.leaflet-bottom[data-v-fd94857e]{z-index:1000;pointer-events:none;position:absolute}.leaflet-top[data-v-fd94857e]{top:0}.leaflet-right[data-v-fd94857e]{right:0}.leaflet-bottom[data-v-fd94857e]{bottom:0}.leaflet-left[data-v-fd94857e]{left:0}.leaflet-control[data-v-fd94857e]{float:left;clear:both}.leaflet-right .leaflet-control[data-v-fd94857e]{float:right}.leaflet-top .leaflet-control[data-v-fd94857e]{margin-top:10px}.leaflet-bottom .leaflet-control[data-v-fd94857e]{margin-bottom:10px}.leaflet-left .leaflet-control[data-v-fd94857e]{margin-left:10px}.leaflet-right .leaflet-control[data-v-fd94857e]{margin-right:10px}.leaflet-fade-anim .leaflet-popup[data-v-fd94857e]{opacity:0;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup[data-v-fd94857e]{opacity:1}.leaflet-zoom-animated[data-v-fd94857e]{transform-origin:0 0}svg.leaflet-zoom-animated[data-v-fd94857e]{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated[data-v-fd94857e]{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile[data-v-fd94857e],.leaflet-pan-anim .leaflet-tile[data-v-fd94857e]{transition:none}.leaflet-zoom-anim .leaflet-zoom-hide[data-v-fd94857e]{visibility:hidden}.leaflet-interactive[data-v-fd94857e]{cursor:pointer}.leaflet-grab[data-v-fd94857e]{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair[data-v-fd94857e],.leaflet-crosshair .leaflet-interactive[data-v-fd94857e]{cursor:crosshair}.leaflet-popup-pane[data-v-fd94857e],.leaflet-control[data-v-fd94857e]{cursor:auto}.leaflet-dragging .leaflet-grab[data-v-fd94857e],.leaflet-dragging .leaflet-grab .leaflet-interactive[data-v-fd94857e],.leaflet-dragging .leaflet-marker-draggable[data-v-fd94857e]{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon[data-v-fd94857e],.leaflet-marker-shadow[data-v-fd94857e],.leaflet-image-layer[data-v-fd94857e],.leaflet-pane>svg path[data-v-fd94857e],.leaflet-tile-container[data-v-fd94857e]{pointer-events:none}.leaflet-marker-icon.leaflet-interactive[data-v-fd94857e],.leaflet-image-layer.leaflet-interactive[data-v-fd94857e],.leaflet-pane>svg path.leaflet-interactive[data-v-fd94857e],svg.leaflet-image-layer.leaflet-interactive path[data-v-fd94857e]{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container[data-v-fd94857e]{outline-offset:1px;background:#ddd}.leaflet-container a[data-v-fd94857e]{color:#0078a8}.leaflet-zoom-box[data-v-fd94857e]{background:#ffffff80;border:2px dotted #38f}.leaflet-container[data-v-fd94857e]{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:.75rem;line-height:1.5}.leaflet-bar[data-v-fd94857e]{border-radius:4px;box-shadow:0 1px 5px #000000a6}.leaflet-bar a[data-v-fd94857e]{text-align:center;color:#000;background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;text-decoration:none;display:block}.leaflet-bar a[data-v-fd94857e],.leaflet-control-layers-toggle[data-v-fd94857e]{background-position:50%;background-repeat:no-repeat;display:block}.leaflet-bar a[data-v-fd94857e]:hover,.leaflet-bar a[data-v-fd94857e]:focus{background-color:#f4f4f4}.leaflet-bar a[data-v-fd94857e]:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a[data-v-fd94857e]:last-child{border-bottom:none;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.leaflet-bar a.leaflet-disabled[data-v-fd94857e]{cursor:default;color:#bbb;background-color:#f4f4f4}.leaflet-touch .leaflet-bar a[data-v-fd94857e]{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a[data-v-fd94857e]:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a[data-v-fd94857e]:last-child{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.leaflet-control-zoom-in[data-v-fd94857e],.leaflet-control-zoom-out[data-v-fd94857e]{text-indent:1px;font:700 18px Lucida Console,Monaco,monospace}.leaflet-touch .leaflet-control-zoom-in[data-v-fd94857e],.leaflet-touch .leaflet-control-zoom-out[data-v-fd94857e]{font-size:22px}.leaflet-control-layers[data-v-fd94857e]{background:#fff;border-radius:5px;box-shadow:0 1px 5px #0006}.leaflet-control-layers-toggle[data-v-fd94857e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle[data-v-fd94857e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle[data-v-fd94857e]{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list[data-v-fd94857e],.leaflet-control-layers-expanded .leaflet-control-layers-toggle[data-v-fd94857e]{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list[data-v-fd94857e]{display:block;position:relative}.leaflet-control-layers-expanded[data-v-fd94857e]{color:#333;background:#fff;padding:6px 10px 6px 6px}.leaflet-control-layers-scrollbar[data-v-fd94857e]{padding-right:5px;overflow:hidden scroll}.leaflet-control-layers-selector[data-v-fd94857e]{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label[data-v-fd94857e]{font-size:1.08333em;display:block}.leaflet-control-layers-separator[data-v-fd94857e]{border-top:1px solid #ddd;height:0;margin:5px -10px 5px -6px}.leaflet-default-icon-path[data-v-fd94857e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution[data-v-fd94857e]{background:#fffc;margin:0}.leaflet-control-attribution[data-v-fd94857e],.leaflet-control-scale-line[data-v-fd94857e]{color:#333;padding:0 5px;line-height:1.4}.leaflet-control-attribution a[data-v-fd94857e]{text-decoration:none}.leaflet-control-attribution a[data-v-fd94857e]:hover,.leaflet-control-attribution a[data-v-fd94857e]:focus{text-decoration:underline}.leaflet-attribution-flag[data-v-fd94857e]{width:1em;height:.6669em;vertical-align:baseline!important;display:inline!important}.leaflet-left .leaflet-control-scale[data-v-fd94857e]{margin-left:5px}.leaflet-bottom .leaflet-control-scale[data-v-fd94857e]{margin-bottom:5px}.leaflet-control-scale-line[data-v-fd94857e]{white-space:nowrap;box-sizing:border-box;text-shadow:1px 1px #fff;background:#fffc;border:2px solid #777;border-top:none;padding:2px 5px 1px;line-height:1.1}.leaflet-control-scale-line[data-v-fd94857e]:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line[data-v-fd94857e]:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution[data-v-fd94857e],.leaflet-touch .leaflet-control-layers[data-v-fd94857e],.leaflet-touch .leaflet-bar[data-v-fd94857e]{box-shadow:none}.leaflet-touch .leaflet-control-layers[data-v-fd94857e],.leaflet-touch .leaflet-bar[data-v-fd94857e]{background-clip:padding-box;border:2px solid #0003}.leaflet-popup[data-v-fd94857e]{text-align:center;margin-bottom:20px;position:absolute}.leaflet-popup-content-wrapper[data-v-fd94857e]{text-align:left;border-radius:12px;padding:1px}.leaflet-popup-content[data-v-fd94857e]{min-height:1px;margin:13px 24px 13px 20px;font-size:1.08333em;line-height:1.3}.leaflet-popup-content p[data-v-fd94857e]{margin:1.3em 0}.leaflet-popup-tip-container[data-v-fd94857e]{pointer-events:none;width:40px;height:20px;margin-top:-1px;margin-left:-20px;position:absolute;left:50%;overflow:hidden}.leaflet-popup-tip[data-v-fd94857e]{pointer-events:auto;width:17px;height:17px;margin:-10px auto 0;padding:1px;transform:rotate(45deg)}.leaflet-popup-content-wrapper[data-v-fd94857e],.leaflet-popup-tip[data-v-fd94857e]{color:#333;background:#fff;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button[data-v-fd94857e]{text-align:center;color:#757575;background:0 0;border:none;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;text-decoration:none;position:absolute;top:0;right:0}.leaflet-container a.leaflet-popup-close-button[data-v-fd94857e]:hover,.leaflet-container a.leaflet-popup-close-button[data-v-fd94857e]:focus{color:#585858}.leaflet-popup-scrolled[data-v-fd94857e]{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper[data-v-fd94857e]{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip[data-v-fd94857e]{-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";width:24px;filter:progid:DXImageTransform.Microsoft.Matrix(M11=.707107, M12=.707107, M21=-.707107, M22=.707107);margin:0 auto}.leaflet-oldie .leaflet-control-zoom[data-v-fd94857e],.leaflet-oldie .leaflet-control-layers[data-v-fd94857e],.leaflet-oldie .leaflet-popup-content-wrapper[data-v-fd94857e],.leaflet-oldie .leaflet-popup-tip[data-v-fd94857e]{border:1px solid #999}.leaflet-div-icon[data-v-fd94857e]{background:#fff;border:1px solid #666}.leaflet-tooltip[data-v-fd94857e]{color:#222;white-space:nowrap;-webkit-user-select:none;user-select:none;pointer-events:none;background-color:#fff;border:1px solid #fff;border-radius:3px;padding:6px;position:absolute;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive[data-v-fd94857e]{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top[data-v-fd94857e]:before,.leaflet-tooltip-bottom[data-v-fd94857e]:before,.leaflet-tooltip-left[data-v-fd94857e]:before,.leaflet-tooltip-right[data-v-fd94857e]:before{pointer-events:none;content:"";background:0 0;border:6px solid #0000;position:absolute}.leaflet-tooltip-bottom[data-v-fd94857e]{margin-top:6px}.leaflet-tooltip-top[data-v-fd94857e]{margin-top:-6px}.leaflet-tooltip-bottom[data-v-fd94857e]:before,.leaflet-tooltip-top[data-v-fd94857e]:before{margin-left:-6px;left:50%}.leaflet-tooltip-top[data-v-fd94857e]:before{border-top-color:#fff;margin-bottom:-12px;bottom:0}.leaflet-tooltip-bottom[data-v-fd94857e]:before{border-bottom-color:#fff;margin-top:-12px;margin-left:-6px;top:0}.leaflet-tooltip-left[data-v-fd94857e]{margin-left:-6px}.leaflet-tooltip-right[data-v-fd94857e]{margin-left:6px}.leaflet-tooltip-left[data-v-fd94857e]:before,.leaflet-tooltip-right[data-v-fd94857e]:before{margin-top:-6px;top:50%}.leaflet-tooltip-left[data-v-fd94857e]:before{border-left-color:#fff;margin-right:-12px;right:0}.leaflet-tooltip-right[data-v-fd94857e]:before{border-right-color:#fff;margin-left:-12px;left:0}@media print{.leaflet-control[data-v-fd94857e]{-webkit-print-color-adjust:exact;print-color-adjust:exact}}.ml-0[data-v-ed9c8a11]{margin-left:0}.ml-4[data-v-ed9c8a11]{margin-left:1rem}.ml-8[data-v-ed9c8a11]{margin-left:2rem}.ml-12[data-v-ed9c8a11]{margin-left:3rem}.ml-16[data-v-ed9c8a11]{margin-left:4rem}.ml-20[data-v-ed9c8a11]{margin-left:5rem}.ml-24[data-v-ed9c8a11]{margin-left:6rem}.ml-28[data-v-ed9c8a11]{margin-left:7rem}.ml-32[data-v-ed9c8a11]{margin-left:8rem}.dropdown-enter-active[data-v-45835eb1],.dropdown-leave-active[data-v-45835eb1]{transition:opacity .12s,transform .12s}.dropdown-enter-from[data-v-45835eb1],.dropdown-leave-to[data-v-45835eb1]{opacity:0;transform:translateY(-4px)}.expand-enter-active[data-v-50d93367],.expand-leave-active[data-v-50d93367]{transition:all .2s;overflow:hidden}.expand-enter-from[data-v-50d93367],.expand-leave-to[data-v-50d93367]{opacity:0;max-height:0}.expand-enter-to[data-v-50d93367],.expand-leave-from[data-v-50d93367]{opacity:1;max-height:2000px}.tab-fade-left[data-v-e8f5e632]{background:linear-gradient(to right, var(--color-surface) 30%, transparent)}.tab-fade-right[data-v-e8f5e632]{background:linear-gradient(to left, var(--color-surface) 30%, transparent)}.tab-fade-enter-active[data-v-e8f5e632],.tab-fade-leave-active[data-v-e8f5e632]{transition:opacity .2s}.tab-fade-enter-from[data-v-e8f5e632],.tab-fade-leave-to[data-v-e8f5e632]{opacity:0} diff --git a/repeater/web/html/assets/ConfirmDialog-DBlDmP2I.js b/repeater/web/html/assets/ConfirmDialog-DBlDmP2I.js new file mode 100644 index 00000000..cf06ed4b --- /dev/null +++ b/repeater/web/html/assets/ConfirmDialog-DBlDmP2I.js @@ -0,0 +1 @@ +import{Ct as e,c as t,g as n,i as r,k as i,l as a,s as o,u as s,xt as c}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{u as l}from"./runtime-dom.esm-bundler-fKU3dih-.js";var u={class:`modal-card max-w-md`},d={class:`flex items-center justify-between mb-4`},f={class:`text-xl font-semibold text-content-primary dark:text-content-primary`},p={class:`mb-6`},m={key:0,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},h={key:1,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},g={key:2,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},_={class:`text-content-secondary dark:text-content-primary/80 text-base leading-relaxed`},v={class:`flex gap-3`},y=n({__name:`ConfirmDialog`,props:{show:{type:Boolean},title:{default:`Confirm Action`},message:{},confirmText:{default:`Confirm`},cancelText:{default:`Cancel`},variant:{default:`warning`}},emits:[`close`,`confirm`],setup(n,{emit:y}){let b=n,x=y,S={danger:`bg-red-100 dark:bg-red-500/20 border-red-500/30 text-red-600 dark:text-red-400`,warning:`bg-yellow-100 dark:bg-yellow-500/20 border-yellow-500/30 text-yellow-600 dark:text-yellow-400`,info:`bg-blue-500/20 border-blue-500/30 text-blue-600 dark:text-blue-400`},C={danger:`bg-red-500 hover:bg-red-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,info:`bg-blue-500 hover:bg-blue-600`};return(n,y)=>(i(),t(r,{to:`body`},[b.show?(i(),s(`div`,{key:0,onClick:y[3]||=l(e=>x(`close`),[`self`]),class:`modal-backdrop`},[o(`div`,u,[o(`div`,d,[o(`h3`,f,e(b.title),1),o(`button`,{onClick:y[0]||=e=>x(`close`),class:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...y[4]||=[o(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),o(`div`,p,[o(`div`,{class:c([`inline-flex p-3 rounded-xl mb-4`,S[b.variant]])},[b.variant===`danger`?(i(),s(`svg`,m,[...y[5]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`},null,-1)]])):b.variant===`warning`?(i(),s(`svg`,h,[...y[6]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`},null,-1)]])):(i(),s(`svg`,g,[...y[7]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2),o(`p`,_,e(b.message),1)]),o(`div`,v,[o(`button`,{onClick:y[1]||=e=>x(`close`),class:`flex-1 px-4 py-3 rounded-xl bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary transition-all duration-200 border border-stroke-subtle dark:border-stroke/10`},e(b.cancelText),1),o(`button`,{onClick:y[2]||=e=>x(`confirm`),class:c([`flex-1 px-4 py-3 rounded-xl text-white transition-all duration-200`,C[b.variant]])},e(b.confirmText),3)])])])):a(``,!0)]))}});export{y as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/ConfirmDialog-PLW-eI8u.js b/repeater/web/html/assets/ConfirmDialog-PLW-eI8u.js deleted file mode 100644 index 196a1f4f..00000000 --- a/repeater/web/html/assets/ConfirmDialog-PLW-eI8u.js +++ /dev/null @@ -1 +0,0 @@ -import{dt as e,g as t,l as n,pt as r,s as i,u as a,w as o}from"./runtime-core.esm-bundler-HnidnMFy.js";import{h as s}from"./index-BFltqMtv.js";var c={class:`flex items-center justify-between mb-4`},l={class:`text-xl font-semibold text-content-primary dark:text-content-primary`},u={class:`mb-6`},d={key:0,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},f={key:1,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},p={key:2,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},m={class:`text-content-secondary dark:text-content-primary/80 text-base leading-relaxed`},h={class:`flex gap-3`},g=t({__name:`ConfirmDialog`,props:{show:{type:Boolean},title:{default:`Confirm Action`},message:{},confirmText:{default:`Confirm`},cancelText:{default:`Cancel`},variant:{default:`warning`}},emits:[`close`,`confirm`],setup(t,{emit:g}){let _=t,v=g,y=e=>{e.target===e.currentTarget&&v(`close`)},b={danger:`bg-red-100 dark:bg-red-500/20 border-red-500/30 text-red-600 dark:text-red-400`,warning:`bg-yellow-100 dark:bg-yellow-500/20 border-yellow-500/30 text-yellow-600 dark:text-yellow-400`,info:`bg-blue-500/20 border-blue-500/30 text-blue-600 dark:text-blue-400`},x={danger:`bg-red-500 hover:bg-red-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,info:`bg-blue-500 hover:bg-blue-600`};return(t,g)=>_.show?(o(),a(`div`,{key:0,onClick:y,class:`fixed inset-0 bg-black/40 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[i(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10`,onClick:g[3]||=s(()=>{},[`stop`])},[i(`div`,c,[i(`h3`,l,r(_.title),1),i(`button`,{onClick:g[0]||=e=>v(`close`),class:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...g[4]||=[i(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),i(`div`,u,[i(`div`,{class:e([`inline-flex p-3 rounded-xl mb-4`,b[_.variant]])},[_.variant===`danger`?(o(),a(`svg`,d,[...g[5]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`},null,-1)]])):_.variant===`warning`?(o(),a(`svg`,f,[...g[6]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`},null,-1)]])):(o(),a(`svg`,p,[...g[7]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2),i(`p`,m,r(_.message),1)]),i(`div`,h,[i(`button`,{onClick:g[1]||=e=>v(`close`),class:`flex-1 px-4 py-3 rounded-xl bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary transition-all duration-200 border border-stroke-subtle dark:border-stroke/10`},r(_.cancelText),1),i(`button`,{onClick:g[2]||=e=>v(`confirm`),class:e([`flex-1 px-4 py-3 rounded-xl text-white transition-all duration-200`,x[_.variant]])},r(_.confirmText),3)])])])):n(``,!0)}});export{g as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/Dashboard-BGrwr2sL.css b/repeater/web/html/assets/Dashboard-BGrwr2sL.css new file mode 100644 index 00000000..d4f7f25d --- /dev/null +++ b/repeater/web/html/assets/Dashboard-BGrwr2sL.css @@ -0,0 +1 @@ +.sparkline-card[data-v-d5c09182]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background:#ffffffbf;border:1px solid #0000000f;border-radius:12px;padding:12px 14px;transition:background .3s,border-color .3s,box-shadow .3s;overflow:hidden;box-shadow:0 4px 16px #0000000a,0 1px 3px #00000005}.dark .sparkline-card[data-v-d5c09182]{background:#0006;border:1px solid #ffffff0d;box-shadow:0 4px 16px #0003}.card-header[data-v-d5c09182]{justify-content:space-between;align-items:baseline;margin-bottom:8px;display:flex}.card-title[data-v-d5c09182]{color:#4b5563b3;text-transform:uppercase;letter-spacing:.05em;font-size:11px;font-weight:500;transition:color .3s}.dark .card-title[data-v-d5c09182]{color:#fff9}.card-value[data-v-d5c09182]{font-variant-numeric:tabular-nums;font-size:22px;font-weight:700;line-height:1}.card-values[data-v-d5c09182]{align-items:baseline;gap:6px;display:flex}.card-secondary-value[data-v-d5c09182]{font-variant-numeric:tabular-nums;opacity:.85;font-size:13px;font-weight:600;line-height:1}.card-chart[data-v-d5c09182]{width:100%;height:28px;overflow:hidden}.card-chart canvas[data-v-d5c09182]{width:100%!important;height:100%!important}@media (width>=1024px){.sparkline-card[data-v-d5c09182]{padding:14px 16px}.card-header[data-v-d5c09182]{margin-bottom:10px}.card-title[data-v-d5c09182]{font-size:12px}.card-value[data-v-d5c09182]{font-size:26px}.card-chart[data-v-d5c09182]{height:32px}}.stats-cards-container[data-v-19814841]{will-change:auto;contain:layout}.stat-card[data-v-19814841]{transition:opacity .3s ease-out}.stat-card[data-v-19814841] .text-lg,.stat-card[data-v-19814841] .text-\[30px\]{transition:color .2s ease-out}canvas[data-v-2e55952b]{width:100%;height:100%}.modal-enter-active[data-v-c8711b75]{transition:all .3s cubic-bezier(.4,0,.2,1)}.modal-leave-active[data-v-c8711b75]{transition:all .2s ease-in}.modal-enter-from[data-v-c8711b75]{opacity:0;transform:scale(.95)translateY(-10px)}.modal-leave-to[data-v-c8711b75]{opacity:0;transform:scale(1.05)}.custom-scrollbar[data-v-c8711b75]{scrollbar-width:thin;scrollbar-color:#ffffff4d transparent}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar{width:6px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-track{background:#ffffff1a;border-radius:3px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-thumb{background:#ffffff4d;border-radius:3px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-thumb:hover{background:#fff6}.glass-card[data-v-c8711b75]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px)}.fade-enter-active[data-v-976ea578],.fade-leave-active[data-v-976ea578]{transition:opacity .3s ease-out,transform .3s ease-out}.fade-enter-from[data-v-976ea578],.fade-leave-to[data-v-976ea578]{opacity:0;transform:translateY(-10px)}.packet-list-enter-active[data-v-976ea578],.packet-list-leave-active[data-v-976ea578],.packet-list-move[data-v-976ea578]{transition:all .4s ease-out}.packet-list-enter-from[data-v-976ea578]{opacity:0;transform:translateY(-30px)scale(.98)}.packet-list-enter-to[data-v-976ea578],.packet-list-leave-from[data-v-976ea578]{opacity:1;transform:translateY(0)scale(1)}.packet-list-leave-to[data-v-976ea578]{opacity:0;transform:translateY(-20px)scale(.95)}.packet-row[data-v-976ea578]{transition:all .3s;position:relative}.packet-list-enter-active .packet-row[data-v-976ea578]{background:linear-gradient(90deg,#4ec9b01a 0%,#4ec9b00d 50%,#0000 100%);border-left:3px solid #4ec9b099;border-radius:8px;padding-left:12px;box-shadow:0 0 20px #4ec9b033}.packet-row[data-v-976ea578]:hover{background:#ffffff05;border-radius:8px;transition:background .2s}@media (width<=1023px){.filter-container[data-v-976ea578]{flex-direction:column;align-items:stretch;gap:1rem}.header-info[data-v-976ea578]{flex-direction:column;align-items:flex-start;gap:.5rem}.packet-count[data-v-976ea578]{order:1}.live-mode-badge[data-v-976ea578]{order:2;align-self:flex-start}.loading-indicator[data-v-976ea578],.error-indicator[data-v-976ea578]{order:3;align-self:flex-start}.filter-controls[data-v-976ea578]{flex-direction:column;grid-template-columns:1fr 1fr;gap:.75rem;display:grid!important}.filter-controls .flex.flex-col[data-v-976ea578]{flex-direction:column;align-items:stretch;gap:.25rem}.filter-controls .flex.flex-col label[data-v-976ea578]{margin-bottom:0;font-size:.75rem}.reset-container[data-v-976ea578]{justify-content:center;margin-top:.5rem;display:flex;grid-column:span 2!important}.pagination-container[data-v-976ea578]{flex-direction:column;align-items:stretch;gap:1rem}.pagination-info[data-v-976ea578]{text-align:center;flex-direction:column;justify-content:center;gap:.5rem}.load-more-section[data-v-976ea578]{justify-content:center}.load-more-count[data-v-976ea578]{display:none}.pagination-controls[data-v-976ea578]{justify-content:center}.page-numbers[data-v-976ea578]{scrollbar-width:none;-ms-overflow-style:none;max-width:200px;overflow-x:auto}.page-numbers[data-v-976ea578]::-webkit-scrollbar{display:none}.ellipsis[data-v-976ea578]{display:none}.page-number[data-v-976ea578]{flex-shrink:0;min-width:40px}}@media (width<=640px){.filter-controls[data-v-976ea578]{gap:.75rem;grid-template-columns:1fr!important}.reset-container[data-v-976ea578]{grid-column:span 1!important}.header-info h3[data-v-976ea578]{font-size:1.125rem}.packet-count[data-v-976ea578]{font-size:.75rem}.live-mode-badge[data-v-976ea578]{padding:.25rem .5rem;font-size:.75rem}.pagination-info span[data-v-976ea578]{font-size:.75rem}.prev-next-btn[data-v-976ea578]{min-width:40px;padding:.5rem}.page-numbers[data-v-976ea578]{gap:.25rem;max-width:150px}.page-number[data-v-976ea578]{min-width:36px;padding:.5rem .25rem;font-size:.75rem}.load-more-section button[data-v-976ea578]{padding:.375rem .75rem;font-size:.6rem}} diff --git a/repeater/web/html/assets/Dashboard-BLK8l9Tc.css b/repeater/web/html/assets/Dashboard-BLK8l9Tc.css deleted file mode 100644 index e03e9742..00000000 --- a/repeater/web/html/assets/Dashboard-BLK8l9Tc.css +++ /dev/null @@ -1 +0,0 @@ -.sparkline-card[data-v-d5c09182]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background:#ffffffbf;border:1px solid #0000000f;border-radius:12px;padding:12px 14px;transition:background .3s,border-color .3s,box-shadow .3s;overflow:hidden;box-shadow:0 4px 16px #0000000a,0 1px 3px #00000005}.dark .sparkline-card[data-v-d5c09182]{background:#0006;border:1px solid #ffffff0d;box-shadow:0 4px 16px #0003}.card-header[data-v-d5c09182]{justify-content:space-between;align-items:baseline;margin-bottom:8px;display:flex}.card-title[data-v-d5c09182]{color:#4b5563b3;text-transform:uppercase;letter-spacing:.05em;font-size:11px;font-weight:500;transition:color .3s}.dark .card-title[data-v-d5c09182]{color:#fff9}.card-value[data-v-d5c09182]{font-variant-numeric:tabular-nums;font-size:22px;font-weight:700;line-height:1}.card-values[data-v-d5c09182]{align-items:baseline;gap:6px;display:flex}.card-secondary-value[data-v-d5c09182]{font-variant-numeric:tabular-nums;opacity:.85;font-size:13px;font-weight:600;line-height:1}.card-chart[data-v-d5c09182]{width:100%;height:28px;overflow:hidden}.card-chart canvas[data-v-d5c09182]{width:100%!important;height:100%!important}@media (width>=1024px){.sparkline-card[data-v-d5c09182]{padding:14px 16px}.card-header[data-v-d5c09182]{margin-bottom:10px}.card-title[data-v-d5c09182]{font-size:12px}.card-value[data-v-d5c09182]{font-size:26px}.card-chart[data-v-d5c09182]{height:32px}}.stats-cards-container[data-v-9aa769d6]{will-change:auto;contain:layout}.stat-card[data-v-9aa769d6]{transition:opacity .3s ease-out}.stat-card[data-v-9aa769d6] .text-lg,.stat-card[data-v-9aa769d6] .text-\[30px\]{transition:color .2s ease-out}canvas[data-v-51cd61e9]{width:100%;height:100%}.modal-enter-active[data-v-c8711b75]{transition:all .3s cubic-bezier(.4,0,.2,1)}.modal-leave-active[data-v-c8711b75]{transition:all .2s ease-in}.modal-enter-from[data-v-c8711b75]{opacity:0;transform:scale(.95)translateY(-10px)}.modal-leave-to[data-v-c8711b75]{opacity:0;transform:scale(1.05)}.custom-scrollbar[data-v-c8711b75]{scrollbar-width:thin;scrollbar-color:#ffffff4d transparent}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar{width:6px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-track{background:#ffffff1a;border-radius:3px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-thumb{background:#ffffff4d;border-radius:3px}.custom-scrollbar[data-v-c8711b75]::-webkit-scrollbar-thumb:hover{background:#fff6}.glass-card[data-v-c8711b75]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px)}.fade-enter-active[data-v-8961931d],.fade-leave-active[data-v-8961931d]{transition:opacity .3s ease-out,transform .3s ease-out}.fade-enter-from[data-v-8961931d],.fade-leave-to[data-v-8961931d]{opacity:0;transform:translateY(-10px)}@keyframes spin-8961931d{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin[data-v-8961931d]{animation:.8s linear infinite spin-8961931d}.packet-list-enter-active[data-v-8961931d],.packet-list-leave-active[data-v-8961931d],.packet-list-move[data-v-8961931d]{transition:all .4s ease-out}.packet-list-enter-from[data-v-8961931d]{opacity:0;transform:translateY(-30px)scale(.98)}.packet-list-enter-to[data-v-8961931d],.packet-list-leave-from[data-v-8961931d]{opacity:1;transform:translateY(0)scale(1)}.packet-list-leave-to[data-v-8961931d]{opacity:0;transform:translateY(-20px)scale(.95)}.packet-row[data-v-8961931d]{transition:all .3s;position:relative}.packet-list-enter-active .packet-row[data-v-8961931d]{background:linear-gradient(90deg,#4ec9b01a 0%,#4ec9b00d 50%,#0000 100%);border-left:3px solid #4ec9b099;border-radius:8px;padding-left:12px;box-shadow:0 0 20px #4ec9b033}.packet-row[data-v-8961931d]:hover{background:#ffffff05;border-radius:8px;transition:background .2s}@media (width<=1023px){.filter-container[data-v-8961931d]{flex-direction:column;align-items:stretch;gap:1rem}.header-info[data-v-8961931d]{flex-direction:column;align-items:flex-start;gap:.5rem}.packet-count[data-v-8961931d]{order:1}.live-mode-badge[data-v-8961931d]{order:2;align-self:flex-start}.loading-indicator[data-v-8961931d],.error-indicator[data-v-8961931d]{order:3;align-self:flex-start}.filter-controls[data-v-8961931d]{flex-direction:column;grid-template-columns:1fr 1fr;gap:.75rem;display:grid!important}.filter-controls .flex.flex-col[data-v-8961931d]{flex-direction:column;align-items:stretch;gap:.25rem}.filter-controls .flex.flex-col label[data-v-8961931d]{margin-bottom:0;font-size:.75rem}.reset-container[data-v-8961931d]{justify-content:center;margin-top:.5rem;display:flex;grid-column:span 2!important}.pagination-container[data-v-8961931d]{flex-direction:column;align-items:stretch;gap:1rem}.pagination-info[data-v-8961931d]{text-align:center;flex-direction:column;justify-content:center;gap:.5rem}.load-more-section[data-v-8961931d]{justify-content:center}.load-more-count[data-v-8961931d]{display:none}.pagination-controls[data-v-8961931d]{justify-content:center}.page-numbers[data-v-8961931d]{scrollbar-width:none;-ms-overflow-style:none;max-width:200px;overflow-x:auto}.page-numbers[data-v-8961931d]::-webkit-scrollbar{display:none}.ellipsis[data-v-8961931d]{display:none}.page-number[data-v-8961931d]{flex-shrink:0;min-width:40px}}@media (width<=640px){.filter-controls[data-v-8961931d]{gap:.75rem;grid-template-columns:1fr!important}.reset-container[data-v-8961931d]{grid-column:span 1!important}.header-info h3[data-v-8961931d]{font-size:1.125rem}.packet-count[data-v-8961931d]{font-size:.75rem}.live-mode-badge[data-v-8961931d]{padding:.25rem .5rem;font-size:.75rem}.pagination-info span[data-v-8961931d]{font-size:.75rem}.prev-next-btn[data-v-8961931d]{min-width:40px;padding:.5rem}.page-numbers[data-v-8961931d]{gap:.25rem;max-width:150px}.page-number[data-v-8961931d]{min-width:36px;padding:.5rem .25rem;font-size:.75rem}.load-more-section button[data-v-8961931d]{padding:.375rem .75rem;font-size:.6rem}} diff --git a/repeater/web/html/assets/Dashboard-BQS_QL_q.js b/repeater/web/html/assets/Dashboard-BQS_QL_q.js new file mode 100644 index 00000000..dbbc8986 --- /dev/null +++ b/repeater/web/html/assets/Dashboard-BQS_QL_q.js @@ -0,0 +1,2 @@ +import{B as e,Ct as t,E as n,K as r,R as i,S as a,St as o,V as s,Y as c,c as l,f as u,g as d,i as f,j as p,k as m,l as h,m as g,nt as _,o as v,p as y,r as b,s as x,u as S,w as C,xt as w}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{o as T,t as E,u as D}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as O}from"./packets-KU2POtN6.js";import{t as k}from"./system-DbBvxitf.js";import{t as A}from"./dataService-DelZA92b.js";import{t as j}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as M}from"./Spinner-CcYauG9D.js";import{t as N}from"./websocket-Bupmxvtc.js";import{t as P}from"./index-DTUpsCzx.js";import{n as F,t as I}from"./preferences-CkCjR0CQ.js";import{d as L,f as R,g as z,l as ee,n as B,o as te,s as V,t as ne,u as re}from"./ChartCard-Dv7_dbhW.js";import{t as ie}from"./useSignalQuality-BurD4HtO.js";var H={class:`sparkline-card`},U={class:`card-header`},W={class:`card-title`},G={class:`card-values`},K={class:`card-chart`},q=j(d({name:`ChartSparkline`,__name:`ChartSparkline`,props:{title:{},value:{},color:{},data:{default:()=>[]},showChart:{type:Boolean,default:!0},secondaryValue:{default:void 0},secondaryLabel:{default:``},secondaryColor:{default:``},secondaryData:{default:()=>[]}},setup(e){V.register(te,L,R,re,ee,z);let s=e,l=c(null),u=c(null),d=e=>{if(e.length<3)return e;let t=Math.min(15,Math.max(3,Math.floor(e.length*.2))),n=[];for(let r=0;re+t,0)/s.length)}let r=Math.min(12,n.length),i=n.length/r,a=[];for(let e=0;e!s.data||s.data.length===0?[]:d(s.data)),p=v(()=>!s.secondaryData||s.secondaryData.length===0?[]:d(s.secondaryData)),g=()=>{if(!l.value)return;let e=l.value.getContext(`2d`);if(!e)return;u.value&&=(u.value.destroy(),null);let t=f.value;if(t.length<2)return;let n=[{data:t,borderColor:s.color,borderWidth:2.5,fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}],i=p.value;i.length>=2&&s.secondaryColor&&n.push({data:i,borderColor:s.secondaryColor,borderWidth:2,borderDash:[4,3],fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}),u.value=r(new V(e,{type:`line`,data:{labels:t.map((e,t)=>t.toString()),datasets:n},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:800,easing:`easeOutQuart`},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1,grid:{display:!1}},y:{display:!1,grid:{display:!1},grace:`10%`}},elements:{line:{capBezierPoints:!0}}}}))},_=()=>{if(!u.value){g();return}let e=f.value;if(e.length<2)return;u.value.data.labels=e.map((e,t)=>t.toString()),u.value.data.datasets[0].data=e;let t=p.value;t.length>=2&&s.secondaryColor&&(u.value.data.datasets.length<2?u.value.data.datasets.push({data:t,borderColor:s.secondaryColor,borderWidth:2,borderDash:[4,3],fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}):u.value.data.datasets[1].data=t),u.value.update(`default`)};return i(()=>s.data,()=>{a(()=>_())},{deep:!0}),i(()=>s.color,()=>{u.value&&(u.value.data.datasets[0].borderColor=s.color,u.value.update(`none`))}),n(()=>{a(()=>g())}),C(()=>{u.value&&=(u.value.destroy(),null)}),(n,r)=>(m(),S(`div`,H,[x(`div`,U,[x(`p`,W,t(e.title),1),x(`div`,G,[x(`span`,{class:`card-value`,style:o({color:e.color})},t(typeof e.value==`number`?e.value.toLocaleString():e.value),5),e.secondaryValue===void 0?h(``,!0):(m(),S(`span`,{key:0,class:`card-secondary-value`,style:o({color:e.secondaryColor})},t(e.secondaryLabel)+t(typeof e.secondaryValue==`number`?e.secondaryValue.toLocaleString():e.secondaryValue),5))])]),x(`div`,K,[e.showChart?(m(),S(`canvas`,{key:0,ref_key:`canvasRef`,ref:l},null,512)):h(``,!0)])]))}}),[[`__scopeId`,`data-v-d5c09182`]]),J={class:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 lg:gap-4 mb-5 stats-cards-container`},ae=j(d({name:`StatsCards`,__name:`StatsCards`,setup(e){let t={uptime:`#EBA0FC`,rx:`#AAE8E8`,forward:`#FFC246`,dropped:`#FB787B`,crcErrors:`#F59E0B`,hashCache:`#9F7AEA`},r=O(),i=k(),a=A(),o=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`},s=v(()=>{let e=r.packetStats,t=i.stats?.uptime_seconds||0,n=e?.total_packets||0,a=e?.dropped_packets||0;return{packetsReceived:n,packetsForwarded:e?.transmitted_packets||0,uptimeFormatted:o(t),droppedPackets:a,crcErrorCount:r.crcErrorCount,hashCacheSize:r.systemStats?.duplicate_cache_size??0}}),c=v(()=>r.sparklineData);return n(()=>{a.ensure(`sparklines`)}),(e,n)=>(m(),S(`div`,J,[g(q,{title:`Up Time`,value:s.value.uptimeFormatted,color:t.uptime,data:[],showChart:!1,class:`stat-card`},null,8,[`value`,`color`]),g(q,{title:`RX Packets`,value:s.value.packetsReceived,color:t.rx,data:c.value.totalPackets,class:`stat-card`},null,8,[`value`,`color`,`data`]),g(q,{title:`Forward`,value:s.value.packetsForwarded,color:t.forward,data:c.value.transmittedPackets,class:`stat-card`},null,8,[`value`,`color`,`data`]),g(q,{title:`Dropped`,value:s.value.droppedPackets,color:t.dropped,data:c.value.droppedPackets,class:`stat-card`},null,8,[`value`,`color`,`data`]),g(q,{title:`CRC Errors`,value:s.value.crcErrorCount,color:t.crcErrors,data:c.value.crcErrors,class:`stat-card`},null,8,[`value`,`color`,`data`]),g(q,{title:`Hash Cache`,value:s.value.hashCacheSize,color:t.hashCache,showChart:!1,class:`stat-card`},null,8,[`value`,`color`])]))}}),[[`__scopeId`,`data-v-19814841`]]),oe={class:`glass-card rounded-[10px] p-4 lg:p-6`},se={key:0,class:`absolute inset-0 flex items-center justify-center`},ce={key:1,class:`h-full flex flex-col`},Y={key:0,class:`absolute top-2 left-1/2 -translate-x-1/2 bg-white/95 dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke rounded-lg px-3 py-2 z-10 pointer-events-none min-w-48`},X={class:`text-content-primary dark:text-content-primary text-sm font-medium mb-1`},le={class:`text-content-primary dark:text-content-primary`},ue={class:`flex-1 flex items-end justify-evenly gap-4 px-4`},de=[`onMouseenter`],fe={class:`text-content-primary dark:text-content-primary text-xs sm:text-sm font-semibold text-center w-full`,style:{"padding-bottom":`5px`}},pe={class:`text-content-secondary dark:text-content-muted text-xs mt-2 text-center`},me={key:0,class:`mt-4 flex flex-wrap justify-center gap-3 sm:gap-4 px-2 sm:px-4 text-[10px] sm:text-xs text-content-secondary dark:text-content-muted`},he={class:`truncate text-left`},ge={key:1,class:`mt-3 text-xs text-content-secondary dark:text-content-muted text-center`},_e=j(d({name:`PacketTypesChart`,__name:`PacketTypesChart`,setup(r){let a=c([]),s=O(),l=N(),u=c(!0),d=c(!1),f=c(null),_=c(`Connecting...`),y=c(null),C=[{name:`Payload`,types:[`Plain Text Message`,`Group Text Message`,`Group Datagram`,`Multi-part Packet`],subColors:[`#3B82F6`,`#60A5FA`,`#93C5FD`,`#BFDBFE`]},{name:`Requests`,types:[`Request`,`Response`,`Anonymous Request`],subColors:[`#10B981`,`#34D399`,`#6EE7B7`]},{name:`Control`,types:[`Node Advertisement`,`Acknowledgment`,`Returned Path`],subColors:[`#F59E0B`,`#FBBF24`,`#FCD34D`]},{name:`Routing`,types:[`Trace`],subColors:[`#8B5CF6`]},{name:`Reserved`,types:[`Reserved Type 11`,`Reserved Type 12`,`Reserved Type 13`],subColors:[`#6B7280`,`#9CA3AF`,`#D1D5DB`]}],w=v(()=>C.map(e=>{let t=a.value.filter(t=>e.types.some(e=>t.name.includes(e)||t.name===e)).sort((e,t)=>t.count-e.count).map((t,n)=>({...t,color:e.subColors[n%e.subColors.length]}));return{name:e.name,color:e.subColors[0],items:t,total:t.reduce((e,t)=>e+t.count,0)}}).filter(e=>e.total>0)),T=v(()=>Math.max(...w.value.map(e=>e.total),1)),E=v(()=>w.value.reduce((e,t)=>e+t.total,0)),D=async()=>{_.value=`Connecting...`,f.value=null,u.value||(d.value=!0);try{let e=await B(`/packet_type_graph_data`,void 0,{onPhaseChange:e=>{_.value=e===`receiving`?`Receiving data...`:`Connecting...`}});if(e?.success&&e?.data){let t=e.data;if(t?.series){let e=[];t.series.forEach((t,n)=>{let r=0;t.data&&Array.isArray(t.data)&&(r=t.data.reduce((e,t)=>e+(t[1]||0),0)),r>0&&e.push({name:t.name||`Type ${t.type}`,type:t.type,count:r,color:``})}),a.value=e,u.value=!1,d.value=!1}else f.value=`No series data in server response`,u.value=!1,d.value=!1}else f.value=`Invalid response from server`,u.value=!1,d.value=!1}catch(e){f.value=e instanceof Error?e.message:`Failed to load data`,u.value=!1,d.value=!1}},k={0:`Request`,1:`Response`,2:`Plain Text Message`,3:`Acknowledgment`,4:`Node Advertisement`,5:`Group Text Message`,6:`Group Datagram`,7:`Anonymous Request`,8:`Returned Path`,9:`Trace`,10:`Multi-part Packet`,15:`Custom Packet`},A=()=>{let e=s.packetTypeBreakdown;!e||e.length===0||(a.value=e.map(e=>({name:k[Number(e.type)]||`Type ${e.type}`,type:e.type,count:e.count,color:``})),u.value=!1,f.value=null)},j=e=>Math.max(e/T.value*90,2),M=(e,t)=>t===0?0:e/t*100;return n(()=>{D()}),i(()=>s.packetTypeBreakdown,()=>A(),{deep:!0,immediate:!0}),P(D,{intervalMs:3e4,enabled:()=>!l.isConnected,immediate:!0}),(n,r)=>(m(),S(`div`,oe,[r[2]||=x(`div`,{class:`flex items-baseline justify-between mb-3 lg:mb-4`},[x(`h3`,{class:`text-content-primary dark:text-content-primary text-lg lg:text-xl font-semibold`},` Packet Types `),x(`p`,{class:`text-content-secondary dark:text-content-muted text-xs lg:text-sm uppercase`},` Distribution by Type `)],-1),g(ne,{class:`h-48 lg:h-56`,"is-loading":u.value,"is-updating":d.value,error:f.value,status:_.value,onRetry:D},{default:e(()=>[w.value.length===0&&!u.value&&!f.value?(m(),S(`div`,se,[...r[1]||=[x(`div`,{class:`text-content-secondary dark:text-content-primary text-sm lg:text-base`},` No packet data available `,-1)]])):h(``,!0),w.value.length>0?(m(),S(`div`,ce,[y.value?(m(),S(`div`,Y,[x(`div`,X,t(y.value.name)+` · `+t(y.value.total.toLocaleString()),1),(m(!0),S(b,null,p(y.value.items,e=>(m(),S(`div`,{key:e.type,class:`flex justify-between gap-4 text-xs text-content-secondary dark:text-content-muted`},[x(`span`,null,t(e.name),1),x(`span`,le,t(e.count.toLocaleString()),1)]))),128))])):h(``,!0),x(`div`,ue,[(m(!0),S(b,null,p(w.value,e=>(m(),S(`div`,{key:e.name,class:`flex flex-col items-center flex-1 max-w-32 h-full justify-end cursor-pointer`,onMouseenter:t=>y.value=e,onMouseleave:r[0]||=e=>y.value=null},[x(`span`,fe,t(e.total.toLocaleString()),1),x(`div`,{class:`w-full rounded-[5px] transition-all duration-300 ease-out hover:opacity-90 overflow-hidden flex flex-col-reverse`,style:o({height:j(e.total)+`%`,minHeight:`8px`})},[(m(!0),S(b,null,p(e.items,t=>(m(),S(`div`,{key:t.type,style:o({height:M(t.count,e.total)+`%`,backgroundColor:t.color})},null,4))),128))],4),x(`span`,pe,t(e.name),1)],40,de))),128))])])):h(``,!0)]),_:1},8,[`is-loading`,`is-updating`,`error`,`status`]),w.value.length>0?(m(),S(`div`,me,[(m(!0),S(b,null,p(w.value,e=>(m(),S(`div`,{key:`legend-`+e.name,class:`flex flex-col gap-0.5 min-w-[100px] max-w-[140px] flex-shrink-0`},[(m(!0),S(b,null,p(e.items,e=>(m(),S(`div`,{key:e.type,class:`flex items-center gap-1.5`},[x(`span`,{class:`w-2 h-2 rounded-sm shrink-0`,style:o({backgroundColor:e.color})},null,4),x(`span`,he,t(e.name),1)]))),128))]))),128))])):h(``,!0),w.value.length>0?(m(),S(`div`,ge,` Total: `+t(E.value.toLocaleString())+` packets `,1)):h(``,!0)]))}}),[[`__scopeId`,`data-v-a30328ce`]]),ve={class:`glass-card rounded-[10px] p-4 lg:p-6`},ye={class:`mt-3 lg:mt-4 grid grid-cols-2 gap-3 lg:gap-4`},be={class:`text-center`},xe={class:`text-lg lg:text-2xl font-bold text-content-primary dark:text-content-primary`},Se={class:`text-center`},Ce={class:`text-lg lg:text-2xl font-bold text-content-primary dark:text-content-primary`},we={class:`mt-2 lg:mt-3 grid grid-cols-3 gap-2 lg:gap-3 text-center`},Te={class:`text-xs lg:text-sm font-semibold text-accent-purple flex items-center justify-center gap-1`},Ee={key:0,class:`inline-block w-1.5 h-1.5 rounded-full bg-secondary opacity-70`,title:`Early data - limited uptime`},De={class:`text-xs text-content-secondary dark:text-content-muted`},Oe={class:`text-xs lg:text-sm font-semibold text-accent-red flex items-center justify-center gap-1`},ke={key:0,class:`inline-block w-1.5 h-1.5 rounded-full bg-secondary opacity-70`,title:`Early data - limited uptime`},Ae={class:`text-xs text-content-secondary dark:text-content-muted`},je={class:`text-xs lg:text-sm font-semibold text-accent-red`},Z=null,Me=12e4,Ne=j(d({name:`AirtimeUtilizationChart`,__name:`AirtimeUtilizationChart`,setup(r){let i={rx:`#EBA0FC`,tx:`#FB787B`},o=()=>{let e=document.documentElement.classList.contains(`dark`);return{gridLine:e?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,axisLabel:e?`rgba(255, 255, 255, 0.5)`:`rgba(0, 0, 0, 0.5)`}},s=O(),l=k(),d=c(null),f=c([]),p=c(!1),b=c(!0),w=c(!1),T=c(null),E=c(`Connecting...`),D=c(30),A=c({totalReceived:0,totalTransmitted:0,dropped:0,firstPacketTime:0}),j=c({sf:9,bwHz:62500,cr:5,preamble:17}),M=(e,t=60)=>{if(e.length===0)return[];let n=1-.5**(1/t),r=Math.min(e.length,Math.max(10,Math.floor(t/3))),i=0,a=0;for(let t=0;t(i=n*e.rxUtil+(1-n)*i,a=n*e.txUtil+(1-n)*a,{...e,rxUtil:i,txUtil:a}))},N=v(()=>{let e=s.packetStats?.total_packets||0,t=s.packetStats?.transmitted_packets||0,n=l.stats?.uptime_seconds||0,r=e||A.value.totalReceived,i=t||A.value.totalTransmitted,a=A.value.firstPacketTime>0?Math.floor(Date.now()/1e3)-A.value.firstPacketTime:0,o=n||a,c=Math.max(o/3600,.1);if(c<1){let e=Math.max(o/60,1);return{rxRate:{value:Math.round(r/e*100)/100,label:c<.5?`RX/min (early)`:`RX/min`},txRate:{value:Math.round(i/e*100)/100,label:c<.5?`TX/min (early)`:`TX/min`},confidence:`low`}}let u=Math.round(r/c*100)/100,d=Math.round(i/c*100)/100,f,p;return c<6?(f=`RX/hr (${Math.round(c)}h)`,p=`medium`):c<24?(f=`RX/hr (${Math.round(c)}h)`,p=`high`):(f=`RX/hr`,p=`high`),{rxRate:{value:u,label:f},txRate:{value:d,label:f.replace(`RX`,`TX`)},confidence:p}}),F=async()=>{E.value=`Connecting...`,T.value=null,b.value||(w.value=!0);try{let e=60*1e3,t=Math.floor(Date.now()/1e3),n=t-24*3600,r=l.stats?.config?.radio;r&&(j.value={sf:r.spreading_factor??9,bwHz:r.bandwidth??62500,cr:r.coding_rate??5,preamble:r.preamble_length??17});let i=await B(`/airtime_chart_data`,{start_timestamp:n,end_timestamp:t,bucket_seconds:60,sf:j.value.sf,bw_hz:j.value.bwHz,cr:j.value.cr,preamble:j.value.preamble},{onPhaseChange:e=>{E.value=e===`receiving`?`Receiving data...`:`Connecting...`}});if(!i.success){f.value=[],p.value=!1,b.value=!1,w.value=!1,a(()=>I());return}let o=i.data,c=o.buckets||[];A.value={totalReceived:o.rx_total||0,totalTransmitted:o.tx_total||0,dropped:s.packetStats?.dropped_packets??0,firstPacketTime:c.length>0?c[0].timestamp:t};let u=24*3600/60,d=new Float64Array(u),m=new Float64Array(u);for(let t of c){let r=Math.floor((t.timestamp-n)/60);r>=0&&r[e.rxUtil,e.txUtil]))*1.05;D.value=Math.max(5,Math.ceil(y/5)*5),Z={data:v,yAxisMax:D.value,fetchedAt:Date.now()},p.value=!1,b.value=!1,w.value=!1,T.value=null,a(()=>I())}catch(e){console.error(`Failed to fetch airtime data:`,e),f.value=[],p.value=!1,b.value=!1,w.value=!1,T.value=e instanceof Error?e.message:`Failed to load chart data`,a(()=>I())}},I=()=>{if(!d.value)return;let e=d.value,t=e.getContext(`2d`);if(!t)return;let n=e.parentElement;if(!n)return;let r=n.getBoundingClientRect(),a=r.width,s=r.height;if(e.width=a*window.devicePixelRatio,e.height=s*window.devicePixelRatio,e.style.width=a+`px`,e.style.height=s+`px`,t.scale(window.devicePixelRatio,window.devicePixelRatio),t.clearRect(0,0,a,s),p.value){t.fillStyle=o().axisLabel,t.font=`16px system-ui`,t.textAlign=`center`,t.fillText(`Loading chart data...`,a/2,s/2);return}if(f.value.length===0){t.fillStyle=o().axisLabel,t.font=`16px system-ui`,t.textAlign=`center`,t.fillText(`No data available`,a/2,s/2);return}let c=a-45-20,l=s-40,u=D.value,m=D.value,h=o();t.strokeStyle=h.gridLine,t.lineWidth=1,t.font=`10px system-ui`,t.textAlign=`right`;for(let e=0;e<=5;e++){let n=20+l*e/5;t.beginPath(),t.moveTo(45,n),t.lineTo(a-20,n),t.stroke();let r=u-e/5*m;t.fillStyle=h.axisLabel,t.fillText(`${r.toFixed(0)}%`,40,n+3)}for(let e=0;e<=6;e++){let n=45+c*e/6;t.beginPath(),t.moveTo(n,20),t.lineTo(n,s-20),t.stroke()}f.value.length>1&&(t.strokeStyle=i.rx,t.lineWidth=2,t.beginPath(),f.value.forEach((e,n)=>{let r=45+c*n/(f.value.length-1),i=s-20-Math.min(e.rxUtil,D.value)/m*l;n===0?t.moveTo(r,i):t.lineTo(r,i)}),t.stroke()),f.value.length>1&&(t.strokeStyle=i.tx,t.lineWidth=2,t.beginPath(),f.value.forEach((e,n)=>{let r=45+c*n/(f.value.length-1),i=s-20-Math.min(e.txUtil,D.value)/m*l;n===0?t.moveTo(r,i):t.lineTo(r,i)}),t.stroke())};return P(F,{intervalMs:12e4,immediate:!1}),n(()=>{Z&&Date.now()-Z.fetchedAt{I(),setTimeout(()=>I(),100)}),window.addEventListener(`resize`,I)}),C(()=>{window.removeEventListener(`resize`,I)}),(n,r)=>(m(),S(`div`,ve,[r[3]||=u(`

Airtime Utilization

Activity (Last 24 Hours)

Rx Util
Tx Util
`,3),g(ne,{class:`h-40 lg:h-48`,"is-loading":b.value,"is-updating":w.value,error:T.value,status:E.value,onRetry:F},{default:e(()=>[x(`canvas`,{ref_key:`chartRef`,ref:d,class:`absolute inset-0 w-full h-full`},null,512)]),_:1},8,[`is-loading`,`is-updating`,`error`,`status`]),x(`div`,ye,[x(`div`,be,[x(`div`,xe,t(_(s).packetStats?.total_packets||A.value.totalReceived),1),r[0]||=x(`div`,{class:`text-xs text-content-secondary dark:text-content-muted uppercase tracking-wide`},` Total Received `,-1)]),x(`div`,Se,[x(`div`,Ce,t(_(s).packetStats?.transmitted_packets||A.value.totalTransmitted),1),r[1]||=x(`div`,{class:`text-xs text-content-secondary dark:text-content-muted uppercase tracking-wide`},` Total Transmitted `,-1)])]),x(`div`,we,[x(`div`,null,[x(`div`,Te,[y(t(N.value.rxRate.value)+` `,1),N.value.confidence===`low`?(m(),S(`span`,Ee)):h(``,!0)]),x(`div`,De,t(N.value.rxRate.label),1)]),x(`div`,null,[x(`div`,Oe,[y(t(N.value.txRate.value)+` `,1),N.value.confidence===`low`?(m(),S(`span`,ke)):h(``,!0)]),x(`div`,Ae,t(N.value.txRate.label),1)]),x(`div`,null,[x(`div`,je,t(_(s).packetStats?.dropped_packets||A.value.dropped),1),r[2]||=x(`div`,{class:`text-xs text-content-secondary dark:text-content-muted`},`Dropped`,-1)])])]))}}),[[`__scopeId`,`data-v-2e55952b`]]),Pe={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] shadow-2xl border border-stroke-subtle dark:border-white/20 flex flex-col h-full overflow-hidden`},Fe={class:`flex items-center justify-between p-8 pb-4 flex-shrink-0`},Ie={class:`text-content-secondary dark:text-content-muted text-sm`},Le={class:`flex items-center gap-2`},Re=[`title`],ze={class:`flex-1 overflow-y-auto custom-scrollbar px-8`},Be={class:`mb-6`},Ve={class:`glass-card bg-white/5 rounded-[15px] p-4`},He={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},Ue={class:`space-y-3`},We={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Ge={class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ke={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},qe={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all`},Je={key:0,class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Ye={class:`text-content-primary dark:text-content-primary font-mono text-xs`},Xe={class:`space-y-3`},Ze={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Qe={class:`text-content-primary dark:text-content-primary font-semibold`},$e={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},et={class:`text-content-primary dark:text-content-primary font-semibold`},tt={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},nt={class:`mb-6`},rt={class:`bg-gray-50 dark:bg-white/5 rounded-[15px] p-4 border border-stroke-subtle dark:border-stroke/10`},it={class:`space-y-3`},at={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},ot={class:`text-content-primary dark:text-content-primary`},st={key:0,class:`pt-2`},ct={class:`glass-card bg-background-mute dark:bg-black/30 rounded-[10px] p-4 mb-4`},lt={class:`w-full overflow-x-auto`},ut={class:`text-content-primary dark:text-content-primary/90 text-xs font-mono whitespace-pre leading-relaxed min-w-full`},dt={class:`flex items-center justify-between mb-3`},ft={class:`text-content-secondary dark:text-content-primary/80 text-sm font-semibold`},pt={class:`text-content-muted dark:text-content-muted text-xs`},mt={class:`bg-background-mute dark:bg-black/40 rounded-[8px] p-3 mb-3`},ht={class:`font-mono text-xs text-content-primary dark:text-content-primary break-all whitespace-pre-wrap leading-relaxed`},gt={class:`bg-gray-50 dark:bg-white/5 rounded-[10px] overflow-hidden`},_t={key:0,class:`min-w-0`},vt={class:`text-cyan-500 text-sm font-mono break-words min-w-0`},yt={class:`text-content-primary dark:text-content-primary text-sm break-words min-w-0`},bt={class:`text-content-primary dark:text-content-primary text-sm font-semibold break-all min-w-0 overflow-hidden`},xt=[`title`],St={key:0,class:`text-orange-500 text-xs font-mono break-all min-w-0 overflow-hidden`},Ct=[`title`],wt={class:`grid grid-cols-2 gap-2`},Tt={class:`text-cyan-500 text-sm font-mono break-words`},Et={class:`text-content-primary dark:text-content-primary text-sm break-words`},Dt=[`title`],Ot={key:0},kt=[`title`],At={key:0,class:`text-content-muted dark:text-content-muted text-xs italic mt-2 px-1`},jt={key:1,class:`py-2`},Mt={class:`mb-6`},Nt={class:`bg-gray-50 dark:bg-white/5 rounded-[15px] p-4 border border-stroke-subtle dark:border-stroke/10`},Pt={class:`space-y-4`},Ft={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},It={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Lt={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Rt={key:0,class:`py-2`},zt={class:`bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},Bt={class:`flex items-center flex-wrap gap-2`},Vt={class:`relative group`},Ht={class:`relative px-3 py-2 bg-gradient-to-br from-blue-500/20 to-cyan-500/20 border border-cyan-400/40 rounded-lg transform transition-all hover:scale-105`},Ut={class:`font-mono text-[10px] font-semibold tracking-tight text-content-primary dark:text-content-primary/90 sm:text-xs`},Wt={class:`pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 transform whitespace-nowrap rounded-md bg-neutral-900 px-2 py-1 font-mono text-xs text-white opacity-0 shadow-lg ring-1 ring-white/10 transition-opacity group-hover:opacity-100`},Gt={key:0,class:`mx-2 text-cyan-600 dark:text-cyan-400/60`},Kt={key:1,class:`py-2`},qt={class:`text-content-secondary dark:text-content-muted text-sm mb-2 flex items-center`},Jt={key:0,class:`w-4 h-4 ml-2 text-yellow-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Yt={key:1,class:`text-yellow-500 text-xs ml-1`},Xt={class:`bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},Zt={class:`flex items-center flex-wrap gap-2`},Qt={class:`relative group`},$t={key:0,class:`absolute -top-1 -right-1 w-2 h-2 bg-yellow-400 rounded-full animate-pulse`},en={class:`pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 transform whitespace-nowrap rounded-md bg-neutral-900 px-2 py-1 font-mono text-xs text-white opacity-0 shadow-lg ring-1 ring-white/10 transition-opacity group-hover:opacity-100`},tn={key:0,class:`mx-1 text-orange-600 dark:text-orange-400/60`},nn={class:`mb-6`},rn={class:`glass-card bg-gray-50 dark:bg-white/5 rounded-[15px] p-4`},an={class:`grid grid-cols-1 md:grid-cols-3 gap-4 mb-4`},on={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},sn={class:`text-lg font-bold text-content-primary dark:text-content-primary`},cn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},ln={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},un={class:`text-lg font-bold text-content-primary dark:text-content-primary`},dn={key:0,class:`mb-4`},fn={class:`flex items-center gap-3`},pn={class:`flex gap-1`},mn={class:`text-content-secondary dark:text-content-primary/80 text-sm capitalize`},hn={key:1,class:`mb-4`},gn={key:2,class:`mb-4`},_n={class:`text-content-secondary dark:text-content-muted text-sm mb-3`},vn={class:`space-y-2`},yn={class:`flex items-center gap-3`},bn={class:`text-content-muted dark:text-content-muted text-sm`},xn={key:3,class:`mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke/10`},Sn={class:`grid grid-cols-1 md:grid-cols-3 gap-3 mb-4`},Cn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},wn={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},Tn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},En={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},Dn={class:`text-content-muted dark:text-content-muted text-xs mt-1`},On={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},kn={class:`text-content-muted dark:text-content-muted text-xs mt-1`},An={key:0,class:`glass-card bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},jn={class:`space-y-3`},Mn={class:`flex-shrink-0 w-16 text-right`},Nn={class:`text-content-secondary dark:text-content-muted text-xs`},Pn={class:`flex-1 relative`},Fn={class:`h-8 rounded-lg overflow-hidden bg-background-mute dark:bg-stroke/5 relative`},In={class:`absolute inset-0 flex items-center px-3`},Ln={class:`text-content-primary dark:text-content-primary text-xs font-mono font-semibold`},Rn={class:`flex-shrink-0 w-12 text-left`},zn={class:`text-content-muted dark:text-content-muted text-xs`},Bn={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},Vn={class:`space-y-2`},Hn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Un={class:`text-content-primary dark:text-content-primary`},Wn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Gn={class:`space-y-2`},Kn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},qn={key:0,class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Jn={class:`text-red-600 dark:text-red-400 text-sm`},Yn={class:`p-8 pt-4 border-t border-stroke-subtle dark:border-stroke/10 flex justify-end flex-shrink-0`},Xn=j(d({name:`PacketDetailsModal`,__name:`PacketDetailsModal`,props:{packet:{},isOpen:{type:Boolean},localHash:{}},emits:[`close`],setup(n,{emit:r}){let{getSignalQuality:a}=ie(),s=n,u=r,d=c(!1),_=e=>new Date(e*1e3).toLocaleString(),v=e=>e.transmitted?e.is_duplicate?`text-amber-600 dark:text-amber-400`:e.drop_reason?`text-red-600 dark:text-red-400`:`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,C=e=>e.transmitted?e.is_duplicate?`Duplicate`:e.drop_reason?`Dropped`:`Forwarded`:`Dropped`,T=e=>({0:`Request`,1:`Response`,2:`Plain Text Message`,3:`Acknowledgment`,4:`Node Advertisement`,5:`Group Text Message`,6:`Group Datagram`,7:`Anonymous Request`,8:`Returned Path`,9:`Trace`,10:`Multi-part Packet`,15:`Custom Packet`})[e]||`Unknown Type (${e})`,O=e=>({0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`})[e]||`Unknown Route (${e})`,k=e=>{if(!e)return`None`;let t=e.replace(/\s+/g,``).toUpperCase().match(/.{2}/g)||[],n=[];for(let e=0;e{try{let r=0,i=t.length/2;if(i>=100){if(t.length>=r+64){let i=t.slice(r,r+64);e.push({name:`Public Key`,byteRange:`${(n+r)/2}-${(n+r+63)/2}`,hexData:i.match(/.{8}/g)?.join(` `)||i,description:`Ed25519 public key of the node (32 bytes)`,fields:[{bits:`0-255`,name:`Ed25519 Public Key`,value:`${i.slice(0,16)}...${i.slice(-16)}`,binary:`32 bytes (256 bits)`}]}),r+=64}if(t.length>=r+8){let i=t.slice(r,r+8),a=parseInt(i,16),o=new Date(a*1e3);e.push({name:`Timestamp`,byteRange:`${(n+r)/2}-${(n+r+7)/2}`,hexData:i.match(/.{2}/g)?.join(` `)||i,description:`Unix timestamp of advertisement`,fields:[{bits:`0-31`,name:`Unix Timestamp`,value:`${a} (${o.toLocaleString()})`,binary:a.toString(2).padStart(32,`0`)}]}),r+=8}if(t.length>=r+128){let i=t.slice(r,r+128);e.push({name:`Signature`,byteRange:`${(n+r)/2}-${(n+r+127)/2}`,hexData:i.match(/.{8}/g)?.join(` `)||i,description:`Ed25519 signature of public key, timestamp, and appdata`,fields:[{bits:`0-511`,name:`Ed25519 Signature`,value:`${i.slice(0,16)}...${i.slice(-16)}`,binary:`64 bytes (512 bits)`}]}),r+=128}t.length>r&&j(e,t.slice(r),n+r)}else e.push({name:`ADVERT AppData (Partial)`,byteRange:`${n/2}-${n/2+i-1}`,hexData:t.match(/.{2}/g)?.join(` `)||t,description:`Partial ADVERT data - appears to be just AppData portion (${i} bytes)`,fields:[{bits:`0-${i*8-1}`,name:`Partial Data`,value:`${i} bytes - attempting to decode as AppData`,binary:`${i} bytes (${i*8} bits)`}]}),j(e,t,n)}catch(n){e.push({name:`ADVERT Parse Error`,byteRange:`N/A`,hexData:t.slice(0,32)+`...`,description:`Failed to parse ADVERT payload structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse error: ${n instanceof Error?n.message:`Unknown error`}`,binary:`Invalid`}]})}},j=(e,t,n)=>{try{let r=t.length/2;e.push({name:`AppData`,byteRange:`${n/2}-${n/2+r-1}`,hexData:t.match(/.{2}/g)?.join(` `)||t,description:`Node advertisement application data (${r} bytes)`,fields:[{bits:`0-${r*8-1}`,name:`Application Data`,value:`${r} bytes (contains flags, location, name, etc.)`,binary:`${r} bytes (${r*8} bits)`}]});let i=0;if(t.length>=2){let r=parseInt(t.slice(i,i+2),16),a=[],o=!!(r&16),s=!!(r&32),c=!!(r&64),l=!!(r&128);if(r&1&&a.push(`is chat node`),r&2&&a.push(`is repeater`),r&4&&a.push(`is room server`),r&8&&a.push(`is sensor`),o&&a.push(`has location`),s&&a.push(`has feature 1`),c&&a.push(`has feature 2`),l&&a.push(`has name`),e.push({name:`AppData Flags`,byteRange:`${(n+i)/2}`,hexData:`0x${t.slice(i,i+2)}`,description:`Flags indicating which optional fields are present`,fields:[{bits:`0-7`,name:`Flags`,value:a.join(`, `)||`none`,binary:r.toString(2).padStart(8,`0`)}]}),i+=2,o&&t.length>=i+16){let r=t.slice(i,i+8),a=[];for(let e=6;e>=0;e-=2)a.push(r.slice(e,e+2));let o=parseInt(a.join(``),16),s=o>2147483647?o-4294967296:o,c=s/1e6,l=t.slice(i+8,i+16),u=[];for(let e=6;e>=0;e-=2)u.push(l.slice(e,e+2));let d=parseInt(u.join(``),16),f=d>2147483647?d-4294967296:d,p=f/1e6;e.push({name:`Location Data`,byteRange:`${(n+i)/2}-${(n+i+15)/2}`,hexData:`${r.match(/.{2}/g)?.join(` `)||r} ${l.match(/.{2}/g)?.join(` `)||l}`,description:`GPS coordinates (latitude and longitude)`,fields:[{bits:`0-31`,name:`Latitude`,value:`${c.toFixed(6)}° (raw: ${s})`,binary:s.toString(2).padStart(32,`0`)},{bits:`32-63`,name:`Longitude`,value:`${p.toFixed(6)}° (raw: ${f})`,binary:f.toString(2).padStart(32,`0`)}]}),i+=16}if(s&&t.length>=i+4){let r=t.slice(i,i+4),a=parseInt(r,16);e.push({name:`Feature 1`,byteRange:`${(n+i)/2}-${(n+i+3)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Reserved feature 1 (2 bytes)`,fields:[{bits:`0-15`,name:`Feature 1 Value`,value:`${a}`,binary:a.toString(2).padStart(16,`0`)}]}),i+=4}if(c&&t.length>=i+4){let r=t.slice(i,i+4),a=parseInt(r,16);e.push({name:`Feature 2`,byteRange:`${(n+i)/2}-${(n+i+3)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Reserved feature 2 (2 bytes)`,fields:[{bits:`0-15`,name:`Feature 2 Value`,value:`${a}`,binary:a.toString(2).padStart(16,`0`)}]}),i+=4}if(l&&t.length>i){let r=t.slice(i),a=r.match(/.{2}/g)||[],o=a.map(e=>{let t=parseInt(e,16);return t>=32&&t<=126?String.fromCharCode(t):`.`}).join(``).replace(/\.+$/,``);e.push({name:`Node Name`,byteRange:`${(n+i)/2}-${(n+t.length-1)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Node name string (${a.length} bytes)`,fields:[{bits:`0-${a.length*8-1}`,name:`Node Name`,value:`"${o}"`,binary:`ASCII text (${a.length} bytes)`}]})}}}catch(n){e.push({name:`AppData Parse Error`,byteRange:`N/A`,hexData:t.slice(0,Math.min(32,t.length)),description:`Failed to parse AppData structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse error: ${n instanceof Error?n.message:`Unknown error`}`,binary:`Invalid`}]})}},M=e=>{if(!e)return[];if(Array.isArray(e))return e;if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return[]},N=e=>{let t=[];if(!e)return t;try{let n=e.raw_packet;if(n){let e=n.replace(/\s+/g,``).toUpperCase(),r=0;if(e.length>=2){let n=e.slice(r,r+2),i=parseInt(n,16),a=i&3,o=(i&60)>>2,s=(i&192)>>6;if(t.push({name:`Header`,byteRange:`0`,hexData:`0x${n}`,description:`Contains routing type, payload type, and payload version`,fields:[{bits:`0-1`,name:`Route Type`,value:{0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`}[a]||`Unknown`,binary:a.toString(2).padStart(2,`0`)},{bits:`2-5`,name:`Payload Type`,value:{0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTIPART`,15:`RAW_CUSTOM`}[o]||`Unknown`,binary:o.toString(2).padStart(4,`0`)},{bits:`6-7`,name:`Version`,value:s.toString(),binary:s.toString(2).padStart(2,`0`)}]}),r+=2,(a===0||a===3)&&e.length>=r+8){let n=e.slice(r,r+8),i=parseInt(n.slice(0,4),16),a=parseInt(n.slice(4,8),16);t.push({name:`Transport Codes`,byteRange:`1-4`,hexData:`${n.slice(0,4)} ${n.slice(4,8)}`,description:`2x 16-bit transport codes for routing optimization`,fields:[{bits:`0-15`,name:`Code 1`,value:i.toString(),binary:i.toString(2).padStart(16,`0`)},{bits:`16-31`,name:`Code 2`,value:a.toString(),binary:a.toString(2).padStart(16,`0`)}]}),r+=8}if(e.length>=r+2){let n=e.slice(r,r+2),i=parseInt(n,16),a=(i>>6)+1,o=i&63,s=o*a;if(t.push({name:`Path Length`,byteRange:`${r/2}`,hexData:`0x${n}`,description:`${o} hop${o===1?``:`s`}, ${a}-byte hash${a>1?`es`:``} (${s} bytes)`,fields:[{bits:`6-7`,name:`Hash Size`,value:`${a}-byte`,binary:(i>>6&3).toString(2).padStart(2,`0`)},{bits:`0-5`,name:`Hop Count`,value:`${o}`,binary:(i&63).toString(2).padStart(6,`0`)}]}),r+=2,s>0&&e.length>=r+s*2){let n=e.slice(r,r+s*2),i=RegExp(`.{${a*2}}`,`g`),c=n.match(i)||[];t.push({name:`Path Data`,byteRange:`${r/2}-${(r+s*2-2)/2}`,hexData:c.join(` `)||n,description:`${o} × ${a}-byte routing hash${o===1?``:`es`}`,fields:c.map((e,t)=>({bits:`${t*a*8}-${(t+1)*a*8-1}`,name:`Hop ${t+1}`,value:e.toUpperCase(),binary:`${a} byte${a>1?`s`:``}`}))}),r+=s*2}}if(e.length>r){let n=e.slice(r),i=n.length/2;o===4?A(t,n,r):t.push({name:`Payload Data`,byteRange:`${r/2}-${r/2+i-1}`,hexData:n.match(/.{2}/g)?.join(` `)||n,description:`Application data content`,fields:[{bits:`0-${i*8-1}`,name:`Application Data`,value:`${i} bytes`,binary:`${i} bytes (${i*8} bits)`}]})}}}else{if(e.header){let n=e.header.replace(/0x/gi,``).replace(/\s+/g,``).toUpperCase(),r=parseInt(n,16),i=r&3,a=(r&60)>>2,o=(r&192)>>6;t.push({name:`Header`,byteRange:`0`,hexData:`0x${n}`,description:`Contains routing type, payload type, and payload version`,fields:[{bits:`0-1`,name:`Route Type`,value:{0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`}[i]||`Unknown`,binary:i.toString(2).padStart(2,`0`)},{bits:`2-5`,name:`Payload Type`,value:{0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTIPART`,15:`RAW_CUSTOM`}[a]||`Unknown`,binary:a.toString(2).padStart(4,`0`)},{bits:`6-7`,name:`Version`,value:o.toString(),binary:o.toString(2).padStart(2,`0`)}]}),e.transport_codes&&t.push({name:`Transport Codes`,byteRange:`1-4`,hexData:e.transport_codes,description:`2x 16-bit transport codes for routing optimization`,fields:[{bits:`0-31`,name:`Transport Codes`,value:e.transport_codes,binary:`Available in separate field`}]}),e.original_path&&e.original_path.length>0&&t.push({name:`Original Path`,byteRange:`?`,hexData:e.original_path.join(` `),description:`Original routing path (${e.original_path.length} nodes)`,fields:[{bits:`0-?`,name:`Path Nodes`,value:`${e.original_path.length} nodes`,binary:`Available as node list`}]}),e.forwarded_path&&e.forwarded_path.length>0&&t.push({name:`Forwarded Path`,byteRange:`?`,hexData:e.forwarded_path.join(` `),description:`Forwarded routing path (${e.forwarded_path.length} nodes)`,fields:[{bits:`0-?`,name:`Path Nodes`,value:`${e.forwarded_path.length} nodes`,binary:`Available as node list`}]})}if(e.payload){let n=e.payload.replace(/\s+/g,``).toUpperCase(),r=n.length/2;e.type===4?A(t,n,0):t.push({name:`Payload Data`,byteRange:`0-${r-1}`,hexData:n.match(/.{2}/g)?.join(` `)||n,description:`Application data content (${r} bytes)`,fields:[{bits:`0-${r*8-1}`,name:`Application Data`,value:`${r} bytes`,binary:`${r} bytes (${r*8} bits)`}]})}}}catch{t.push({name:`Parse Error`,byteRange:`N/A`,hexData:`Error`,description:`Unable to parse packet structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse failed`,binary:`Invalid`}]})}return t},P=(e,t)=>e==null||t==null?`text-content-muted dark:text-content-muted`:a(t).color,F=e=>{if(e==null)return{level:0,className:`signal-none`};let t=a(e),n,r;return t.bars>=5?(n=4,r=`signal-excellent`):t.bars>=4?(n=3,r=`signal-good`):t.bars>=2?(n=2,r=`signal-fair`):t.bars>=1?(n=1,r=`signal-poor`):(n=0,r=`signal-none`),{level:n,className:r}},I=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},L=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`,R=e=>{e.key===`Escape`&&u(`close`)},z=e=>{e.target===e.currentTarget&&u(`close`)};return i(()=>s.isOpen,e=>{e?document.body.style.overflow=`hidden`:document.body.style.overflow=``},{immediate:!0}),(r,i)=>(m(),l(f,{to:`body`},[g(E,{name:`modal`,appear:``},{default:e(()=>[n.isOpen&&n.packet?(m(),S(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 overflow-hidden`,onClick:z,onKeydown:R,tabindex:`0`},[i[51]||=x(`div`,{class:`absolute inset-0 bg-black/60 backdrop-blur-md pointer-events-none`},null,-1),x(`div`,{class:`relative w-full max-w-4xl max-h-[90vh] flex flex-col`,onClick:i[3]||=D(()=>{},[`stop`])},[x(`div`,Pe,[x(`div`,Fe,[x(`div`,null,[i[4]||=x(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary mb-1`},` Packet Details `,-1),x(`p`,Ie,t(T(n.packet.type))+` - `+t(O(n.packet.route)),1)]),x(`div`,Le,[x(`button`,{onClick:i[0]||=e=>d.value=!d.value,class:w([`flex items-center gap-2 px-3 py-1.5 rounded-lg transition-all duration-200`,d.value?`bg-cyan-500/20 border border-cyan-400/30 text-cyan-600 dark:text-cyan-400`:`bg-background-mute dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-secondary dark:text-content-muted`]),title:d.value?`Hide binary values`:`Show binary values`},[...i[5]||=[x(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4`})],-1),x(`span`,{class:`text-xs font-medium`},`Binary`,-1)]],10,Re),x(`button`,{onClick:i[1]||=e=>u(`close`),class:`w-8 h-8 flex items-center justify-center rounded-full bg-background-mute dark:bg-white/10 hover:bg-stroke-subtle dark:hover:bg-white/20 transition-colors duration-200 text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary`},[...i[6]||=[x(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),x(`div`,ze,[x(`div`,Be,[i[13]||=x(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[x(`div`,{class:`w-2 h-2 rounded-full bg-cyan-400 mr-3`}),y(` Basic Information `)],-1),x(`div`,Ve,[x(`div`,He,[x(`div`,Ue,[x(`div`,We,[i[7]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Timestamp`,-1),x(`span`,Ge,t(_(n.packet.timestamp)),1)]),x(`div`,Ke,[i[8]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Packet Hash`,-1),x(`span`,qe,t(n.packet.packet_hash),1)]),n.packet.header?(m(),S(`div`,Je,[i[9]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Header`,-1),x(`span`,Ye,t(n.packet.header),1)])):h(``,!0)]),x(`div`,Xe,[x(`div`,Ze,[i[10]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Type`,-1),x(`span`,Qe,t(n.packet.type)+` (`+t(T(n.packet.type))+`)`,1)]),x(`div`,$e,[i[11]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Route`,-1),x(`span`,et,t(n.packet.route)+` (`+t(O(n.packet.route))+`)`,1)]),x(`div`,tt,[i[12]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Status`,-1),x(`span`,{class:w([`font-semibold`,v(n.packet)])},t(C(n.packet)),3)])])])])]),x(`div`,nt,[i[25]||=x(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[x(`div`,{class:`w-2 h-2 rounded-full bg-orange-400 mr-3`}),y(` Payload Data `)],-1),x(`div`,rt,[x(`div`,it,[x(`div`,at,[i[14]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Payload Length`,-1),x(`span`,ot,t(n.packet.payload_length||n.packet.length)+` bytes`,1)]),n.packet.payload?(m(),S(`div`,st,[i[23]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3`},` Payload Analysis `,-1),x(`div`,ct,[i[15]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-2 font-semibold`},` Raw Hex Data `,-1),x(`div`,lt,[x(`pre`,ut,t(k(n.packet.payload)),1)])]),(m(!0),S(b,null,p(N(n.packet).filter(e=>!e.name.includes(`Parse Error`)),(e,n)=>(m(),S(`div`,{key:n,class:`mb-4`},[x(`div`,dt,[x(`h4`,ft,t(e.name),1),x(`span`,pt,`Bytes `+t(e.byteRange),1)]),x(`div`,mt,[x(`div`,ht,t(e.hexData),1)]),x(`div`,gt,[x(`div`,{class:w([`hidden md:grid gap-3 p-3 bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-muted text-xs font-semibold uppercase tracking-wide`,d.value?`grid-cols-4`:`grid-cols-3`])},[i[16]||=x(`div`,{class:`min-w-0`},`Bits`,-1),i[17]||=x(`div`,{class:`min-w-0`},`Field`,-1),i[18]||=x(`div`,{class:`min-w-0`},`Value`,-1),d.value?(m(),S(`div`,_t,`Binary`)):h(``,!0)],2),(m(!0),S(b,null,p(e.fields,(e,n)=>(m(),S(`div`,{key:n,class:w([`hidden md:grid gap-3 p-3 border-b border-stroke-subtle dark:border-stroke/5 last:border-b-0 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors`,d.value?`grid-cols-4`:`grid-cols-3`])},[x(`div`,vt,t(e.bits),1),x(`div`,yt,t(e.name),1),x(`div`,bt,[x(`span`,{class:`block`,title:e.value},t(e.value),9,xt)]),d.value?(m(),S(`div`,St,[x(`span`,{class:`block`,title:e.binary},t(e.binary),9,Ct)])):h(``,!0)],2))),128)),(m(!0),S(b,null,p(e.fields,(e,n)=>(m(),S(`div`,{key:`mobile-${n}`,class:`md:hidden p-3 border-b border-stroke-subtle dark:border-stroke/5 last:border-b-0 space-y-2`},[x(`div`,wt,[x(`div`,null,[i[19]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Bits:`,-1),x(`div`,Tt,t(e.bits),1)]),x(`div`,null,[i[20]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Field:`,-1),x(`div`,Et,t(e.name),1)])]),x(`div`,null,[i[21]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Value:`,-1),x(`div`,{class:`text-content-primary dark:text-content-primary text-sm font-semibold break-all`,title:e.value},t(e.value),9,Dt)]),d.value?(m(),S(`div`,Ot,[i[22]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Binary:`,-1),x(`div`,{class:`text-orange-500 text-xs font-mono break-all`,title:e.binary},t(e.binary),9,kt)])):h(``,!0)]))),128))]),e.description?(m(),S(`div`,At,t(e.description),1)):h(``,!0)]))),128))])):(m(),S(`div`,jt,[...i[24]||=[x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Payload:`,-1),x(`span`,{class:`text-content-muted dark:text-content-muted ml-2`},`None`,-1)]]))])])]),x(`div`,Mt,[i[33]||=x(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[x(`div`,{class:`w-2 h-2 rounded-full bg-purple-400 mr-3`}),y(` Path Information `)],-1),x(`div`,Nt,[x(`div`,Pt,[x(`div`,Ft,[x(`div`,It,[i[26]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Source Hash`,-1),x(`span`,{class:w([`text-content-primary dark:text-content-primary font-mono text-xs`,s.localHash&&n.packet.src_hash===s.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},t(n.packet.src_hash||`Unknown`),3)]),x(`div`,Lt,[i[27]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Destination Hash`,-1),x(`span`,{class:w([`text-content-primary dark:text-content-primary font-mono text-xs`,s.localHash&&n.packet.dst_hash===s.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},t(n.packet.dst_hash||`Broadcast`),3)])]),M(n.packet.original_path).length>0?(m(),S(`div`,Rt,[i[29]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-2`},` Original Path `,-1),x(`div`,zt,[x(`div`,Bt,[(m(!0),S(b,null,p(M(n.packet.original_path),(e,r)=>(m(),S(`div`,{key:r,class:`flex items-center`},[x(`div`,Vt,[x(`div`,Ht,[x(`div`,Ut,t(e.toUpperCase()),1)]),x(`div`,Wt,` Node: `+t(e.toUpperCase()),1)]),r0?(m(),S(`div`,Kt,[x(`div`,qt,[i[31]||=y(` Forwarded Path `,-1),JSON.stringify(M(n.packet.original_path))===JSON.stringify(M(n.packet.forwarded_path))?h(``,!0):(m(),S(`svg`,Jt,[...i[30]||=[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])),JSON.stringify(M(n.packet.original_path))===JSON.stringify(M(n.packet.forwarded_path))?h(``,!0):(m(),S(`span`,Yt,`(Modified)`))]),x(`div`,Xt,[x(`div`,Zt,[(m(!0),S(b,null,p(M(n.packet.forwarded_path),(e,r)=>(m(),S(`div`,{key:r,class:`flex items-center`},[x(`div`,Qt,[x(`div`,{class:w([`relative px-3 py-2 bg-gradient-to-br from-orange-500/20 to-yellow-500/20 border border-orange-500 dark:border-orange-400/40 rounded-lg transform transition-all hover:scale-105`,s.localHash&&e===s.localHash?`bg-gradient-to-br from-yellow-400/30 to-orange-400/30 border-yellow-300 shadow-yellow-400/20 shadow-lg`:`hover:border-orange-500 dark:border-orange-400/60`])},[x(`div`,{class:w([`font-mono text-[10px] font-semibold tracking-tight sm:text-xs`,s.localHash&&e===s.localHash?`text-yellow-200`:`text-white/90`])},t(e.toUpperCase()),3),s.localHash&&e===s.localHash?(m(),S(`div`,$t)):h(``,!0)],2),x(`div`,en,t(e.toUpperCase()),1)]),rx(`div`,{key:e,class:w([`w-2 h-6 rounded-sm transition-all duration-300`,e<=F(n.packet.rssi).level?{"signal-excellent":`bg-green-400`,"signal-good":`bg-cyan-400`,"signal-fair":`bg-yellow-400`,"signal-poor":`bg-red-400`}[F(n.packet.rssi).className]:`bg-stroke-subtle dark:bg-stroke/10`])},null,2)),64))]),x(`span`,mn,t(F(n.packet.rssi).className.replace(`signal-`,``)),1)])])),n.packet.is_trace&&n.packet.path_snr_details&&n.packet.path_snr_details.length>0?(m(),S(`div`,gn,[x(`div`,_n,` Path SNR Details (`+t(n.packet.path_snr_details.length)+` hops) `,1),x(`div`,vn,[(m(!0),S(b,null,p(n.packet.path_snr_details,(e,n)=>(m(),S(`div`,{key:n,class:`flex items-center justify-between p-2 glass-card bg-background-mute dark:bg-black/20 rounded-[8px]`},[x(`div`,yn,[x(`span`,bn,t(n+1)+`.`,1),x(`span`,{class:w([`font-mono text-xs text-content-primary dark:text-content-primary`,s.localHash&&e.hash===s.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},t(e.hash.toUpperCase()),3)]),x(`span`,{class:w([`text-sm font-bold`,P(e.snr_db,null)])},t(e.snr_db.toFixed(1))+`dB `,3)]))),128))])])):h(``,!0),n.packet.transmitted&&n.packet.lbt_attempts!==void 0?(m(),S(`div`,xn,[i[45]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3 flex items-center`},[x(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z`})]),y(` Listen Before Talk (LBT) Metrics `)],-1),x(`div`,Sn,[x(`div`,Cn,[i[41]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` CAD Attempts `,-1),x(`div`,wn,t(n.packet.lbt_attempts),1)]),x(`div`,Tn,[i[42]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Total LBT Delay `,-1),x(`div`,En,t(L(I(n.packet.lbt_backoff_delays_ms).reduce((e,t)=>e+t,0))),1),x(`div`,Dn,t(I(n.packet.lbt_backoff_delays_ms).length)+` backoffs `,1)]),x(`div`,On,[i[43]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Channel Status `,-1),x(`div`,{class:w([`text-lg font-bold`,n.packet.lbt_channel_busy?`text-yellow-600 dark:text-yellow-400`:`text-green-600 dark:text-green-400`])},t(n.packet.lbt_channel_busy?`BUSY`:`CLEAR`),3),x(`div`,kn,t(n.packet.lbt_channel_busy?`Waited for clear`:`Immediate TX`),1)])]),I(n.packet.lbt_backoff_delays_ms).length>0?(m(),S(`div`,An,[i[44]||=x(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-3 font-semibold`},` Backoff Pattern (Exponential with Jitter) `,-1),x(`div`,jn,[(m(!0),S(b,null,p(I(n.packet.lbt_backoff_delays_ms),(e,r)=>(m(),S(`div`,{key:r,class:`flex items-center gap-3`},[x(`div`,Mn,[x(`span`,Nn,`Attempt `+t(r+1),1)]),x(`div`,Pn,[x(`div`,Fn,[x(`div`,{class:w([`h-full rounded-lg transition-all duration-300`,[r===0?`bg-gradient-to-r from-cyan-500/50 to-cyan-600/50`:r===1?`bg-gradient-to-r from-yellow-500/50 to-yellow-600/50`:r===2?`bg-gradient-to-r from-orange-500/50 to-orange-600/50`:`bg-gradient-to-r from-red-500/50 to-red-600/50`]]),style:o({width:`${Math.min(100,e/Math.max(...I(n.packet.lbt_backoff_delays_ms))*100)}%`})},[x(`div`,In,[x(`span`,Ln,t(L(e)),1)])],6)])]),x(`div`,Rn,[x(`span`,zn,t(Math.round(e/I(n.packet.lbt_backoff_delays_ms).reduce((e,t)=>e+t,0)*100))+`% `,1)])]))),128))])])):h(``,!0)])):h(``,!0),x(`div`,Bn,[x(`div`,Vn,[x(`div`,Hn,[i[46]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`TX Delay`,-1),x(`span`,Un,t(Number(n.packet.tx_delay_ms)>0?Number(n.packet.tx_delay_ms).toFixed(1)+`ms`:`-`),1)]),x(`div`,Wn,[i[47]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Transmitted`,-1),x(`span`,{class:w(n.packet.transmitted?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`)},t(n.packet.transmitted?`Yes`:`No`),3)])]),x(`div`,Gn,[x(`div`,Kn,[i[48]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Is Duplicate`,-1),x(`span`,{class:w(n.packet.is_duplicate?`text-amber-600 dark:text-amber-400`:`text-content-muted dark:text-content-muted`)},t(n.packet.is_duplicate?`Yes`:`No`),3)]),n.packet.drop_reason?(m(),S(`div`,qn,[i[49]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Drop Reason`,-1),x(`span`,Jn,t(n.packet.drop_reason),1)])):h(``,!0)])])])])]),x(`div`,Yn,[x(`button`,{onClick:i[2]||=e=>u(`close`),class:`px-6 py-2 bg-gradient-to-r from-cyan-500/20 to-cyan-400/20 hover:from-cyan-500/30 hover:to-cyan-400/30 border border-cyan-400/30 rounded-[10px] text-content-primary dark:text-content-primary transition-all duration-200 backdrop-blur-sm`},` Close `)])])])],32)):h(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-c8711b75`]]),Zn={class:`glass-card rounded-[20px] p-6`},Qn={class:`flex flex-col lg:flex-row lg:justify-between lg:items-center mb-6 gap-4 filter-container`},$n={class:`flex items-center gap-2 header-info relative`},er={class:`text-content-secondary dark:text-content-muted text-sm packet-count`},tr=[`title`],nr={class:`hidden sm:inline`},rr={key:1,class:`text-accent-red text-sm error-indicator`},ir={class:`flex items-center gap-3 lg:flex filter-controls`},ar={class:`flex flex-col`},or=[`value`],sr={class:`flex flex-col`},cr=[`value`],lr={class:`flex flex-col`},ur={class:`flex flex-col reset-container`},dr=[`disabled`],fr={class:`space-y-4 overflow-hidden`},pr={class:`space-y-4`},mr=[`onClick`],hr={class:`hidden lg:grid grid-cols-12 gap-2 items-center`},gr={class:`col-span-1 text-content-primary dark:text-content-primary text-sm`},_r={class:`col-span-1 flex items-center gap-2`},vr={class:`flex flex-col`},yr={class:`text-content-primary dark:text-content-primary text-xs`},br=[`title`],xr={class:`col-span-2`},Sr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Cr={class:`col-span-2`},wr={class:`space-y-1`},Tr={key:0,class:`flex items-center gap-0.5 flex-wrap`},Er=[`title`],Dr={key:0,class:`w-2.5 h-2.5 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Or={key:0,class:`text-[9px] text-content-muted dark:text-content-muted ml-1`},kr={key:1,class:`flex items-center gap-1`},Ar={class:`inline-block px-2 py-0.5 rounded bg-badge-cyan-bg text-badge-cyan-text text-xs font-mono`},jr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Mr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Nr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Pr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Fr={key:0,class:`flex items-center gap-1`},Ir={class:`col-span-1`},Lr={key:0,class:`text-accent-red text-[8px] italic truncate`},Rr={class:`lg:hidden space-y-2`},zr={class:`flex items-center justify-between`},Br={class:`flex items-center gap-2`},Vr={class:`flex flex-col`},Hr={class:`text-content-primary dark:text-content-primary text-sm font-medium`},Ur=[`title`],Wr={class:`flex items-center gap-2 text-right`},Gr={class:`text-content-secondary dark:text-content-muted text-xs`},Kr={class:`flex items-center justify-between`},qr={class:`flex items-center gap-1.5`},Jr={key:0,class:`flex flex-wrap items-center gap-0.5`},Yr=[`title`],Xr={key:0,class:`w-2.5 h-2.5 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Zr={key:0,class:`text-[9px] text-content-muted dark:text-content-muted ml-1`},Qr={class:`flex items-center gap-1`},$r={class:`inline-block px-2 py-0.5 rounded bg-badge-cyan-bg text-badge-cyan-text text-xs font-mono font-semibold`},ei={class:`flex items-center gap-0.5 text-content-muted dark:text-content-muted/60`},ti={key:0,class:`text-[9px] font-medium`,title:`Multi-hop path`},ni={class:`flex items-center gap-1`},ri={class:`flex items-center gap-2`},ii={class:`flex items-center gap-1`},ai={key:0,class:`flex gap-0.5`},oi={class:`text-content-primary dark:text-content-primary text-xs`},si={class:`flex items-center justify-between text-content-secondary dark:text-content-muted text-xs`},ci={class:`flex items-center gap-3`},li={class:`flex items-center gap-2`},ui={key:0,class:`flex items-center gap-1`},di={key:0,class:`text-accent-red text-xs italic`},fi={key:0,class:`flex justify-between items-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke pagination-container`},pi={class:`flex items-center gap-4 pagination-info`},mi={class:`text-content-secondary dark:text-content-muted text-sm`},hi={key:0,class:`flex items-center gap-2 load-more-section`},gi=[`disabled`],_i={class:`text-content-secondary dark:text-content-muted text-xs load-more-count`},vi={class:`flex items-center gap-2 pagination-controls`},yi=[`disabled`],bi={class:`flex items-center gap-1 page-numbers`},xi={key:1,class:`text-content-secondary dark:text-content-muted text-sm px-2 ellipsis`},Si=[`onClick`],Ci={key:2,class:`text-content-secondary dark:text-content-muted text-sm px-2 ellipsis`},wi=[`disabled`],Ti={key:1,class:`flex justify-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke`},Ei={class:`flex items-center gap-4`},Di={class:`text-content-secondary dark:text-content-muted text-sm`},Oi={class:`text-content-secondary dark:text-content-muted text-xs`},ki={key:2,class:`flex justify-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke`},Ai={class:`flex items-center gap-2`},Q=10,$=1e3,ji=j(d({name:`PacketTable`,__name:`PacketTable`,setup(e){let r=O(),a=A(),o=c(1),l=c(100),d=c(!1),f=c(!1),y=null;i(()=>r.isLoading,e=>{e?(y&&=(clearTimeout(y),null),f.value=!0):y=window.setTimeout(()=>{f.value=!1,y=null},600)});let E=c(null),D=c(!1),k=async e=>{if(E.value=e,D.value=!0,e.packet_hash&&(!e.header||!e.raw_packet))try{let t=await r.getPacketByHash(e.packet_hash);t&&E.value?.packet_hash===e.packet_hash&&(E.value={...E.value,...t})}catch{}},j=()=>{D.value=!1,E.value=null},N=c(I(`packetTable_selectedType`,`all`)),P=c(I(`packetTable_selectedRoute`,`all`)),L=c(!1),R=c(null),z=[`all`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`],ee=[`all`,`1`,`2`];i(N,e=>{F(`packetTable_selectedType`,e),o.value=1}),i(P,e=>{F(`packetTable_selectedRoute`,e),o.value=1}),i(L,()=>{o.value=1});let B=v(()=>{let e=r.recentPackets;if(N.value!==`all`){let t=parseInt(N.value);e=e.filter(e=>e.type===t)}if(P.value!==`all`){let t=parseInt(P.value);e=e.filter(e=>e.route===t)}return L.value&&R.value!==null&&(e=e.filter(e=>e.timestamp>=R.value)),e}),te=v(()=>{let e=(o.value-1)*Q,t=e+Q;return B.value.slice(e,t)}),V=v(()=>Math.ceil(B.value.length/Q)),ne=v(()=>o.value===V.value),re=v(()=>r.recentPackets.length>=l.value&&l.value<$),ie=v(()=>ne.value&&re.value&&!d.value),H=e=>new Date(e*1e3).toLocaleTimeString(void 0,{hour12:!0}),U=e=>({0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTI_PART`,11:`CONTROL`})[e]||`TYPE_${e}`,W=e=>({0:`T-Flood`,1:`Flood`,2:`Direct`,3:`T-Direct`})[e]||`Route ${e}`,G=e=>e.transmitted?`text-accent-green`:`text-primary`,K=e=>e.drop_reason?`Dropped`:e.transmitted?`Forward`:`Received`,q=e=>e===1?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-badge-neutral-bg text-badge-neutral-text`,J=e=>({0:`bg-primary`,1:`bg-accent-green`,2:`bg-secondary`,3:`bg-accent-purple`,4:`bg-accent-red`,5:`bg-accent-cyan`,6:`bg-primary`,7:`bg-accent-purple`,8:`bg-accent-green`,9:`bg-secondary`})[e]||`bg-gray-500`,ae=e=>({0:`border-l-primary`,1:`border-l-accent-green`,2:`border-l-secondary`,3:`border-l-accent-purple`,4:`border-l-accent-red`,5:`border-l-accent-cyan`,6:`border-l-primary`,7:`border-l-accent-purple`,8:`border-l-accent-green`,9:`border-l-secondary`})[e]||`border-l-gray-500`,oe=e=>!e.transmitted||!e.lbt_attempts||e.lbt_attempts===0?`bg-green-400`:e.lbt_attempts===1?`bg-cyan-400`:e.lbt_attempts===2?`bg-yellow-400`:`bg-orange-400`,se=e=>e>=1e3?(e/1e3).toFixed(2)+`s`:e.toFixed(1)+`ms`,ce=e=>{if(!e)return[];if(Array.isArray(e))return e;if(typeof e==`string`)try{let t=JSON.parse(e);return typeof t==`string`?JSON.parse(t):Array.isArray(t)?t:[]}catch{return[]}return[]},Y=e=>{let t=ce(e.original_path),n=ce(e.forwarded_path),r=t.length>0?t:n;return r.length===0?null:{hops:r.length-1,nodes:r.map(e=>e.toUpperCase())}},X=e=>{if(e.type!==4||!e.payload)return null;try{let t=e.payload.replace(/\s+/g,``).toUpperCase(),n=t,r=0;if(t.length/2>=100)if(t.length>200)n=t.slice(200),r=0;else return null;if(n.length>=2){let e=parseInt(n.slice(0,2),16);r+=2;let t=!!(e&16),i=!!(e&32),a=!!(e&64);if(!(e&128))return null;if(t&&n.length>=r+16&&(r+=16),i&&n.length>=r+4&&(r+=4),a&&n.length>=r+4&&(r+=4),n.length>r){let e=(n.slice(r).match(/.{2}/g)||[]).map(e=>{let t=parseInt(e,16);return t>=32&&t<=126?String.fromCharCode(t):`.`}).join(``).replace(/\.*$/,``);return e.length>0?e:null}}}catch(e){console.error(`Error parsing ADVERT node name:`,e)}return null},le=()=>{N.value=`all`,P.value=`all`,L.value=!1,R.value=null,o.value=1},ue=()=>{L.value?(L.value=!1,R.value=null):(L.value=!0,R.value=Date.now()/1e3),o.value=1},de=v(()=>R.value?new Date(R.value*1e3).toLocaleTimeString(void 0,{hour12:!0}):``),fe=async e=>{try{let t=e||l.value;await r.fetchRecentPackets({limit:t})}catch(e){console.error(`Error fetching packet data:`,e)}},pe=async()=>{if(!(d.value||l.value>=$)){d.value=!0;try{let e=Math.min(l.value+200,$);l.value=e,await fe(e)}catch(e){console.error(`Error loading more records:`,e)}finally{d.value=!1}}};return n(()=>{a.ensure(`recentPackets`)}),C(()=>{y&&clearTimeout(y)}),(e,n)=>(m(),S(b,null,[x(`div`,Zn,[x(`div`,Qn,[x(`div`,$n,[n[7]||=x(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold`},` Recent Packets `,-1),x(`span`,er,` (`+t(B.value.length)+` of `+t(_(r).recentPackets.length)+`) `,1),L.value?(m(),S(`span`,{key:0,class:`text-primary text-xs sm:text-sm bg-primary/10 px-2 py-1 rounded-md border border-primary/20 live-mode-badge whitespace-nowrap`,title:`Filter activated at ${de.value}`},[x(`span`,nr,`Live Mode (since `+t(de.value)+`)`,1),n[6]||=x(`span`,{class:`sm:hidden`},`Live`,-1)],8,tr)):h(``,!0),_(r).error?(m(),S(`span`,rr,t(_(r).error),1)):h(``,!0)]),x(`div`,ir,[x(`div`,ar,[n[8]||=x(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Type`,-1),s(x(`select`,{"onUpdate:modelValue":n[0]||=e=>N.value=e,class:`glass-card border border-stroke-subtle dark:border-stroke rounded-[10px] px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all duration-200 min-w-[120px] cursor-pointer hover:border-primary/50`},[(m(),S(b,null,p(z,e=>x(`option`,{key:e,value:e,class:`bg-surface dark:bg-surface-elevated text-content-primary dark:text-content-primary`},t(e===`all`?`All Types`:`Type ${e} (${U(parseInt(e))})`),9,or)),64))],512),[[T,N.value]])]),x(`div`,sr,[n[9]||=x(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Route`,-1),s(x(`select`,{"onUpdate:modelValue":n[1]||=e=>P.value=e,class:`glass-card border border-stroke-subtle dark:border-stroke rounded-[10px] px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all duration-200 min-w-[120px] cursor-pointer hover:border-primary/50`},[(m(),S(b,null,p(ee,e=>x(`option`,{key:e,value:e,class:`bg-surface dark:bg-surface-elevated text-content-primary dark:text-content-primary`},t(e===`all`?`All Routes`:`Route ${e} (${W(parseInt(e))})`),9,cr)),64))],512),[[T,P.value]])]),x(`div`,lr,[n[10]||=x(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Filter`,-1),x(`button`,{onClick:ue,class:w([`glass-card border rounded-[10px] px-4 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 min-w-[120px]`,{"border-primary bg-primary/10 text-primary":L.value,"border-stroke-subtle dark:border-stroke text-content-secondary dark:text-content-muted hover:border-primary hover:text-content-primary dark:hover:text-content-primary hover:bg-primary/5":!L.value}])},t(L.value?`New Only`:`Show New`),3)]),x(`div`,ur,[n[11]||=x(`label`,{class:`text-transparent text-xs mb-1`},`.`,-1),x(`button`,{onClick:le,class:w([`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[10px] px-4 py-2 text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary text-sm transition-all duration-200 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20`,{"opacity-50 cursor-not-allowed hover:border-stroke-subtle dark:hover:border-stroke hover:text-content-secondary dark:hover:text-content-muted":N.value===`all`&&P.value===`all`&&!L.value,"hover:bg-primary/10":N.value!==`all`||P.value!==`all`||L.value}]),disabled:N.value===`all`&&P.value===`all`&&!L.value},` Reset `,10,dr)])])]),n[25]||=u(``,1),x(`div`,fr,[x(`div`,pr,[(m(!0),S(b,null,p(te.value,(e,r)=>(m(),S(`div`,{key:`${e.packet_hash}_${e.timestamp}_${r}`,class:w([`packet-row border-b border-stroke-subtle dark:border-dark-border/50 pb-4 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors duration-150 cursor-pointer rounded-[10px] p-2 border-l-4`,ae(e.type)]),onClick:t=>k(e)},[x(`div`,hr,[x(`div`,gr,t(H(e.timestamp)),1),x(`div`,_r,[x(`div`,{class:w([`w-2 h-2 rounded-full`,J(e.type)])},null,2),x(`div`,vr,[x(`span`,yr,t(U(e.type)),1),e.type===4&&X(e)?(m(),S(`span`,{key:0,class:`text-accent-red/70 text-[10px] font-medium max-w-[80px] truncate`,title:X(e)||void 0},t(X(e)),9,br)):h(``,!0)])]),x(`div`,xr,[x(`span`,{class:w([`inline-block px-2 py-1 rounded text-xs font-medium`,q(e.route)])},t(W(e.route)),3)]),x(`div`,Sr,t(e.length)+`B `,1),x(`div`,Cr,[x(`div`,wr,[Y(e)?(m(),S(`div`,Tr,[(m(!0),S(b,null,p(Y(e).nodes,(r,i)=>(m(),S(b,{key:i},[x(`span`,{class:w([`inline-block max-w-full truncate px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-tight tracking-tight`,i===0?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-gray-500/20 text-content-muted dark:text-content-muted`]),title:r},t(r),11,Er),i0?(m(),S(`span`,Or,` (`+t(Y(e).hops)+` hop`+t(Y(e).hops>1?`s`:``)+`) `,1)):h(``,!0)])):(m(),S(`div`,kr,[x(`span`,Ar,t(e.src_hash?.slice(-4).toUpperCase()||`????`),1),n[13]||=x(`svg`,{class:`w-3 h-3 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1),x(`span`,{class:w([`inline-block px-2 py-0.5 rounded text-xs font-mono`,e.dst_hash?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-yellow-500/20 text-yellow-700 dark:text-yellow-300`])},t(e.dst_hash?e.dst_hash.slice(-4).toUpperCase():`BCAST`),3)]))])]),x(`div`,jr,t(e.rssi==null?`N/A`:e.rssi.toFixed(0)+` dBm`),1),x(`div`,Mr,t(e.snr==null?`N/A`:e.snr.toFixed(1)+`dB`),1),x(`div`,Nr,t(e.score==null?`N/A`:e.score.toFixed(2)),1),x(`div`,Pr,[Number(e.tx_delay_ms)>0?(m(),S(`div`,Fr,[e.transmitted?(m(),S(`div`,{key:0,class:w([`w-1.5 h-1.5 rounded-full flex-shrink-0`,oe(e)])},null,2)):h(``,!0),x(`span`,null,t(se(Number(e.tx_delay_ms))),1)])):h(``,!0)]),x(`div`,Ir,[x(`div`,null,[x(`span`,{class:w([`text-xs font-medium`,G(e)])},t(K(e)),3),e.drop_reason?(m(),S(`p`,Lr,t(e.drop_reason),1)):h(``,!0)])])]),x(`div`,Rr,[x(`div`,zr,[x(`div`,Br,[x(`div`,{class:w([`w-2 h-2 rounded-full flex-shrink-0`,J(e.type)])},null,2),x(`div`,Vr,[x(`span`,Hr,t(U(e.type)),1),e.type===4&&X(e)?(m(),S(`span`,{key:0,class:`text-accent-red/70 text-[10px] font-medium leading-tight`,title:X(e)||void 0},t(X(e)),9,Ur)):h(``,!0)]),x(`span`,{class:w([`inline-block px-2 py-1 rounded text-xs font-medium ml-2`,q(e.route)])},t(W(e.route)),3)]),x(`div`,Wr,[x(`span`,Gr,t(H(e.timestamp)),1),x(`span`,{class:w([`text-xs font-medium`,G(e)])},t(K(e)),3)])]),x(`div`,Kr,[x(`div`,qr,[Y(e)?(m(),S(`div`,Jr,[n[15]||=x(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`PATH`,-1),(m(!0),S(b,null,p(Y(e).nodes,(r,i)=>(m(),S(b,{key:i},[x(`span`,{class:w([`inline-block max-w-full truncate px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-tight tracking-tight`,i===0?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-gray-500/20 text-content-muted dark:text-content-muted`]),title:r},t(r),11,Yr),i0?(m(),S(`span`,Zr,` (`+t(Y(e).hops)+` hop`+t(Y(e).hops>1?`s`:``)+`) `,1)):h(``,!0)])):(m(),S(b,{key:1},[x(`div`,Qr,[n[16]||=x(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`SRC`,-1),x(`span`,$r,t(e.src_hash?.slice(-4)||`????`),1)]),x(`div`,ei,[n[18]||=x(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1),e.route===1?(m(),S(`span`,ti,[...n[17]||=[x(`svg`,{class:`w-2.5 h-2.5 inline`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[x(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 5l7 7-7 7M5 5l7 7-7 7`})],-1)]])):h(``,!0)]),x(`div`,ni,[x(`span`,{class:w([`inline-block px-2 py-0.5 rounded text-xs font-mono font-semibold`,e.dst_hash?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-yellow-500/20 text-yellow-700 dark:text-yellow-300`])},t(e.dst_hash?e.dst_hash.slice(-4).toUpperCase():`BCAST`),3),n[19]||=x(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`DST`,-1)])],64))]),x(`div`,ri,[x(`div`,ii,[e.snr==null?h(``,!0):(m(),S(`div`,ai,[x(`div`,{class:w([`w-1 h-3 rounded-sm`,e.snr>=-10?`bg-green-400`:`bg-white/20`])},null,2),x(`div`,{class:w([`w-1 h-4 rounded-sm`,e.snr>=-5?`bg-green-400`:`bg-white/20`])},null,2),x(`div`,{class:w([`w-1 h-5 rounded-sm`,e.snr>=0?`bg-green-400`:`bg-white/20`])},null,2),x(`div`,{class:w([`w-1 h-6 rounded-sm`,e.snr>=10?`bg-green-400`:`bg-white/20`])},null,2)])),x(`span`,oi,t(e.rssi==null?`TX`:e.rssi.toFixed(0)+`dBm`),1)])])]),x(`div`,si,[x(`div`,ci,[x(`span`,null,t(e.length)+`B`,1),x(`span`,null,`SNR: `+t(e.snr==null?`N/A`:e.snr.toFixed(1)+`dB`),1),x(`span`,null,`Score: `+t(e.score==null?`N/A`:e.score.toFixed(2)),1)]),x(`div`,li,[Number(e.tx_delay_ms)>0?(m(),S(`span`,ui,[e.transmitted?(m(),S(`div`,{key:0,class:w([`w-1.5 h-1.5 rounded-full flex-shrink-0`,oe(e)])},null,2)):h(``,!0),x(`span`,null,t(se(Number(e.tx_delay_ms))),1)])):h(``,!0)])]),e.drop_reason?(m(),S(`div`,di,t(e.drop_reason),1)):h(``,!0)])],10,mr))),128))])]),V.value>1?(m(),S(`div`,fi,[x(`div`,pi,[x(`span`,mi,` Showing `+t((o.value-1)*Q+1)+` - `+t(Math.min(o.value*Q,B.value.length))+` of `+t(B.value.length)+` packets `,1),ie.value?(m(),S(`div`,hi,[n[20]||=x(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`•`,-1),x(`button`,{onClick:pe,disabled:d.value,class:w([`glass-card border border-primary rounded-[8px] px-3 py-1.5 text-xs transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 hover:bg-primary/5`,{"text-primary border-primary cursor-pointer":!d.value,"text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke cursor-not-allowed opacity-50":d.value}])},t(d.value?`Loading...`:`Load ${Math.min(200,$-l.value)} more`),11,gi),x(`span`,_i,`(`+t(l.value)+`/`+t($)+` max)`,1)])):h(``,!0)]),x(`div`,vi,[x(`button`,{onClick:n[2]||=e=>--o.value,disabled:o.value<=1,class:w([`glass-card border rounded-[10px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 prev-next-btn`,{"border-stroke-subtle dark:border-stroke text-content-muted dark:text-content-muted cursor-not-allowed opacity-50":o.value<=1,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value>1}])},[...n[21]||=[x(`span`,{class:`hidden sm:inline`},`Previous`,-1),x(`span`,{class:`sm:hidden`},`‹`,-1)]],10,yi),x(`div`,bi,[o.value>3?(m(),S(`button`,{key:0,onClick:n[3]||=e=>o.value=1,class:`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[8px] px-3 py-2 text-sm text-content-primary dark:text-content-primary hover:text-primary hover:bg-primary/5 transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20`},` 1 `)):h(``,!0),o.value>4?(m(),S(`span`,xi,`...`)):h(``,!0),(m(!0),S(b,null,p(Array.from({length:Math.min(5,V.value)},(e,t)=>Math.max(1,Math.min(o.value-2,V.value-4))+t).filter(e=>e<=V.value),e=>(m(),S(`button`,{key:e,onClick:t=>o.value=e,class:w([`glass-card border rounded-[8px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 page-number`,{"border-primary bg-primary/10 text-primary":o.value===e,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value!==e}])},t(e),11,Si))),128)),o.valueo.value=V.value,class:`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[8px] px-3 py-2 text-sm text-content-primary dark:text-content-primary hover:text-primary hover:bg-primary/5 transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20`},t(V.value),1)):h(``,!0)]),x(`button`,{onClick:n[5]||=e=>o.value+=1,disabled:o.value>=V.value,class:w([`glass-card border rounded-[10px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 prev-next-btn`,{"border-stroke-subtle dark:border-stroke text-content-muted dark:text-content-muted cursor-not-allowed opacity-50":o.value>=V.value,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value(m(),S(`div`,null,[g(ae),x(`div`,Mi,[g(Ne),g(_e)]),g(ji)]))}});export{Ni as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Dashboard-ClL05x7j.js b/repeater/web/html/assets/Dashboard-ClL05x7j.js deleted file mode 100644 index bb230253..00000000 --- a/repeater/web/html/assets/Dashboard-ClL05x7j.js +++ /dev/null @@ -1,2 +0,0 @@ -import{A as e,E as t,I as n,K as r,S as i,b as a,c as o,dt as s,f as c,ft as l,g as u,i as d,j as f,k as p,l as m,m as h,o as g,p as _,pt as v,r as y,s as b,u as x,w as S,x as C,z as w}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as T}from"./api-CbM6k1ZB.js";import{t as E}from"./system-BH4r-ii6.js";import{t as D}from"./packets-C-dzvp0W.js";import{t as O}from"./websocket-nXR7EYbj.js";import{t as k}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{a as A,c as ee,d as te,h as j}from"./index-BFltqMtv.js";import{n as M,t as N}from"./preferences-Bv8i60GL.js";import{a as P,c as F,i as I,l as L,m as ne,s as R,u as re}from"./chart-B1uYMRrx.js";import{t as z}from"./useSignalQuality-BfZWbBxN.js";var ie={class:`sparkline-card`},B={class:`card-header`},ae={class:`card-title`},V={class:`card-values`},H={class:`card-chart`},U=k(u({name:`ChartSparkline`,__name:`ChartSparkline`,props:{title:{},value:{},color:{},data:{default:()=>[]},showChart:{type:Boolean,default:!0},secondaryValue:{default:void 0},secondaryLabel:{default:``},secondaryColor:{default:``},secondaryData:{default:()=>[]}},setup(e){P.register(I,L,re,F,R,ne);let t=e,r=w(null),o=w(null),s=e=>{if(e.length<3)return e;let t=Math.min(15,Math.max(3,Math.floor(e.length*.2))),n=[];for(let r=0;re+t,0)/s.length)}let r=Math.min(12,n.length),i=n.length/r,a=[];for(let e=0;e!t.data||t.data.length===0?[]:s(t.data)),u=g(()=>!t.secondaryData||t.secondaryData.length===0?[]:s(t.secondaryData)),d=()=>{if(!r.value)return;let e=r.value.getContext(`2d`);if(!e)return;o.value&&=(o.value.destroy(),null);let i=c.value;if(i.length<2)return;let a=[{data:i,borderColor:t.color,borderWidth:2.5,fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}],s=u.value;s.length>=2&&t.secondaryColor&&a.push({data:s,borderColor:t.secondaryColor,borderWidth:2,borderDash:[4,3],fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}),o.value=n(new P(e,{type:`line`,data:{labels:i.map((e,t)=>t.toString()),datasets:a},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:800,easing:`easeOutQuart`},plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1,grid:{display:!1}},y:{display:!1,grid:{display:!1},grace:`10%`}},elements:{line:{capBezierPoints:!0}}}}))},f=()=>{if(!o.value){d();return}let e=c.value;if(e.length<2)return;o.value.data.labels=e.map((e,t)=>t.toString()),o.value.data.datasets[0].data=e;let n=u.value;n.length>=2&&t.secondaryColor&&(o.value.data.datasets.length<2?o.value.data.datasets.push({data:n,borderColor:t.secondaryColor,borderWidth:2,borderDash:[4,3],fill:!1,tension:.4,pointRadius:0,pointHoverRadius:0}):o.value.data.datasets[1].data=n),o.value.update(`default`)};return p(()=>t.data,()=>{a(()=>f())},{deep:!0}),p(()=>t.color,()=>{o.value&&(o.value.data.datasets[0].borderColor=t.color,o.value.update(`none`))}),i(()=>{a(()=>d())}),C(()=>{o.value&&=(o.value.destroy(),null)}),(t,n)=>(S(),x(`div`,ie,[b(`div`,B,[b(`p`,ae,v(e.title),1),b(`div`,V,[b(`span`,{class:`card-value`,style:l({color:e.color})},v(typeof e.value==`number`?e.value.toLocaleString():e.value),5),e.secondaryValue===void 0?m(``,!0):(S(),x(`span`,{key:0,class:`card-secondary-value`,style:l({color:e.secondaryColor})},v(e.secondaryLabel)+v(typeof e.secondaryValue==`number`?e.secondaryValue.toLocaleString():e.secondaryValue),5))])]),b(`div`,H,[e.showChart?(S(),x(`canvas`,{key:0,ref_key:`canvasRef`,ref:r},null,512)):m(``,!0)])]))}}),[[`__scopeId`,`data-v-d5c09182`]]),W={class:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3 lg:gap-4 mb-5 stats-cards-container`},G=k(u({name:`StatsCards`,__name:`StatsCards`,setup(e){let t=D(),n=O(),r=w(null),o=w(!1),s=g(()=>{let e=t.packetStats,n=t.systemStats,r=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`},i=e?.total_packets||0,a=e?.dropped_packets||0,o=i>0?Math.round(a/i*100):0;return{packetsReceived:i,packetsForwarded:e?.transmitted_packets||0,uptimeFormatted:n?r(n.uptime_seconds||0):`0m`,uptimeHours:n?Math.floor((n.uptime_seconds||0)/3600):0,droppedPackets:a,dropPercent:`${o}%`,signalQuality:Math.round((e?.avg_rssi||0)+120),crcErrorCount:t.crcErrorCount}}),c=g(()=>t.sparklineData),l=async()=>{if(!o.value)try{o.value=!0,await Promise.all([t.fetchSystemStats(),t.fetchPacketStats({hours:24})]),await a()}catch(e){console.error(`Error fetching stats:`,e)}finally{o.value=!1}};return i(async()=>{await t.initializeSparklineHistory(),l(),r.value=window.setInterval(()=>{t.interpolateRates()},6e4)}),A(l,{intervalMs:3e4,enabled:()=>!n.isConnected,immediate:!1}),C(()=>{r.value&&clearInterval(r.value)}),(e,t)=>(S(),x(`div`,W,[h(U,{title:`Up Time`,value:s.value.uptimeFormatted,color:`#EBA0FC`,data:[],showChart:!1,class:`stat-card`},null,8,[`value`]),h(U,{title:`RX Packets`,value:s.value.packetsReceived,color:`#AAE8E8`,data:c.value.totalPackets,class:`stat-card`},null,8,[`value`,`data`]),h(U,{title:`Forward`,value:s.value.packetsForwarded,color:`#FFC246`,data:c.value.transmittedPackets,class:`stat-card`},null,8,[`value`,`data`]),h(U,{title:`Dropped`,value:s.value.droppedPackets,color:`#FB787B`,data:c.value.droppedPackets,class:`stat-card`},null,8,[`value`,`data`]),h(U,{title:`CRC Errors`,value:s.value.crcErrorCount,color:`#F59E0B`,data:c.value.crcErrors,class:`stat-card`},null,8,[`value`,`data`])]))}}),[[`__scopeId`,`data-v-9aa769d6`]]),K={class:`glass-card rounded-[10px] p-4 lg:p-6`},q={class:`h-48 lg:h-56 relative`},oe={key:0,class:`absolute inset-0 flex items-center justify-center`},J={key:1,class:`absolute inset-0 flex items-center justify-center`},se={class:`text-red-600 dark:text-red-400 text-sm lg:text-base`},ce={key:2,class:`absolute inset-0 flex items-center justify-center`},Y={key:3,class:`h-full flex flex-col`},X={key:0,class:`absolute top-2 left-1/2 -translate-x-1/2 bg-white/95 dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke rounded-lg px-3 py-2 z-10 pointer-events-none min-w-48`},le={class:`text-content-primary dark:text-content-primary text-sm font-medium mb-1`},ue={class:`text-content-primary dark:text-content-primary`},de={class:`flex-1 flex items-end justify-evenly gap-4 px-4`},Z=[`onMouseenter`],fe={class:`text-content-primary dark:text-content-primary text-xs sm:text-sm font-semibold text-center w-full`,style:{"padding-bottom":`5px`}},pe={class:`text-content-secondary dark:text-content-muted text-xs mt-2 text-center`},me={key:0,class:`mt-4 flex flex-wrap justify-center gap-3 sm:gap-4 px-2 sm:px-4 text-[10px] sm:text-xs text-content-secondary dark:text-content-muted`},he={class:`truncate text-left`},ge={key:1,class:`mt-3 text-xs text-content-secondary dark:text-content-muted text-center`},_e=k(u({name:`PacketTypesChart`,__name:`PacketTypesChart`,setup(e){let n=w([]),r=D(),a=O(),o=w(!0),s=w(null),c=w(null),u=[{name:`Payload`,types:[`Plain Text Message`,`Group Text Message`,`Group Datagram`,`Multi-part Packet`],subColors:[`#3B82F6`,`#60A5FA`,`#93C5FD`,`#BFDBFE`]},{name:`Requests`,types:[`Request`,`Response`,`Anonymous Request`],subColors:[`#10B981`,`#34D399`,`#6EE7B7`]},{name:`Control`,types:[`Node Advertisement`,`Acknowledgment`,`Returned Path`],subColors:[`#F59E0B`,`#FBBF24`,`#FCD34D`]},{name:`Routing`,types:[`Trace`],subColors:[`#8B5CF6`]},{name:`Reserved`,types:[`Reserved Type 11`,`Reserved Type 12`,`Reserved Type 13`],subColors:[`#6B7280`,`#9CA3AF`,`#D1D5DB`]}],d=g(()=>u.map(e=>{let t=n.value.filter(t=>e.types.some(e=>t.name.includes(e)||t.name===e)).sort((e,t)=>t.count-e.count).map((t,n)=>({...t,color:e.subColors[n%e.subColors.length]}));return{name:e.name,color:e.subColors[0],items:t,total:t.reduce((e,t)=>e+t.count,0)}}).filter(e=>e.total>0)),f=g(()=>Math.max(...d.value.map(e=>e.total),1)),h=g(()=>d.value.reduce((e,t)=>e+t.total,0)),_=async()=>{try{s.value=null;let e=await T.get(`/packet_type_graph_data`);if(e?.success&&e?.data){let t=e.data;if(t?.series){let e=[];t.series.forEach((t,n)=>{let r=0;t.data&&Array.isArray(t.data)&&(r=t.data.reduce((e,t)=>e+(t[1]||0),0)),r>0&&e.push({name:t.name||`Type ${t.type}`,type:t.type,count:r,color:``})}),n.value=e,o.value=!1}else s.value=`No series data in server response`,o.value=!1}else s.value=`Invalid response from server`,o.value=!1}catch(e){s.value=e instanceof Error?e.message:`Failed to load data`,o.value=!1}},C={0:`Request`,1:`Response`,2:`Plain Text Message`,3:`Acknowledgment`,4:`Node Advertisement`,5:`Group Text Message`,6:`Group Datagram`,7:`Anonymous Request`,8:`Returned Path`,9:`Trace`,10:`Multi-part Packet`,15:`Custom Packet`},E=()=>{let e=r.packetTypeBreakdown;!e||e.length===0||(n.value=e.map(e=>({name:C[Number(e.type)]||`Type ${e.type}`,type:e.type,count:e.count,color:``})),o.value=!1,s.value=null)},k=e=>Math.max(e/f.value*90,2),ee=(e,t)=>t===0?0:e/t*100;return i(()=>{_()}),p(()=>r.packetTypeBreakdown,()=>E(),{deep:!0,immediate:!0}),A(_,{intervalMs:3e4,enabled:()=>!a.isConnected,immediate:!0}),(e,n)=>(S(),x(`div`,K,[n[3]||=b(`div`,{class:`flex items-baseline justify-between mb-3 lg:mb-4`},[b(`h3`,{class:`text-content-primary dark:text-content-primary text-lg lg:text-xl font-semibold`},` Packet Types `),b(`p`,{class:`text-content-secondary dark:text-content-muted text-xs lg:text-sm uppercase`},` Distribution by Type `)],-1),b(`div`,q,[o.value?(S(),x(`div`,oe,[...n[1]||=[b(`div`,{class:`text-content-secondary dark:text-content-primary text-sm lg:text-base`},` Loading packet types... `,-1)]])):s.value?(S(),x(`div`,J,[b(`div`,se,v(s.value),1)])):d.value.length===0?(S(),x(`div`,ce,[...n[2]||=[b(`div`,{class:`text-content-secondary dark:text-content-primary text-sm lg:text-base`},` No packet data available `,-1)]])):(S(),x(`div`,Y,[c.value?(S(),x(`div`,X,[b(`div`,le,v(c.value.name)+` · `+v(c.value.total.toLocaleString()),1),(S(!0),x(y,null,t(c.value.items,e=>(S(),x(`div`,{key:e.type,class:`flex justify-between gap-4 text-xs text-content-secondary dark:text-content-muted`},[b(`span`,null,v(e.name),1),b(`span`,ue,v(e.count.toLocaleString()),1)]))),128))])):m(``,!0),b(`div`,de,[(S(!0),x(y,null,t(d.value,e=>(S(),x(`div`,{key:e.name,class:`flex flex-col items-center flex-1 max-w-32 h-full justify-end cursor-pointer`,onMouseenter:t=>c.value=e,onMouseleave:n[0]||=e=>c.value=null},[b(`span`,fe,v(e.total.toLocaleString()),1),b(`div`,{class:`w-full rounded-[5px] transition-all duration-300 ease-out hover:opacity-90 overflow-hidden flex flex-col-reverse`,style:l({height:k(e.total)+`%`,minHeight:`8px`})},[(S(!0),x(y,null,t(e.items,t=>(S(),x(`div`,{key:t.type,style:l({height:ee(t.count,e.total)+`%`,backgroundColor:t.color})},null,4))),128))],4),b(`span`,pe,v(e.name),1)],40,Z))),128))])]))]),d.value.length>0?(S(),x(`div`,me,[(S(!0),x(y,null,t(d.value,e=>(S(),x(`div`,{key:`legend-`+e.name,class:`flex flex-col gap-0.5 min-w-[100px] max-w-[140px] flex-shrink-0`},[(S(!0),x(y,null,t(e.items,e=>(S(),x(`div`,{key:e.type,class:`flex items-center gap-1.5`},[b(`span`,{class:`w-2 h-2 rounded-sm shrink-0`,style:l({backgroundColor:e.color})},null,4),b(`span`,he,v(e.name),1)]))),128))]))),128))])):m(``,!0),d.value.length>0?(S(),x(`div`,ge,` Total: `+v(h.value.toLocaleString())+` packets `,1)):m(``,!0)]))}}),[[`__scopeId`,`data-v-fdd759f8`]]),ve={class:`glass-card rounded-[10px] p-4 lg:p-6`},ye={class:`relative h-40 lg:h-48`},be={class:`mt-3 lg:mt-4 grid grid-cols-2 gap-3 lg:gap-4`},xe={class:`text-center`},Se={class:`text-lg lg:text-2xl font-bold text-content-primary dark:text-content-primary`},Ce={class:`text-center`},we={class:`text-lg lg:text-2xl font-bold text-content-primary dark:text-content-primary`},Te={class:`mt-2 lg:mt-3 grid grid-cols-3 gap-2 lg:gap-3 text-center`},Ee={class:`text-xs lg:text-sm font-semibold text-accent-purple flex items-center justify-center gap-1`},De={key:0,class:`inline-block w-1.5 h-1.5 rounded-full bg-secondary opacity-70`,title:`Early data - limited uptime`},Oe={class:`text-xs text-content-secondary dark:text-content-muted`},ke={class:`text-xs lg:text-sm font-semibold text-accent-red flex items-center justify-center gap-1`},Ae={key:0,class:`inline-block w-1.5 h-1.5 rounded-full bg-secondary opacity-70`,title:`Early data - limited uptime`},je={class:`text-xs text-content-secondary dark:text-content-muted`},Me={class:`text-xs lg:text-sm font-semibold text-white`},Ne=k(u({name:`AirtimeUtilizationChart`,__name:`AirtimeUtilizationChart`,setup(e){let t=D(),n=E(),o=w(null),s=w([]),l=w(!0),u=w(null),d=w(30),f=w({totalReceived:0,totalTransmitted:0,dropped:0,firstPacketTime:0}),p=w({sf:9,bwHz:62500,cr:5,preamble:17}),h=(e,t=60)=>{if(e.length===0)return[];let n=1-.5**(1/t),r=Math.min(e.length,Math.max(10,Math.floor(t/3))),i=0,a=0;for(let t=0;t(i=n*e.rxUtil+(1-n)*i,a=n*e.txUtil+(1-n)*a,{...e,rxUtil:i,txUtil:a}))},y=g(()=>{let e=t.packetStats?.total_packets||0,r=t.packetStats?.transmitted_packets||0,i=n.stats?.uptime_seconds||0,a=e||f.value.totalReceived,o=r||f.value.totalTransmitted,s=f.value.firstPacketTime>0?Math.floor(Date.now()/1e3)-f.value.firstPacketTime:0,c=i||s,l=Math.max(c/3600,.1);if(l<1){let e=Math.max(c/60,1);return{rxRate:{value:Math.round(a/e*100)/100,label:l<.5?`RX/min (early)`:`RX/min`},txRate:{value:Math.round(o/e*100)/100,label:l<.5?`TX/min (early)`:`TX/min`},confidence:`low`}}let u=Math.round(a/l*100)/100,d=Math.round(o/l*100)/100,p,m;return l<6?(p=`RX/hr (${Math.round(l)}h)`,m=`medium`):l<24?(p=`RX/hr (${Math.round(l)}h)`,m=`high`):(p=`RX/hr`,m=`high`),{rxRate:{value:u,label:p},txRate:{value:d,label:p.replace(`RX`,`TX`)},confidence:m}}),O=async()=>{l.value=!0;try{let e=60*1e3,t=Math.floor(Date.now()/1e3),n=t-24*3600,r=0;try{let e=await T.get(`/stats`);if(e.success&&e.data){let t=e.data,n=t.config;if(n?.radio){let e=n.radio;p.value={sf:e.spreading_factor??9,bwHz:e.bandwidth??62500,cr:e.coding_rate??5,preamble:e.preamble_length??17}}r=t.dropped_count??0}}catch{}let i=await T.get(`/airtime_chart_data`,{start_timestamp:n,end_timestamp:t,bucket_seconds:60,sf:p.value.sf,bw_hz:p.value.bwHz,cr:p.value.cr,preamble:p.value.preamble});if(!i.success){s.value=[],l.value=!1,a(()=>k());return}let o=i.data,c=o.buckets||[];f.value={totalReceived:o.rx_total||0,totalTransmitted:o.tx_total||0,dropped:r,firstPacketTime:c.length>0?c[0].timestamp:t};let u=24*3600/60,m=new Float64Array(u),g=new Float64Array(u);for(let t of c){let r=Math.floor((t.timestamp-n)/60);r>=0&&r[e.rxUtil,e.txUtil]))*1.05;d.value=Math.max(5,Math.ceil(x/5)*5),l.value=!1,a(()=>k())}catch(e){console.error(`Failed to fetch airtime data:`,e),s.value=[],l.value=!1,a(()=>k())}},k=()=>{if(!o.value)return;let e=o.value,t=e.getContext(`2d`);if(!t)return;let n=e.parentElement;if(!n)return;let r=n.getBoundingClientRect(),i=r.width,a=r.height;if(e.width=i*window.devicePixelRatio,e.height=a*window.devicePixelRatio,e.style.width=i+`px`,e.style.height=a+`px`,t.scale(window.devicePixelRatio,window.devicePixelRatio),t.clearRect(0,0,i,a),l.value){t.fillStyle=`#666`,t.font=`16px system-ui`,t.textAlign=`center`,t.fillText(`Loading chart data...`,i/2,a/2);return}if(s.value.length===0){t.fillStyle=`#666`,t.font=`16px system-ui`,t.textAlign=`center`,t.fillText(`No data available`,i/2,a/2);return}let c=i-45-20,u=a-40,f=d.value,p=d.value;t.strokeStyle=`rgba(255, 255, 255, 0.1)`,t.lineWidth=1,t.font=`10px system-ui`,t.textAlign=`right`;for(let e=0;e<=5;e++){let n=20+u*e/5;t.beginPath(),t.moveTo(45,n),t.lineTo(i-20,n),t.stroke();let r=f-e/5*p;t.fillStyle=`rgba(255, 255, 255, 0.5)`,t.fillText(`${r.toFixed(0)}%`,40,n+3)}for(let e=0;e<=6;e++){let n=45+c*e/6;t.beginPath(),t.moveTo(n,20),t.lineTo(n,a-20),t.stroke()}s.value.length>1&&(t.strokeStyle=`#EBA0FC`,t.lineWidth=2,t.beginPath(),s.value.forEach((e,n)=>{let r=45+c*n/(s.value.length-1),i=a-20-Math.min(e.rxUtil,d.value)/p*u;n===0?t.moveTo(r,i):t.lineTo(r,i)}),t.stroke()),s.value.length>1&&(t.strokeStyle=`#FB787B`,t.lineWidth=2,t.beginPath(),s.value.forEach((e,n)=>{let r=45+c*n/(s.value.length-1),i=a-20-Math.min(e.txUtil,d.value)/p*u;n===0?t.moveTo(r,i):t.lineTo(r,i)}),t.stroke())};return i(()=>{O(),u.value=window.setInterval(O,3e4),a(()=>{k(),setTimeout(()=>k(),100)}),window.addEventListener(`resize`,k)}),C(()=>{u.value&&clearInterval(u.value),window.removeEventListener(`resize`,k)}),(e,n)=>(S(),x(`div`,ve,[n[3]||=c(`

Airtime Utilization

Activity (Last 24 Hours)

Rx Util
Tx Util
`,3),b(`div`,ye,[b(`canvas`,{ref_key:`chartRef`,ref:o,class:`absolute inset-0 w-full h-full`},null,512)]),b(`div`,be,[b(`div`,xe,[b(`div`,Se,v(r(t).packetStats?.total_packets||f.value.totalReceived),1),n[0]||=b(`div`,{class:`text-xs text-content-secondary dark:text-content-muted uppercase tracking-wide`},` Total Received `,-1)]),b(`div`,Ce,[b(`div`,we,v(r(t).packetStats?.transmitted_packets||f.value.totalTransmitted),1),n[1]||=b(`div`,{class:`text-xs text-content-secondary dark:text-content-muted uppercase tracking-wide`},` Total Transmitted `,-1)])]),b(`div`,Te,[b(`div`,null,[b(`div`,Ee,[_(v(y.value.rxRate.value)+` `,1),y.value.confidence===`low`?(S(),x(`span`,De)):m(``,!0)]),b(`div`,Oe,v(y.value.rxRate.label),1)]),b(`div`,null,[b(`div`,ke,[_(v(y.value.txRate.value)+` `,1),y.value.confidence===`low`?(S(),x(`span`,Ae)):m(``,!0)]),b(`div`,je,v(y.value.txRate.label),1)]),b(`div`,null,[b(`div`,Me,v(r(t).packetStats?.dropped_packets||f.value.dropped),1),n[2]||=b(`div`,{class:`text-xs text-white/60`},`Dropped`,-1)])])]))}}),[[`__scopeId`,`data-v-51cd61e9`]]),Pe={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] shadow-2xl border border-stroke-subtle dark:border-white/20 flex flex-col h-full overflow-hidden`},Fe={class:`flex items-center justify-between p-8 pb-4 flex-shrink-0`},Ie={class:`text-content-secondary dark:text-content-muted text-sm`},Le={class:`flex items-center gap-2`},Re=[`title`],ze={class:`flex-1 overflow-y-auto custom-scrollbar px-8`},Be={class:`mb-6`},Ve={class:`glass-card bg-white/5 rounded-[15px] p-4`},He={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},Ue={class:`space-y-3`},We={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Ge={class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ke={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},qe={class:`text-content-primary dark:text-content-primary font-mono text-xs break-all`},Je={key:0,class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Ye={class:`text-content-primary dark:text-content-primary font-mono text-xs`},Xe={class:`space-y-3`},Ze={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Qe={class:`text-content-primary dark:text-content-primary font-semibold`},$e={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},et={class:`text-content-primary dark:text-content-primary font-semibold`},tt={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},nt={class:`mb-6`},rt={class:`bg-gray-50 dark:bg-white/5 rounded-[15px] p-4 border border-stroke-subtle dark:border-stroke/10`},it={class:`space-y-3`},at={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},ot={class:`text-content-primary dark:text-content-primary`},st={key:0,class:`pt-2`},ct={class:`glass-card bg-background-mute dark:bg-black/30 rounded-[10px] p-4 mb-4`},lt={class:`w-full overflow-x-auto`},ut={class:`text-content-primary dark:text-content-primary/90 text-xs font-mono whitespace-pre leading-relaxed min-w-full`},dt={class:`flex items-center justify-between mb-3`},ft={class:`text-content-secondary dark:text-content-primary/80 text-sm font-semibold`},pt={class:`text-content-muted dark:text-content-muted text-xs`},mt={class:`bg-background-mute dark:bg-black/40 rounded-[8px] p-3 mb-3`},ht={class:`font-mono text-xs text-content-primary dark:text-content-primary break-all whitespace-pre-wrap leading-relaxed`},gt={class:`bg-gray-50 dark:bg-white/5 rounded-[10px] overflow-hidden`},_t={key:0,class:`min-w-0`},vt={class:`text-cyan-500 text-sm font-mono break-words min-w-0`},yt={class:`text-content-primary dark:text-content-primary text-sm break-words min-w-0`},bt={class:`text-content-primary dark:text-content-primary text-sm font-semibold break-all min-w-0 overflow-hidden`},xt=[`title`],St={key:0,class:`text-orange-500 text-xs font-mono break-all min-w-0 overflow-hidden`},Ct=[`title`],wt={class:`grid grid-cols-2 gap-2`},Tt={class:`text-cyan-500 text-sm font-mono break-words`},Et={class:`text-content-primary dark:text-content-primary text-sm break-words`},Dt=[`title`],Ot={key:0},kt=[`title`],At={key:0,class:`text-content-muted dark:text-content-muted text-xs italic mt-2 px-1`},jt={key:1,class:`py-2`},Mt={class:`mb-6`},Nt={class:`bg-gray-50 dark:bg-white/5 rounded-[15px] p-4 border border-stroke-subtle dark:border-stroke/10`},Pt={class:`space-y-4`},Ft={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},It={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Lt={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Rt={key:0,class:`py-2`},zt={class:`bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},Bt={class:`flex items-center flex-wrap gap-2`},Vt={class:`relative group`},Ht={class:`relative px-3 py-2 bg-gradient-to-br from-blue-500/20 to-cyan-500/20 border border-cyan-400/40 rounded-lg transform transition-all hover:scale-105`},Ut={class:`font-mono text-[10px] font-semibold tracking-tight text-content-primary dark:text-content-primary/90 sm:text-xs`},Wt={class:`pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 transform whitespace-nowrap rounded-md bg-neutral-900 px-2 py-1 font-mono text-xs text-white opacity-0 shadow-lg ring-1 ring-white/10 transition-opacity group-hover:opacity-100`},Gt={key:0,class:`mx-2 text-cyan-600 dark:text-cyan-400/60`},Kt={key:1,class:`py-2`},qt={class:`text-content-secondary dark:text-content-muted text-sm mb-2 flex items-center`},Jt={key:0,class:`w-4 h-4 ml-2 text-yellow-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Yt={key:1,class:`text-yellow-500 text-xs ml-1`},Xt={class:`bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},Zt={class:`flex items-center flex-wrap gap-2`},Qt={class:`relative group`},$t={key:0,class:`absolute -top-1 -right-1 w-2 h-2 bg-yellow-400 rounded-full animate-pulse`},en={class:`pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 transform whitespace-nowrap rounded-md bg-neutral-900 px-2 py-1 font-mono text-xs text-white opacity-0 shadow-lg ring-1 ring-white/10 transition-opacity group-hover:opacity-100`},tn={key:0,class:`mx-1 text-orange-600 dark:text-orange-400/60`},nn={class:`mb-6`},rn={class:`glass-card bg-gray-50 dark:bg-white/5 rounded-[15px] p-4`},an={class:`grid grid-cols-1 md:grid-cols-3 gap-4 mb-4`},on={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},sn={class:`text-lg font-bold text-content-primary dark:text-content-primary`},cn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},ln={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},un={class:`text-lg font-bold text-content-primary dark:text-content-primary`},dn={key:0,class:`mb-4`},fn={class:`flex items-center gap-3`},pn={class:`flex gap-1`},mn={class:`text-content-secondary dark:text-content-primary/80 text-sm capitalize`},hn={key:1,class:`mb-4`},gn={key:2,class:`mb-4`},_n={class:`text-content-secondary dark:text-content-muted text-sm mb-3`},vn={class:`space-y-2`},yn={class:`flex items-center gap-3`},bn={class:`text-content-muted dark:text-content-muted text-sm`},xn={key:3,class:`mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke/10`},Sn={class:`grid grid-cols-1 md:grid-cols-3 gap-3 mb-4`},Cn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},wn={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},Tn={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},En={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},Dn={class:`text-content-muted dark:text-content-muted text-xs mt-1`},On={class:`text-center p-3 glass-card bg-background-mute dark:bg-black/20 rounded-[10px]`},kn={class:`text-content-muted dark:text-content-muted text-xs mt-1`},An={key:0,class:`glass-card bg-background-mute dark:bg-black/20 rounded-[10px] p-4`},jn={class:`space-y-3`},Mn={class:`flex-shrink-0 w-16 text-right`},Nn={class:`text-content-secondary dark:text-content-muted text-xs`},Pn={class:`flex-1 relative`},Fn={class:`h-8 rounded-lg overflow-hidden bg-background-mute dark:bg-stroke/5 relative`},In={class:`absolute inset-0 flex items-center px-3`},Ln={class:`text-content-primary dark:text-content-primary text-xs font-mono font-semibold`},Rn={class:`flex-shrink-0 w-12 text-left`},zn={class:`text-content-muted dark:text-content-muted text-xs`},Bn={class:`grid grid-cols-1 md:grid-cols-2 gap-4`},Vn={class:`space-y-2`},Hn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Un={class:`text-content-primary dark:text-content-primary`},Wn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Gn={class:`space-y-2`},Kn={class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},qn={key:0,class:`flex justify-between py-2 border-b border-stroke-subtle dark:border-stroke/10`},Jn={class:`text-red-600 dark:text-red-400 text-sm`},Yn={class:`p-8 pt-4 border-t border-stroke-subtle dark:border-stroke/10 flex justify-end flex-shrink-0`},Xn=k(u({name:`PacketDetailsModal`,__name:`PacketDetailsModal`,props:{packet:{},isOpen:{type:Boolean},localHash:{}},emits:[`close`],setup(n,{emit:r}){let{getSignalQuality:i}=z(),a=n,c=r,u=w(!1),f=e=>new Date(e*1e3).toLocaleString(),g=e=>e.transmitted?e.is_duplicate?`text-amber-600 dark:text-amber-400`:e.drop_reason?`text-red-600 dark:text-red-400`:`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,C=e=>e.transmitted?e.is_duplicate?`Duplicate`:e.drop_reason?`Dropped`:`Forwarded`:`Dropped`,T=e=>({0:`Request`,1:`Response`,2:`Plain Text Message`,3:`Acknowledgment`,4:`Node Advertisement`,5:`Group Text Message`,6:`Group Datagram`,7:`Anonymous Request`,8:`Returned Path`,9:`Trace`,10:`Multi-part Packet`,15:`Custom Packet`})[e]||`Unknown Type (${e})`,E=e=>({0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`})[e]||`Unknown Route (${e})`,D=e=>{if(!e)return`None`;let t=e.replace(/\s+/g,``).toUpperCase().match(/.{2}/g)||[],n=[];for(let e=0;e{try{let r=0,i=t.length/2;if(i>=100){if(t.length>=r+64){let i=t.slice(r,r+64);e.push({name:`Public Key`,byteRange:`${(n+r)/2}-${(n+r+63)/2}`,hexData:i.match(/.{8}/g)?.join(` `)||i,description:`Ed25519 public key of the node (32 bytes)`,fields:[{bits:`0-255`,name:`Ed25519 Public Key`,value:`${i.slice(0,16)}...${i.slice(-16)}`,binary:`32 bytes (256 bits)`}]}),r+=64}if(t.length>=r+8){let i=t.slice(r,r+8),a=parseInt(i,16),o=new Date(a*1e3);e.push({name:`Timestamp`,byteRange:`${(n+r)/2}-${(n+r+7)/2}`,hexData:i.match(/.{2}/g)?.join(` `)||i,description:`Unix timestamp of advertisement`,fields:[{bits:`0-31`,name:`Unix Timestamp`,value:`${a} (${o.toLocaleString()})`,binary:a.toString(2).padStart(32,`0`)}]}),r+=8}if(t.length>=r+128){let i=t.slice(r,r+128);e.push({name:`Signature`,byteRange:`${(n+r)/2}-${(n+r+127)/2}`,hexData:i.match(/.{8}/g)?.join(` `)||i,description:`Ed25519 signature of public key, timestamp, and appdata`,fields:[{bits:`0-511`,name:`Ed25519 Signature`,value:`${i.slice(0,16)}...${i.slice(-16)}`,binary:`64 bytes (512 bits)`}]}),r+=128}t.length>r&&k(e,t.slice(r),n+r)}else e.push({name:`ADVERT AppData (Partial)`,byteRange:`${n/2}-${n/2+i-1}`,hexData:t.match(/.{2}/g)?.join(` `)||t,description:`Partial ADVERT data - appears to be just AppData portion (${i} bytes)`,fields:[{bits:`0-${i*8-1}`,name:`Partial Data`,value:`${i} bytes - attempting to decode as AppData`,binary:`${i} bytes (${i*8} bits)`}]}),k(e,t,n)}catch(n){e.push({name:`ADVERT Parse Error`,byteRange:`N/A`,hexData:t.slice(0,32)+`...`,description:`Failed to parse ADVERT payload structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse error: ${n instanceof Error?n.message:`Unknown error`}`,binary:`Invalid`}]})}},k=(e,t,n)=>{try{let r=t.length/2;e.push({name:`AppData`,byteRange:`${n/2}-${n/2+r-1}`,hexData:t.match(/.{2}/g)?.join(` `)||t,description:`Node advertisement application data (${r} bytes)`,fields:[{bits:`0-${r*8-1}`,name:`Application Data`,value:`${r} bytes (contains flags, location, name, etc.)`,binary:`${r} bytes (${r*8} bits)`}]});let i=0;if(t.length>=2){let r=parseInt(t.slice(i,i+2),16),a=[],o=!!(r&16),s=!!(r&32),c=!!(r&64),l=!!(r&128);if(r&1&&a.push(`is chat node`),r&2&&a.push(`is repeater`),r&4&&a.push(`is room server`),r&8&&a.push(`is sensor`),o&&a.push(`has location`),s&&a.push(`has feature 1`),c&&a.push(`has feature 2`),l&&a.push(`has name`),e.push({name:`AppData Flags`,byteRange:`${(n+i)/2}`,hexData:`0x${t.slice(i,i+2)}`,description:`Flags indicating which optional fields are present`,fields:[{bits:`0-7`,name:`Flags`,value:a.join(`, `)||`none`,binary:r.toString(2).padStart(8,`0`)}]}),i+=2,o&&t.length>=i+16){let r=t.slice(i,i+8),a=[];for(let e=6;e>=0;e-=2)a.push(r.slice(e,e+2));let o=parseInt(a.join(``),16),s=o>2147483647?o-4294967296:o,c=s/1e6,l=t.slice(i+8,i+16),u=[];for(let e=6;e>=0;e-=2)u.push(l.slice(e,e+2));let d=parseInt(u.join(``),16),f=d>2147483647?d-4294967296:d,p=f/1e6;e.push({name:`Location Data`,byteRange:`${(n+i)/2}-${(n+i+15)/2}`,hexData:`${r.match(/.{2}/g)?.join(` `)||r} ${l.match(/.{2}/g)?.join(` `)||l}`,description:`GPS coordinates (latitude and longitude)`,fields:[{bits:`0-31`,name:`Latitude`,value:`${c.toFixed(6)}° (raw: ${s})`,binary:s.toString(2).padStart(32,`0`)},{bits:`32-63`,name:`Longitude`,value:`${p.toFixed(6)}° (raw: ${f})`,binary:f.toString(2).padStart(32,`0`)}]}),i+=16}if(s&&t.length>=i+4){let r=t.slice(i,i+4),a=parseInt(r,16);e.push({name:`Feature 1`,byteRange:`${(n+i)/2}-${(n+i+3)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Reserved feature 1 (2 bytes)`,fields:[{bits:`0-15`,name:`Feature 1 Value`,value:`${a}`,binary:a.toString(2).padStart(16,`0`)}]}),i+=4}if(c&&t.length>=i+4){let r=t.slice(i,i+4),a=parseInt(r,16);e.push({name:`Feature 2`,byteRange:`${(n+i)/2}-${(n+i+3)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Reserved feature 2 (2 bytes)`,fields:[{bits:`0-15`,name:`Feature 2 Value`,value:`${a}`,binary:a.toString(2).padStart(16,`0`)}]}),i+=4}if(l&&t.length>i){let r=t.slice(i),a=r.match(/.{2}/g)||[],o=a.map(e=>{let t=parseInt(e,16);return t>=32&&t<=126?String.fromCharCode(t):`.`}).join(``).replace(/\.+$/,``);e.push({name:`Node Name`,byteRange:`${(n+i)/2}-${(n+t.length-1)/2}`,hexData:r.match(/.{2}/g)?.join(` `)||r,description:`Node name string (${a.length} bytes)`,fields:[{bits:`0-${a.length*8-1}`,name:`Node Name`,value:`"${o}"`,binary:`ASCII text (${a.length} bytes)`}]})}}}catch(n){e.push({name:`AppData Parse Error`,byteRange:`N/A`,hexData:t.slice(0,Math.min(32,t.length)),description:`Failed to parse AppData structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse error: ${n instanceof Error?n.message:`Unknown error`}`,binary:`Invalid`}]})}},A=e=>{if(!e)return[];if(Array.isArray(e))return e;if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return[]},te=e=>{let t=[];if(!e)return t;try{let n=e.raw_packet;if(n){let e=n.replace(/\s+/g,``).toUpperCase(),r=0;if(e.length>=2){let n=e.slice(r,r+2),i=parseInt(n,16),a=i&3,o=(i&60)>>2,s=(i&192)>>6;if(t.push({name:`Header`,byteRange:`0`,hexData:`0x${n}`,description:`Contains routing type, payload type, and payload version`,fields:[{bits:`0-1`,name:`Route Type`,value:{0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`}[a]||`Unknown`,binary:a.toString(2).padStart(2,`0`)},{bits:`2-5`,name:`Payload Type`,value:{0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTIPART`,15:`RAW_CUSTOM`}[o]||`Unknown`,binary:o.toString(2).padStart(4,`0`)},{bits:`6-7`,name:`Version`,value:s.toString(),binary:s.toString(2).padStart(2,`0`)}]}),r+=2,(a===0||a===3)&&e.length>=r+8){let n=e.slice(r,r+8),i=parseInt(n.slice(0,4),16),a=parseInt(n.slice(4,8),16);t.push({name:`Transport Codes`,byteRange:`1-4`,hexData:`${n.slice(0,4)} ${n.slice(4,8)}`,description:`2x 16-bit transport codes for routing optimization`,fields:[{bits:`0-15`,name:`Code 1`,value:i.toString(),binary:i.toString(2).padStart(16,`0`)},{bits:`16-31`,name:`Code 2`,value:a.toString(),binary:a.toString(2).padStart(16,`0`)}]}),r+=8}if(e.length>=r+2){let n=e.slice(r,r+2),i=parseInt(n,16),a=(i>>6)+1,o=i&63,s=o*a;if(t.push({name:`Path Length`,byteRange:`${r/2}`,hexData:`0x${n}`,description:`${o} hop${o===1?``:`s`}, ${a}-byte hash${a>1?`es`:``} (${s} bytes)`,fields:[{bits:`6-7`,name:`Hash Size`,value:`${a}-byte`,binary:(i>>6&3).toString(2).padStart(2,`0`)},{bits:`0-5`,name:`Hop Count`,value:`${o}`,binary:(i&63).toString(2).padStart(6,`0`)}]}),r+=2,s>0&&e.length>=r+s*2){let n=e.slice(r,r+s*2),i=RegExp(`.{${a*2}}`,`g`),c=n.match(i)||[];t.push({name:`Path Data`,byteRange:`${r/2}-${(r+s*2-2)/2}`,hexData:c.join(` `)||n,description:`${o} × ${a}-byte routing hash${o===1?``:`es`}`,fields:c.map((e,t)=>({bits:`${t*a*8}-${(t+1)*a*8-1}`,name:`Hop ${t+1}`,value:e.toUpperCase(),binary:`${a} byte${a>1?`s`:``}`}))}),r+=s*2}}if(e.length>r){let n=e.slice(r),i=n.length/2;o===4?O(t,n,r):t.push({name:`Payload Data`,byteRange:`${r/2}-${r/2+i-1}`,hexData:n.match(/.{2}/g)?.join(` `)||n,description:`Application data content`,fields:[{bits:`0-${i*8-1}`,name:`Application Data`,value:`${i} bytes`,binary:`${i} bytes (${i*8} bits)`}]})}}}else{if(e.header){let n=e.header.replace(/0x/gi,``).replace(/\s+/g,``).toUpperCase(),r=parseInt(n,16),i=r&3,a=(r&60)>>2,o=(r&192)>>6;t.push({name:`Header`,byteRange:`0`,hexData:`0x${n}`,description:`Contains routing type, payload type, and payload version`,fields:[{bits:`0-1`,name:`Route Type`,value:{0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`}[i]||`Unknown`,binary:i.toString(2).padStart(2,`0`)},{bits:`2-5`,name:`Payload Type`,value:{0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTIPART`,15:`RAW_CUSTOM`}[a]||`Unknown`,binary:a.toString(2).padStart(4,`0`)},{bits:`6-7`,name:`Version`,value:o.toString(),binary:o.toString(2).padStart(2,`0`)}]}),e.transport_codes&&t.push({name:`Transport Codes`,byteRange:`1-4`,hexData:e.transport_codes,description:`2x 16-bit transport codes for routing optimization`,fields:[{bits:`0-31`,name:`Transport Codes`,value:e.transport_codes,binary:`Available in separate field`}]}),e.original_path&&e.original_path.length>0&&t.push({name:`Original Path`,byteRange:`?`,hexData:e.original_path.join(` `),description:`Original routing path (${e.original_path.length} nodes)`,fields:[{bits:`0-?`,name:`Path Nodes`,value:`${e.original_path.length} nodes`,binary:`Available as node list`}]}),e.forwarded_path&&e.forwarded_path.length>0&&t.push({name:`Forwarded Path`,byteRange:`?`,hexData:e.forwarded_path.join(` `),description:`Forwarded routing path (${e.forwarded_path.length} nodes)`,fields:[{bits:`0-?`,name:`Path Nodes`,value:`${e.forwarded_path.length} nodes`,binary:`Available as node list`}]})}if(e.payload){let n=e.payload.replace(/\s+/g,``).toUpperCase(),r=n.length/2;e.type===4?O(t,n,0):t.push({name:`Payload Data`,byteRange:`0-${r-1}`,hexData:n.match(/.{2}/g)?.join(` `)||n,description:`Application data content (${r} bytes)`,fields:[{bits:`0-${r*8-1}`,name:`Application Data`,value:`${r} bytes`,binary:`${r} bytes (${r*8} bits)`}]})}}}catch{t.push({name:`Parse Error`,byteRange:`N/A`,hexData:`Error`,description:`Unable to parse packet structure`,fields:[{bits:`N/A`,name:`Error`,value:`Parse failed`,binary:`Invalid`}]})}return t},M=(e,t)=>e==null||t==null?`text-content-muted dark:text-content-muted`:i(t).color,N=e=>{if(e==null)return{level:0,className:`signal-none`};let t=i(e),n,r;return t.bars>=5?(n=4,r=`signal-excellent`):t.bars>=4?(n=3,r=`signal-good`):t.bars>=2?(n=2,r=`signal-fair`):t.bars>=1?(n=1,r=`signal-poor`):(n=0,r=`signal-none`),{level:n,className:r}},P=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},F=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`,I=e=>{e.key===`Escape`&&c(`close`)},L=e=>{e.target===e.currentTarget&&c(`close`)};return p(()=>a.isOpen,e=>{e?document.body.style.overflow=`hidden`:document.body.style.overflow=``},{immediate:!0}),(r,i)=>(S(),o(d,{to:`body`},[h(ee,{name:`modal`,appear:``},{default:e(()=>[n.isOpen&&n.packet?(S(),x(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 overflow-hidden`,onClick:L,onKeydown:I,tabindex:`0`},[i[51]||=b(`div`,{class:`absolute inset-0 bg-black/60 backdrop-blur-md pointer-events-none`},null,-1),b(`div`,{class:`relative w-full max-w-4xl max-h-[90vh] flex flex-col`,onClick:i[3]||=j(()=>{},[`stop`])},[b(`div`,Pe,[b(`div`,Fe,[b(`div`,null,[i[4]||=b(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary mb-1`},` Packet Details `,-1),b(`p`,Ie,v(T(n.packet.type))+` - `+v(E(n.packet.route)),1)]),b(`div`,Le,[b(`button`,{onClick:i[0]||=e=>u.value=!u.value,class:s([`flex items-center gap-2 px-3 py-1.5 rounded-lg transition-all duration-200`,u.value?`bg-cyan-500/20 border border-cyan-400/30 text-cyan-600 dark:text-cyan-400`:`bg-background-mute dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-secondary dark:text-content-muted`]),title:u.value?`Hide binary values`:`Show binary values`},[...i[5]||=[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4`})],-1),b(`span`,{class:`text-xs font-medium`},`Binary`,-1)]],10,Re),b(`button`,{onClick:i[1]||=e=>c(`close`),class:`w-8 h-8 flex items-center justify-center rounded-full bg-background-mute dark:bg-white/10 hover:bg-stroke-subtle dark:hover:bg-white/20 transition-colors duration-200 text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary`},[...i[6]||=[b(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),b(`div`,ze,[b(`div`,Be,[i[13]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[b(`div`,{class:`w-2 h-2 rounded-full bg-cyan-400 mr-3`}),_(` Basic Information `)],-1),b(`div`,Ve,[b(`div`,He,[b(`div`,Ue,[b(`div`,We,[i[7]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Timestamp`,-1),b(`span`,Ge,v(f(n.packet.timestamp)),1)]),b(`div`,Ke,[i[8]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Packet Hash`,-1),b(`span`,qe,v(n.packet.packet_hash),1)]),n.packet.header?(S(),x(`div`,Je,[i[9]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Header`,-1),b(`span`,Ye,v(n.packet.header),1)])):m(``,!0)]),b(`div`,Xe,[b(`div`,Ze,[i[10]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Type`,-1),b(`span`,Qe,v(n.packet.type)+` (`+v(T(n.packet.type))+`)`,1)]),b(`div`,$e,[i[11]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Route`,-1),b(`span`,et,v(n.packet.route)+` (`+v(E(n.packet.route))+`)`,1)]),b(`div`,tt,[i[12]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Status`,-1),b(`span`,{class:s([`font-semibold`,g(n.packet)])},v(C(n.packet)),3)])])])])]),b(`div`,nt,[i[25]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[b(`div`,{class:`w-2 h-2 rounded-full bg-orange-400 mr-3`}),_(` Payload Data `)],-1),b(`div`,rt,[b(`div`,it,[b(`div`,at,[i[14]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Payload Length`,-1),b(`span`,ot,v(n.packet.payload_length||n.packet.length)+` bytes`,1)]),n.packet.payload?(S(),x(`div`,st,[i[23]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3`},` Payload Analysis `,-1),b(`div`,ct,[i[15]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-2 font-semibold`},` Raw Hex Data `,-1),b(`div`,lt,[b(`pre`,ut,v(D(n.packet.payload)),1)])]),(S(!0),x(y,null,t(te(n.packet).filter(e=>!e.name.includes(`Parse Error`)),(e,n)=>(S(),x(`div`,{key:n,class:`mb-4`},[b(`div`,dt,[b(`h4`,ft,v(e.name),1),b(`span`,pt,`Bytes `+v(e.byteRange),1)]),b(`div`,mt,[b(`div`,ht,v(e.hexData),1)]),b(`div`,gt,[b(`div`,{class:s([`hidden md:grid gap-3 p-3 bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-muted text-xs font-semibold uppercase tracking-wide`,u.value?`grid-cols-4`:`grid-cols-3`])},[i[16]||=b(`div`,{class:`min-w-0`},`Bits`,-1),i[17]||=b(`div`,{class:`min-w-0`},`Field`,-1),i[18]||=b(`div`,{class:`min-w-0`},`Value`,-1),u.value?(S(),x(`div`,_t,`Binary`)):m(``,!0)],2),(S(!0),x(y,null,t(e.fields,(e,t)=>(S(),x(`div`,{key:t,class:s([`hidden md:grid gap-3 p-3 border-b border-stroke-subtle dark:border-stroke/5 last:border-b-0 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors`,u.value?`grid-cols-4`:`grid-cols-3`])},[b(`div`,vt,v(e.bits),1),b(`div`,yt,v(e.name),1),b(`div`,bt,[b(`span`,{class:`block`,title:e.value},v(e.value),9,xt)]),u.value?(S(),x(`div`,St,[b(`span`,{class:`block`,title:e.binary},v(e.binary),9,Ct)])):m(``,!0)],2))),128)),(S(!0),x(y,null,t(e.fields,(e,t)=>(S(),x(`div`,{key:`mobile-${t}`,class:`md:hidden p-3 border-b border-stroke-subtle dark:border-stroke/5 last:border-b-0 space-y-2`},[b(`div`,wt,[b(`div`,null,[i[19]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Bits:`,-1),b(`div`,Tt,v(e.bits),1)]),b(`div`,null,[i[20]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Field:`,-1),b(`div`,Et,v(e.name),1)])]),b(`div`,null,[i[21]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Value:`,-1),b(`div`,{class:`text-content-primary dark:text-content-primary text-sm font-semibold break-all`,title:e.value},v(e.value),9,Dt)]),u.value?(S(),x(`div`,Ot,[i[22]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase tracking-wide`},`Binary:`,-1),b(`div`,{class:`text-orange-500 text-xs font-mono break-all`,title:e.binary},v(e.binary),9,kt)])):m(``,!0)]))),128))]),e.description?(S(),x(`div`,At,v(e.description),1)):m(``,!0)]))),128))])):(S(),x(`div`,jt,[...i[24]||=[b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Payload:`,-1),b(`span`,{class:`text-content-muted dark:text-content-muted ml-2`},`None`,-1)]]))])])]),b(`div`,Mt,[i[33]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4 flex items-center`},[b(`div`,{class:`w-2 h-2 rounded-full bg-purple-400 mr-3`}),_(` Path Information `)],-1),b(`div`,Nt,[b(`div`,Pt,[b(`div`,Ft,[b(`div`,It,[i[26]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Source Hash`,-1),b(`span`,{class:s([`text-content-primary dark:text-content-primary font-mono text-xs`,a.localHash&&n.packet.src_hash===a.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},v(n.packet.src_hash||`Unknown`),3)]),b(`div`,Lt,[i[27]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Destination Hash`,-1),b(`span`,{class:s([`text-content-primary dark:text-content-primary font-mono text-xs`,a.localHash&&n.packet.dst_hash===a.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},v(n.packet.dst_hash||`Broadcast`),3)])]),A(n.packet.original_path).length>0?(S(),x(`div`,Rt,[i[29]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-2`},` Original Path `,-1),b(`div`,zt,[b(`div`,Bt,[(S(!0),x(y,null,t(A(n.packet.original_path),(e,t)=>(S(),x(`div`,{key:t,class:`flex items-center`},[b(`div`,Vt,[b(`div`,Ht,[b(`div`,Ut,v(e.toUpperCase()),1)]),b(`div`,Wt,` Node: `+v(e.toUpperCase()),1)]),t0?(S(),x(`div`,Kt,[b(`div`,qt,[i[31]||=_(` Forwarded Path `,-1),JSON.stringify(A(n.packet.original_path))===JSON.stringify(A(n.packet.forwarded_path))?m(``,!0):(S(),x(`svg`,Jt,[...i[30]||=[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])),JSON.stringify(A(n.packet.original_path))===JSON.stringify(A(n.packet.forwarded_path))?m(``,!0):(S(),x(`span`,Yt,`(Modified)`))]),b(`div`,Xt,[b(`div`,Zt,[(S(!0),x(y,null,t(A(n.packet.forwarded_path),(e,t)=>(S(),x(`div`,{key:t,class:`flex items-center`},[b(`div`,Qt,[b(`div`,{class:s([`relative px-3 py-2 bg-gradient-to-br from-orange-500/20 to-yellow-500/20 border border-orange-500 dark:border-orange-400/40 rounded-lg transform transition-all hover:scale-105`,a.localHash&&e===a.localHash?`bg-gradient-to-br from-yellow-400/30 to-orange-400/30 border-yellow-300 shadow-yellow-400/20 shadow-lg`:`hover:border-orange-500 dark:border-orange-400/60`])},[b(`div`,{class:s([`font-mono text-[10px] font-semibold tracking-tight sm:text-xs`,a.localHash&&e===a.localHash?`text-yellow-200`:`text-white/90`])},v(e.toUpperCase()),3),a.localHash&&e===a.localHash?(S(),x(`div`,$t)):m(``,!0)],2),b(`div`,en,v(e.toUpperCase()),1)]),tb(`div`,{key:e,class:s([`w-2 h-6 rounded-sm transition-all duration-300`,e<=N(n.packet.rssi).level?{"signal-excellent":`bg-green-400`,"signal-good":`bg-cyan-400`,"signal-fair":`bg-yellow-400`,"signal-poor":`bg-red-400`}[N(n.packet.rssi).className]:`bg-stroke-subtle dark:bg-stroke/10`])},null,2)),64))]),b(`span`,mn,v(N(n.packet.rssi).className.replace(`signal-`,``)),1)])])),n.packet.is_trace&&n.packet.path_snr_details&&n.packet.path_snr_details.length>0?(S(),x(`div`,gn,[b(`div`,_n,` Path SNR Details (`+v(n.packet.path_snr_details.length)+` hops) `,1),b(`div`,vn,[(S(!0),x(y,null,t(n.packet.path_snr_details,(e,t)=>(S(),x(`div`,{key:t,class:`flex items-center justify-between p-2 glass-card bg-background-mute dark:bg-black/20 rounded-[8px]`},[b(`div`,yn,[b(`span`,bn,v(t+1)+`.`,1),b(`span`,{class:s([`font-mono text-xs text-content-primary dark:text-content-primary`,a.localHash&&e.hash===a.localHash?`bg-cyan-400/20 text-cyan-600 dark:text-cyan-300 px-1 rounded`:``])},v(e.hash.toUpperCase()),3)]),b(`span`,{class:s([`text-sm font-bold`,M(e.snr_db,null)])},v(e.snr_db.toFixed(1))+`dB `,3)]))),128))])])):m(``,!0),n.packet.transmitted&&n.packet.lbt_attempts!==void 0?(S(),x(`div`,xn,[i[45]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3 flex items-center`},[b(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z`})]),_(` Listen Before Talk (LBT) Metrics `)],-1),b(`div`,Sn,[b(`div`,Cn,[i[41]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` CAD Attempts `,-1),b(`div`,wn,v(n.packet.lbt_attempts),1)]),b(`div`,Tn,[i[42]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Total LBT Delay `,-1),b(`div`,En,v(F(P(n.packet.lbt_backoff_delays_ms).reduce((e,t)=>e+t,0))),1),b(`div`,Dn,v(P(n.packet.lbt_backoff_delays_ms).length)+` backoffs `,1)]),b(`div`,On,[i[43]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Channel Status `,-1),b(`div`,{class:s([`text-lg font-bold`,n.packet.lbt_channel_busy?`text-yellow-600 dark:text-yellow-400`:`text-green-600 dark:text-green-400`])},v(n.packet.lbt_channel_busy?`BUSY`:`CLEAR`),3),b(`div`,kn,v(n.packet.lbt_channel_busy?`Waited for clear`:`Immediate TX`),1)])]),P(n.packet.lbt_backoff_delays_ms).length>0?(S(),x(`div`,An,[i[44]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-3 font-semibold`},` Backoff Pattern (Exponential with Jitter) `,-1),b(`div`,jn,[(S(!0),x(y,null,t(P(n.packet.lbt_backoff_delays_ms),(e,t)=>(S(),x(`div`,{key:t,class:`flex items-center gap-3`},[b(`div`,Mn,[b(`span`,Nn,`Attempt `+v(t+1),1)]),b(`div`,Pn,[b(`div`,Fn,[b(`div`,{class:s([`h-full rounded-lg transition-all duration-300`,[t===0?`bg-gradient-to-r from-cyan-500/50 to-cyan-600/50`:t===1?`bg-gradient-to-r from-yellow-500/50 to-yellow-600/50`:t===2?`bg-gradient-to-r from-orange-500/50 to-orange-600/50`:`bg-gradient-to-r from-red-500/50 to-red-600/50`]]),style:l({width:`${Math.min(100,e/Math.max(...P(n.packet.lbt_backoff_delays_ms))*100)}%`})},[b(`div`,In,[b(`span`,Ln,v(F(e)),1)])],6)])]),b(`div`,Rn,[b(`span`,zn,v(Math.round(e/P(n.packet.lbt_backoff_delays_ms).reduce((e,t)=>e+t,0)*100))+`% `,1)])]))),128))])])):m(``,!0)])):m(``,!0),b(`div`,Bn,[b(`div`,Vn,[b(`div`,Hn,[i[46]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`TX Delay`,-1),b(`span`,Un,v(Number(n.packet.tx_delay_ms)>0?Number(n.packet.tx_delay_ms).toFixed(1)+`ms`:`-`),1)]),b(`div`,Wn,[i[47]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Transmitted`,-1),b(`span`,{class:s(n.packet.transmitted?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`)},v(n.packet.transmitted?`Yes`:`No`),3)])]),b(`div`,Gn,[b(`div`,Kn,[i[48]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Is Duplicate`,-1),b(`span`,{class:s(n.packet.is_duplicate?`text-amber-600 dark:text-amber-400`:`text-content-muted dark:text-content-muted`)},v(n.packet.is_duplicate?`Yes`:`No`),3)]),n.packet.drop_reason?(S(),x(`div`,qn,[i[49]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Drop Reason`,-1),b(`span`,Jn,v(n.packet.drop_reason),1)])):m(``,!0)])])])])]),b(`div`,Yn,[b(`button`,{onClick:i[2]||=e=>c(`close`),class:`px-6 py-2 bg-gradient-to-r from-cyan-500/20 to-cyan-400/20 hover:from-cyan-500/30 hover:to-cyan-400/30 border border-cyan-400/30 rounded-[10px] text-content-primary dark:text-content-primary transition-all duration-200 backdrop-blur-sm`},` Close `)])])])],32)):m(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-c8711b75`]]),Zn={class:`glass-card rounded-[20px] p-6`},Qn={class:`flex flex-col lg:flex-row lg:justify-between lg:items-center mb-6 gap-4 filter-container`},$n={class:`flex items-center gap-2 header-info relative`},er={class:`text-content-secondary dark:text-content-muted text-sm packet-count`},tr=[`title`],nr={class:`hidden sm:inline`},rr={key:1,class:`text-accent-red text-sm error-indicator`},ir={class:`flex items-center gap-3 lg:flex filter-controls`},ar={class:`flex flex-col`},or=[`value`],sr={class:`flex flex-col`},cr=[`value`],lr={class:`flex flex-col`},ur={class:`flex flex-col reset-container`},dr=[`disabled`],fr={class:`space-y-4 overflow-hidden`},pr={class:`space-y-4`},mr=[`onClick`],hr={class:`hidden lg:grid grid-cols-12 gap-2 items-center`},gr={class:`col-span-1 text-content-primary dark:text-content-primary text-sm`},_r={class:`col-span-1 flex items-center gap-2`},vr={class:`flex flex-col`},yr={class:`text-content-primary dark:text-content-primary text-xs`},br=[`title`],xr={class:`col-span-2`},Sr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Cr={class:`col-span-2`},wr={class:`space-y-1`},Tr={key:0,class:`flex items-center gap-0.5 flex-wrap`},Er=[`title`],Dr={key:0,class:`w-2.5 h-2.5 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Or={key:0,class:`text-[9px] text-content-muted dark:text-content-muted ml-1`},kr={key:1,class:`flex items-center gap-1`},Ar={class:`inline-block px-2 py-0.5 rounded bg-badge-cyan-bg text-badge-cyan-text text-xs font-mono`},jr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Mr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Nr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Pr={class:`col-span-1 text-content-primary dark:text-content-primary text-xs`},Fr={key:0,class:`flex items-center gap-1`},Ir={class:`col-span-1`},Lr={key:0,class:`text-accent-red text-[8px] italic truncate`},Rr={class:`lg:hidden space-y-2`},zr={class:`flex items-center justify-between`},Br={class:`flex items-center gap-2`},Vr={class:`flex flex-col`},Hr={class:`text-content-primary dark:text-content-primary text-sm font-medium`},Ur=[`title`],Wr={class:`flex items-center gap-2 text-right`},Gr={class:`text-content-secondary dark:text-content-muted text-xs`},Kr={class:`flex items-center justify-between`},qr={class:`flex items-center gap-1.5`},Jr={key:0,class:`flex flex-wrap items-center gap-0.5`},Yr=[`title`],Xr={key:0,class:`w-2.5 h-2.5 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Zr={key:0,class:`text-[9px] text-content-muted dark:text-content-muted ml-1`},Qr={class:`flex items-center gap-1`},$r={class:`inline-block px-2 py-0.5 rounded bg-badge-cyan-bg text-badge-cyan-text text-xs font-mono font-semibold`},ei={class:`flex items-center gap-0.5 text-content-muted dark:text-content-muted/60`},ti={key:0,class:`text-[9px] font-medium`,title:`Multi-hop path`},ni={class:`flex items-center gap-1`},ri={class:`flex items-center gap-2`},ii={class:`flex items-center gap-1`},ai={key:0,class:`flex gap-0.5`},oi={class:`text-content-primary dark:text-content-primary text-xs`},si={class:`flex items-center justify-between text-content-secondary dark:text-content-muted text-xs`},ci={class:`flex items-center gap-3`},li={class:`flex items-center gap-2`},ui={key:0,class:`flex items-center gap-1`},di={key:0,class:`text-accent-red text-xs italic`},fi={key:0,class:`flex justify-between items-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke pagination-container`},pi={class:`flex items-center gap-4 pagination-info`},mi={class:`text-content-secondary dark:text-content-muted text-sm`},hi={key:0,class:`flex items-center gap-2 load-more-section`},gi=[`disabled`],_i={class:`text-content-secondary dark:text-content-muted text-xs load-more-count`},vi={class:`flex items-center gap-2 pagination-controls`},yi=[`disabled`],bi={class:`flex items-center gap-1 page-numbers`},xi={key:1,class:`text-content-secondary dark:text-content-muted text-sm px-2 ellipsis`},Si=[`onClick`],Ci={key:2,class:`text-content-secondary dark:text-content-muted text-sm px-2 ellipsis`},wi=[`disabled`],Ti={key:1,class:`flex justify-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke`},Ei={class:`flex items-center gap-4`},Di={class:`text-content-secondary dark:text-content-muted text-sm`},Oi={class:`text-content-secondary dark:text-content-muted text-xs`},ki={key:2,class:`flex justify-center mt-6 pt-4 border-t border-stroke-subtle dark:border-stroke`},Q=10,$=1e3,Ai=k(u({name:`PacketTable`,__name:`PacketTable`,setup(e){let n=D(),a=O(),o=w(1),l=w(100),u=w(!1),d=w(!1),_=null;p(()=>n.isLoading,e=>{e?(_&&=(clearTimeout(_),null),d.value=!0):_=window.setTimeout(()=>{d.value=!1,_=null},600)});let T=w(null),E=w(!1),k=async e=>{if(T.value=e,E.value=!0,e.packet_hash&&(!e.header||!e.raw_packet))try{let t=await n.getPacketByHash(e.packet_hash);t&&T.value?.packet_hash===e.packet_hash&&(T.value={...T.value,...t})}catch{}},ee=()=>{E.value=!1,T.value=null},j=w(N(`packetTable_selectedType`,`all`)),P=w(N(`packetTable_selectedRoute`,`all`)),F=w(!1),I=w(null),L=[`all`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`],ne=[`all`,`1`,`2`];p(j,e=>{M(`packetTable_selectedType`,e),o.value=1}),p(P,e=>{M(`packetTable_selectedRoute`,e),o.value=1}),p(F,()=>{o.value=1});let R=g(()=>{let e=n.recentPackets;if(j.value!==`all`){let t=parseInt(j.value);e=e.filter(e=>e.type===t)}if(P.value!==`all`){let t=parseInt(P.value);e=e.filter(e=>e.route===t)}return F.value&&I.value!==null&&(e=e.filter(e=>e.timestamp>=I.value)),e}),re=g(()=>{let e=(o.value-1)*Q,t=e+Q;return R.value.slice(e,t)}),z=g(()=>Math.ceil(R.value.length/Q)),ie=g(()=>o.value===z.value),B=g(()=>n.recentPackets.length>=l.value&&l.value<$),ae=g(()=>ie.value&&B.value&&!u.value),V=e=>new Date(e*1e3).toLocaleTimeString(void 0,{hour12:!0}),H=e=>({0:`REQ`,1:`RESPONSE`,2:`TXT_MSG`,3:`ACK`,4:`ADVERT`,5:`GRP_TXT`,6:`GRP_DATA`,7:`ANON_REQ`,8:`PATH`,9:`TRACE`,10:`MULTI_PART`,11:`CONTROL`})[e]||`TYPE_${e}`,U=e=>({0:`T-Flood`,1:`Flood`,2:`Direct`,3:`T-Direct`})[e]||`Route ${e}`,W=e=>e.transmitted?`text-accent-green`:`text-primary`,G=e=>e.drop_reason?`Dropped`:e.transmitted?`Forward`:`Received`,K=e=>e===1?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-badge-neutral-bg text-badge-neutral-text`,q=e=>({0:`bg-primary`,1:`bg-accent-green`,2:`bg-secondary`,3:`bg-accent-purple`,4:`bg-accent-red`,5:`bg-accent-cyan`,6:`bg-primary`,7:`bg-accent-purple`,8:`bg-accent-green`,9:`bg-secondary`})[e]||`bg-gray-500`,oe=e=>({0:`border-l-primary`,1:`border-l-accent-green`,2:`border-l-secondary`,3:`border-l-accent-purple`,4:`border-l-accent-red`,5:`border-l-accent-cyan`,6:`border-l-primary`,7:`border-l-accent-purple`,8:`border-l-accent-green`,9:`border-l-secondary`})[e]||`border-l-gray-500`,J=e=>!e.transmitted||!e.lbt_attempts||e.lbt_attempts===0?`bg-green-400`:e.lbt_attempts===1?`bg-cyan-400`:e.lbt_attempts===2?`bg-yellow-400`:`bg-orange-400`,se=e=>e>=1e3?(e/1e3).toFixed(2)+`s`:e.toFixed(1)+`ms`,ce=e=>{if(!e)return[];if(Array.isArray(e))return e;if(typeof e==`string`)try{let t=JSON.parse(e);return typeof t==`string`?JSON.parse(t):Array.isArray(t)?t:[]}catch{return[]}return[]},Y=e=>{let t=ce(e.original_path),n=ce(e.forwarded_path),r=t.length>0?t:n;return r.length===0?null:{hops:r.length-1,nodes:r.map(e=>e.toUpperCase())}},X=e=>{if(e.type!==4||!e.payload)return null;try{let t=e.payload.replace(/\s+/g,``).toUpperCase(),n=t,r=0;if(t.length/2>=100)if(t.length>200)n=t.slice(200),r=0;else return null;if(n.length>=2){let e=parseInt(n.slice(0,2),16);r+=2;let t=!!(e&16),i=!!(e&32),a=!!(e&64);if(!(e&128))return null;if(t&&n.length>=r+16&&(r+=16),i&&n.length>=r+4&&(r+=4),a&&n.length>=r+4&&(r+=4),n.length>r){let e=(n.slice(r).match(/.{2}/g)||[]).map(e=>{let t=parseInt(e,16);return t>=32&&t<=126?String.fromCharCode(t):`.`}).join(``).replace(/\.*$/,``);return e.length>0?e:null}}}catch(e){console.error(`Error parsing ADVERT node name:`,e)}return null},le=()=>{j.value=`all`,P.value=`all`,F.value=!1,I.value=null,o.value=1},ue=()=>{F.value?(F.value=!1,I.value=null):(F.value=!0,I.value=Date.now()/1e3),o.value=1},de=g(()=>I.value?new Date(I.value*1e3).toLocaleTimeString(void 0,{hour12:!0}):``),Z=async e=>{try{let t=e||l.value;await n.fetchRecentPackets({limit:t})}catch(e){console.error(`Error fetching packet data:`,e)}},fe=async()=>{if(!(u.value||l.value>=$)){u.value=!0;try{let e=Math.min(l.value+200,$);l.value=e,await Z(e)}catch(e){console.error(`Error loading more records:`,e)}finally{u.value=!1}}};return i(async()=>{await Z()}),A(()=>Z(),{intervalMs:1e4,enabled:()=>!a.isConnected,immediate:!1}),C(()=>{_&&clearTimeout(_)}),(e,i)=>(S(),x(y,null,[b(`div`,Zn,[b(`div`,Qn,[b(`div`,$n,[i[7]||=b(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold`},` Recent Packets `,-1),b(`span`,er,` (`+v(R.value.length)+` of `+v(r(n).recentPackets.length)+`) `,1),F.value?(S(),x(`span`,{key:0,class:`text-primary text-xs sm:text-sm bg-primary/10 px-2 py-1 rounded-md border border-primary/20 live-mode-badge whitespace-nowrap`,title:`Filter activated at ${de.value}`},[b(`span`,nr,`Live Mode (since `+v(de.value)+`)`,1),i[6]||=b(`span`,{class:`sm:hidden`},`Live`,-1)],8,tr)):m(``,!0),r(n).error?(S(),x(`span`,rr,v(r(n).error),1)):m(``,!0)]),b(`div`,ir,[b(`div`,ar,[i[8]||=b(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Type`,-1),f(b(`select`,{"onUpdate:modelValue":i[0]||=e=>j.value=e,class:`glass-card border border-stroke-subtle dark:border-stroke rounded-[10px] px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all duration-200 min-w-[120px] cursor-pointer hover:border-primary/50`},[(S(),x(y,null,t(L,e=>b(`option`,{key:e,value:e,class:`bg-surface dark:bg-surface-elevated text-content-primary dark:text-content-primary`},v(e===`all`?`All Types`:`Type ${e} (${H(parseInt(e))})`),9,or)),64))],512),[[te,j.value]])]),b(`div`,sr,[i[9]||=b(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Route`,-1),f(b(`select`,{"onUpdate:modelValue":i[1]||=e=>P.value=e,class:`glass-card border border-stroke-subtle dark:border-stroke rounded-[10px] px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all duration-200 min-w-[120px] cursor-pointer hover:border-primary/50`},[(S(),x(y,null,t(ne,e=>b(`option`,{key:e,value:e,class:`bg-surface dark:bg-surface-elevated text-content-primary dark:text-content-primary`},v(e===`all`?`All Routes`:`Route ${e} (${U(parseInt(e))})`),9,cr)),64))],512),[[te,P.value]])]),b(`div`,lr,[i[10]||=b(`label`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},`Filter`,-1),b(`button`,{onClick:ue,class:s([`glass-card border rounded-[10px] px-4 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 min-w-[120px]`,{"border-primary bg-primary/10 text-primary":F.value,"border-stroke-subtle dark:border-stroke text-content-secondary dark:text-content-muted hover:border-primary hover:text-content-primary dark:hover:text-content-primary hover:bg-primary/5":!F.value}])},v(F.value?`New Only`:`Show New`),3)]),b(`div`,ur,[i[11]||=b(`label`,{class:`text-transparent text-xs mb-1`},`.`,-1),b(`button`,{onClick:le,class:s([`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[10px] px-4 py-2 text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary text-sm transition-all duration-200 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20`,{"opacity-50 cursor-not-allowed hover:border-stroke-subtle dark:hover:border-stroke hover:text-content-secondary dark:hover:text-content-muted":j.value===`all`&&P.value===`all`&&!F.value,"hover:bg-primary/10":j.value!==`all`||P.value!==`all`||F.value}]),disabled:j.value===`all`&&P.value===`all`&&!F.value},` Reset `,10,dr)])])]),i[25]||=c(``,1),b(`div`,fr,[b(`div`,pr,[(S(!0),x(y,null,t(re.value,(e,n)=>(S(),x(`div`,{key:`${e.packet_hash}_${e.timestamp}_${n}`,class:s([`packet-row border-b border-stroke-subtle dark:border-dark-border/50 pb-4 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors duration-150 cursor-pointer rounded-[10px] p-2 border-l-4`,oe(e.type)]),onClick:t=>k(e)},[b(`div`,hr,[b(`div`,gr,v(V(e.timestamp)),1),b(`div`,_r,[b(`div`,{class:s([`w-2 h-2 rounded-full`,q(e.type)])},null,2),b(`div`,vr,[b(`span`,yr,v(H(e.type)),1),e.type===4&&X(e)?(S(),x(`span`,{key:0,class:`text-accent-red/70 text-[10px] font-medium max-w-[80px] truncate`,title:X(e)||void 0},v(X(e)),9,br)):m(``,!0)])]),b(`div`,xr,[b(`span`,{class:s([`inline-block px-2 py-1 rounded text-xs font-medium`,K(e.route)])},v(U(e.route)),3)]),b(`div`,Sr,v(e.length)+`B `,1),b(`div`,Cr,[b(`div`,wr,[Y(e)?(S(),x(`div`,Tr,[(S(!0),x(y,null,t(Y(e).nodes,(t,n)=>(S(),x(y,{key:n},[b(`span`,{class:s([`inline-block max-w-full truncate px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-tight tracking-tight`,n===0?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-gray-500/20 text-content-muted dark:text-content-muted`]),title:t},v(t),11,Er),n0?(S(),x(`span`,Or,` (`+v(Y(e).hops)+` hop`+v(Y(e).hops>1?`s`:``)+`) `,1)):m(``,!0)])):(S(),x(`div`,kr,[b(`span`,Ar,v(e.src_hash?.slice(-4).toUpperCase()||`????`),1),i[13]||=b(`svg`,{class:`w-3 h-3 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1),b(`span`,{class:s([`inline-block px-2 py-0.5 rounded text-xs font-mono`,e.dst_hash?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-yellow-500/20 text-yellow-700 dark:text-yellow-300`])},v(e.dst_hash?e.dst_hash.slice(-4).toUpperCase():`BCAST`),3)]))])]),b(`div`,jr,v(e.rssi==null?`N/A`:e.rssi.toFixed(0)),1),b(`div`,Mr,v(e.snr==null?`N/A`:e.snr.toFixed(1)+`dB`),1),b(`div`,Nr,v(e.score==null?`N/A`:e.score.toFixed(2)),1),b(`div`,Pr,[Number(e.tx_delay_ms)>0?(S(),x(`div`,Fr,[e.transmitted?(S(),x(`div`,{key:0,class:s([`w-1.5 h-1.5 rounded-full flex-shrink-0`,J(e)])},null,2)):m(``,!0),b(`span`,null,v(se(Number(e.tx_delay_ms))),1)])):m(``,!0)]),b(`div`,Ir,[b(`div`,null,[b(`span`,{class:s([`text-xs font-medium`,W(e)])},v(G(e)),3),e.drop_reason?(S(),x(`p`,Lr,v(e.drop_reason),1)):m(``,!0)])])]),b(`div`,Rr,[b(`div`,zr,[b(`div`,Br,[b(`div`,{class:s([`w-2 h-2 rounded-full flex-shrink-0`,q(e.type)])},null,2),b(`div`,Vr,[b(`span`,Hr,v(H(e.type)),1),e.type===4&&X(e)?(S(),x(`span`,{key:0,class:`text-accent-red/70 text-[10px] font-medium leading-tight`,title:X(e)||void 0},v(X(e)),9,Ur)):m(``,!0)]),b(`span`,{class:s([`inline-block px-2 py-1 rounded text-xs font-medium ml-2`,K(e.route)])},v(U(e.route)),3)]),b(`div`,Wr,[b(`span`,Gr,v(V(e.timestamp)),1),b(`span`,{class:s([`text-xs font-medium`,W(e)])},v(G(e)),3)])]),b(`div`,Kr,[b(`div`,qr,[Y(e)?(S(),x(`div`,Jr,[i[15]||=b(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`PATH`,-1),(S(!0),x(y,null,t(Y(e).nodes,(t,n)=>(S(),x(y,{key:n},[b(`span`,{class:s([`inline-block max-w-full truncate px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-tight tracking-tight`,n===0?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-gray-500/20 text-content-muted dark:text-content-muted`]),title:t},v(t),11,Yr),n0?(S(),x(`span`,Zr,` (`+v(Y(e).hops)+` hop`+v(Y(e).hops>1?`s`:``)+`) `,1)):m(``,!0)])):(S(),x(y,{key:1},[b(`div`,Qr,[i[16]||=b(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`SRC`,-1),b(`span`,$r,v(e.src_hash?.slice(-4)||`????`),1)]),b(`div`,ei,[i[18]||=b(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M9 5l7 7-7 7`})],-1),e.route===1?(S(),x(`span`,ti,[...i[17]||=[b(`svg`,{class:`w-2.5 h-2.5 inline`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 5l7 7-7 7M5 5l7 7-7 7`})],-1)]])):m(``,!0)]),b(`div`,ni,[b(`span`,{class:s([`inline-block px-2 py-0.5 rounded text-xs font-mono font-semibold`,e.dst_hash?`bg-badge-cyan-bg text-badge-cyan-text`:`bg-yellow-500/20 text-yellow-700 dark:text-yellow-300`])},v(e.dst_hash?e.dst_hash.slice(-4).toUpperCase():`BCAST`),3),i[19]||=b(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] font-medium`},`DST`,-1)])],64))]),b(`div`,ri,[b(`div`,ii,[e.snr==null?m(``,!0):(S(),x(`div`,ai,[b(`div`,{class:s([`w-1 h-3 rounded-sm`,e.snr>=-10?`bg-green-400`:`bg-white/20`])},null,2),b(`div`,{class:s([`w-1 h-4 rounded-sm`,e.snr>=-5?`bg-green-400`:`bg-white/20`])},null,2),b(`div`,{class:s([`w-1 h-5 rounded-sm`,e.snr>=0?`bg-green-400`:`bg-white/20`])},null,2),b(`div`,{class:s([`w-1 h-6 rounded-sm`,e.snr>=10?`bg-green-400`:`bg-white/20`])},null,2)])),b(`span`,oi,v(e.rssi==null?`TX`:e.rssi.toFixed(0)+`dBm`),1)])])]),b(`div`,si,[b(`div`,ci,[b(`span`,null,v(e.length)+`B`,1),b(`span`,null,`SNR: `+v(e.snr==null?`N/A`:e.snr.toFixed(1)+`dB`),1),b(`span`,null,`Score: `+v(e.score==null?`N/A`:e.score.toFixed(2)),1)]),b(`div`,li,[Number(e.tx_delay_ms)>0?(S(),x(`span`,ui,[e.transmitted?(S(),x(`div`,{key:0,class:s([`w-1.5 h-1.5 rounded-full flex-shrink-0`,J(e)])},null,2)):m(``,!0),b(`span`,null,v(se(Number(e.tx_delay_ms))),1)])):m(``,!0)])]),e.drop_reason?(S(),x(`div`,di,v(e.drop_reason),1)):m(``,!0)])],10,mr))),128))])]),z.value>1?(S(),x(`div`,fi,[b(`div`,pi,[b(`span`,mi,` Showing `+v((o.value-1)*Q+1)+` - `+v(Math.min(o.value*Q,R.value.length))+` of `+v(R.value.length)+` packets `,1),ae.value?(S(),x(`div`,hi,[i[20]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`•`,-1),b(`button`,{onClick:fe,disabled:u.value,class:s([`glass-card border border-primary rounded-[8px] px-3 py-1.5 text-xs transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 hover:bg-primary/5`,{"text-primary border-primary cursor-pointer":!u.value,"text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke cursor-not-allowed opacity-50":u.value}])},v(u.value?`Loading...`:`Load ${Math.min(200,$-l.value)} more`),11,gi),b(`span`,_i,`(`+v(l.value)+`/`+v($)+` max)`,1)])):m(``,!0)]),b(`div`,vi,[b(`button`,{onClick:i[2]||=e=>--o.value,disabled:o.value<=1,class:s([`glass-card border rounded-[10px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 prev-next-btn`,{"border-stroke-subtle dark:border-stroke text-content-muted dark:text-content-muted cursor-not-allowed opacity-50":o.value<=1,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value>1}])},[...i[21]||=[b(`span`,{class:`hidden sm:inline`},`Previous`,-1),b(`span`,{class:`sm:hidden`},`‹`,-1)]],10,yi),b(`div`,bi,[o.value>3?(S(),x(`button`,{key:0,onClick:i[3]||=e=>o.value=1,class:`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[8px] px-3 py-2 text-sm text-content-primary dark:text-content-primary hover:text-primary hover:bg-primary/5 transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20`},` 1 `)):m(``,!0),o.value>4?(S(),x(`span`,xi,`...`)):m(``,!0),(S(!0),x(y,null,t(Array.from({length:Math.min(5,z.value)},(e,t)=>Math.max(1,Math.min(o.value-2,z.value-4))+t).filter(e=>e<=z.value),e=>(S(),x(`button`,{key:e,onClick:t=>o.value=e,class:s([`glass-card border rounded-[8px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 page-number`,{"border-primary bg-primary/10 text-primary":o.value===e,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value!==e}])},v(e),11,Si))),128)),o.valueo.value=z.value,class:`glass-card border border-stroke-subtle dark:border-stroke hover:border-primary rounded-[8px] px-3 py-2 text-sm text-content-primary dark:text-content-primary hover:text-primary hover:bg-primary/5 transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20`},v(z.value),1)):m(``,!0)]),b(`button`,{onClick:i[5]||=e=>o.value+=1,disabled:o.value>=z.value,class:s([`glass-card border rounded-[10px] px-3 py-2 text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-primary/20 prev-next-btn`,{"border-stroke-subtle dark:border-stroke text-content-muted dark:text-content-muted cursor-not-allowed opacity-50":o.value>=z.value,"border-stroke-subtle dark:border-stroke text-content-primary dark:text-content-primary hover:border-primary hover:text-primary hover:bg-primary/5":o.value(S(),x(`div`,null,[h(G),b(`div`,ji,[h(Ne),h(_e)]),h(Ai)]))}});export{Mi as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/GPSDiagnostics-crPCBW12.js b/repeater/web/html/assets/GPSDiagnostics-crPCBW12.js new file mode 100644 index 00000000..1166950c --- /dev/null +++ b/repeater/web/html/assets/GPSDiagnostics-crPCBW12.js @@ -0,0 +1,4104 @@ +import{Ct as e,D as t,E as n,R as r,S as i,St as a,V as o,Y as s,g as c,j as l,k as u,l as d,o as f,p,r as m,s as h,u as g,w as _,xt as v}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{c as y}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{l as b,t as x}from"./api-3gMnsCKh.js";import{t as S}from"./_plugin-vue_export-helper-B7aGp3iI.js";var C={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},w={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},T=1e3,E=1001,D=1002,O=1003,k=1004,A=1005,j=1006,ee=1007,te=1008,ne=1009,M=1010,N=1011,re=1012,ie=1013,ae=1014,oe=1015,P=1016,se=1017,ce=1018,le=1020,ue=35902,de=35899,fe=1021,pe=1022,me=1023,he=1026,ge=1027,_e=1028,ve=1029,ye=1030,be=1031,xe=1033,F=33776,Se=33777,Ce=33778,we=33779,Te=35840,Ee=35841,De=35842,Oe=35843,ke=36196,I=37492,Ae=37496,L=37488,je=37489,R=37490,z=37491,B=37808,V=37809,Me=37810,Ne=37811,Pe=37812,Fe=37813,Ie=37814,Le=37815,Re=37816,ze=37817,Be=37818,Ve=37819,He=37820,Ue=37821,We=36492,Ge=36494,Ke=36495,qe=36283,Je=36284,Ye=36285,Xe=36286,Ze=2300,Qe=2301,$e=2302,et=2303,tt=2400,nt=2401,rt=2402,it=3200,at=`srgb`,ot=`srgb-linear`,st=`linear`,ct=`srgb`,lt=7680,ut=35044,dt=35048,ft=2e3;function pt(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function mt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ht(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function gt(){let e=ht(`canvas`);return e.style.display=`block`,e}var _t={},vt=null;function yt(...e){let t=`THREE.`+e.shift();vt?vt(`log`,t,...e):console.log(t,...e)}function bt(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function H(...e){e=bt(e);let t=`THREE.`+e.shift();if(vt)vt(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function U(...e){e=bt(e);let t=`THREE.`+e.shift();if(vt)vt(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function xt(...e){let t=e.join(` `);t in _t||(_t[t]=!0,H(...e))}function St(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Ct={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},wt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+Tt[e>>16&255]+Tt[e>>24&255]+`-`+Tt[t&255]+Tt[t>>8&255]+`-`+Tt[t>>16&15|64]+Tt[t>>24&255]+`-`+Tt[n&63|128]+Tt[n>>8&255]+`-`+Tt[n>>16&255]+Tt[n>>24&255]+Tt[r&255]+Tt[r>>8&255]+Tt[r>>16&255]+Tt[r>>24&255]).toLowerCase()}function W(e,t,n){return Math.max(t,Math.min(n,e))}function At(e,t){return(e%t+t)%t}function jt(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Mt(e,t,n){return e===t?0:(n-e)/(t-e)}function Nt(e,t,n){return(1-n)*e+n*t}function Pt(e,t,n,r){return Nt(e,t,1-Math.exp(-n*r))}function Ft(e,t=1){return t-Math.abs(At(e,t*2)-t)}function It(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Lt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Rt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function zt(e,t){return e+Math.random()*(t-e)}function Bt(e){return e*(.5-Math.random())}function Vt(e){e!==void 0&&(Et=e);let t=Et+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ht(e){return e*Dt}function Ut(e){return e*Ot}function Wt(e){return(e&e-1)==0&&e!==0}function Gt(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Kt(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function qt(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:H(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Jt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function G(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Yt={DEG2RAD:Dt,RAD2DEG:Ot,generateUUID:kt,clamp:W,euclideanModulo:At,mapLinear:jt,inverseLerp:Mt,lerp:Nt,damp:Pt,pingpong:Ft,smoothstep:It,smootherstep:Lt,randInt:Rt,randFloat:zt,randFloatSpread:Bt,seededRandom:Vt,degToRad:Ht,radToDeg:Ut,isPowerOfTwo:Wt,ceilPowerOfTwo:Gt,floorPowerOfTwo:Kt,setQuaternionFromProperEuler:qt,normalize:G,denormalize:Jt},K=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=W(this.x,e.x,t.x),this.y=W(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=W(this.x,e,t),this.y=W(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(W(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(W(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Xt=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:H(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(W(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},q=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Qt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Qt.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=W(this.x,e.x,t.x),this.y=W(this.y,e.y,t.y),this.z=W(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=W(this.x,e,t),this.y=W(this.y,e,t),this.z=W(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(W(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Zt.copy(this).projectOnVector(e),this.sub(Zt)}reflect(e){return this.sub(Zt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(W(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Zt=new q,Qt=new Xt,J=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply($t.makeScale(e,t)),this}rotate(e){return this.premultiply($t.makeRotation(-e)),this}translate(e,t){return this.premultiply($t.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},$t=new J,en=new J().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),tn=new J().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function nn(){let e={enabled:!0,workingColorSpace:ot,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=rn(e.r),e.g=rn(e.g),e.b=rn(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=an(e.r),e.g=an(e.g),e.b=an(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?st:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return xt(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return xt(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[ot]:{primaries:t,whitePoint:r,transfer:st,toXYZ:en,fromXYZ:tn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:at},outputColorSpaceConfig:{drawingBufferColorSpace:at}},[at]:{primaries:t,whitePoint:r,transfer:ct,toXYZ:en,fromXYZ:tn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:at}}}),e}var Y=nn();function rn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function an(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var on,sn=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{on===void 0&&(on=ht(`canvas`)),on.width=e.width,on.height=e.height;let t=on.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=on}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=ht(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(fn).x}get height(){return this.source.getSize(fn).y}get depth(){return this.source.getSize(fn).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){H(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){H(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case T:e.x-=Math.floor(e.x);break;case E:e.x=e.x<0?0:1;break;case D:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case T:e.y-=Math.floor(e.y);break;case E:e.y=e.y<0?0:1;break;case D:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};pn.DEFAULT_IMAGE=null,pn.DEFAULT_MAPPING=300,pn.DEFAULT_ANISOTROPY=1;var mn=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;ts+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Jn)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new qn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Xn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Zn={h:0,s:0,l:0},Qn={h:0,s:0,l:0};function $n(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=at){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Y.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Y.workingColorSpace){return this.r=e,this.g=t,this.b=n,Y.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Y.workingColorSpace){if(e=At(e,1),t=W(t,0,1),n=W(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=$n(i,r,e+1/3),this.g=$n(i,r,e),this.b=$n(i,r,e-1/3)}return Y.colorSpaceToWorking(this,r),this}setStyle(e,t=at){function n(t){t!==void 0&&parseFloat(t)<1&&H(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:H(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);H(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=at){let n=Xn[e.toLowerCase()];return n===void 0?H(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=rn(e.r),this.g=rn(e.g),this.b=rn(e.b),this}copyLinearToSRGB(e){return this.r=an(e.r),this.g=an(e.g),this.b=an(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=at){return Y.workingToColorSpace(er.copy(this),e),Math.round(W(er.r*255,0,255))*65536+Math.round(W(er.g*255,0,255))*256+Math.round(W(er.b*255,0,255))}getHexString(e=at){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Y.workingColorSpace){Y.workingToColorSpace(er.copy(this),t);let n=er.r,r=er.g,i=er.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},nr=new q,rr=new q,ir=new q,ar=new q,or=new q,sr=new q,cr=new q,lr=new q,ur=new q,dr=new q,fr=new mn,pr=new mn,mr=new mn,hr=class e{constructor(e=new q,t=new q,n=new q){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),nr.subVectors(e,t),r.cross(nr);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){nr.subVectors(r,t),rr.subVectors(n,t),ir.subVectors(e,t);let a=nr.dot(nr),o=nr.dot(rr),s=nr.dot(ir),c=rr.dot(rr),l=rr.dot(ir),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ar)===null?!1:ar.x>=0&&ar.y>=0&&ar.x+ar.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,ar)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,ar.x),s.addScaledVector(a,ar.y),s.addScaledVector(o,ar.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return fr.setScalar(0),pr.setScalar(0),mr.setScalar(0),fr.fromBufferAttribute(e,t),pr.fromBufferAttribute(e,n),mr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(fr,i.x),a.addScaledVector(pr,i.y),a.addScaledVector(mr,i.z),a}static isFrontFacing(e,t,n,r){return nr.subVectors(n,t),rr.subVectors(e,t),nr.cross(rr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return nr.subVectors(this.c,this.b),rr.subVectors(this.a,this.b),nr.cross(rr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;or.subVectors(r,n),sr.subVectors(i,n),lr.subVectors(e,n);let s=or.dot(lr),c=sr.dot(lr);if(s<=0&&c<=0)return t.copy(n);ur.subVectors(e,r);let l=or.dot(ur),u=sr.dot(ur);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(or,a);dr.subVectors(e,i);let f=or.dot(dr),p=sr.dot(dr);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(sr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return cr.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(cr,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(or,a).addScaledVector(sr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},gr=class{constructor(e=new q(1/0,1/0,1/0),t=new q(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,vr),vr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Er),Dr.subVectors(this.max,Er),br.subVectors(e.a,Er),xr.subVectors(e.b,Er),Sr.subVectors(e.c,Er),Cr.subVectors(xr,br),wr.subVectors(Sr,xr),Tr.subVectors(br,Sr);let t=[0,-Cr.z,Cr.y,0,-wr.z,wr.y,0,-Tr.z,Tr.y,Cr.z,0,-Cr.x,wr.z,0,-wr.x,Tr.z,0,-Tr.x,-Cr.y,Cr.x,0,-wr.y,wr.x,0,-Tr.y,Tr.x,0];return!Ar(t,br,xr,Sr,Dr)||(t=[1,0,0,0,1,0,0,0,1],!Ar(t,br,xr,Sr,Dr))?!1:(Or.crossVectors(Cr,wr),t=[Or.x,Or.y,Or.z],Ar(t,br,xr,Sr,Dr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(_r[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_r[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_r[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_r[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_r[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_r[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_r[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_r[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_r),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},_r=[new q,new q,new q,new q,new q,new q,new q,new q],vr=new q,yr=new gr,br=new q,xr=new q,Sr=new q,Cr=new q,wr=new q,Tr=new q,Er=new q,Dr=new q,Or=new q,kr=new q;function Ar(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){kr.fromArray(e,a);let o=i.x*Math.abs(kr.x)+i.y*Math.abs(kr.y)+i.z*Math.abs(kr.z),s=t.dot(kr),c=n.dot(kr),l=r.dot(kr);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var jr=new q,Mr=new K,Nr=0,Pr=class extends wt{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:Nr++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ut,this.updateRanges=[],this.gpuType=oe,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;zr.subVectors(e,this.center);let t=zr.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(zr,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Br.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zr.copy(e.center).add(Br)),this.expandByPoint(zr.copy(e.center).sub(Br))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Hr=0,Ur=new yn,Wr=new Kn,Gr=new q,Kr=new gr,qr=new gr,Jr=new q,Yr=class e extends wt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Hr++}),this.uuid=kt(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(pt(e)?Ir:Fr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new J().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ur.makeRotationFromQuaternion(e),this.applyMatrix4(Ur),this}rotateX(e){return Ur.makeRotationX(e),this.applyMatrix4(Ur),this}rotateY(e){return Ur.makeRotationY(e),this.applyMatrix4(Ur),this}rotateZ(e){return Ur.makeRotationZ(e),this.applyMatrix4(Ur),this}translate(e,t,n){return Ur.makeTranslation(e,t,n),this.applyMatrix4(Ur),this}scale(e,t,n){return Ur.makeScale(e,t,n),this.applyMatrix4(Ur),this}lookAt(e){return Wr.lookAt(e),Wr.updateMatrix(),this.applyMatrix4(Wr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gr).negate(),this.translate(Gr.x,Gr.y,Gr.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&H(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){U(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){H(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){H(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},ti=class extends ei{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},ni,ri=new q,ii=new q,ai=new q,oi=new K,si=new K,ci=new yn,li=new q,ui=new q,di=new q,fi=new K,pi=new K,mi=new K,hi=class extends Kn{constructor(e=new ti){if(super(),this.isSprite=!0,this.type=`Sprite`,ni===void 0){ni=new Yr;let e=new Xr(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);ni.setIndex([0,1,2,0,2,3]),ni.setAttribute(`position`,new Qr(e,3,0,!1)),ni.setAttribute(`uv`,new Qr(e,2,3,!1))}this.geometry=ni,this.material=e,this.center=new K(.5,.5),this.count=1}raycast(e,t){e.camera===null&&U(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),ii.setFromMatrixScale(this.matrixWorld),ci.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ai.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ii.multiplyScalar(-ai.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;gi(li.set(-.5,-.5,0),ai,a,ii,r,i),gi(ui.set(.5,-.5,0),ai,a,ii,r,i),gi(di.set(.5,.5,0),ai,a,ii,r,i),fi.set(0,0),pi.set(1,0),mi.set(1,1);let o=e.ray.intersectTriangle(li,ui,di,!1,ri);if(o===null&&(gi(ui.set(-.5,.5,0),ai,a,ii,r,i),pi.set(0,1),o=e.ray.intersectTriangle(li,di,ui,!1,ri),o===null))return;let s=e.ray.origin.distanceTo(ri);se.far||t.push({distance:s,point:ri.clone(),uv:hr.getInterpolation(ri,li,ui,di,fi,pi,mi,new K),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function gi(e,t,n,r,i,a){oi.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?si.copy(oi):(si.x=a*oi.x-i*oi.y,si.y=i*oi.x+a*oi.y),e.copy(t),e.x+=si.x,e.y+=si.y,e.applyMatrix4(ci)}var _i=new q,vi=new q,yi=new q,bi=new q,xi=new q,Si=new q,Ci=new q,wi=class{constructor(e=new q,t=new q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_i)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=_i.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_i.copy(this.origin).addScaledVector(this.direction,t),_i.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){vi.copy(e).add(t).multiplyScalar(.5),yi.copy(t).sub(e).normalize(),bi.copy(this.origin).sub(vi);let i=e.distanceTo(t)*.5,a=-this.direction.dot(yi),o=bi.dot(this.direction),s=-bi.dot(yi),c=bi.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(vi).addScaledVector(yi,d),f}intersectSphere(e,t){_i.subVectors(e.center,this.origin);let n=_i.dot(this.direction),r=_i.dot(_i)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,_i)!==null}intersectTriangle(e,t,n,r,i){xi.subVectors(t,e),Si.subVectors(n,e),Ci.crossVectors(xi,Si);let a=this.direction.dot(Ci),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;bi.subVectors(this.origin,e);let s=o*this.direction.dot(Si.crossVectors(bi,Si));if(s<0)return null;let c=o*this.direction.dot(xi.cross(bi));if(c<0||s+c>a)return null;let l=-o*bi.dot(Ci);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ti=class extends ei{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ei=new yn,Di=new wi,Oi=new Vr,ki=new q,Ai=new q,ji=new q,Mi=new q,Ni=new q,Pi=new q,Fi=new q,Ii=new q,Li=class extends Kn{constructor(e=new Yr,t=new Ti){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Ei.copy(i).invert(),Di.copy(e.ray).applyMatrix4(Ei),!(n.boundingBox!==null&&Di.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Di)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:Ii.clone(),object:e}}function zi(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Ai),e.getVertexPosition(c,ji),e.getVertexPosition(l,Mi);let u=Ri(e,t,n,r,Ai,ji,Mi,Fi);if(u){let e=new q;hr.getBarycoord(Fi,Ai,ji,Mi,e),i&&(u.uv=hr.getInterpolatedAttribute(i,s,c,l,e,new K)),a&&(u.uv1=hr.getInterpolatedAttribute(a,s,c,l,e,new K)),o&&(u.normal=hr.getInterpolatedAttribute(o,s,c,l,e,new q),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new q,materialIndex:0};hr.getNormal(Ai,ji,Mi,t.normal),u.face=t,u.barycoord=e}return u}var Bi=class extends pn{constructor(e=null,t=1,n=1,r,i,a,o,s,c=O,l=O,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Vi=new q,Hi=new q,Ui=new J,Wi=class{constructor(e=new q(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Vi.subVectors(n,t).cross(Hi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(Vi),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Ui.getNormalMatrix(e),r=this.coplanarPoint(Vi).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Gi=new Vr,Ki=new K(.5,.5),qi=new q,Ji=class{constructor(e=new Wi,t=new Wi,n=new Wi,r=new Wi,i=new Wi,a=new Wi){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ft,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Gi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Gi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gi)}intersectsSprite(e){return Gi.center.set(0,0,0),Gi.radius=.7071067811865476+Ki.distanceTo(e.center),Gi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gi)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,qi.y=r.normal.y>0?e.max.y:e.min.y,qi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(qi)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Yi=class extends ei{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Xi=new q,Zi=new q,Qi=new yn,$i=new wi,ea=new Vr,ta=new q,na=new q,ra=class extends Kn{constructor(e=new Yr,t=new Yi){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;ta.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(ta);if(!(ct.far))return{distance:c,point:na.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var aa=class extends pn{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},oa=class extends pn{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},sa=class extends pn{constructor(e,t,n=ae,r,i,a,o=O,s=O,c,l=he,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ln(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ca=class extends sa{constructor(e,t=ae,n=301,r,i,a=O,o=O,s,c=he){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},la=class extends pn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ua=class e extends Yr{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Lr(c,3)),this.setAttribute(`normal`,new Lr(l,3)),this.setAttribute(`uv`,new Lr(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new q;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Sa=class extends xa{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Ca=class extends ei{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new X(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wa=class extends ei{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=it,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Ta=class extends ei{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Ea(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Da=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(U(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(U(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){U(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){U(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&mt(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){U(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===$e,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Ma.prototype.ValueTypeName=``,Ma.prototype.TimeBufferType=Float32Array,Ma.prototype.ValueBufferType=Float32Array,Ma.prototype.DefaultInterpolation=Qe;var Na=class extends Ma{constructor(e,t,n){super(e,t,n)}};Na.prototype.ValueTypeName=`bool`,Na.prototype.ValueBufferType=Array,Na.prototype.DefaultInterpolation=Ze,Na.prototype.InterpolantFactoryMethodLinear=void 0,Na.prototype.InterpolantFactoryMethodSmooth=void 0;var Pa=class extends Ma{constructor(e,t,n,r){super(e,t,n,r)}};Pa.prototype.ValueTypeName=`color`;var Fa=class extends Ma{constructor(e,t,n,r){super(e,t,n,r)}};Fa.prototype.ValueTypeName=`number`;var Ia=class extends Da{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Xt.slerpFlat(i,0,a,c-o,a,c,s);return i}},La=class extends Ma{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Ia(this.times,this.values,this.getValueSize(),e)}};La.prototype.ValueTypeName=`quaternion`,La.prototype.InterpolantFactoryMethodSmooth=void 0;var Ra=class extends Ma{constructor(e,t,n){super(e,t,n)}};Ra.prototype.ValueTypeName=`string`,Ra.prototype.ValueBufferType=Array,Ra.prototype.DefaultInterpolation=Ze,Ra.prototype.InterpolantFactoryMethodLinear=void 0,Ra.prototype.InterpolantFactoryMethodSmooth=void 0;var za=class extends Ma{constructor(e,t,n,r){super(e,t,n,r)}};za.prototype.ValueTypeName=`vector`;var Ba={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(Va(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!Va(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Va(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var Ha=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;te.start-t.start);let t=0;for(let e=1;e 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,envmap_fragment:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,envmap_vertex:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,skinning_vertex:`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,skinnormal_vertex:`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,distance_vert:`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},Q={common:{diffuse:{value:new X(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new J},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new J}},envmap:{envMap:{value:null},envMapRotation:{value:new J},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new J}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new J}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new J},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new J},normalScale:{value:new K(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new J},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new J}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new J}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new J}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new X(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new q},probesMax:{value:new q},probesResolution:{value:new q}},points:{diffuse:{value:new X(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0},uvTransform:{value:new J}},sprite:{diffuse:{value:new X(16777215)},opacity:{value:1},center:{value:new K(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new J},alphaMap:{value:null},alphaMapTransform:{value:new J},alphaTest:{value:0}}},Lo={basic:{uniforms:ma([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.fog]),vertexShader:Z.meshbasic_vert,fragmentShader:Z.meshbasic_frag},lambert:{uniforms:ma([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new X(0)},envMapIntensity:{value:1}}]),vertexShader:Z.meshlambert_vert,fragmentShader:Z.meshlambert_frag},phong:{uniforms:ma([Q.common,Q.specularmap,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,Q.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Z.meshphong_vert,fragmentShader:Z.meshphong_frag},standard:{uniforms:ma([Q.common,Q.envmap,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.roughnessmap,Q.metalnessmap,Q.fog,Q.lights,{emissive:{value:new X(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag},toon:{uniforms:ma([Q.common,Q.aomap,Q.lightmap,Q.emissivemap,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.gradientmap,Q.fog,Q.lights,{emissive:{value:new X(0)}}]),vertexShader:Z.meshtoon_vert,fragmentShader:Z.meshtoon_frag},matcap:{uniforms:ma([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,Q.fog,{matcap:{value:null}}]),vertexShader:Z.meshmatcap_vert,fragmentShader:Z.meshmatcap_frag},points:{uniforms:ma([Q.points,Q.fog]),vertexShader:Z.points_vert,fragmentShader:Z.points_frag},dashed:{uniforms:ma([Q.common,Q.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Z.linedashed_vert,fragmentShader:Z.linedashed_frag},depth:{uniforms:ma([Q.common,Q.displacementmap]),vertexShader:Z.depth_vert,fragmentShader:Z.depth_frag},normal:{uniforms:ma([Q.common,Q.bumpmap,Q.normalmap,Q.displacementmap,{opacity:{value:1}}]),vertexShader:Z.meshnormal_vert,fragmentShader:Z.meshnormal_frag},sprite:{uniforms:ma([Q.sprite,Q.fog]),vertexShader:Z.sprite_vert,fragmentShader:Z.sprite_frag},background:{uniforms:{uvTransform:{value:new J},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Z.background_vert,fragmentShader:Z.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new J}},vertexShader:Z.backgroundCube_vert,fragmentShader:Z.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Z.cube_vert,fragmentShader:Z.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Z.equirect_vert,fragmentShader:Z.equirect_frag},distance:{uniforms:ma([Q.common,Q.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Z.distance_vert,fragmentShader:Z.distance_frag},shadow:{uniforms:ma([Q.lights,Q.fog,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Z.shadow_vert,fragmentShader:Z.shadow_frag}};Lo.physical={uniforms:ma([Lo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new J},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new J},clearcoatNormalScale:{value:new K(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new J},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new J},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new J},sheen:{value:0},sheenColor:{value:new X(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new J},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new J},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new J},transmissionSamplerSize:{value:new K},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new J},attenuationDistance:{value:0},attenuationColor:{value:new X(0)},specularColor:{value:new X(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new J},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new J},anisotropyVector:{value:new K},anisotropyMap:{value:null},anisotropyMapTransform:{value:new J}}]),vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag};var Ro={r:0,b:0,g:0},zo=new yn,Bo=new J;Bo.set(-1,0,0,0,1,0,0,0,1);function Vo(e,t,n,r,i,a){let o=new X(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new Li(new ua(1,1,1),new xa({name:`BackgroundCubeMaterial`,uniforms:pa(Lo.backgroundCube.uniforms),vertexShader:Lo.backgroundCube.vertexShader,fragmentShader:Lo.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,`envMap`,{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(zo.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Bo),l.material.toneMapped=Y.getTransfer(i.colorSpace)!==ct,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new Li(new da(2,2),new xa({name:`BackgroundMaterial`,uniforms:pa(Lo.background.uniforms),vertexShader:Lo.background.vertexShader,fragmentShader:Lo.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,`map`,{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=Y.getTransfer(i.colorSpace)!==ct,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(Ro,_a(e)),n.buffers.color.setClear(Ro.r,Ro.g,Ro.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function Ho(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(H(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&H(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function Go(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Wi,s=new J,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=us(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ls(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=us()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ls());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;os(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Xo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-Ko?n-d+Ko:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,os(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Xo),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,os(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Xo)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&U(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*Jo-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):Jo;m>Jo&&H(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Jo}`);let h=[],g=0;for(let e=0;e_-Ko?r-_+Ko:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Xo)}};function is(e){let t=[],n=[],r=[],i=e,a=e-Ko+1+qo.length;for(let o=0;oe-Ko?s=qo[o-e+Ko-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Yr;h.setAttribute(`position`,new Pr(f,3)),h.setAttribute(`uv`,new Pr(p,2)),h.setAttribute(`faceIndex`,new Pr(m,1)),r.push(new Li(h,null)),i>Ko&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function as(e,t,n){let r=new gn(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function os(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function ss(e,t,n){return new xa({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:Yo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ds(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1})}function cs(e,t,n){let r=new Float32Array(Jo),i=new q(0,1,0);return new xa({name:`SphericalGaussianBlur`,defines:{n:Jo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:ds(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function ls(){return new xa({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:ds(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function us(){return new xa({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ds(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function ds(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}var fs=class extends gn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1};this.texture=new aa([n,n,n,n,n,n]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new ua(5,5,5),i=new xa({name:`CubemapFromEquirect`,uniforms:pa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Li(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=j),new po(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function ps(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new fs(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new rs(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new rs(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function ms(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&xt(`WebGLRenderer: `+e+` extension not supported.`),t}}}function hs(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?Ir:Fr)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new _n(h,p,m,u);g.type=oe,g.needsUpdate=!0;let _=f*4;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),l=new Li(s,c),u=new oo(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,g=[],_=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&g[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e0)return e;let i=t*n,a=Ds[i];if(a===void 0&&(a=new Float32Array(i),Ds[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Ns(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function kc(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var Ac=37297,jc=0;function Mc(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}var Nc=new J;function Pc(e){Y._getMatrix(Nc,Y.workingColorSpace,e);let t=`mat3( ${Nc.elements.map(e=>e.toFixed(4))} )`;switch(Y.getTransfer(e)){case st:return[t,`LinearTransferOETF`];case ct:return[t,`sRGBTransferOETF`];default:return H(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function Fc(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+Mc(e.getShaderSource(t),r)}else return i}function Ic(e,t){let n=Pc(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var Lc={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function Rc(e,t){let n=Lc[t];return n===void 0?(H(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var zc=new q;function Bc(){return Y.getLuminanceCoefficients(zc),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${zc.x.toFixed(4)}, ${zc.y.toFixed(4)}, ${zc.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function Vc(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(Wc).join(` +`)}function Hc(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function Uc(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Jc(e){return e.replace(qc,Xc)}var Yc=new Map;function Xc(e,t){let n=Z[t];if(n===void 0){let e=Yc.get(t);if(e!==void 0)n=Z[e],H(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return Jc(n)}var Zc=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Qc(e){return e.replace(Zc,$c)}function $c(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Wc).join(` +`),_.length>0&&(_+=` +`)):(g=[el(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(Wc).join(` +`),_=[el(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Z.tonemapping_pars_fragment,n.toneMapping===0?``:Rc(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Z.colorspace_pars_fragment,Ic(`linearToOutputTexel`,n.outputColorSpace),Bc(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(Wc).join(` +`)),o=Jc(o),o=Gc(o,n),o=Kc(o,n),s=Jc(s),s=Gc(s,n),s=Kc(s,n),o=Qc(o),s=Qc(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=kc(i,i.VERTEX_SHADER,y),S=kc(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Fc(i,x,`vertex`),n=Fc(i,S,`fragment`);U(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+o+` +`+e+` +`+n)}else o===``?(s===``||c===``)&&(u=!1):H(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new Oc(i,h),T=Uc(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,Ac)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=jc++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var dl=0,fl=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new pl(e),t.set(e,n)),n}},pl=class{constructor(e){this.id=dl++,this.code=e,this.usedTimes=0}};function ml(e){return e===1030||e===37490||e===36285}function hl(e,t,n,r,i,a){let o=new An,s=new fl,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&H(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=Lo[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),k=s.getVertexShaderID(i),A=s.getFragmentShaderID(i);let j=e.getRenderTarget(),ee=e.state.buffers.depth.getReversed(),te=h.isInstancedMesh===!0,ne=h.isBatchedMesh===!0,M=!!i.map,N=!!i.matcap,re=!!x,ie=!!i.aoMap,ae=!!i.lightMap,oe=!!i.bumpMap,P=!!i.normalMap,se=!!i.displacementMap,ce=!!i.emissiveMap,le=!!i.metalnessMap,ue=!!i.roughnessMap,de=i.anisotropy>0,fe=i.clearcoat>0,pe=i.dispersion>0,me=i.iridescence>0,he=i.sheen>0,ge=i.transmission>0,_e=de&&!!i.anisotropyMap,ve=fe&&!!i.clearcoatMap,ye=fe&&!!i.clearcoatNormalMap,be=fe&&!!i.clearcoatRoughnessMap,xe=me&&!!i.iridescenceMap,F=me&&!!i.iridescenceThicknessMap,Se=he&&!!i.sheenColorMap,Ce=he&&!!i.sheenRoughnessMap,we=!!i.specularMap,Te=!!i.specularColorMap,Ee=!!i.specularIntensityMap,De=ge&&!!i.transmissionMap,Oe=ge&&!!i.thicknessMap,ke=!!i.gradientMap,I=!!i.alphaMap,Ae=i.alphaTest>0,L=!!i.alphaHash,je=!!i.extensions,R=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(R=e.toneMapping);let z={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:ne,batchingColor:ne&&h._colorsTexture!==null,instancing:te,instancingColor:te&&h.instanceColor!==null,instancingMorph:te&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Y.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:M,matcap:N,envMap:re,envMapMode:re&&x.mapping,envMapCubeUVHeight:S,aoMap:ie,lightMap:ae,bumpMap:oe,normalMap:P,displacementMap:se,emissiveMap:ce,normalMapObjectSpace:P&&i.normalMapType===1,normalMapTangentSpace:P&&i.normalMapType===0,packedNormalMap:P&&i.normalMapType===0&&ml(i.normalMap.format),metalnessMap:le,roughnessMap:ue,anisotropy:de,anisotropyMap:_e,clearcoat:fe,clearcoatMap:ve,clearcoatNormalMap:ye,clearcoatRoughnessMap:be,dispersion:pe,iridescence:me,iridescenceMap:xe,iridescenceThicknessMap:F,sheen:he,sheenColorMap:Se,sheenRoughnessMap:Ce,specularMap:we,specularColorMap:Te,specularIntensityMap:Ee,transmission:ge,transmissionMap:De,thicknessMap:Oe,gradientMap:ke,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:I,alphaTest:Ae,alphaHash:L,combine:i.combine,mapUv:M&&m(i.map.channel),aoMapUv:ie&&m(i.aoMap.channel),lightMapUv:ae&&m(i.lightMap.channel),bumpMapUv:oe&&m(i.bumpMap.channel),normalMapUv:P&&m(i.normalMap.channel),displacementMapUv:se&&m(i.displacementMap.channel),emissiveMapUv:ce&&m(i.emissiveMap.channel),metalnessMapUv:le&&m(i.metalnessMap.channel),roughnessMapUv:ue&&m(i.roughnessMap.channel),anisotropyMapUv:_e&&m(i.anisotropyMap.channel),clearcoatMapUv:ve&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:ye&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:be&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:F&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:Se&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:Ce&&m(i.sheenRoughnessMap.channel),specularMapUv:we&&m(i.specularMap.channel),specularColorMapUv:Te&&m(i.specularColorMap.channel),specularIntensityMapUv:Ee&&m(i.specularIntensityMap.channel),transmissionMapUv:De&&m(i.transmissionMap.channel),thicknessMapUv:Oe&&m(i.thicknessMap.channel),alphaMapUv:I&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(P||de),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(M||I),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&P===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ee,skinning:h.isSkinnedMesh===!0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:R,decodeVideoTexture:M&&i.map.isVideoTexture===!0&&Y.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:ce&&i.emissiveMap.isVideoTexture===!0&&Y.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:je&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(je&&i.extensions.multiDraw===!0||ne)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return z.vertexUv1s=c.has(1),z.vertexUv2s=c.has(2),z.vertexUv3s=c.has(3),c.clear(),z}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=Lo[t];n=va.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new ul(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function gl(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function _l(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function vl(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function yl(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||_l),r.length>1&&r.sort(t||vl),i.length>1&&i.sort(t||vl)}function d(){for(let n=t,r=e.length;n=r.length?(i=new yl,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function xl(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new q,color:new X};break;case`SpotLight`:n={position:new q,direction:new q,color:new X,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new q,color:new X,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new q,skyColor:new X,groundColor:new X};break;case`RectAreaLight`:n={color:new X,position:new q,halfWidth:new q,halfHeight:new q};break}return e[t.id]=n,n}}}function Sl(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Cl=0;function wl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Tl(e){let t=new xl,n=Sl(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new q);let i=new q,a=new yn,o=new yn;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(wl);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=Q.LTC_FLOAT_1,r.rectAreaLTC2=Q.LTC_FLOAT_2):(r.rectAreaLTC1=Q.LTC_HALF_1,r.rectAreaLTC2=Q.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=Cl++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new El(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var Ol=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,kl=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,Al=[new q(1,0,0),new q(-1,0,0),new q(0,1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1)],jl=[new q(0,-1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1),new q(0,-1,0),new q(0,-1,0)],Ml=new yn,Nl=new q,Pl=new q;function Fl(e,t,n){let r=new Ji,i=new K,a=new K,o=new mn,s=new wa,c=new Ta,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new xa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new K},radius:{value:4}},vertexShader:Ol,fragmentShader:kl}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Yr;m.setAttribute(`position`,new Pr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Li(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(H(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){H(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new gn(i.x,i.y,{format:ye,type:P,minFilter:j,magFilter:j,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new sa(i.x,i.y,oe),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=he,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=O,d.map.depthTexture.magFilter=O}else l.isPointLight?(d.map=new fs(i.x),d.map.depthTexture=new ca(i.x,ae)):(d.map=new gn(i.x,i.y),d.map.depthTexture=new sa(i.x,i.y,ae)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=he,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=j,d.map.depthTexture.magFilter=j):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=O,d.map.depthTexture.magFilter=O);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(ne=parseFloat(/^WebGL (\d)/.exec(M)[1]),te=ne>=1);let N=null,re={},ie=e.getParameter(e.SCISSOR_BOX),ae=e.getParameter(e.VIEWPORT),oe=new mn().fromArray(ie),P=new mn().fromArray(ae);function se(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new K,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):ht(`canvas`)}function g(e,t,n){let r=1,i=z(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),H(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&H(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];H(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||H(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?st:Y.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,H(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),ne(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),N(t)}function ne(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&M(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function M(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function N(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&H(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),re+=1,e}function se(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function ce(t,i){let a=r.get(t);if(t.isVideoTexture&&je(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)H(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)H(`WebGLRenderer: Texture marked for update but image is incomplete`);else{be(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function le(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){be(a,t,i);return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function ue(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){be(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function de(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){xe(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let fe={[T]:e.REPEAT,[E]:e.CLAMP_TO_EDGE,[D]:e.MIRRORED_REPEAT},pe={[O]:e.NEAREST,[k]:e.NEAREST_MIPMAP_NEAREST,[A]:e.NEAREST_MIPMAP_LINEAR,[j]:e.LINEAR,[ee]:e.LINEAR_MIPMAP_NEAREST,[te]:e.LINEAR_MIPMAP_LINEAR},me={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function he(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&H(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,fe[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,fe[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,fe[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,pe[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,pe[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,me[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function _e(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=se(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&M(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function ve(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ye(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=No(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0);else H(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=No(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w)if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}let r=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,r,i,a,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=z(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=z(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),L(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,Ae(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function Se(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;L(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ae(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,Ae(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)Ce(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?Ce(i.__webglFramebuffer[0],t,0):Ce(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),Se(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),Se(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function Te(t,n,i){let a=r.get(t);n!==void 0&&F(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&we(t)}function Ee(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&L(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(L(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function je(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function R(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Y.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&H(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):U(`WebGLTextures: Unsupported texture color space:`,n)),t}function z(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=P,this.resetTextureUnits=ie,this.getTextureUnits=ae,this.setTextureUnits=oe,this.setTexture2D=ce,this.setTexture2DArray=le,this.setTexture3D=ue,this.setTextureCube=de,this.rebindTextures=Te,this.setupRenderTarget=Ee,this.updateRenderTargetMipmap=De,this.updateMultisampleRenderTarget=I,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=F,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Rl(e,t){function n(n,r=``){let i,a=Y.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var zl=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Bl=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,Vl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new la(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new xa({vertexShader:zl,fragmentShader:Bl,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Li(new da(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Hl=class extends wt{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new Vl,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new K,C=null,w=new ao;w.viewport=new mn;let T=new ao;T.viewport=new mn;let E=[w,T],D=new mo,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Yn,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Yn,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Yn,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,ee);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let te=new q,M=new q;function N(e,t,n){te.setFromMatrixPosition(t.matrixWorld),M.setFromMatrixPosition(n.matrixWorld);let r=te.distanceTo(M),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function re(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;re(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(Ul.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(Wl),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Kl(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?H(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):H(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ql=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Jl=null;function Yl(){return Jl===null&&(Jl=new Bi(ql,16,16,ye,P),Jl.name=`DFG_LUT`,Jl.minFilter=j,Jl.magFilter=j,Jl.wrapS=E,Jl.wrapT=E,Jl.generateMipmaps=!1,Jl.needsUpdate=!0),Jl}var Xl=class{constructor(e={}){let{canvas:t=gt(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=ne}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([xe,be,ve]),g=new Set([ne,ae,re,le,se,ce]),_=new Uint32Array(4),v=new Int32Array(4),y=new q,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null;this._outputColorSpace=at;let O=0,k=0,A=null,j=-1,ee=null,M=new mn,N=new mn,ie=null,oe=new X(0),ue=0,de=t.width,fe=t.height,pe=1,me=null,he=null,ge=new mn(0,0,de,fe),_e=new mn(0,0,de,fe),ye=!1,F=new Ji,Se=!1,Ce=!1,we=new yn,Te=new q,Ee=new mn,De={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Oe=!1;function ke(){return A===null?pe:1}let I=n;function Ae(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r184`),t.addEventListener(`webglcontextlost`,Ze,!1),t.addEventListener(`webglcontextrestored`,Qe,!1),t.addEventListener(`webglcontextcreationerror`,$e,!1),I===null){let t=`webgl2`;if(I=Ae(t,e),I===null)throw Ae(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw U(`WebGLRenderer: `+e.message),e}let L,je,R,z,B,V,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je;function Ye(){L=new ms(I),L.init(),Ke=new Rl(I,L),je=new Wo(I,L,e,Ke),R=new Il(I,L),je.reversedDepthBuffer&&d&&R.buffers.depth.setReversed(!0),z=new _s(I),B=new gl,V=new Ll(I,L,R,B,je,Ke,z),Me=new ps(T),Ne=new Io(I),qe=new Ho(I,Ne),Pe=new hs(I,Ne,z,qe),Fe=new ys(I,Pe,Ne,qe,z),Ue=new vs(I,je,V),Be=new Go(B),Ie=new hl(T,Me,L,je,qe,Be),Le=new Gl(T,B),Re=new bl,ze=new Dl(L),He=new Vo(T,Me,R,Fe,p,s),Ve=new Fl(T,Fe,je),Je=new Kl(I,z,je,R),We=new Uo(I,L,z),Ge=new gs(I,L,z),z.programs=Ie.programs,T.capabilities=je,T.extensions=L,T.properties=B,T.renderLists=Re,T.shadowMap=Ve,T.state=R,T.info=z}Ye(),m!==1009&&(w=new xs(m,t.width,t.height,r,i));let Xe=new Hl(T,I);this.xr=Xe,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let e=L.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=L.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return pe},this.setPixelRatio=function(e){e!==void 0&&(pe=e,this.setSize(de,fe,!1))},this.getSize=function(e){return e.set(de,fe)},this.setSize=function(e,n,r=!0){if(Xe.isPresenting){H(`WebGLRenderer: Can't change size while VR device is presenting.`);return}de=e,fe=n,t.width=Math.floor(e*pe),t.height=Math.floor(n*pe),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(de*pe,fe*pe).floor()},this.setDrawingBufferSize=function(e,n,r){de=e,fe=n,pe=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){U(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}L.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let it=null;function ot(e){it&&it(e)}function st(){lt.stop()}function ct(){lt.start()}let lt=new Fo;lt.setAnimationLoop(ot),typeof self<`u`&<.setContext(self),this.setAnimationLoop=function(e){it=e,Xe.setAnimationLoop(e),e===null?lt.stop():lt.start()},Xe.addEventListener(`sessionstart`,st),Xe.addEventListener(`sessionend`,ct),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){U(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Xe.enabled===!0&&Xe.isPresenting===!0,r=w!==null&&(A===null||n)&&w.begin(T,A);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Xe.enabled===!0&&Xe.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Xe.cameraAutoUpdate===!0&&Xe.updateCamera(t),t=Xe.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,A),x=ze.get(e,C.length),x.init(t),x.state.textureUnits=V.getTextureUnits(),C.push(x),we.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),F.setFromProjectionMatrix(we,ft,t.reversedDepth),Ce=this.localClippingEnabled,Se=Be.init(this.clippingPlanes,Ce),b=Re.get(e,S.length),b.init(),S.push(b),Xe.enabled===!0&&Xe.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&ut(e,t,-1/0,T.sortObjects)}ut(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(me,he),Oe=Xe.enabled===!1||Xe.isPresenting===!1||Xe.hasDepthSensing()===!1,Oe&&He.addToRenderList(b,e),this.info.render.frame++,Se===!0&&Be.beginShadows();let i=x.state.shadowsArray;if(Ve.render(i,e,t),Se===!0&&Be.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&pt(n,r,e,t),Oe&&He.render(e),dt(b,e,t)}A!==null&&k===0&&(V.updateMultisampleRenderTarget(A),V.updateRenderTargetMipmap(A)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),qe.resetDefaultState(),j=-1,ee=null,C.pop(),C.length>0?(x=C[C.length-1],V.setTextureUnits(x.state.textureUnits),Se===!0&&Be.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function ut(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||F.intersectsSprite(e)){r&&Ee.setFromMatrixPosition(e.matrixWorld).applyMatrix4(we);let t=Fe.update(e),i=e.material;i.visible&&b.push(e,t,i,n,Ee.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||F.intersectsObject(e))){let t=Fe.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),Ee.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),Ee.copy(e.boundingSphere.center)),Ee.applyMatrix4(e.matrixWorld).applyMatrix4(we)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&mt(i,t,n),a.length>0&&mt(a,t,n),o.length>0&&mt(o,t,n),R.buffers.depth.setTest(!0),R.buffers.depth.setMask(!0),R.buffers.color.setMask(!0),R.setPolygonOffset(!1)}function pt(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=L.has(`EXT_color_buffer_half_float`)||L.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new gn(1,1,{generateMipmaps:!0,type:e?P:ne,minFilter:te,samples:Math.max(4,je.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Y.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||M;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(oe),ue=T.getClearAlpha(),ue<1&&T.setClearColor(16777215,.5),T.clear(),Oe&&He.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),Se===!0&&Be.setGlobalState(T.clippingPlanes,r),mt(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),L.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function vt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Oc.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function bt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function xt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=x.state.lights;if(Se===!0&&(Ce===!0||e!==ee)){let t=e===ee&&r.id===j;Be.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Be.numPlanes||v.numIntersection!==Be.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=_t(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(R.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==j&&(j=r.id,w=!0),v.needsLights){let e=xt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ee!==e){R.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(I,`projectionMatrix`,e.projectionMatrix),O.setValue(I,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(I,Te.setFromMatrixPosition(e.matrixWorld)),je.logarithmicDepthBuffer&&O.setValue(I,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(I,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(I,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&O.setValue(I,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&O.setValue(I,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){O.setOptional(I,i,`bindMatrix`),O.setOptional(I,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(I,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(O.setOptional(I,i,`batchingTexture`),O.setValue(I,`batchingTexture`,i._matricesTexture,V),O.setOptional(I,i,`batchingIdTexture`),O.setValue(I,`batchingIdTexture`,i._indirectTexture,V),O.setOptional(I,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(I,`batchingColorTexture`,i._colorsTexture,V));let te=n.morphAttributes;if((te.position!==void 0||te.normal!==void 0||te.color!==void 0)&&Ue.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(I,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=Yl()),w){if(O.setValue(I,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&wt(k,E),a&&r.fog===!0&&Le.refreshFogUniforms(k,a),Le.refreshMaterialUniforms(k,r,pe,fe,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}Oc.upload(I,vt(v),k,V)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Oc.upload(I,vt(v),k,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(I,`center`,i.center),O.setValue(I,`modelViewMatrix`,i.modelViewMatrix),O.setValue(I,`normalMatrix`,i.normalMatrix),O.setValue(I,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,M.copy(e.viewport),N.copy(e.scissor),ie=e.scissorTest}else M.copy(ge).multiplyScalar(pe).floor(),N.copy(_e).multiplyScalar(pe).floor(),ie=ye;if(n!==0&&(r=Et),R.bindFramebuffer(I.FRAMEBUFFER,r)&&R.drawBuffers(e,r),R.viewport(M),R.scissor(N),R.setScissorTest(ie),i){let r=B.get(e.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&I.readBuffer(I.COLOR_ATTACHMENT0+s),!je.textureFormatReadable(c)){U(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!je.textureTypeReadable(l)){U(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&I.readPixels(t,n,r,i,Ke.convert(c),Ke.convert(l),a)}finally{let e=A===null?null:B.get(A).__webglFramebuffer;R.bindFramebuffer(I.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){R.bindFramebuffer(I.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+s),!je.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!je.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,d),I.bufferData(I.PIXEL_PACK_BUFFER,a.byteLength,I.STREAM_READ),I.readPixels(t,n,r,i,Ke.convert(l),Ke.convert(u),0);let f=A===null?null:B.get(A).__webglFramebuffer;R.bindFramebuffer(I.FRAMEBUFFER,f);let p=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await St(I,p,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,d),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,a),I.deleteBuffer(d),I.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),I.copyTexSubImage2D(I.TEXTURE_2D,n,0,0,o,s,i,a),R.unbindTexture()};let Dt=I.createFramebuffer(),Ot=I.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ke.convert(t.format),_=Ke.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=I.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=I.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=I.TEXTURE_2D),R.activeTexture(I.TEXTURE0),R.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,t.flipY),R.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),R.pixelStorei(I.UNPACK_ALIGNMENT,t.unpackAlignment);let y=R.getParameter(I.UNPACK_ROW_LENGTH),b=R.getParameter(I.UNPACK_IMAGE_HEIGHT),x=R.getParameter(I.UNPACK_SKIP_PIXELS),S=R.getParameter(I.UNPACK_SKIP_ROWS),C=R.getParameter(I.UNPACK_SKIP_IMAGES);R.pixelStorei(I.UNPACK_ROW_LENGTH,h.width),R.pixelStorei(I.UNPACK_IMAGE_HEIGHT,h.height),R.pixelStorei(I.UNPACK_SKIP_PIXELS,l),R.pixelStorei(I.UNPACK_SKIP_ROWS,u),R.pixelStorei(I.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);R.bindFramebuffer(I.READ_FRAMEBUFFER,h.__webglFramebuffer),R.bindFramebuffer(I.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;nMath.PI&&(n-=iu),r<-Math.PI?r+=iu:r>Math.PI&&(r-=iu),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(ru.setFromSpherical(this._spherical),ru.applyQuaternion(this._quatInverse),t.copy(this.target).add(ru),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=ru.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new q(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new q(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=ru.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(eu.origin.copy(this.object.position),eu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(eu.direction))au||8*(1-this._lastQuaternion.dot(this.object.quaternion))>au||this._lastTargetPosition.distanceToSquared(this.target)>au?(this.dispatchEvent(Zl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?iu/60/60*this.autoRotateSpeed:iu/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ru.setFromMatrixColumn(t,0),ru.multiplyScalar(-e),this._panOffset.add(ru)}_panUp(e,t){this.screenSpacePanning===!0?ru.setFromMatrixColumn(t,1):(ru.setFromMatrixColumn(t,0),ru.crossVectors(this.object.up,ru)),ru.multiplyScalar(e),this._panOffset.add(ru)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;ru.copy(r).sub(this.target);let i=ru.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(iu*this._rotateDelta.x/t.clientHeight),this._rotateUp(iu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(iu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-iu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(iu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-iu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(iu*this._rotateDelta.x/t.clientHeight),this._rotateUp(iu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t{T.value.has(e)?T.value.delete(e):T.value.add(e),T.value=new Set(T.value)},D=s(null),O=s(!0),k=s(null),A=s(null),j=s(!1),ee=s(null),te=s(null),ne=s(null),M=s(!1),N=s(`Waiting for satellite data`),re=s(null),ie=s({left:`0px`,top:`0px`}),ae=f(()=>D.value?.status??{}),oe=f(()=>D.value?.fix??{}),P=f(()=>D.value?.position??{}),se=f(()=>D.value?.gps_position??D.value?.position??{}),ce=f(()=>D.value?.manual_position??null),le=f(()=>{let e=D.value?.position_meta??{},t=e.gps_fix_valid??!!ae.value.fix_valid;return{source:e.source??`gps`,source_label:e.source_label??(t?`GPS fix`:`GPS estimate`),policy:e.policy??`gps_only`,manual_config_available:!!e.manual_config_available,gps_fix_valid:t}}),ue=f(()=>D.value?.motion??{}),de=f(()=>D.value?.accuracy??{}),fe=f(()=>D.value?.time??{}),pe=f(()=>D.value?.satellites??{}),me=f(()=>D.value?.nmea??{}),he=f(()=>D.value?.source??{}),ge=e=>{D.value=e,A.value=new Date,k.value=null,O.value=!1},_e=async()=>{try{D.value||(O.value=!0),k.value=null;let e=await x.getGpsDiagnostics();if(e.success===!1)throw Error(e.error||`GPS API error`);ge(e.data??null)}catch(e){k.value=e instanceof Error?e.message:`Failed to load GPS diagnostics`}finally{O.value=!1}},ve=()=>{ee.value&&=(ee.value.close(),null)},ye=()=>{ve();let e=b(),t=e?`?token=${encodeURIComponent(e)}`:``;ee.value=new EventSource(`/api/gps-stream${t}`),ee.value.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t||typeof t!=`object`)return;let n=t;if(n.type===`snapshot`){ge(n.data??null);return}n.success===!0&&ge(n.data??null)}catch(e){console.error(`Failed to parse GPS SSE payload:`,e)}},ee.value.onerror=()=>{D.value||(k.value=`GPS live stream disconnected. Reconnecting...`,O.value=!1)}};n(async()=>{await _e(),ye()}),t(()=>{ve()});let be=e=>{let t=Number(e);return Number.isFinite(t)?t:null},xe=e=>String(Number.isInteger(e)?e:Number(e.toFixed(6))),F=(e,t=``)=>e==null||e===``?`n/a`:typeof e==`boolean`?e?`yes`:`no`:Array.isArray(e)?e.length?e.join(`, `):`none`:typeof e==`number`?`${xe(e)}${t?` ${t}`:``}`:`${String(e)}${t?` ${t}`:``}`,Se=(e,t)=>e==null||t==null?`n/a`:`${xe(e)}, ${xe(t)}`,Ce=f(()=>(ae.value.state??`unknown`).split(`_`).join(` `)),we=f(()=>{switch(ae.value.state){case`valid_fix`:return`text-accent-green`;case`error`:return`text-accent-red`;case`invalid_fix`:case`stale`:case`no_data`:case`disabled`:return`text-secondary`;default:return`text-content-muted`}}),Te=f(()=>[{label:`Fix State`,value:Ce.value,note:ae.value.last_error||`quality: ${F(oe.value.quality_label)}`,valueClass:we.value},{label:`Coordinates`,value:Se(P.value.latitude,P.value.longitude),note:`${F(le.value.source_label)} | altitude: ${F(P.value.altitude_m,`m`)}`,valueClass:`text-content-heading dark:text-white`},{label:`Satellites`,value:`${F(pe.value.used_count)} / ${F(pe.value.in_view_count)}`,note:`SNR avg: ${F(pe.value.snr?.avg,`dB`)}`,valueClass:`text-content-heading dark:text-white`},{label:`Freshness`,value:ae.value.age_seconds===null||ae.value.age_seconds===void 0?`n/a`:`${F(ae.value.age_seconds)}s`,note:ae.value.last_update||`last update unknown`,valueClass:ae.value.stale?`text-secondary`:`text-content-heading dark:text-white`},{label:`GPS Time`,value:fe.value.utc_time??`n/a`,note:fe.value.date??`no date`,valueClass:fe.value.utc_time?`text-content-heading dark:text-white`:`text-content-muted`}]),Ee=f(()=>[{title:`Receiver Source`,rows:[[`enabled`,D.value?.enabled],[`running`,D.value?.running],[`source type`,he.value.type],[`device`,he.value.device],[`baud rate`,he.value.baud_rate],[`source path`,he.value.source_path],[`read timeout`,he.value.read_timeout_seconds,`s`],[`poll interval`,he.value.poll_interval_seconds,`s`],[`stale after`,he.value.stale_after_seconds,`s`]]},{title:`Fix`,rows:[[`valid`,oe.value.valid],[`status`,oe.value.status],[`quality`,oe.value.quality],[`quality label`,oe.value.quality_label],[`GSA fix type`,oe.value.gsa_fix_type],[`GSA label`,oe.value.gsa_fix_type_label]]},{title:`Position`,rows:[[`display source`,le.value.source_label||le.value.source],[`policy`,le.value.policy],[`display latitude`,P.value.latitude],[`display longitude`,P.value.longitude],[`GPS latitude`,se.value.latitude],[`GPS longitude`,se.value.longitude],[`manual latitude`,ce.value?.latitude],[`manual longitude`,ce.value?.longitude],[`altitude`,P.value.altitude_m,`m`],[`geoid separation`,P.value.geoid_separation_m,`m`]]},{title:`Motion`,rows:[[`speed`,ue.value.speed_knots,`knots`],[`speed`,ue.value.speed_kmh,`km/h`],[`course`,ue.value.course_degrees,`deg`],[`magnetic variation`,ue.value.magnetic_variation_degrees,`deg`]]},{title:`Accuracy`,rows:[[`HDOP`,de.value.hdop],[`PDOP`,de.value.pdop],[`VDOP`,de.value.vdop]]},{title:`Time`,rows:[[`UTC time`,fe.value.utc_time],[`date`,fe.value.date],[`datetime UTC`,fe.value.datetime_utc]]},{title:`NMEA Health`,rows:[[`last talker`,me.value.last_talker],[`last sentence type`,me.value.last_sentence_type],[`seen sentence types`,me.value.seen_sentence_types],[`valid checksums`,me.value.valid_checksum_count],[`invalid checksums`,me.value.invalid_checksum_count],[`missing checksums`,me.value.missing_checksum_count],[`last sentence`,me.value.last_sentence]]}]),De=f(()=>pe.value.in_view??[]),Oe=f(()=>me.value.recent_sentences??[]),ke=s(new Map),I=f(()=>[...ke.value.values()].sort((e,t)=>e.prn.localeCompare(t.prn,void 0,{numeric:!0})));r(pe,e=>{let t=e?.in_view??[],n=new Set((e?.used_prns??[]).map(String)),r=new Set;for(let e of t){let t=String(e.prn??`?`);r.add(t);let i=ke.value.get(t);i?(i.staleTimer!==null&&(clearTimeout(i.staleTimer),i.staleTimer=null),i.data=e,i.used=n.has(t),i.stale=!1):ke.value.set(t,{prn:t,data:e,used:n.has(t),stale:!1,staleTimer:null})}for(let[e,t]of ke.value)!r.has(e)&&!t.stale&&(t.stale=!0,t.staleTimer=setTimeout(()=>{ke.value.delete(e),ke.value=new Map(ke.value)},Hd));ke.value=new Map(ke.value)},{deep:!1});let Ae=f(()=>{let e=new Set((pe.value.used_prns??[]).map(String));return De.value.map(t=>{let n=be(t.azimuth_degrees),r=be(t.elevation_degrees);if(n===null||r===null)return null;let i=Math.max(0,Math.min(60,be(t.snr_db)??0)),a=(1-Math.max(0,Math.min(90,r))/90)*82,o=n*Math.PI/180,s=t.prn??`?`;return{key:`${s}-${n}-${r}`,prn:String(s),x:100+Math.sin(o)*a,y:100-Math.cos(o)*a,size:4+i/60*7,used:e.has(String(s)),snr:i,elevation:r,azimuth:n,raw:t}}).filter(e=>e!==null)}),L=f(()=>`${Ae.value.length} sat${Ae.value.length===1?``:`s`}`),je=e=>({left:`${e.x/2}%`,top:`${e.y/2}%`,"--size":`${e.size+5}px`}),R=null,z=(e,t)=>typeof window>`u`?t:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,B=e=>{let t=Ae.value.length;if(!e){N.value=`Waiting for satellite data`;return}N.value=t?`2D fallback: ${t} satellites plotted from GSV az/el`:`Waiting for satellites in view`},V=()=>{let e=ne.value,t=te.value;if(!e||!t)throw Error(`Satellite globe container is not mounted`);let n=new tr,r=new ao(38,1,.1,100),i=new Xl({canvas:e,alpha:!0,antialias:!0,powerPreference:`low-power`}),a=new ou(r,i.domElement),o=new qn,s=new qn,c=new qn,l=new qn,u=new Oo,d=new K,f=new q,p=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,m=new Map,h=null,g=0;r.position.set(0,.1,3.72),i.setClearColor(0,0),i.setPixelRatio(Math.min(window.devicePixelRatio||1,1.5)),a.enableDamping=!0,a.dampingFactor=.08,a.enablePan=!1,a.minDistance=2.45,a.maxDistance=5.6,a.rotateSpeed=.55,a.zoomSpeed=.72,a.target.set(0,0,0),a.update(),n.add(new lo(16777215,.84));let _=new co(16777215,.78);_.position.set(2.7,2.2,3.4),n.add(_);let v=new Ca({color:new X(z(`--color-primary`,`#0d7377`)),roughness:.62,metalness:.04}),y=new Li(new fa(1,56,36),v);new Ka().load(S,e=>{e.anisotropy=window.innerWidth<1024?Math.min(2,i.capabilities.getMaxAnisotropy()):i.capabilities.getMaxAnisotropy(),v.map=e,v.color.set(16777215),v.roughness=.82,v.needsUpdate=!0},void 0,()=>{N.value=`Earth texture unavailable; using local fallback globe`});let b=new Li(new fa(1.006,28,18),new Ti({color:new X(z(`--color-primary`,`#aae8e8`)),wireframe:!0,transparent:!0,opacity:.16})),x=new Li(new fa(1.045,48,24),new Ti({color:new X(z(`--color-primary`,`#aae8e8`)),transparent:!0,opacity:.1,side:1}));o.add(y,b,x,l,c,s),n.add(o);let C=()=>{let e=t.getBoundingClientRect(),n=Math.max(240,Math.floor(e.width)),a=Math.max(240,Math.floor(e.height));i.setSize(n,a,!1),r.aspect=n/a,r.updateProjectionMatrix()},w=e=>{let t=e;t.geometry?.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(e=>{e&&(e.map?.dispose(),e.dispose())})},T=e=>{for(;e.children.length;){let t=e.children.pop();t&&(t.traverse(w),e.remove(t))}},E=(e,t,n=1)=>{let r=e*Math.PI/180,i=t*Math.PI/180;return new q(Math.cos(r)*Math.cos(i),Math.sin(r),-Math.cos(r)*Math.sin(i)).multiplyScalar(n)},D=(e,t)=>{let n=e*Math.PI/180,r=t*Math.PI/180,i=E(e,t,1).normalize();return{east:new q(-Math.sin(r),0,-Math.cos(r)).normalize(),north:new q(-Math.sin(n)*Math.cos(r),Math.cos(n),Math.sin(n)*Math.sin(r)).normalize(),up:i}},O=(e,t,n,r,i,a)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath()},k=(e,t,n,r=1,i=c)=>{let a=document.createElement(`canvas`);a.width=192,a.height=76;let o=a.getContext(`2d`);if(!o)return;o.font=`800 28px Inter, sans-serif`,o.textAlign=`center`,o.textBaseline=`middle`,O(o,20,14,152,48,16),o.fillStyle=`rgba(3, 8, 10, 0.88)`,o.fill(),o.lineWidth=3,o.strokeStyle=n,o.stroke(),o.fillStyle=`#ffffff`,o.shadowColor=`rgba(0, 0, 0, 0.92)`,o.shadowBlur=7,o.fillText(e,96,39);let s=new hi(new ti({map:new oa(a),transparent:!0,opacity:.98,depthTest:!1,depthWrite:!1}));return s.position.copy(t),s.scale.set(.3*r,.12*r,1),s.renderOrder=10,i.add(s),s},A=(e=!1)=>{h=null,re.value=null},j=(e,n)=>{let r=e.userData.satellite;if(!r)return;let i=t.getBoundingClientRect();ie.value={left:`${Math.max(86,Math.min(i.width-86,n.clientX-i.left))}px`,top:`${Math.max(84,Math.min(i.height-12,n.clientY-i.top))}px`},re.value=r},ee=t=>{let n=e.getBoundingClientRect();d.x=(t.clientX-n.left)/n.width*2-1,d.y=-((t.clientY-n.top)/n.height*2-1),u.setFromCamera(d,r);let i=[...m.values()].map(e=>e.mesh),a=u.intersectObjects(i,!1)[0];h=a?a.object:null,h?j(h,t):A()},M=(e,t,n)=>{let r=e.azimuth*Math.PI/180,i=Math.max(0,Math.min(90,e.elevation))*Math.PI/180,a=t.north.clone().multiplyScalar(Math.cos(r)).add(t.east.clone().multiplyScalar(Math.sin(r))).multiplyScalar(Math.cos(i)).add(t.up.clone().multiplyScalar(Math.sin(i))).normalize();return n.clone().add(a.multiplyScalar(.62))},ae=(e,t,n)=>{let r=M(e,t,n),i=e.used?z(`--color-accent-green`,`#a5e5b6`):z(`--color-primary`,`#aae8e8`),a=.024+e.snr/60*.042,o=new Ti({color:new X(i),transparent:!0,opacity:0}),s=new Li(new fa(a,16,12),o);s.position.copy(r),s.userData={satellite:e,used:e.used},c.add(s);let u=n.clone().multiplyScalar(1.012),d=new Pr(new Float32Array([u.x,u.y,u.z,r.x,r.y,r.z]),3);d.setUsage(dt);let f=new Yr;f.setAttribute(`position`,d);let p=new Yi({color:new X(i),transparent:!0,opacity:0}),m=new ra(f,p);l.add(m);let h=r.clone().multiplyScalar(1.035),g=new ti({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1}),_=k(e.prn,h,i,.88),v=_.material;return g.map=v.map,v.dispose(),_.material=g,{mesh:s,meshMat:o,line:m,lineMat:p,linePosAttr:d,labelSprite:_,labelMat:g,opacity:0,targetOpacity:1,pos:r.clone(),targetPos:r.clone()}},oe=(e,t)=>{let n=E(e,t,1.022),r=D(e,t),i=z(`--color-accent-green`,`#a5e5b6`),a=new Li(new fa(.032,18,14),new Ti({color:new X(i)}));a.position.copy(n),s.add(a),k(`YOU`,n.clone().multiplyScalar(1.08),i,1,s);let o=[];for(let e=0;e<=96;e+=1){let t=e/96*Math.PI*2;o.push(n.clone().add(r.north.clone().multiplyScalar(Math.cos(t)*.62)).add(r.east.clone().multiplyScalar(Math.sin(t)*.62)))}let c=new Yr().setFromPoints(o),l=new Yi({color:new X(i),transparent:!0,opacity:.28});return s.add(new ra(c,l)),{basis:r,userPosition:n}},P=e=>{let t=be(e?.position?.latitude),n=be(e?.position?.longitude);for(let e of m.values())e.targetOpacity=0;if(T(s),t===null||n===null){N.value=`Waiting for receiver position`,A();return}let r=E(t,n,1).normalize(),i=new q(.1,.1,1).normalize();o.quaternion.copy(new Xt().setFromUnitVectors(r,i));let{basis:a,userPosition:c}=oe(t,n);for(let e of Ae.value){let t=e.prn,n=M(e,a,c),r=e.used?z(`--color-accent-green`,`#a5e5b6`):z(`--color-primary`,`#aae8e8`),i=e.used?.46:.26,o=m.get(t);if(o)o.targetPos.copy(n),o.targetOpacity=1,o.meshMat.color.set(r),o.lineMat.color.set(r),o.mesh.userData={satellite:e,used:e.used},o.linePosAttr.setXYZ(1,n.x,n.y,n.z),o.linePosAttr.needsUpdate=!0,o.labelSprite.position.copy(n.clone().multiplyScalar(1.035)),o.lineMat._targetOpacity=i;else{let n=ae(e,a,c);m.set(t,n)}}N.value=Ae.value.length?`${Ae.value.length} satellites plotted from GSV az/el using ${F(le.value.source_label||`receiver position`)}`:`No satellites in view yet`},se=new ResizeObserver(C);se.observe(t),C();let ce=()=>A(!0),ue=e=>e.preventDefault();e.addEventListener(`pointermove`,ee),e.addEventListener(`pointerleave`,ce),e.addEventListener(`wheel`,ue,{passive:!1});let de=()=>{p||(x.rotation.y+=.0012,b.rotation.y+=5e-4),a.update();let e=[];for(let[t,n]of m){n.opacity+=(n.targetOpacity-n.opacity)*.08;let r=Math.max(0,Math.min(1,n.opacity));n.meshMat.opacity=r;let i=(n.lineMat._targetOpacity??.46)*r;n.lineMat.opacity=i,n.labelMat.opacity=r,n.pos.lerp(n.targetPos,.12),n.mesh.position.copy(n.pos),n.labelSprite.position.copy(n.pos.clone().multiplyScalar(1.035)),n.linePosAttr.setXYZ(1,n.pos.x,n.pos.y,n.pos.z),n.linePosAttr.needsUpdate=!0;let a=n.mesh===h?1.75:1;f.set(a,a,a),n.mesh.scale.lerp(f,.18),n.targetOpacity===0&&r<.01&&e.push(t)}for(let t of e){let e=m.get(t);c.remove(e.mesh),l.remove(e.line),c.remove(e.labelSprite),e.mesh.geometry.dispose(),e.meshMat.dispose(),e.line.geometry.dispose(),e.lineMat.dispose(),e.labelMat.map?.dispose(),e.labelMat.dispose(),h===e.mesh&&(h=null,re.value=null),m.delete(t)}i.render(n,r),g=window.requestAnimationFrame(de)};return de(),{update:P,dispose(){window.cancelAnimationFrame(g),se.disconnect(),e.removeEventListener(`pointermove`,ee),e.removeEventListener(`pointerleave`,ce),e.removeEventListener(`wheel`,ue),a.dispose();for(let e of m.values())e.mesh.geometry.dispose(),e.meshMat.dispose(),e.line.geometry.dispose(),e.lineMat.dispose(),e.labelMat.map?.dispose(),e.labelMat.dispose();m.clear(),T(s),T(c),T(l),o.traverse(w),i.forceContextLoss(),i.dispose()}}},Me=async(e=D.value)=>{if(await i(),M.value){B(e);return}try{if(R&&te.value){let e=te.value.getBoundingClientRect();(e.width===0||e.height===0)&&(R.dispose(),R=null)}R||=V(),R.update(e)}catch(t){console.warn(`Satellite globe failed; using fallback`,t),M.value=!0,B(e)}};n(()=>{Me()}),r(D,e=>{Me(e)},{flush:`post`}),r(C,e=>{e===`overview`&&Me()}),r(w,e=>{e===`globe`&&Me()}),_(()=>{R?.dispose(),R=null});let Ne=f(()=>JSON.stringify(D.value??{},null,2));return(t,n)=>(u(),g(`div`,yu,[h(`div`,bu,[n[4]||=h(`div`,null,[h(`h1`,{class:`text-2xl font-semibold text-content-heading dark:text-white`},`GPS Diagnostics`),h(`p`,{class:`text-sm text-content-muted`},` Live NMEA receiver state, parsed fix data, and satellite visibility. `)],-1),h(`button`,{type:`button`,class:`rounded-[10px] border border-stroke-subtle dark:border-white/10 bg-white/80 dark:bg-white/10 px-4 py-2 text-sm font-semibold text-content-primary dark:text-white transition-colors hover:bg-white dark:hover:bg-white/20 disabled:cursor-not-allowed disabled:opacity-60`,disabled:O.value,onClick:_e},e(O.value?`Refreshing`:`Refresh`),9,xu)]),k.value?(u(),g(`div`,Su,e(k.value),1)):d(``,!0),h(`div`,Cu,[(u(!0),g(m,null,l(Te.value,t=>(u(),g(`section`,{key:t.label,class:`glass-card min-h-[118px] p-4`},[h(`p`,wu,e(t.label),1),h(`p`,{class:v([`mt-2 break-words text-xl font-semibold leading-tight`,t.valueClass])},e(t.value),3),h(`p`,Tu,e(t.note),1)]))),128))]),h(`div`,Eu,[(u(),g(m,null,l([{id:`overview`,label:`Overview`},{id:`satellites`,label:`Satellites`},{id:`details`,label:`Details`}],t=>h(`button`,{key:t.id,type:`button`,class:v([`page-tab`,{"page-tab-active":C.value===t.id}]),onClick:e=>C.value=t.id},e(t.label),11,Du)),64))]),o(h(`div`,null,[h(`div`,Ou,[h(`section`,ku,[h(`div`,Au,[h(`div`,null,[n[5]||=h(`h2`,{class:`text-lg font-semibold text-content-heading dark:text-white`},` Satellites `,-1),h(`p`,ju,e(Ae.value.length)+` satellite`+e(Ae.value.length===1?``:`s`)+` plotted from GSV azimuth, elevation, and SNR. `,1)]),h(`div`,Mu,[h(`span`,Nu,e(L.value),1),h(`div`,Pu,[h(`button`,{type:`button`,class:v([`inner-tab`,{"inner-tab-active":w.value===`globe`}]),onClick:n[0]||=e=>w.value=`globe`},`Globe`,2),h(`button`,{type:`button`,class:v([`inner-tab`,{"inner-tab-active":w.value===`table`}]),onClick:n[1]||=e=>w.value=`table`},`Table`,2)])])]),o(h(`div`,null,[h(`div`,{ref_key:`globeStage`,ref:te,class:`globe-stage`},[o(h(`canvas`,{ref_key:`globeCanvas`,ref:ne,"aria-label":`3D globe showing satellites around the current receiver position`},null,512),[[y,!M.value]]),M.value?(u(),g(`div`,Fu,[Ae.value.length?(u(),g(`div`,Iu,[(u(!0),g(m,null,l(Ae.value,t=>(u(),g(`div`,{key:t.key,class:v([`fallback-sat`,{"fallback-sat-used":t.used}]),style:a(je(t))},[h(`span`,null,e(t.prn),1)],6))),128))])):(u(),g(`div`,Lu,`No satellites in view yet`))])):d(``,!0),re.value?(u(),g(`div`,{key:1,class:`globe-tooltip`,style:a(ie.value),role:`status`,"aria-live":`polite`},[h(`div`,Ru,`SAT `+e(re.value.prn),1),h(`div`,zu,[n[6]||=h(`span`,{class:`tooltip-key`},`SNR`,-1),h(`span`,Bu,e(F(re.value.snr,`dB`)),1),n[7]||=h(`span`,{class:`tooltip-key`},`Elevation`,-1),h(`span`,Vu,e(F(re.value.elevation,`deg`)),1),n[8]||=h(`span`,{class:`tooltip-key`},`Azimuth`,-1),h(`span`,Hu,e(F(re.value.azimuth,`deg`)),1),n[9]||=h(`span`,{class:`tooltip-key`},`Used in fix`,-1),h(`span`,Uu,e(F(re.value.used)),1)])],4)):d(``,!0)],512),h(`div`,Wu,[h(`span`,null,e(N.value),1),n[10]||=h(`span`,null,`Drag to rotate · Scroll to zoom · Hover for details`,-1)]),h(`div`,Gu,[n[11]||=h(`span`,{class:`inline-flex items-center gap-2`},[h(`span`,{class:`h-2.5 w-2.5 rounded-full bg-accent-green`}),p(`Used in fix `)],-1),n[12]||=h(`span`,{class:`inline-flex items-center gap-2`},[h(`span`,{class:`h-2.5 w-2.5 rounded-full bg-primary`}),p(`In view `)],-1),h(`span`,null,`Last refresh: `+e(A.value?A.value.toLocaleTimeString():`n/a`),1)])],512),[[y,w.value===`globe`]]),o(h(`div`,null,[h(`div`,Ku,[h(`table`,qu,[n[14]||=h(`thead`,{class:`border-b border-stroke-subtle text-xs uppercase text-content-muted`},[h(`tr`,null,[h(`th`,{class:`py-2 pr-4 font-semibold`},`PRN`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Used`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Elevation`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Azimuth`),h(`th`,{class:`py-2 pr-4 font-semibold`},`SNR`)])],-1),h(`tbody`,Ju,[(u(!0),g(m,null,l(I.value,t=>(u(),g(`tr`,{key:t.prn,class:v([`sat-row`,{"sat-row-stale":t.stale}])},[h(`td`,{class:v([`py-2 pr-4 font-medium`,t.used?`text-accent-green`:`text-content-primary dark:text-white`])},e(t.prn),3),h(`td`,Yu,[h(`span`,{class:v(t.used?`inline-flex items-center gap-1.5 text-accent-green`:`text-content-muted`)},[t.used?(u(),g(`span`,Xu)):d(``,!0),p(` `+e(t.used?`yes`:`–`),1)],2)]),h(`td`,Zu,e(F(t.data.elevation_degrees,`deg`)),1),h(`td`,Qu,e(F(t.data.azimuth_degrees,`deg`)),1),h(`td`,$u,e(F(t.data.snr_db,`dB`)),1)],2))),128)),I.value.length===0?(u(),g(`tr`,ed,[...n[13]||=[h(`td`,{colspan:`5`,class:`py-6 text-center text-content-muted`},`No satellites in view yet`,-1)]])):d(``,!0)])])])],512),[[y,w.value===`table`]])]),h(`section`,td,[n[20]||=h(`h2`,{class:`mb-4 text-lg font-semibold text-content-heading dark:text-white`},`Position`,-1),h(`div`,nd,[h(`div`,rd,[n[15]||=h(`span`,{class:`text-content-muted`},`Display source`,-1),h(`span`,id,e(F(le.value.source_label||le.value.source)),1)]),h(`div`,ad,[n[16]||=h(`span`,{class:`text-content-muted`},`Display location`,-1),h(`span`,od,e(Se(P.value.latitude,P.value.longitude)),1)]),h(`div`,sd,[n[17]||=h(`span`,{class:`text-content-muted`},`GPS location`,-1),h(`span`,cd,e(Se(se.value.latitude,se.value.longitude)),1)]),h(`div`,ld,[n[18]||=h(`span`,{class:`text-content-muted`},`Manual location`,-1),h(`span`,ud,e(ce.value?Se(ce.value.latitude,ce.value.longitude):`n/a`),1)]),h(`div`,dd,[n[19]||=h(`span`,{class:`text-content-muted`},`Policy`,-1),h(`span`,fd,e(F(le.value.policy)),1)])])])])],512),[[y,C.value===`overview`]]),o(h(`div`,null,[h(`section`,pd,[n[23]||=h(`h2`,{class:`mb-4 text-lg font-semibold text-content-heading dark:text-white`},`Satellites In View`,-1),h(`div`,md,[h(`table`,hd,[n[22]||=h(`thead`,{class:`border-b border-stroke-subtle text-xs uppercase text-content-muted`},[h(`tr`,null,[h(`th`,{class:`py-2 pr-4 font-semibold`},`PRN`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Used`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Elevation`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Azimuth`),h(`th`,{class:`py-2 pr-4 font-semibold`},`SNR`)])],-1),h(`tbody`,gd,[(u(!0),g(m,null,l(I.value,t=>(u(),g(`tr`,{key:t.prn,class:v([`sat-row`,{"sat-row-stale":t.stale}])},[h(`td`,{class:v([`py-2 pr-4 font-medium`,t.used?`text-accent-green`:`text-content-primary dark:text-white`])},e(t.prn),3),h(`td`,_d,[h(`span`,{class:v(t.used?`inline-flex items-center gap-1.5 text-accent-green`:`text-content-muted`)},[t.used?(u(),g(`span`,vd)):d(``,!0),p(` `+e(t.used?`yes`:`–`),1)],2)]),h(`td`,yd,e(F(t.data.elevation_degrees,`deg`)),1),h(`td`,bd,e(F(t.data.azimuth_degrees,`deg`)),1),h(`td`,xd,e(F(t.data.snr_db,`dB`)),1)],2))),128)),I.value.length===0?(u(),g(`tr`,Sd,[...n[21]||=[h(`td`,{colspan:`5`,class:`py-6 text-center text-content-muted`},`No satellites in view yet`,-1)]])):d(``,!0)])])])])],512),[[y,C.value===`satellites`]]),o(h(`div`,null,[h(`div`,Cd,[(u(!0),g(m,null,l(Ee.value,t=>(u(),g(`div`,{key:t.title,class:`glass-card overflow-hidden`},[h(`button`,{type:`button`,class:`accordion-header`,onClick:e=>E(t.title)},[h(`span`,Td,e(t.title),1),(u(),g(`svg`,{class:v([`accordion-chevron`,{"accordion-chevron-open":T.value.has(t.title)}]),xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[...n[24]||=[h(`polyline`,{points:`6 9 12 15 18 9`},null,-1)]],2))],8,wd),T.value.has(t.title)?(u(),g(`div`,Ed,[h(`div`,Dd,[(u(!0),g(m,null,l(t.rows,n=>(u(),g(m,{key:`${t.title}-${n[0]}`},[h(`div`,Od,e(n[0]),1),h(`div`,kd,e(F(n[1],n[2])),1)],64))),128))])])):d(``,!0)]))),128))]),h(`section`,Ad,[h(`button`,{type:`button`,class:`accordion-header`,onClick:n[2]||=e=>E(`__nmea__`)},[n[26]||=h(`span`,{class:`font-semibold text-content-heading dark:text-white`},`Recent NMEA Sentences`,-1),(u(),g(`svg`,{class:v([`accordion-chevron`,{"accordion-chevron-open":T.value.has(`__nmea__`)}]),xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[...n[25]||=[h(`polyline`,{points:`6 9 12 15 18 9`},null,-1)]],2))]),T.value.has(`__nmea__`)?(u(),g(`div`,jd,[h(`div`,Md,[h(`table`,Nd,[n[28]||=h(`thead`,{class:`border-b border-stroke-subtle text-xs uppercase text-content-muted`},[h(`tr`,null,[h(`th`,{class:`py-2 pr-4 font-semibold`},`Timestamp`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Type`),h(`th`,{class:`py-2 pr-4 font-semibold`},`Sentence`)])],-1),h(`tbody`,Pd,[(u(!0),g(m,null,l(Oe.value,t=>(u(),g(`tr`,{key:`${t.timestamp}-${t.sentence}`},[h(`td`,Fd,e(F(t.timestamp)),1),h(`td`,Id,e(F(t.sentence_type)),1),h(`td`,Ld,e(F(t.sentence)),1)]))),128)),Oe.value.length===0?(u(),g(`tr`,Rd,[...n[27]||=[h(`td`,{colspan:`3`,class:`py-6 text-center text-content-muted`},`No NMEA sentences captured yet`,-1)]])):d(``,!0)])])])])):d(``,!0)]),h(`section`,zd,[h(`div`,Bd,[n[29]||=h(`h2`,{class:`text-lg font-semibold text-content-heading dark:text-white`},`Raw Snapshot`,-1),h(`button`,{type:`button`,class:`rounded-[10px] border border-stroke-subtle dark:border-white/10 bg-white/70 dark:bg-white/10 px-3 py-1.5 text-xs font-semibold text-content-primary dark:text-white hover:bg-white dark:hover:bg-white/20`,onClick:n[3]||=e=>j.value=!j.value},e(j.value?`Hide`:`Show`),1)]),j.value?(u(),g(`pre`,Vd,e(Ne.value),1)):d(``,!0)])],512),[[y,C.value===`details`]])]))}}),[[`__scopeId`,`data-v-517bbbeb`]]);export{Ud as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/GPSDiagnostics-ozfiXH-7.css b/repeater/web/html/assets/GPSDiagnostics-ozfiXH-7.css new file mode 100644 index 00000000..20a39cea --- /dev/null +++ b/repeater/web/html/assets/GPSDiagnostics-ozfiXH-7.css @@ -0,0 +1 @@ +.globe-stage[data-v-517bbbeb]{border:1px solid var(--color-border-subtle);background:radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--color-primary) 24%, transparent), transparent 34%), radial-gradient(circle at 48% 50%, #ffffff24, transparent 20%), linear-gradient(145deg, var(--color-background-soft), var(--color-background));cursor:grab;touch-action:none;border-radius:10px;min-height:330px;position:relative;overflow:hidden}.globe-stage[data-v-517bbbeb]:active{cursor:grabbing}.globe-stage canvas[data-v-517bbbeb]{width:100%;height:330px;display:block}.globe-tooltip[data-v-517bbbeb]{z-index:2;color:#fff;pointer-events:none;background:#050a0ceb;border:1px solid #ffffff2e;border-radius:12px;min-width:154px;padding:10px 11px;position:absolute;transform:translate(-50%,calc(-100% - 22px));box-shadow:0 14px 40px #0000005c}.tooltip-title[data-v-517bbbeb]{color:var(--color-accent-green);letter-spacing:.06em;text-transform:uppercase;font-size:.82rem;font-weight:800}.tooltip-grid[data-v-517bbbeb]{grid-template-columns:auto 1fr;gap:4px 10px;margin-top:7px;font-size:.78rem;display:grid}.tooltip-key[data-v-517bbbeb]{color:#ffffffa8}.tooltip-value[data-v-517bbbeb]{color:#fff;text-align:right;font-weight:700}.globe-fallback[data-v-517bbbeb]{padding:18px;position:absolute;inset:0}.fallback-sky[data-v-517bbbeb]{aspect-ratio:1;border:1px solid color-mix(in srgb, var(--color-primary) 34%, var(--color-border-subtle));background:radial-gradient(circle, color-mix(in srgb, var(--color-primary) 18%, transparent) 0 2px, transparent 3px), repeating-radial-gradient(circle, transparent 0 31%, color-mix(in srgb, var(--color-border) 70%, transparent) 31.5% 32%, transparent 32.5% 49%), linear-gradient(90deg, transparent 49.7%, color-mix(in srgb, var(--color-border) 78%, transparent) 49.7% 50.3%, transparent 50.3%), linear-gradient(0deg, transparent 49.7%, color-mix(in srgb, var(--color-border) 78%, transparent) 49.7% 50.3%, transparent 50.3%);border-radius:50%;width:min(250px,72vw);margin:0 auto;position:relative}.fallback-sat[data-v-517bbbeb]{width:var(--size);height:var(--size);background:var(--color-primary);box-shadow:0 0 16px color-mix(in srgb, var(--color-primary) 70%, transparent);border-radius:999px;position:absolute;transform:translate(-50%,-50%)}.fallback-sat-used[data-v-517bbbeb]{background:var(--color-accent-green);box-shadow:0 0 16px color-mix(in srgb, var(--color-accent-green) 70%, transparent)}.fallback-sat span[data-v-517bbbeb]{color:var(--color-text-primary);white-space:nowrap;font-size:.65rem;font-weight:700;position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%)}.sky-empty[data-v-517bbbeb]{color:var(--color-text-muted);pointer-events:none;place-items:center;font-size:.875rem;display:grid;position:absolute;inset:0}.sat-row[data-v-517bbbeb]{opacity:1;transition:opacity .6s,color .4s}.sat-row-stale[data-v-517bbbeb]{opacity:.35}.page-tabs[data-v-517bbbeb]{border-bottom:1px solid var(--color-border-subtle,#0000001a);gap:2px;padding-bottom:0;display:flex}.page-tab[data-v-517bbbeb]{color:var(--color-text-muted,#888);cursor:pointer;background:0 0;border:none;border-bottom:2px solid #0000;margin-bottom:-1px;padding:8px 18px;font-size:.875rem;font-weight:600;transition:color .18s,border-color .18s}.page-tab[data-v-517bbbeb]:hover{color:var(--color-text-primary,#fff)}.page-tab-active[data-v-517bbbeb]{color:var(--color-primary,#aae8e8);border-bottom-color:var(--color-primary,#aae8e8)}.inner-tabs[data-v-517bbbeb]{border:1px solid var(--color-border-subtle,#ffffff1a);background:#ffffff0a;border-radius:8px;gap:2px;padding:2px;display:flex}.inner-tab[data-v-517bbbeb]{color:var(--color-text-muted,#888);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:.75rem;font-weight:600;transition:background .15s,color .15s}.inner-tab[data-v-517bbbeb]:hover{color:var(--color-text-primary,#fff)}.inner-tab-active[data-v-517bbbeb]{background:var(--color-primary,#aae8e8);color:#000}.accordion-header[data-v-517bbbeb]{cursor:pointer;text-align:left;background:0 0;border:none;justify-content:space-between;align-items:center;width:100%;padding:14px 20px;font-size:.9rem;transition:background .15s;display:flex}.accordion-header[data-v-517bbbeb]:hover{background:#ffffff0a}.accordion-chevron[data-v-517bbbeb]{color:var(--color-text-muted,#888);flex-shrink:0;transition:transform .2s}.accordion-chevron-open[data-v-517bbbeb]{transform:rotate(180deg)}.accordion-body[data-v-517bbbeb]{padding:0 20px 16px} diff --git a/repeater/web/html/assets/Help-CaIFoQMt.js b/repeater/web/html/assets/Help-CfDEEAoD.js similarity index 58% rename from repeater/web/html/assets/Help-CaIFoQMt.js rename to repeater/web/html/assets/Help-CfDEEAoD.js index 749b931c..a6805e3c 100644 --- a/repeater/web/html/assets/Help-CaIFoQMt.js +++ b/repeater/web/html/assets/Help-CfDEEAoD.js @@ -1 +1 @@ -import{f as e,g as t,u as n,w as r}from"./runtime-core.esm-bundler-HnidnMFy.js";var i=t({name:`HelpView`,__name:`Help`,setup(t){return(t,i)=>(r(),n(`div`,null,[...i[0]||=[e(`

Help & Documentation

pyMC Repeater Wiki

Access documentation, setup guides, troubleshooting tips, and community resources on our official wiki.

Visit Wiki Documentation
Opens in a new tab
`,1)]]))}});export{i as default}; \ No newline at end of file +import{f as e,g as t,k as n,u as r}from"./runtime-core.esm-bundler-C5QBTNWE.js";var i=t({name:`HelpView`,__name:`Help`,setup(t){return(t,i)=>(n(),r(`div`,null,[...i[0]||=[e(`

Help & Documentation

pyMC Repeater Wiki

Access documentation, setup guides, troubleshooting tips, and community resources on our official wiki.

Visit Wiki Documentation
Opens in a new tab
`,1)]]))}});export{i as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/LocationPicker-KRjSN9TZ.js b/repeater/web/html/assets/LocationPicker-KRjSN9TZ.js new file mode 100644 index 00000000..ef642561 --- /dev/null +++ b/repeater/web/html/assets/LocationPicker-KRjSN9TZ.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/leaflet-src-rW8DhqPH.js","assets/chunk-DECur_0Z.js"])))=>i.map(i=>d[i]); +import{r as e}from"./chunk-DECur_0Z.js";import{D as t,R as n,S as r,V as i,Y as a,c as o,g as s,i as c,k as l,l as u,p as d,s as f,u as p}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{s as m,u as h}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{o as g}from"./api-3gMnsCKh.js";import{t as _}from"./_plugin-vue_export-helper-B7aGp3iI.js";/* empty css */var v={class:`glass-card border border-stroke-subtle dark:border-white/20 rounded-[15px] w-full max-w-3xl max-h-[90vh] flex flex-col shadow-2xl`},y={class:`flex-1 relative min-h-[400px]`},b={class:`p-6 border-t border-stroke-subtle dark:border-stroke/10 space-y-4`},x={class:`grid grid-cols-2 gap-4`},S=_(s({__name:`LocationPicker`,props:{isOpen:{type:Boolean},latitude:{},longitude:{}},emits:[`close`,`select`],setup(s,{emit:_}){let S=s,C=_,w=a(null),T=a(S.latitude||0),E=a(S.longitude||0),D=null,O=null,k=async()=>{if(w.value){A();try{let t=(await g(async()=>{let{default:t}=await import(`./leaflet-src-rW8DhqPH.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default;delete t.Icon.Default.prototype._getIconUrl,t.Icon.Default.mergeOptions({iconRetinaUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png`,iconUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png`,shadowUrl:`https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png`}),await r();let n=T.value||0,i=E.value||0,a=n===0&&i===0?2:13;D=t.map(w.value).setView([n,i],a);try{let e=t.tileLayer(`https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png`,{maxZoom:19,attribution:`© OpenStreetMap contributors © CARTO`,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`}),n=t.tileLayer(`https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png`,{maxZoom:19,attribution:``,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`});e.addTo(D),n.addTo(D)}catch(e){console.warn(`Error loading tiles:`,e)}(n!==0||i!==0)&&(O=t.marker([n,i]).addTo(D)),D.on(`click`,e=>{T.value=e.latlng.lat,E.value=e.latlng.lng,O?O.setLatLng(e.latlng):O=t.marker(e.latlng).addTo(D)}),setTimeout(()=>{D?.invalidateSize()},200)}catch(e){console.error(`Failed to initialize map:`,e)}}},A=()=>{D&&(D.remove(),D=null,O=null)};n(()=>S.isOpen,async e=>{e?(await r(),await k()):A()}),n(()=>[S.latitude,S.longitude],([e,t])=>{T.value=e,E.value=t});let j=()=>{C(`select`,{latitude:Math.round(T.value*1e6)/1e6,longitude:Math.round(E.value*1e6)/1e6}),C(`close`)},M=()=>{C(`close`)},N=()=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(async t=>{if(T.value=t.coords.latitude,E.value=t.coords.longitude,D){D.setView([T.value,E.value],13);let t=(await g(async()=>{let{default:t}=await import(`./leaflet-src-rW8DhqPH.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default;O?O.setLatLng([T.value,E.value]):O=t.marker([T.value,E.value]).addTo(D)}},e=>{console.error(`Error getting location:`,e),alert(`Unable to get current location. Please check browser permissions.`)}):alert(`Geolocation is not supported by this browser.`)};return t(()=>{A()}),(e,t)=>(l(),o(c,{to:`body`},[s.isOpen?(l(),p(`div`,{key:0,class:`fixed inset-0 z-[400] flex items-center justify-center p-4 bg-black/50 backdrop-blur-lg`,onClick:h(M,[`self`])},[f(`div`,v,[f(`div`,{class:`flex items-center justify-between p-6 border-b border-stroke-subtle dark:border-stroke/10`},[t[3]||=f(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Select Location `,-1),f(`button`,{onClick:M,class:`text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...t[2]||=[f(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),f(`div`,y,[f(`div`,{ref_key:`mapContainer`,ref:w,class:`absolute inset-0 rounded-b-[15px] overflow-hidden`},null,512)]),f(`div`,b,[f(`div`,x,[f(`div`,null,[t[4]||=f(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Latitude`,-1),i(f(`input`,{"onUpdate:modelValue":t[0]||=e=>T.value=e,type:`number`,step:`0.000001`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary`,readonly:``},null,512),[[m,T.value,void 0,{number:!0}]])]),f(`div`,null,[t[5]||=f(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-muted mb-2`},`Longitude`,-1),i(f(`input`,{"onUpdate:modelValue":t[1]||=e=>E.value=e,type:`number`,step:`0.000001`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary`,readonly:``},null,512),[[m,E.value,void 0,{number:!0}]])])]),f(`div`,{class:`flex gap-3`},[f(`button`,{onClick:N,class:`flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm flex items-center justify-center gap-2`},[...t[6]||=[f(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),d(` Use Current Location `,-1)]]),f(`button`,{onClick:M,class:`px-6 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm`},` Cancel `),f(`button`,{onClick:j,class:`px-6 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm`},` Select Location `)]),t[7]||=f(`p`,{class:`text-content-muted dark:text-content-muted text-xs text-center`},` Click on the map to select a location `,-1)])])])):u(``,!0)]))}}),[[`__scopeId`,`data-v-a6ceb55e`]]);export{S as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/LocationPicker-KkKL2lD_.css b/repeater/web/html/assets/LocationPicker-KkKL2lD_.css new file mode 100644 index 00000000..8e190f9b --- /dev/null +++ b/repeater/web/html/assets/LocationPicker-KkKL2lD_.css @@ -0,0 +1 @@ +.leaflet-pane[data-v-a6ceb55e],.leaflet-tile[data-v-a6ceb55e],.leaflet-marker-icon[data-v-a6ceb55e],.leaflet-marker-shadow[data-v-a6ceb55e],.leaflet-tile-container[data-v-a6ceb55e],.leaflet-pane>svg[data-v-a6ceb55e],.leaflet-pane>canvas[data-v-a6ceb55e],.leaflet-zoom-box[data-v-a6ceb55e],.leaflet-image-layer[data-v-a6ceb55e],.leaflet-layer[data-v-a6ceb55e]{position:absolute;top:0;left:0}.leaflet-container[data-v-a6ceb55e]{overflow:hidden}.leaflet-tile[data-v-a6ceb55e],.leaflet-marker-icon[data-v-a6ceb55e],.leaflet-marker-shadow[data-v-a6ceb55e]{-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile[data-v-a6ceb55e]::selection{background:0 0}.leaflet-safari .leaflet-tile[data-v-a6ceb55e]{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container[data-v-a6ceb55e]{-webkit-transform-origin:0 0;width:1600px;height:1600px}.leaflet-marker-icon[data-v-a6ceb55e],.leaflet-marker-shadow[data-v-a6ceb55e]{display:block}.leaflet-container .leaflet-overlay-pane svg[data-v-a6ceb55e]{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img[data-v-a6ceb55e],.leaflet-container .leaflet-shadow-pane img[data-v-a6ceb55e],.leaflet-container .leaflet-tile-pane img[data-v-a6ceb55e],.leaflet-container img.leaflet-image-layer[data-v-a6ceb55e],.leaflet-container .leaflet-tile[data-v-a6ceb55e]{width:auto;padding:0;max-width:none!important;max-height:none!important}.leaflet-container img.leaflet-tile[data-v-a6ceb55e]{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom[data-v-a6ceb55e]{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag[data-v-a6ceb55e]{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom[data-v-a6ceb55e]{-ms-touch-action:none;touch-action:none}.leaflet-container[data-v-a6ceb55e]{-webkit-tap-highlight-color:transparent}.leaflet-container a[data-v-a6ceb55e]{-webkit-tap-highlight-color:#33b5e566}.leaflet-tile[data-v-a6ceb55e]{filter:inherit;visibility:hidden}.leaflet-tile-loaded[data-v-a6ceb55e]{visibility:inherit}.leaflet-zoom-box[data-v-a6ceb55e]{box-sizing:border-box;z-index:800;width:0;height:0}.leaflet-overlay-pane svg[data-v-a6ceb55e]{-moz-user-select:none}.leaflet-pane[data-v-a6ceb55e]{z-index:400}.leaflet-tile-pane[data-v-a6ceb55e]{z-index:200}.leaflet-overlay-pane[data-v-a6ceb55e]{z-index:400}.leaflet-shadow-pane[data-v-a6ceb55e]{z-index:500}.leaflet-marker-pane[data-v-a6ceb55e]{z-index:600}.leaflet-tooltip-pane[data-v-a6ceb55e]{z-index:650}.leaflet-popup-pane[data-v-a6ceb55e]{z-index:700}.leaflet-map-pane canvas[data-v-a6ceb55e]{z-index:100}.leaflet-map-pane svg[data-v-a6ceb55e]{z-index:200}.leaflet-vml-shape[data-v-a6ceb55e]{width:1px;height:1px}.lvml[data-v-a6ceb55e]{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control[data-v-a6ceb55e]{z-index:800;pointer-events:visiblePainted;pointer-events:auto;position:relative}.leaflet-top[data-v-a6ceb55e],.leaflet-bottom[data-v-a6ceb55e]{z-index:1000;pointer-events:none;position:absolute}.leaflet-top[data-v-a6ceb55e]{top:0}.leaflet-right[data-v-a6ceb55e]{right:0}.leaflet-bottom[data-v-a6ceb55e]{bottom:0}.leaflet-left[data-v-a6ceb55e]{left:0}.leaflet-control[data-v-a6ceb55e]{float:left;clear:both}.leaflet-right .leaflet-control[data-v-a6ceb55e]{float:right}.leaflet-top .leaflet-control[data-v-a6ceb55e]{margin-top:10px}.leaflet-bottom .leaflet-control[data-v-a6ceb55e]{margin-bottom:10px}.leaflet-left .leaflet-control[data-v-a6ceb55e]{margin-left:10px}.leaflet-right .leaflet-control[data-v-a6ceb55e]{margin-right:10px}.leaflet-fade-anim .leaflet-popup[data-v-a6ceb55e]{opacity:0;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup[data-v-a6ceb55e]{opacity:1}.leaflet-zoom-animated[data-v-a6ceb55e]{transform-origin:0 0}svg.leaflet-zoom-animated[data-v-a6ceb55e]{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated[data-v-a6ceb55e]{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile[data-v-a6ceb55e],.leaflet-pan-anim .leaflet-tile[data-v-a6ceb55e]{transition:none}.leaflet-zoom-anim .leaflet-zoom-hide[data-v-a6ceb55e]{visibility:hidden}.leaflet-interactive[data-v-a6ceb55e]{cursor:pointer}.leaflet-grab[data-v-a6ceb55e]{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair[data-v-a6ceb55e],.leaflet-crosshair .leaflet-interactive[data-v-a6ceb55e]{cursor:crosshair}.leaflet-popup-pane[data-v-a6ceb55e],.leaflet-control[data-v-a6ceb55e]{cursor:auto}.leaflet-dragging .leaflet-grab[data-v-a6ceb55e],.leaflet-dragging .leaflet-grab .leaflet-interactive[data-v-a6ceb55e],.leaflet-dragging .leaflet-marker-draggable[data-v-a6ceb55e]{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon[data-v-a6ceb55e],.leaflet-marker-shadow[data-v-a6ceb55e],.leaflet-image-layer[data-v-a6ceb55e],.leaflet-pane>svg path[data-v-a6ceb55e],.leaflet-tile-container[data-v-a6ceb55e]{pointer-events:none}.leaflet-marker-icon.leaflet-interactive[data-v-a6ceb55e],.leaflet-image-layer.leaflet-interactive[data-v-a6ceb55e],.leaflet-pane>svg path.leaflet-interactive[data-v-a6ceb55e],svg.leaflet-image-layer.leaflet-interactive path[data-v-a6ceb55e]{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container[data-v-a6ceb55e]{outline-offset:1px;background:#ddd}.leaflet-container a[data-v-a6ceb55e]{color:#0078a8}.leaflet-zoom-box[data-v-a6ceb55e]{background:#ffffff80;border:2px dotted #38f}.leaflet-container[data-v-a6ceb55e]{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:.75rem;line-height:1.5}.leaflet-bar[data-v-a6ceb55e]{border-radius:4px;box-shadow:0 1px 5px #000000a6}.leaflet-bar a[data-v-a6ceb55e]{text-align:center;color:#000;background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;text-decoration:none;display:block}.leaflet-bar a[data-v-a6ceb55e],.leaflet-control-layers-toggle[data-v-a6ceb55e]{background-position:50%;background-repeat:no-repeat;display:block}.leaflet-bar a[data-v-a6ceb55e]:hover,.leaflet-bar a[data-v-a6ceb55e]:focus{background-color:#f4f4f4}.leaflet-bar a[data-v-a6ceb55e]:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a[data-v-a6ceb55e]:last-child{border-bottom:none;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.leaflet-bar a.leaflet-disabled[data-v-a6ceb55e]{cursor:default;color:#bbb;background-color:#f4f4f4}.leaflet-touch .leaflet-bar a[data-v-a6ceb55e]{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a[data-v-a6ceb55e]:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a[data-v-a6ceb55e]:last-child{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.leaflet-control-zoom-in[data-v-a6ceb55e],.leaflet-control-zoom-out[data-v-a6ceb55e]{text-indent:1px;font:700 18px Lucida Console,Monaco,monospace}.leaflet-touch .leaflet-control-zoom-in[data-v-a6ceb55e],.leaflet-touch .leaflet-control-zoom-out[data-v-a6ceb55e]{font-size:22px}.leaflet-control-layers[data-v-a6ceb55e]{background:#fff;border-radius:5px;box-shadow:0 1px 5px #0006}.leaflet-control-layers-toggle[data-v-a6ceb55e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle[data-v-a6ceb55e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle[data-v-a6ceb55e]{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list[data-v-a6ceb55e],.leaflet-control-layers-expanded .leaflet-control-layers-toggle[data-v-a6ceb55e]{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list[data-v-a6ceb55e]{display:block;position:relative}.leaflet-control-layers-expanded[data-v-a6ceb55e]{color:#333;background:#fff;padding:6px 10px 6px 6px}.leaflet-control-layers-scrollbar[data-v-a6ceb55e]{padding-right:5px;overflow:hidden scroll}.leaflet-control-layers-selector[data-v-a6ceb55e]{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label[data-v-a6ceb55e]{font-size:1.08333em;display:block}.leaflet-control-layers-separator[data-v-a6ceb55e]{border-top:1px solid #ddd;height:0;margin:5px -10px 5px -6px}.leaflet-default-icon-path[data-v-a6ceb55e]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution[data-v-a6ceb55e]{background:#fffc;margin:0}.leaflet-control-attribution[data-v-a6ceb55e],.leaflet-control-scale-line[data-v-a6ceb55e]{color:#333;padding:0 5px;line-height:1.4}.leaflet-control-attribution a[data-v-a6ceb55e]{text-decoration:none}.leaflet-control-attribution a[data-v-a6ceb55e]:hover,.leaflet-control-attribution a[data-v-a6ceb55e]:focus{text-decoration:underline}.leaflet-attribution-flag[data-v-a6ceb55e]{width:1em;height:.6669em;vertical-align:baseline!important;display:inline!important}.leaflet-left .leaflet-control-scale[data-v-a6ceb55e]{margin-left:5px}.leaflet-bottom .leaflet-control-scale[data-v-a6ceb55e]{margin-bottom:5px}.leaflet-control-scale-line[data-v-a6ceb55e]{white-space:nowrap;box-sizing:border-box;text-shadow:1px 1px #fff;background:#fffc;border:2px solid #777;border-top:none;padding:2px 5px 1px;line-height:1.1}.leaflet-control-scale-line[data-v-a6ceb55e]:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line[data-v-a6ceb55e]:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution[data-v-a6ceb55e],.leaflet-touch .leaflet-control-layers[data-v-a6ceb55e],.leaflet-touch .leaflet-bar[data-v-a6ceb55e]{box-shadow:none}.leaflet-touch .leaflet-control-layers[data-v-a6ceb55e],.leaflet-touch .leaflet-bar[data-v-a6ceb55e]{background-clip:padding-box;border:2px solid #0003}.leaflet-popup[data-v-a6ceb55e]{text-align:center;margin-bottom:20px;position:absolute}.leaflet-popup-content-wrapper[data-v-a6ceb55e]{text-align:left;border-radius:12px;padding:1px}.leaflet-popup-content[data-v-a6ceb55e]{min-height:1px;margin:13px 24px 13px 20px;font-size:1.08333em;line-height:1.3}.leaflet-popup-content p[data-v-a6ceb55e]{margin:1.3em 0}.leaflet-popup-tip-container[data-v-a6ceb55e]{pointer-events:none;width:40px;height:20px;margin-top:-1px;margin-left:-20px;position:absolute;left:50%;overflow:hidden}.leaflet-popup-tip[data-v-a6ceb55e]{pointer-events:auto;width:17px;height:17px;margin:-10px auto 0;padding:1px;transform:rotate(45deg)}.leaflet-popup-content-wrapper[data-v-a6ceb55e],.leaflet-popup-tip[data-v-a6ceb55e]{color:#333;background:#fff;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button[data-v-a6ceb55e]{text-align:center;color:#757575;background:0 0;border:none;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;text-decoration:none;position:absolute;top:0;right:0}.leaflet-container a.leaflet-popup-close-button[data-v-a6ceb55e]:hover,.leaflet-container a.leaflet-popup-close-button[data-v-a6ceb55e]:focus{color:#585858}.leaflet-popup-scrolled[data-v-a6ceb55e]{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper[data-v-a6ceb55e]{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip[data-v-a6ceb55e]{-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";width:24px;filter:progid:DXImageTransform.Microsoft.Matrix(M11=.707107, M12=.707107, M21=-.707107, M22=.707107);margin:0 auto}.leaflet-oldie .leaflet-control-zoom[data-v-a6ceb55e],.leaflet-oldie .leaflet-control-layers[data-v-a6ceb55e],.leaflet-oldie .leaflet-popup-content-wrapper[data-v-a6ceb55e],.leaflet-oldie .leaflet-popup-tip[data-v-a6ceb55e]{border:1px solid #999}.leaflet-div-icon[data-v-a6ceb55e]{background:#fff;border:1px solid #666}.leaflet-tooltip[data-v-a6ceb55e]{color:#222;white-space:nowrap;-webkit-user-select:none;user-select:none;pointer-events:none;background-color:#fff;border:1px solid #fff;border-radius:3px;padding:6px;position:absolute;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive[data-v-a6ceb55e]{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top[data-v-a6ceb55e]:before,.leaflet-tooltip-bottom[data-v-a6ceb55e]:before,.leaflet-tooltip-left[data-v-a6ceb55e]:before,.leaflet-tooltip-right[data-v-a6ceb55e]:before{pointer-events:none;content:"";background:0 0;border:6px solid #0000;position:absolute}.leaflet-tooltip-bottom[data-v-a6ceb55e]{margin-top:6px}.leaflet-tooltip-top[data-v-a6ceb55e]{margin-top:-6px}.leaflet-tooltip-bottom[data-v-a6ceb55e]:before,.leaflet-tooltip-top[data-v-a6ceb55e]:before{margin-left:-6px;left:50%}.leaflet-tooltip-top[data-v-a6ceb55e]:before{border-top-color:#fff;margin-bottom:-12px;bottom:0}.leaflet-tooltip-bottom[data-v-a6ceb55e]:before{border-bottom-color:#fff;margin-top:-12px;margin-left:-6px;top:0}.leaflet-tooltip-left[data-v-a6ceb55e]{margin-left:-6px}.leaflet-tooltip-right[data-v-a6ceb55e]{margin-left:6px}.leaflet-tooltip-left[data-v-a6ceb55e]:before,.leaflet-tooltip-right[data-v-a6ceb55e]:before{margin-top:-6px;top:50%}.leaflet-tooltip-left[data-v-a6ceb55e]:before{border-left-color:#fff;margin-right:-12px;right:0}.leaflet-tooltip-right[data-v-a6ceb55e]:before{border-right-color:#fff;margin-left:-12px;left:0}@media print{.leaflet-control[data-v-a6ceb55e]{-webkit-print-color-adjust:exact;print-color-adjust:exact}} diff --git a/repeater/web/html/assets/Login-9CbeeXng.css b/repeater/web/html/assets/Login-9CbeeXng.css new file mode 100644 index 00000000..727ec128 --- /dev/null +++ b/repeater/web/html/assets/Login-9CbeeXng.css @@ -0,0 +1 @@ +.bg-gradient-light[data-v-a8af9668]{background:linear-gradient(#0d73774d,#aae8e833)}.bg-gradient-dark[data-v-a8af9668]{background:linear-gradient(#aae8e82e,#0d73771a)}.login-card[data-v-a8af9668]{-webkit-backdrop-filter:blur(40px)saturate(180%);background:#ffffffd9}.dark .login-card[data-v-a8af9668]{background:#1a1e1fcc}.input-glass[data-v-a8af9668]{-webkit-backdrop-filter:blur(20px);background:#ffffffe6;border:1px solid #d1d5db}.dark .input-glass[data-v-a8af9668]{background:#ffffff0d;border-color:#ffffff1a}.input-glass[data-v-a8af9668]:focus{background:#fff}.dark .input-glass[data-v-a8af9668]:focus{background:#ffffff1a}.input-glass[data-v-a8af9668]:focus{box-shadow:0 0 0 1px #aae8e833,0 0 20px #aae8e826,inset 0 1px #ffffff1a}.input-glow[data-v-a8af9668]{opacity:0;transition:opacity .3s;box-shadow:inset 0 1px #ffffff0d}.input-glass:focus+.input-glow[data-v-a8af9668]{opacity:1;box-shadow:0 0 20px #aae8e833,inset 0 1px #ffffff1a}.button-glass[data-v-a8af9668]{-webkit-backdrop-filter:blur(20px);position:relative}.button-glass[data-v-a8af9668]:before{content:"";-webkit-mask-composite:xor;background:linear-gradient(90deg,#0000 0%,#aae8e84d 50%,#0000 100%);border-radius:12px;padding:1px;transition:transform 1s;position:absolute;inset:0;transform:translate(-100%);-webkit-mask-image:linear-gradient(#fff 0 0),linear-gradient(#fff 0 0);-webkit-mask-position:0 0,0 0;-webkit-mask-size:auto,auto;-webkit-mask-repeat:repeat,repeat;-webkit-mask-clip:content-box,border-box;-webkit-mask-origin:content-box,border-box;-webkit-mask-composite:xor;mask-composite:exclude;-webkit-mask-source-type:auto,auto;mask-mode:match-source,match-source}.button-glass[data-v-a8af9668]:hover:not(:disabled):before{transform:translate(100%)}.button-glass[data-v-a8af9668]{box-shadow:0 0 0 1px #aae8e833,0 4px 16px #0003,inset 0 1px #ffffff1a}.button-glass[data-v-a8af9668]:hover:not(:disabled){box-shadow:0 0 0 1px #aae8e866,0 0 30px #aae8e84d,0 4px 20px #0000004d,inset 0 1px #ffffff26}@keyframes float-a8af9668{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse-slow-a8af9668{0%,to{opacity:.8;transform:scale(1)}50%{opacity:.6;transform:scale(1.05)}}@keyframes pulse-slower-a8af9668{0%,to{opacity:.75;transform:scale(1)}50%{opacity:.5;transform:scale(1.08)}}@keyframes pulse-slowest-a8af9668{0%,to{opacity:.8;transform:scale(1)}50%{opacity:.6;transform:scale(1.06)}}.animate-pulse-slow[data-v-a8af9668]{animation:8s ease-in-out infinite pulse-slow-a8af9668}.animate-pulse-slower[data-v-a8af9668]{animation:10s ease-in-out infinite pulse-slower-a8af9668}.animate-pulse-slowest[data-v-a8af9668]{animation:12s ease-in-out infinite pulse-slowest-a8af9668}@keyframes shake-a8af9668{0%,to{transform:translate(0)}10%,30%,50%,70%,90%{transform:translate(-5px)}20%,40%,60%,80%{transform:translate(5px)}}.animate-shake[data-v-a8af9668]{animation:.5s ease-in-out shake-a8af9668}.form-group[data-v-a8af9668]{position:relative}.form-group:hover label[data-v-a8af9668]{color:#aae8e8e6;transition:color .3s} diff --git a/repeater/web/html/assets/Login-CRioMgum.css b/repeater/web/html/assets/Login-CRioMgum.css deleted file mode 100644 index 3b1a4848..00000000 --- a/repeater/web/html/assets/Login-CRioMgum.css +++ /dev/null @@ -1 +0,0 @@ -.bg-gradient-light[data-v-fec81ee3]{background:linear-gradient(#0ea5e966,#06b6d44d)}.bg-gradient-dark[data-v-fec81ee3]{background:linear-gradient(#67e8f94d,#a5f3fc26)}.login-card[data-v-fec81ee3]{-webkit-backdrop-filter:blur(40px)saturate(180%);background:#ffffffb3}.dark .login-card[data-v-fec81ee3]{background:#11191c66}.input-glass[data-v-fec81ee3]{-webkit-backdrop-filter:blur(20px);background:#ffffffe6;border:1px solid #d1d5db}.dark .input-glass[data-v-fec81ee3]{background:#ffffff0d;border-color:#ffffff1a}.input-glass[data-v-fec81ee3]:focus{background:#fff}.dark .input-glass[data-v-fec81ee3]:focus{background:#ffffff1a}.input-glass[data-v-fec81ee3]:focus{box-shadow:0 0 0 1px #aae8e833,0 0 20px #aae8e826,inset 0 1px #ffffff1a}.input-glow[data-v-fec81ee3]{opacity:0;transition:opacity .3s;box-shadow:inset 0 1px #ffffff0d}.input-glass:focus+.input-glow[data-v-fec81ee3]{opacity:1;box-shadow:0 0 20px #aae8e833,inset 0 1px #ffffff1a}.button-glass[data-v-fec81ee3]{-webkit-backdrop-filter:blur(20px);position:relative}.button-glass[data-v-fec81ee3]:before{content:"";-webkit-mask-composite:xor;background:linear-gradient(90deg,#0000 0%,#aae8e84d 50%,#0000 100%);border-radius:12px;padding:1px;transition:transform 1s;position:absolute;inset:0;transform:translate(-100%);-webkit-mask-image:linear-gradient(#fff 0 0),linear-gradient(#fff 0 0);-webkit-mask-position:0 0,0 0;-webkit-mask-size:auto,auto;-webkit-mask-repeat:repeat,repeat;-webkit-mask-clip:content-box,border-box;-webkit-mask-origin:content-box,border-box;-webkit-mask-composite:xor;mask-composite:exclude;-webkit-mask-source-type:auto,auto;mask-mode:match-source,match-source}.button-glass[data-v-fec81ee3]:hover:not(:disabled):before{transform:translate(100%)}.button-glass[data-v-fec81ee3]{box-shadow:0 0 0 1px #aae8e833,0 4px 16px #0003,inset 0 1px #ffffff1a}.button-glass[data-v-fec81ee3]:hover:not(:disabled){box-shadow:0 0 0 1px #aae8e866,0 0 30px #aae8e84d,0 4px 20px #0000004d,inset 0 1px #ffffff26}.login-content:has(.button-glass:hover:not(:disabled)) .logo-image[data-v-fec81ee3]{filter:brightness(1.4)drop-shadow(0 0 12px #aae8e8b3);transform:scale(1.02)}.login-content:has(.button-glass:hover:not(:disabled)) .logo-glow[data-v-fec81ee3]{opacity:.6;transform:scale(1.15)}.logo-glow[data-v-fec81ee3]{opacity:0}.dark .logo-glow[data-v-fec81ee3]{opacity:1}@keyframes float-fec81ee3{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse-slow-fec81ee3{0%,to{opacity:.8;transform:scale(1)}50%{opacity:.6;transform:scale(1.05)}}@keyframes pulse-slower-fec81ee3{0%,to{opacity:.75;transform:scale(1)}50%{opacity:.5;transform:scale(1.08)}}@keyframes pulse-slowest-fec81ee3{0%,to{opacity:.8;transform:scale(1)}50%{opacity:.6;transform:scale(1.06)}}.animate-pulse-slow[data-v-fec81ee3]{animation:8s ease-in-out infinite pulse-slow-fec81ee3}.animate-pulse-slower[data-v-fec81ee3]{animation:10s ease-in-out infinite pulse-slower-fec81ee3}.animate-pulse-slowest[data-v-fec81ee3]{animation:12s ease-in-out infinite pulse-slowest-fec81ee3}@keyframes shake-fec81ee3{0%,to{transform:translate(0)}10%,30%,50%,70%,90%{transform:translate(-5px)}20%,40%,60%,80%{transform:translate(5px)}}.animate-shake[data-v-fec81ee3]{animation:.5s ease-in-out shake-fec81ee3}@keyframes logo-aura-cycle-fec81ee3{0%,to{filter:brightness()saturate()drop-shadow(0 0 7px #38bdf873)}25%{filter:brightness(1.02)saturate(1.05)drop-shadow(0 0 10px #6366f16b)}50%{filter:brightness()saturate(1.03)drop-shadow(0 0 8px #22d3ee73)}75%{filter:brightness(1.02)saturate(1.05)drop-shadow(0 0 10px #34d3996b)}}.logo-image-animated[data-v-fec81ee3]{will-change:filter;animation:6s ease-in-out infinite logo-aura-cycle-fec81ee3}.form-group[data-v-fec81ee3]{position:relative}.form-group:hover label[data-v-fec81ee3]{color:#aae8e8e6;transition:color .3s} diff --git a/repeater/web/html/assets/Login-DTJPC25k.js b/repeater/web/html/assets/Login-DTJPC25k.js new file mode 100644 index 00000000..05579945 --- /dev/null +++ b/repeater/web/html/assets/Login-DTJPC25k.js @@ -0,0 +1 @@ +import{Ct as e,E as t,V as n,Y as r,c as i,g as a,i as o,k as s,l as c,m as l,o as u,p as d,s as f,u as p}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{s as m,u as h}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{c as g,f as _,h as v,i as y,r as b}from"./api-3gMnsCKh.js";import{t as x}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as S}from"./useTheme-B2sN4eXt.js";import{t as C}from"./Spinner-CcYauG9D.js";import{a as w,c as T,i as ee,r as E,s as te}from"./index-DTUpsCzx.js";var D={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/20 rounded-[15px] p-6 max-w-md w-full shadow-2xl`},O={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`},k={class:`text-red-600 dark:text-red-400 text-sm`},A={key:1,class:`bg-green-500/10 border border-green-600/40 dark:border-green-500/30 rounded-lg p-3`},j={class:`text-green-600 dark:text-green-400 text-sm`},M={class:`flex justify-end gap-3 mt-6`},N=[`disabled`],P=[`disabled`],F=a({name:`ChangePasswordModal`,__name:`ChangePasswordModal`,props:{isOpen:{type:Boolean},canSkip:{type:Boolean,default:!0}},emits:[`close`,`success`],setup(t,{emit:a}){let l=a,u=r(``),g=r(``),_=r(``),v=r(!1),y=r(``),x=r(``),S=()=>{v.value||l(`close`)},w=()=>{l(`close`)},T=async()=>{if(y.value=``,x.value=``,g.value.length<8){y.value=`New password must be at least 8 characters long`;return}if(g.value!==_.value){y.value=`Passwords do not match`;return}if(g.value===u.value){y.value=`New password must be different from current password`;return}v.value=!0;try{let e=(await b.post(`/auth/change_password`,{current_password:u.value,new_password:g.value})).data;e&&e.success?(x.value=e.message||`Password changed successfully!`,setTimeout(()=>{l(`success`),l(`close`)},1500)):y.value=e?.error||`Failed to change password`}catch(e){console.error(`Password change error:`,e),y.value=e.response?.data?.error||`Failed to change password. Please try again.`}finally{v.value=!1}};return(r,a)=>(s(),i(o,{to:`body`},[t.isOpen?(s(),p(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:h(S,[`self`])},[f(`div`,D,[a[6]||=f(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-2`},` Change Default Password `,-1),a[7]||=f(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mb-6`},` You're using the default password. Please change it to secure your account. `,-1),f(`form`,{onSubmit:h(T,[`prevent`]),class:`space-y-4`},[f(`div`,null,[a[3]||=f(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`Current Password`,-1),n(f(`input`,{"onUpdate:modelValue":a[0]||=e=>u.value=e,type:`password`,required:``,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Enter current password`},null,512),[[m,u.value]])]),f(`div`,null,[a[4]||=f(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`New Password`,-1),n(f(`input`,{"onUpdate:modelValue":a[1]||=e=>g.value=e,type:`password`,required:``,minlength:`8`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Enter new password (min 8 characters)`},null,512),[[m,g.value]])]),f(`div`,null,[a[5]||=f(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`Confirm New Password`,-1),n(f(`input`,{"onUpdate:modelValue":a[2]||=e=>_.value=e,type:`password`,required:``,minlength:`8`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Confirm new password`},null,512),[[m,_.value]])]),y.value?(s(),p(`div`,O,[f(`p`,k,e(y.value),1)])):c(``,!0),x.value?(s(),p(`div`,A,[f(`p`,j,e(x.value),1)])):c(``,!0),f(`div`,M,[t.canSkip?(s(),p(`button`,{key:0,type:`button`,onClick:w,disabled:v.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors disabled:opacity-50`},` Skip for Now `,8,N)):c(``,!0),f(`button`,{type:`submit`,disabled:v.value,class:`btn-primary flex items-center gap-2`},[v.value?(s(),i(C,{key:0,size:`sm`,color:`current`})):c(``,!0),d(` `+e(v.value?`Changing...`:`Change Password`),1)],8,P)])],32)])])):c(``,!0)]))}}),I={class:`min-h-screen bg-background dark:bg-background overflow-hidden relative flex items-start sm:items-center justify-center p-2 sm:p-4 pt-8 sm:pt-4`},L={class:`absolute top-4 right-4 z-20`},R={class:`login-card relative z-10 w-full max-w-md p-6 sm:p-10 rounded-[16px] sm:rounded-[24px] border-0 sm:border sm:border-stroke-subtle dark:sm:border-stroke/20 shadow-[0_8px_32px_0_rgba(0,0,0,0.1)] dark:shadow-[0_8px_32px_0_rgba(0,0,0,0.37)] backdrop-blur-xl`},z={class:`relative login-content`},B={class:`text-center mb-6 sm:mb-10`},V={class:`mb-4 sm:mb-6 flex justify-center`},H=[`src`],U={key:0,class:`text-content-primary dark:text-content-primary text-sm sm:text-base font-semibold mb-1`},W={class:`form-group`},G={class:`relative`},K=[`disabled`],q={class:`form-group`},J={class:`relative`},Y=[`disabled`],X={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-[12px] p-2.5 sm:p-3.5 backdrop-blur-sm animate-shake`},Z={class:`text-red-600 dark:text-red-400 text-xs sm:text-sm font-medium`},ne=[`disabled`],re={key:1,class:`w-4 h-4 sm:w-5 sm:h-5 group-hover:translate-x-1 transition-transform duration-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ie={class:`relative`},Q={class:`mt-6 sm:mt-8 pt-4 sm:pt-6 border-t border-stroke-subtle dark:border-stroke/10`},ae={class:`flex items-center justify-center gap-3`},oe={href:`https://github.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-primary/20 dark:hover:bg-primary/30 hover:border-primary/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`GitHub`},se={href:`https://buymeacoffee.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-yellow-50 dark:hover:bg-yellow-500/20 hover:border-yellow-500/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`Buy Me a Coffee`},$=x(a({name:`LoginView`,__name:`Login`,setup(a){let o=v(),d=y(),{theme:x}=S(),D=u(()=>x.value===`dark`?w:ee),O=r(`admin`),k=r(``),A=r(!1),j=r(``),M=r(!1),N=r(!1),P=r(``);t(async()=>{try{P.value=(await b.get(`/api/site_info`)).data?.site_name??``}catch{}});let $=async()=>{j.value=``,A.value=!0;try{let e=g(),t=(await b.post(`/auth/login`,{username:O.value,password:k.value,client_id:e})).data;t.success&&t.token?k.value===`admin123`?(_(t.token),d.markAuthenticated(),N.value=!0,M.value=!0):(_(t.token),d.markAuthenticated(),o.push(`/`)):j.value=t.error||`Login failed`}catch(e){console.error(`Login error:`,e),j.value=e.response?.data?.error||`Connection error. Please try again.`}finally{A.value=!1}},ce=()=>{M.value=!1,o.push(`/`)},le=()=>{M.value=!1,N.value&&o.push(`/`)};return(t,r)=>(s(),p(`div`,I,[f(`div`,L,[l(E)]),r[10]||=f(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slow -top-[79px] left-[575px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),r[11]||=f(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-75 animate-pulse-slower -top-[94px] -left-[92px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),r[12]||=f(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slowest top-[373px] left-[246px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),f(`div`,R,[r[9]||=f(`div`,{class:`absolute inset-0 rounded-[24px] bg-gradient-to-br from-primary/3 dark:from-primary/5 to-transparent pointer-events-none`},null,-1),f(`div`,z,[f(`div`,B,[f(`div`,V,[f(`img`,{src:D.value,alt:`pyMC`,class:`logo-image h-36 sm:h-40 relative z-10`},null,8,H)]),P.value?(s(),p(`p`,U,e(P.value),1)):c(``,!0),r[2]||=f(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Sign in to access your dashboard `,-1)]),f(`form`,{onSubmit:h($,[`prevent`]),class:`space-y-4 sm:space-y-5`},[f(`div`,W,[r[4]||=f(`label`,{for:`username`,class:`block text-content-secondary dark:text-content-primary/90 text-xs sm:text-sm font-medium mb-2`},` Username `,-1),f(`div`,G,[n(f(`input`,{id:`username`,"onUpdate:modelValue":r[0]||=e=>O.value=e,type:`text`,autocomplete:`username`,required:``,class:`input-glass w-full px-3 sm:px-4 py-2.5 sm:py-3.5 rounded-[12px] text-content-primary dark:text-content-primary text-sm placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 transition-all duration-300`,placeholder:`Enter username`,disabled:A.value},null,8,K),[[m,O.value]]),r[3]||=f(`div`,{class:`absolute inset-0 rounded-[12px] pointer-events-none input-glow`},null,-1)])]),f(`div`,q,[r[6]||=f(`label`,{for:`password`,class:`block text-content-secondary dark:text-content-primary/90 text-xs sm:text-sm font-medium mb-2`},` Password `,-1),f(`div`,J,[n(f(`input`,{id:`password`,"onUpdate:modelValue":r[1]||=e=>k.value=e,type:`password`,autocomplete:`current-password`,required:``,class:`input-glass w-full px-3 sm:px-4 py-2.5 sm:py-3.5 rounded-[12px] text-content-primary dark:text-content-primary text-sm placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 transition-all duration-300`,placeholder:`Enter password`,disabled:A.value},null,8,Y),[[m,k.value]]),r[5]||=f(`div`,{class:`absolute inset-0 rounded-[12px] pointer-events-none input-glow`},null,-1)])]),j.value?(s(),p(`div`,X,[f(`p`,Z,e(j.value),1)])):c(``,!0),f(`button`,{type:`submit`,disabled:A.value,class:`button-glass w-full relative overflow-hidden bg-primary/20 hover:bg-primary/30 active:scale-[0.98] text-primary dark:text-white font-semibold py-3 sm:py-4 px-4 rounded-[12px] border border-primary/50 hover:border-primary/60 transition-all duration-300 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 sm:gap-2.5 group mt-6 sm:mt-8 text-sm sm:text-base backdrop-blur-sm`},[A.value?(s(),i(C,{key:0,size:`sm`,color:`white`})):(s(),p(`svg`,re,[...r[7]||=[f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1`},null,-1)]])),f(`span`,ie,e(A.value?`Signing in...`:`Sign In`),1)],8,ne)],32),f(`div`,Q,[r[8]||=f(`div`,{class:`flex flex-col items-center justify-center mb-4`},[f(`p`,{class:`text-content-muted dark:text-content-muted text-[10px] sm:text-xs mb-1.5 tracking-wide uppercase opacity-60`},`Powered by`),f(`img`,{src:`/assets/meshcore-DQNtEl5I.svg`,alt:`MeshCore`,class:`h-4 sm:h-5 opacity-50 brightness-0 dark:brightness-100`})],-1),f(`div`,ae,[f(`a`,oe,[l(T,{class:`w-5 h-5 sm:w-6 sm:h-6 text-white group-hover:text-primary transition-colors`})]),f(`a`,se,[l(te,{class:`w-5 h-5 sm:w-6 sm:h-6 text-white group-hover:text-yellow-500 transition-colors`})])])])])]),l(F,{"is-open":M.value,"can-skip":!0,onClose:le,onSuccess:ce},null,8,[`is-open`])]))}}),[[`__scopeId`,`data-v-a8af9668`]]);export{$ as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Login-Yx7HUvzW.js b/repeater/web/html/assets/Login-Yx7HUvzW.js deleted file mode 100644 index 8045fde9..00000000 --- a/repeater/web/html/assets/Login-Yx7HUvzW.js +++ /dev/null @@ -1 +0,0 @@ -import{g as e,j as t,l as n,m as r,p as i,pt as a,s as o,u as s,w as c,z as l}from"./runtime-core.esm-bundler-HnidnMFy.js";import{i as u}from"./vue-router-Cr0wB7EX.js";import{f as d,n as f,r as p,s as m}from"./api-CbM6k1ZB.js";import{t as h}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{f as g,h as _,i as v,r as y,t as b}from"./index-BFltqMtv.js";var x={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/20 rounded-[15px] p-6 max-w-md w-full shadow-2xl`},S={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`},C={class:`text-red-600 dark:text-red-400 text-sm`},w={key:1,class:`bg-green-500/10 border border-green-600/40 dark:border-green-500/30 rounded-lg p-3`},T={class:`text-green-600 dark:text-green-400 text-sm`},E={class:`flex justify-end gap-3 mt-6`},D=[`disabled`],O=[`disabled`],k={key:0,class:`w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin`},A=e({name:`ChangePasswordModal`,__name:`ChangePasswordModal`,props:{isOpen:{type:Boolean},canSkip:{type:Boolean,default:!0}},emits:[`close`,`success`],setup(e,{emit:r}){let u=r,d=l(``),p=l(``),m=l(``),h=l(!1),v=l(``),y=l(``),b=()=>{h.value||u(`close`)},A=()=>{u(`close`)},j=async()=>{if(v.value=``,y.value=``,p.value.length<8){v.value=`New password must be at least 8 characters long`;return}if(p.value!==m.value){v.value=`Passwords do not match`;return}if(p.value===d.value){v.value=`New password must be different from current password`;return}h.value=!0;try{let e=(await f.post(`/auth/change_password`,{current_password:d.value,new_password:p.value})).data;e&&e.success?(y.value=e.message||`Password changed successfully!`,setTimeout(()=>{u(`success`),u(`close`)},1500)):v.value=e?.error||`Failed to change password`}catch(e){console.error(`Password change error:`,e),v.value=e.response?.data?.error||`Failed to change password. Please try again.`}finally{h.value=!1}};return(r,l)=>e.isOpen?(c(),s(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm`,onClick:_(b,[`self`])},[o(`div`,x,[l[6]||=o(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary mb-2`},` Change Default Password `,-1),l[7]||=o(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mb-6`},` You're using the default password. Please change it to secure your account. `,-1),o(`form`,{onSubmit:_(j,[`prevent`]),class:`space-y-4`},[o(`div`,null,[l[3]||=o(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`Current Password`,-1),t(o(`input`,{"onUpdate:modelValue":l[0]||=e=>d.value=e,type:`password`,required:``,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Enter current password`},null,512),[[g,d.value]])]),o(`div`,null,[l[4]||=o(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`New Password`,-1),t(o(`input`,{"onUpdate:modelValue":l[1]||=e=>p.value=e,type:`password`,required:``,minlength:`8`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Enter new password (min 8 characters)`},null,512),[[g,p.value]])]),o(`div`,null,[l[5]||=o(`label`,{class:`block text-sm font-medium text-content-secondary dark:text-content-primary/70 mb-2`},`Confirm New Password`,-1),t(o(`input`,{"onUpdate:modelValue":l[2]||=e=>m.value=e,type:`password`,required:``,minlength:`8`,class:`w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors`,placeholder:`Confirm new password`},null,512),[[g,m.value]])]),v.value?(c(),s(`div`,S,[o(`p`,C,a(v.value),1)])):n(``,!0),y.value?(c(),s(`div`,w,[o(`p`,T,a(y.value),1)])):n(``,!0),o(`div`,E,[e.canSkip?(c(),s(`button`,{key:0,type:`button`,onClick:A,disabled:h.value,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors disabled:opacity-50`},` Skip for Now `,8,D)):n(``,!0),o(`button`,{type:`submit`,disabled:h.value,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-white rounded-lg border border-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2`},[h.value?(c(),s(`div`,k)):n(``,!0),i(` `+a(h.value?`Changing...`:`Change Password`),1)],8,O)])],32)])])):n(``,!0)}}),j={class:`min-h-screen bg-background dark:bg-background overflow-hidden relative flex items-start sm:items-center justify-center p-2 sm:p-4 pt-8 sm:pt-4`},M={class:`absolute top-4 right-4 z-20`},N={class:`login-card relative z-10 w-full max-w-md p-6 sm:p-10 rounded-[16px] sm:rounded-[24px] border-0 sm:border sm:border-stroke-subtle dark:sm:border-stroke/20 shadow-[0_8px_32px_0_rgba(0,0,0,0.1)] dark:shadow-[0_8px_32px_0_rgba(0,0,0,0.37)] backdrop-blur-xl`},P={class:`relative login-content`},F={class:`form-group`},I={class:`relative`},L=[`disabled`],R={class:`form-group`},z={class:`relative`},B=[`disabled`],V={key:0,class:`bg-red-500/10 border border-red-500/30 rounded-[12px] p-2.5 sm:p-3.5 backdrop-blur-sm animate-shake`},H={class:`text-red-600 dark:text-red-400 text-xs sm:text-sm font-medium`},U=[`disabled`],W={key:0,class:`w-4 h-4 sm:w-5 sm:h-5 border-2 border-white border-t-transparent rounded-full animate-spin`},G={key:1,class:`w-4 h-4 sm:w-5 sm:h-5 group-hover:translate-x-1 transition-transform duration-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},K={class:`relative`},q={class:`mt-6 sm:mt-8 pt-4 sm:pt-6 border-t border-stroke-subtle dark:border-stroke/10`},J={class:`flex items-center justify-center gap-3`},Y={href:`https://github.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-primary/20 dark:hover:bg-primary/30 hover:border-primary/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`GitHub`},X={href:`https://buymeacoffee.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-yellow-50 dark:hover:bg-yellow-500/20 hover:border-yellow-500/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`Buy Me a Coffee`},Z=h(e({name:`LoginView`,__name:`Login`,setup(e){let i=u(),h=p(),x=l(`admin`),S=l(``),C=l(!1),w=l(``),T=l(!1),E=l(!1),D=async()=>{w.value=``,C.value=!0;try{let e=m(),t=(await f.post(`/auth/login`,{username:x.value,password:S.value,client_id:e})).data;t.success&&t.token?S.value===`admin123`?(d(t.token),h.markAuthenticated(),E.value=!0,T.value=!0):(d(t.token),h.markAuthenticated(),i.push(`/`)):w.value=t.error||`Login failed`}catch(e){console.error(`Login error:`,e),w.value=e.response?.data?.error||`Connection error. Please try again.`}finally{C.value=!1}},O=()=>{T.value=!1,i.push(`/`)},k=()=>{T.value=!1,E.value&&i.push(`/`)};return(e,i)=>(c(),s(`div`,j,[o(`div`,M,[r(b)]),i[10]||=o(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slow -top-[79px] left-[575px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),i[11]||=o(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-75 animate-pulse-slower -top-[94px] -left-[92px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),i[12]||=o(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slowest top-[373px] left-[246px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),o(`div`,N,[i[9]||=o(`div`,{class:`absolute inset-0 rounded-[24px] bg-gradient-to-br from-primary/3 dark:from-primary/5 to-transparent pointer-events-none`},null,-1),o(`div`,P,[i[8]||=o(`div`,{class:`text-center mb-6 sm:mb-10`},[o(`div`,{class:`mb-4 sm:mb-6 flex justify-center`},[o(`img`,{src:`/assets/pymclogo-ew909fnk.png`,alt:`pyMC`,class:`logo-image logo-image-animated h-36 sm:h-40 relative z-10`})]),o(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Sign in to access your dashboard `)],-1),o(`form`,{onSubmit:_(D,[`prevent`]),class:`space-y-4 sm:space-y-5`},[o(`div`,F,[i[3]||=o(`label`,{for:`username`,class:`block text-content-secondary dark:text-content-primary/90 text-xs sm:text-sm font-medium mb-2`},` Username `,-1),o(`div`,I,[t(o(`input`,{id:`username`,"onUpdate:modelValue":i[0]||=e=>x.value=e,type:`text`,autocomplete:`username`,required:``,class:`input-glass w-full px-3 sm:px-4 py-2.5 sm:py-3.5 rounded-[12px] text-content-primary dark:text-content-primary text-sm placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 transition-all duration-300`,placeholder:`Enter username`,disabled:C.value},null,8,L),[[g,x.value]]),i[2]||=o(`div`,{class:`absolute inset-0 rounded-[12px] pointer-events-none input-glow`},null,-1)])]),o(`div`,R,[i[5]||=o(`label`,{for:`password`,class:`block text-content-secondary dark:text-content-primary/90 text-xs sm:text-sm font-medium mb-2`},` Password `,-1),o(`div`,z,[t(o(`input`,{id:`password`,"onUpdate:modelValue":i[1]||=e=>S.value=e,type:`password`,autocomplete:`current-password`,required:``,class:`input-glass w-full px-3 sm:px-4 py-2.5 sm:py-3.5 rounded-[12px] text-content-primary dark:text-content-primary text-sm placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 transition-all duration-300`,placeholder:`Enter password`,disabled:C.value},null,8,B),[[g,S.value]]),i[4]||=o(`div`,{class:`absolute inset-0 rounded-[12px] pointer-events-none input-glow`},null,-1)])]),w.value?(c(),s(`div`,V,[o(`p`,H,a(w.value),1)])):n(``,!0),o(`button`,{type:`submit`,disabled:C.value,class:`button-glass w-full relative overflow-hidden bg-primary/20 hover:bg-primary/30 active:scale-[0.98] text-primary dark:text-white font-semibold py-3 sm:py-4 px-4 rounded-[12px] border border-primary/50 hover:border-primary/60 transition-all duration-300 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 sm:gap-2.5 group mt-6 sm:mt-8 text-sm sm:text-base backdrop-blur-sm`},[C.value?(c(),s(`div`,W)):(c(),s(`svg`,G,[...i[6]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1`},null,-1)]])),o(`span`,K,a(C.value?`Signing in...`:`Sign In`),1)],8,U)],32),o(`div`,q,[i[7]||=o(`div`,{class:`flex flex-col items-center justify-center mb-4`},[o(`p`,{class:`text-content-muted dark:text-content-muted text-[10px] sm:text-xs mb-1.5 tracking-wide uppercase opacity-60`},`Powered by`),o(`img`,{src:`/assets/meshcore-DQNtEl5I.svg`,alt:`MeshCore`,class:`h-4 sm:h-5 opacity-50 brightness-0 dark:brightness-100`})],-1),o(`div`,J,[o(`a`,Y,[r(v,{class:`w-5 h-5 sm:w-6 sm:h-6 text-white group-hover:text-primary transition-colors`})]),o(`a`,X,[r(y,{class:`w-5 h-5 sm:w-6 sm:h-6 text-white group-hover:text-yellow-500 transition-colors`})])])])])]),r(A,{"is-open":T.value,"can-skip":!0,onClose:k,onSuccess:O},null,8,[`is-open`])]))}}),[[`__scopeId`,`data-v-fec81ee3`]]);export{Z as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Logs-DiVYCMnG.js b/repeater/web/html/assets/Logs-DiVYCMnG.js deleted file mode 100644 index e8c0a50a..00000000 --- a/repeater/web/html/assets/Logs-DiVYCMnG.js +++ /dev/null @@ -1 +0,0 @@ -import{E as e,S as t,dt as n,f as r,g as i,l as a,o,p as s,pt as c,r as l,s as u,u as d,w as f,x as p,z as m}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as h}from"./api-CbM6k1ZB.js";var g={class:`space-y-6`},_={class:`glass-card backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},v={class:`flex items-center justify-between mb-4`},y=[`disabled`],b={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},x={class:`flex flex-wrap gap-2`},S=[`onClick`],C={key:0,class:`w-px h-6 bg-stroke-subtle dark:bg-stroke/20 mx-2 self-center`},w=[`onClick`],T={class:`glass-card backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[15px] overflow-hidden`},E={key:0,class:`p-8 text-center`},D={key:1,class:`p-8 text-center`},O={class:`text-content-secondary dark:text-content-muted mb-4`},k={key:2,class:`max-h-[600px] overflow-y-auto`},A={key:0,class:`p-8 text-center`},j={key:1,class:`divide-y divide-gray-200 dark:divide-white/5`},M={class:`flex-shrink-0 text-content-secondary dark:text-content-muted`},N={class:`flex-shrink-0 px-2 py-1 text-xs font-medium rounded bg-blue-500/20 text-blue-600 dark:text-blue-400`},P={class:`text-content-primary dark:text-content-primary flex-1 break-all`},F=i({name:`LogsView`,__name:`Logs`,setup(i){let F=m([]),I=m(new Set),L=m(new Set([`DEBUG`,`INFO`,`WARNING`,`ERROR`])),R=m(new Set),z=m(new Set),B=m(!0),V=m(null),H=null,U=e=>{let t=e.match(/- ([^-]+) - (?:DEBUG|INFO|WARNING|ERROR) -/);return t?t[1].trim():`Unknown`},ee=e=>{let t=e.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} - [^-]+ - (?:DEBUG|INFO|WARNING|ERROR) - (.+)$/);return t?t[1]:e},W=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},G=async()=>{try{let e=await h.getLogs();if(e.logs&&e.logs.length>0){F.value=e.logs;let t=new Set;F.value.forEach(e=>{let n=U(e.message);t.add(n)});let n=new Set;F.value.forEach(e=>{n.add(e.level)}),I.value.size===0&&(I.value=new Set(t));let r=!W(R.value,t),i=!W(z.value,n);r&&(R.value=t),i&&(z.value=n),V.value=null}}catch(e){console.error(`Error loading logs:`,e),V.value=e instanceof Error?e.message:`Failed to load logs`}finally{B.value=!1}},K=o(()=>F.value.filter(e=>{let t=U(e.message),n=I.value.has(t),r=L.value.has(e.level);return n&&r})),q=o(()=>Array.from(R.value).sort()),J=o(()=>{let e=[`ERROR`,`WARNING`,`WARN`,`INFO`,`DEBUG`];return Array.from(z.value).sort((t,n)=>{let r=e.indexOf(t),i=e.indexOf(n);return r!==-1&&i!==-1?r-i:t.localeCompare(n)})}),Y=e=>{L.value.has(e)?L.value.delete(e):L.value.add(e),L.value=new Set(L.value)},X=e=>new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),Z=e=>({ERROR:`text-red-600 dark:text-red-400 bg-red-900/20`,WARNING:`text-yellow-600 dark:text-yellow-400 bg-yellow-900/20`,WARN:`text-yellow-600 dark:text-yellow-400 bg-yellow-900/20`,INFO:`text-blue-600 dark:text-blue-400 bg-blue-900/20`,DEBUG:`text-gray-400 bg-gray-900/20`})[e]||`text-gray-400 bg-gray-900/20`,Q=(e,t)=>t?{ERROR:`bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 border-red-500/50`,WARNING:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-600 dark:text-yellow-400 border-yellow-500/50`,WARN:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-600 dark:text-yellow-400 border-yellow-500/50`,INFO:`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`,DEBUG:`bg-gray-500/20 text-gray-400 border-gray-500/50`}[e]||`bg-primary/20 text-primary border-primary/50`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-white/60 border-stroke-subtle dark:border-white/20 hover:bg-stroke-subtle dark:hover:bg-white/10`,$=e=>{I.value.has(e)?I.value.delete(e):I.value.add(e),I.value=new Set(I.value)},te=()=>{I.value=new Set(R.value)},ne=()=>{I.value=new Set},re=()=>{L.value=new Set(z.value)},ie=()=>{L.value=new Set},ae=()=>{H&&clearInterval(H),H=setInterval(G,5e3)},oe=()=>{H&&=(clearInterval(H),null)};return t(()=>{G(),ae()}),p(()=>{oe()}),(t,i)=>(f(),d(`div`,g,[u(`div`,_,[u(`div`,v,[i[1]||=u(`div`,null,[u(`h1`,{class:`text-content-primary dark:text-content-primary text-2xl font-semibold mb-2`},` System Logs `),u(`p`,{class:`text-content-secondary dark:text-content-muted`},` Real-time system events and diagnostics `)],-1),u(`button`,{onClick:G,disabled:B.value,class:`flex items-center gap-2 px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary border border-primary/50 rounded-lg transition-colors disabled:opacity-50`},[(f(),d(`svg`,{class:n([`w-4 h-4`,{"animate-spin":B.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...i[0]||=[u(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`},null,-1)]],2)),s(` `+c(B.value?`Loading...`:`Refresh`),1)],8,y)]),u(`div`,b,[u(`div`,{class:`flex flex-wrap items-center gap-3 mb-4`},[i[2]||=u(`span`,{class:`text-content-primary dark:text-content-primary font-medium`},`Filters:`,-1),u(`button`,{onClick:te,class:`px-3 py-1 text-xs bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/50 rounded transition-colors`},` All Loggers `),u(`button`,{onClick:ne,class:`px-3 py-1 text-xs bg-accent-red/20 hover:bg-accent-red/30 text-accent-red border border-accent-red/50 rounded transition-colors`},` Clear Loggers `),i[3]||=u(`div`,{class:`w-px h-4 bg-white/20 mx-1`},null,-1),u(`button`,{onClick:re,class:`px-3 py-1 text-xs bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/50 rounded transition-colors`},` All Levels `),u(`button`,{onClick:ie,class:`px-3 py-1 text-xs bg-accent-red/20 hover:bg-accent-red/30 text-accent-red border border-accent-red/50 rounded transition-colors`},` Clear Levels `)]),u(`div`,x,[(f(!0),d(l,null,e(q.value,e=>(f(),d(`button`,{key:`logger-`+e,onClick:t=>$(e),class:n([`px-3 py-1 text-xs border rounded-full transition-colors`,I.value.has(e)?`bg-primary/20 text-primary border-primary/50`:`bg-background-mute dark:bg-white/5 text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/10`])},c(e),11,S))),128)),q.value.length>0&&J.value.length>0?(f(),d(`div`,C)):a(``,!0),(f(!0),d(l,null,e(J.value,e=>(f(),d(`button`,{key:`level-`+e,onClick:t=>Y(e),class:n([`px-3 py-1 text-xs border rounded-full transition-colors font-medium`,L.value.has(e)?Q(e,!0):Q(e,!1)])},c(e),11,w))),128))])])]),u(`div`,T,[B.value&&F.value.length===0?(f(),d(`div`,E,[...i[4]||=[u(`div`,{class:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4`},null,-1),u(`p`,{class:`text-content-secondary dark:text-content-muted`},`Loading system logs...`,-1)]])):V.value?(f(),d(`div`,D,[i[5]||=u(`div`,{class:`text-red-600 dark:text-red-400 mb-4`},[u(`svg`,{class:`w-12 h-12 mx-auto mb-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[u(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})])],-1),i[6]||=u(`h3`,{class:`text-content-primary dark:text-content-primary text-lg font-medium mb-2`},` Error Loading Logs `,-1),u(`p`,O,c(V.value),1),u(`button`,{onClick:G,class:`px-4 py-2 bg-red-100 dark:bg-red-500/20 hover:bg-red-500/30 text-red-600 dark:text-red-400 border border-red-500/50 rounded-lg transition-colors`},` Try Again `)])):(f(),d(`div`,k,[K.value.length===0?(f(),d(`div`,A,[...i[7]||=[r(`

No Logs to Display

No logs match the current filter criteria.

`,3)]])):(f(),d(`div`,j,[(f(!0),d(l,null,e(K.value,(e,t)=>(f(),d(`div`,{key:t,class:`flex items-start gap-4 p-4 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors font-mono text-sm`},[u(`span`,M,` [`+c(X(e.timestamp))+`] `,1),u(`span`,N,c(U(e.message)),1),u(`span`,{class:n([`flex-shrink-0 px-2 py-1 text-xs font-medium rounded`,Z(e.level)])},c(e.level),3),u(`span`,P,c(ee(e.message)),1)]))),128))]))]))])]))}});export{F as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Logs-Dw5-qzdU.js b/repeater/web/html/assets/Logs-Dw5-qzdU.js new file mode 100644 index 00000000..55c123b2 --- /dev/null +++ b/repeater/web/html/assets/Logs-Dw5-qzdU.js @@ -0,0 +1 @@ +import{Ct as e,E as t,Y as n,f as r,g as i,j as a,k as o,l as s,m as c,o as l,p as u,r as d,s as f,u as p,w as m,xt as h}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{t as g}from"./api-3gMnsCKh.js";import{t as _}from"./Spinner-CcYauG9D.js";var v={class:`space-y-6`},ee={class:`glass-card backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},y={class:`flex items-center justify-between mb-4`},b=[`disabled`],x={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4`},S={class:`flex flex-wrap gap-2`},C=[`onClick`],w={key:0,class:`w-px h-6 bg-stroke-subtle dark:bg-stroke/20 mx-2 self-center`},T=[`onClick`],E={class:`glass-card backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[15px] overflow-hidden`},te={key:0,class:`p-8 text-center`},D={key:1,class:`p-8 text-center`},O={class:`text-content-secondary dark:text-content-muted mb-4`},k={key:2,class:`max-h-[600px] overflow-y-auto`},A={key:0,class:`p-8 text-center`},j={key:1,class:`divide-y divide-gray-200 dark:divide-white/5`},M={class:`flex-shrink-0 text-content-secondary dark:text-content-muted`},N={class:`flex-shrink-0 px-2 py-1 text-xs font-medium rounded bg-blue-500/20 text-blue-600 dark:text-blue-400`},P={class:`text-content-primary dark:text-content-primary flex-1 break-all`},F=i({name:`LogsView`,__name:`Logs`,setup(i){let F=n([]),I=n(new Set),L=n(new Set([`DEBUG`,`INFO`,`WARNING`,`ERROR`])),R=n(new Set),z=n(new Set),B=n(!0),V=n(null),H=null,U=e=>{let t=e.match(/- ([^-]+) - (?:DEBUG|INFO|WARNING|ERROR) -/);return t?t[1].trim():`Unknown`},W=e=>{let t=e.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} - [^-]+ - (?:DEBUG|INFO|WARNING|ERROR) - (.+)$/);return t?t[1]:e},G=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},K=async()=>{try{let e=await g.getLogs();if(e.logs&&e.logs.length>0){F.value=e.logs;let t=new Set;F.value.forEach(e=>{let n=U(e.message);t.add(n)});let n=new Set;F.value.forEach(e=>{n.add(e.level)}),I.value.size===0&&(I.value=new Set(t));let r=!G(R.value,t),i=!G(z.value,n);r&&(R.value=t),i&&(z.value=n),V.value=null}}catch(e){console.error(`Error loading logs:`,e),V.value=e instanceof Error?e.message:`Failed to load logs`}finally{B.value=!1}},q=l(()=>F.value.filter(e=>{let t=U(e.message),n=I.value.has(t),r=L.value.has(e.level);return n&&r})),J=l(()=>Array.from(R.value).sort()),Y=l(()=>{let e=[`ERROR`,`WARNING`,`WARN`,`INFO`,`DEBUG`];return Array.from(z.value).sort((t,n)=>{let r=e.indexOf(t),i=e.indexOf(n);return r!==-1&&i!==-1?r-i:t.localeCompare(n)})}),X=e=>{L.value.has(e)?L.value.delete(e):L.value.add(e),L.value=new Set(L.value)},Z=e=>new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),Q=e=>({ERROR:`text-red-600 dark:text-red-400 bg-red-900/20`,WARNING:`text-yellow-600 dark:text-yellow-400 bg-yellow-900/20`,WARN:`text-yellow-600 dark:text-yellow-400 bg-yellow-900/20`,INFO:`text-blue-600 dark:text-blue-400 bg-blue-900/20`,DEBUG:`text-gray-400 bg-gray-900/20`})[e]||`text-gray-400 bg-gray-900/20`,$=(e,t)=>t?{ERROR:`bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 border-red-500/50`,WARNING:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-600 dark:text-yellow-400 border-yellow-500/50`,WARN:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-600 dark:text-yellow-400 border-yellow-500/50`,INFO:`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`,DEBUG:`bg-gray-500/20 text-gray-400 border-gray-500/50`}[e]||`bg-primary/20 text-primary border-primary/50`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-white/60 border-stroke-subtle dark:border-white/20 hover:bg-stroke-subtle dark:hover:bg-white/10`,ne=e=>{I.value.has(e)?I.value.delete(e):I.value.add(e),I.value=new Set(I.value)},re=()=>{I.value=new Set(R.value)},ie=()=>{I.value=new Set},ae=()=>{L.value=new Set(z.value)},oe=()=>{L.value=new Set},se=()=>{H&&clearInterval(H),H=setInterval(K,5e3)},ce=()=>{H&&=(clearInterval(H),null)};return t(()=>{K(),se()}),m(()=>{ce()}),(t,n)=>(o(),p(`div`,v,[f(`div`,ee,[f(`div`,y,[n[1]||=f(`div`,null,[f(`h1`,{class:`text-content-primary dark:text-content-primary text-2xl font-semibold mb-2`},` System Logs `),f(`p`,{class:`text-content-secondary dark:text-content-muted`},` Real-time system events and diagnostics `)],-1),f(`button`,{onClick:K,disabled:B.value,class:`btn-primary flex items-center gap-2`},[(o(),p(`svg`,{class:h([`w-4 h-4`,{"animate-spin":B.value}]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...n[0]||=[f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`},null,-1)]],2)),u(` `+e(B.value?`Loading...`:`Refresh`),1)],8,b)]),f(`div`,x,[f(`div`,{class:`flex flex-wrap items-center gap-3 mb-4`},[n[2]||=f(`span`,{class:`text-content-primary dark:text-content-primary font-medium`},`Filters:`,-1),f(`button`,{onClick:re,class:`btn-success-xs`},` All Loggers `),f(`button`,{onClick:ie,class:`btn-danger-xs`},` Clear Loggers `),n[3]||=f(`div`,{class:`w-px h-4 bg-white/20 mx-1`},null,-1),f(`button`,{onClick:ae,class:`btn-success-xs`},` All Levels `),f(`button`,{onClick:oe,class:`btn-danger-xs`},` Clear Levels `)]),f(`div`,S,[(o(!0),p(d,null,a(J.value,t=>(o(),p(`button`,{key:`logger-`+t,onClick:e=>ne(t),class:h([`px-3 py-1 text-xs border rounded-full transition-colors`,I.value.has(t)?`bg-primary/20 text-primary border-primary/50`:`bg-background-mute dark:bg-white/5 text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/10`])},e(t),11,C))),128)),J.value.length>0&&Y.value.length>0?(o(),p(`div`,w)):s(``,!0),(o(!0),p(d,null,a(Y.value,t=>(o(),p(`button`,{key:`level-`+t,onClick:e=>X(t),class:h([`px-3 py-1 text-xs border rounded-full transition-colors font-medium`,L.value.has(t)?$(t,!0):$(t,!1)])},e(t),11,T))),128))])])]),f(`div`,E,[B.value&&F.value.length===0?(o(),p(`div`,te,[c(_,{class:`mx-auto mb-4`}),n[4]||=f(`p`,{class:`text-content-secondary dark:text-content-muted`},`Loading system logs...`,-1)])):V.value?(o(),p(`div`,D,[n[5]||=f(`div`,{class:`text-red-600 dark:text-red-400 mb-4`},[f(`svg`,{class:`w-12 h-12 mx-auto mb-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[f(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})])],-1),n[6]||=f(`h3`,{class:`text-content-primary dark:text-content-primary text-lg font-medium mb-2`},` Error Loading Logs `,-1),f(`p`,O,e(V.value),1),f(`button`,{onClick:K,class:`px-4 py-2 bg-red-100 dark:bg-red-500/20 hover:bg-red-500/30 text-red-600 dark:text-red-400 border border-red-500/50 rounded-lg transition-colors`},` Try Again `)])):(o(),p(`div`,k,[q.value.length===0?(o(),p(`div`,A,[...n[7]||=[r(`

No Logs to Display

No logs match the current filter criteria.

`,3)]])):(o(),p(`div`,j,[(o(!0),p(d,null,a(q.value,(t,n)=>(o(),p(`div`,{key:n,class:`flex items-start gap-4 p-4 hover:bg-background-mute dark:hover:bg-stroke/5 transition-colors font-mono text-sm`},[f(`span`,M,` [`+e(Z(t.timestamp))+`] `,1),f(`span`,N,e(U(t.message)),1),f(`span`,{class:h([`flex-shrink-0 px-2 py-1 text-xs font-medium rounded`,Q(t.level)])},e(t.level),3),f(`span`,P,e(W(t.message)),1)]))),128))]))]))])]))}});export{F as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/MessageDialog-CEzYMZ-3.js b/repeater/web/html/assets/MessageDialog-CEzYMZ-3.js deleted file mode 100644 index 1323a406..00000000 --- a/repeater/web/html/assets/MessageDialog-CEzYMZ-3.js +++ /dev/null @@ -1 +0,0 @@ -import{dt as e,g as t,l as n,pt as r,s as i,u as a,w as o}from"./runtime-core.esm-bundler-HnidnMFy.js";import{h as s}from"./index-BFltqMtv.js";var c={class:`mb-6`},l={key:0,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},u={key:1,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},d={key:2,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},f={class:`text-content-secondary dark:text-content-primary/80 text-base leading-relaxed`},p={class:`flex`},m=t({__name:`MessageDialog`,props:{show:{type:Boolean},message:{},variant:{default:`success`}},emits:[`close`],setup(t,{emit:m}){let h=t,g=m,_=e=>{e.target===e.currentTarget&&g(`close`)},v={success:`bg-green-100 dark:bg-green-500/20 border-green-600/40 dark:border-green-500/30 text-green-600 dark:text-green-400`,error:`bg-red-100 dark:bg-red-500/20 border-red-500/30 text-red-600 dark:text-red-400`,info:`bg-blue-500/20 border-blue-500/30 text-blue-600 dark:text-blue-400`},y={success:`bg-green-500 hover:bg-green-600`,error:`bg-red-500 hover:bg-red-600`,info:`bg-blue-500 hover:bg-blue-600`};return(t,m)=>h.show?(o(),a(`div`,{key:0,onClick:_,class:`fixed inset-0 bg-black/40 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[i(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10`,onClick:m[1]||=s(()=>{},[`stop`])},[i(`div`,c,[i(`div`,{class:e([`inline-flex p-3 rounded-xl mb-4`,v[h.variant]])},[h.variant===`success`?(o(),a(`svg`,l,[...m[2]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`},null,-1)]])):h.variant===`error`?(o(),a(`svg`,u,[...m[3]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(o(),a(`svg`,d,[...m[4]||=[i(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2),i(`p`,f,r(h.message),1)]),i(`div`,p,[i(`button`,{onClick:m[0]||=e=>g(`close`),class:e([`flex-1 px-4 py-3 rounded-xl text-white transition-all duration-200`,y[h.variant]])},` OK `,2)])])])):n(``,!0)}});export{m as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/MessageDialog-bhwyqS5K.js b/repeater/web/html/assets/MessageDialog-bhwyqS5K.js new file mode 100644 index 00000000..e6923ff2 --- /dev/null +++ b/repeater/web/html/assets/MessageDialog-bhwyqS5K.js @@ -0,0 +1 @@ +import{Ct as e,c as t,g as n,i as r,k as i,l as a,s as o,u as s,xt as c}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{u as l}from"./runtime-dom.esm-bundler-fKU3dih-.js";var u={class:`modal-card max-w-md`},d={class:`mb-6`},f={key:0,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},p={key:1,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},m={key:2,class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},h={class:`text-content-secondary dark:text-content-primary/80 text-base leading-relaxed`},g={class:`flex`},_=n({__name:`MessageDialog`,props:{show:{type:Boolean},message:{},variant:{default:`success`}},emits:[`close`],setup(n,{emit:_}){let v=n,y=_,b={success:`bg-green-100 dark:bg-green-500/20 border-green-600/40 dark:border-green-500/30 text-green-600 dark:text-green-400`,error:`bg-red-100 dark:bg-red-500/20 border-red-500/30 text-red-600 dark:text-red-400`,info:`bg-blue-500/20 border-blue-500/30 text-blue-600 dark:text-blue-400`},x={success:`bg-green-500 hover:bg-green-600`,error:`bg-red-500 hover:bg-red-600`,info:`bg-blue-500 hover:bg-blue-600`};return(n,_)=>(i(),t(r,{to:`body`},[v.show?(i(),s(`div`,{key:0,onClick:_[1]||=l(e=>y(`close`),[`self`]),class:`modal-backdrop`},[o(`div`,u,[o(`div`,d,[o(`div`,{class:c([`inline-flex p-3 rounded-xl mb-4`,b[v.variant]])},[v.variant===`success`?(i(),s(`svg`,f,[..._[2]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`},null,-1)]])):v.variant===`error`?(i(),s(`svg`,p,[..._[3]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(i(),s(`svg`,m,[..._[4]||=[o(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2),o(`p`,h,e(v.message),1)]),o(`div`,g,[o(`button`,{onClick:_[0]||=e=>y(`close`),class:c([`flex-1 px-4 py-3 rounded-xl text-white transition-all duration-200`,x[v.variant]])},` OK `,2)])])])):a(``,!0)]))}});export{_ as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/Neighbors-Bng0BMwC.css b/repeater/web/html/assets/Neighbors-Bng0BMwC.css new file mode 100644 index 00000000..8da54b84 --- /dev/null +++ b/repeater/web/html/assets/Neighbors-Bng0BMwC.css @@ -0,0 +1 @@ +.modal-enter-active[data-v-a7b4afec],.modal-leave-active[data-v-a7b4afec]{transition:opacity .2s}.modal-enter-from[data-v-a7b4afec],.modal-leave-to[data-v-a7b4afec]{opacity:0}.modal-enter-active>div[data-v-a7b4afec],.modal-leave-active>div[data-v-a7b4afec]{transition:transform .2s}.modal-enter-from>div[data-v-a7b4afec],.modal-leave-to>div[data-v-a7b4afec]{transform:scale(.95)}.packet-enter-active[data-v-a7b4afec],.packet-leave-active[data-v-a7b4afec]{transition:all .15s}.packet-enter-from[data-v-a7b4afec],.packet-leave-to[data-v-a7b4afec]{opacity:0;transform:translate(-50%)scale(.5)}.custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar{width:8px}.custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar-track{background:0 0}.custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar-thumb{background:#0003;border-radius:4px}.dark .custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar-thumb{background:#fff3}.custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar-thumb:hover{background:#0000004d}.dark .custom-scrollbar[data-v-dc69b1d1]::-webkit-scrollbar-thumb:hover{background:#ffffff4d}.modal-enter-active[data-v-dc69b1d1],.modal-leave-active[data-v-dc69b1d1]{transition:opacity .3s}.modal-enter-active>div[data-v-dc69b1d1],.modal-leave-active>div[data-v-dc69b1d1]{transition:transform .3s,opacity .3s}.modal-enter-from[data-v-dc69b1d1],.modal-leave-to[data-v-dc69b1d1]{opacity:0}.modal-enter-from>div[data-v-dc69b1d1],.modal-leave-to>div[data-v-dc69b1d1]{opacity:0;transform:scale(.95)}.leaflet-container{background:0 0}.custom-marker{background:0 0!important;border:none!important}.map-container[data-v-47bae275]{background:0 0;border-radius:15px;position:relative;overflow:hidden}.leaflet-map-container[data-v-47bae275]{-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);background:linear-gradient(135deg,#09090bcc 0%,#0009 100%)}.map-legend[data-v-47bae275]{color:#fff;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:200;background:#0006;border:1px solid #ffffff1a;border-radius:15px;min-width:150px;max-width:180px;padding:12px;font-size:12px;position:absolute;top:10px;right:10px;box-shadow:0 8px 32px #0000004d}.legend-title[data-v-47bae275]{color:#fff;margin-bottom:10px;font-size:13px;font-weight:700}.legend-section[data-v-47bae275]{margin-bottom:10px}.legend-section[data-v-47bae275]:last-of-type{margin-bottom:8px}.legend-subtitle[data-v-47bae275]{color:#fffc;text-transform:uppercase;letter-spacing:.5px;margin-bottom:6px;font-size:11px;font-weight:600}.legend-footer[data-v-47bae275]{color:#fff9;text-align:center;border-top:1px solid #ffffff1a;margin-top:10px;padding-top:8px;font-size:10px}.legend-items[data-v-47bae275]{flex-direction:column;gap:4px;display:flex}.legend-item[data-v-47bae275]{align-items:center;gap:6px;display:flex}.legend-icon[data-v-47bae275]{border:1px solid #fffc;border-radius:50%;flex-shrink:0;width:8px;height:8px;box-shadow:0 1px 2px #0003}.legend-icon.cluster-icon[data-v-47bae275]{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);border:1px solid #aae8e8;border-radius:50%;width:16px;height:16px}.legend-line[data-v-47bae275]{border-radius:1px;flex-shrink:0;width:16px;height:2px;position:relative}.legend-line-dashed[data-v-47bae275]{background-color:#0000!important;background-image:repeating-linear-gradient(90deg,currentColor 0 4px,#0000 4px 8px)!important}.legend-line-dashed[style*=\#FFC246][data-v-47bae275]{color:#ffc246!important}.legend-line-dashed[style*=\#ea580c][data-v-47bae275]{color:#ea580c!important}.marker-highlight{z-index:1000!important;border-radius:50%!important;animation:1s ease-in-out infinite marker-glow-47bae275!important;position:relative!important;transform:scale(1.2)!important;box-shadow:0 0 0 3px #a5e5b6,0 0 8px #a5e5b6,0 0 16px #a5e5b6!important}@keyframes marker-glow-47bae275{0%,to{filter:brightness();box-shadow:0 0 0 3px #a5e5b6,0 0 8px #a5e5b6,0 0 16px #a5e5b6}50%{filter:brightness(1.3);box-shadow:0 0 0 5px #a5e5b6,0 0 12px #a5e5b6,0 0 24px #a5e5b6}}@keyframes pulse-highlight-47bae275{0%{box-shadow:0 0 #3b82f6b3}70%{box-shadow:0 0 0 8px #3b82f600}to{box-shadow:0 0 #3b82f600}}.leaflet-popup-content-wrapper{color:#fff!important;-webkit-backdrop-filter:blur(20px)!important;backdrop-filter:blur(20px)!important;background:#0006!important;border:1px solid #ffffff1a!important;border-radius:15px!important;box-shadow:0 8px 32px #0000004d!important}.leaflet-popup-tip{background:#0006!important;border:1px solid #ffffff1a!important}.leaflet-popup-close-button{color:#fff9!important;font-size:18px!important}.leaflet-popup-close-button:hover{color:#fff!important}.custom-div-icon,.custom-cluster-icon{background:0 0!important;border:none!important}.custom-cluster-icon div{cursor:pointer!important;transition:all .3s!important}.custom-cluster-icon:hover div{transform:scale(1.1)!important;box-shadow:0 6px 16px #aae8e880!important}.leaflet-control-zoom{overflow:hidden;-webkit-backdrop-filter:blur(20px)!important;backdrop-filter:blur(20px)!important;border:1px solid #ffffff1a!important;border-radius:15px!important}.leaflet-control-zoom a{color:#fff!important;background-color:#0006!important;border-bottom:1px solid #ffffff1a!important;transition:all .2s!important}.leaflet-control-zoom a:hover{color:#fff!important;background-color:#ffffff1a!important}.leaflet-control-attribution{color:#9ca3af!important;background-color:#1f2937cc!important;border-top:1px solid #4b55634d!important;border-radius:4px!important;padding:4px 8px!important;font-size:11px!important}.leaflet-control-attribution a{text-decoration:none;color:#60a5fa!important}.leaflet-control-attribution a:hover{text-decoration:underline;color:#93c5fd!important}.leaflet-bottom.leaflet-left .leaflet-control-attribution{margin-bottom:10px!important;margin-left:10px!important}.map-attribution[data-v-47bae275]{color:#fff9;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:1000;background:#0006;border:1px solid #ffffff1a;border-radius:15px;padding:4px 8px;font-size:10px;position:absolute;bottom:10px;left:10px}@media (width<=640px){.leaflet-control-attribution{display:none!important}} diff --git a/repeater/web/html/assets/Neighbors-CQcUQfDG.js b/repeater/web/html/assets/Neighbors-CQcUQfDG.js deleted file mode 100644 index 28d4e1b9..00000000 --- a/repeater/web/html/assets/Neighbors-CQcUQfDG.js +++ /dev/null @@ -1,65 +0,0 @@ -import{r as e}from"./chunk-DECur_0Z.js";import{A as t,C as n,E as r,S as i,b as a,c as o,dt as s,f as c,ft as l,g as u,i as d,j as f,k as p,l as m,m as h,o as g,p as _,pt as v,r as y,s as b,u as x,w as S,z as C}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as w}from"./api-CbM6k1ZB.js";import{t as T}from"./system-BH4r-ii6.js";import{t as E}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{c as D,d as O,f as k,h as A,p as j}from"./index-BFltqMtv.js";import{t as M}from"./leaflet-src-PYB8oVmQ.js";/* empty css */import{n as N,t as P}from"./preferences-Bv8i60GL.js";import{t as F}from"./useSignalQuality-BfZWbBxN.js";var I={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mb-6`},L={class:`flex items-center gap-3`},R={class:`flex-1 min-w-0`},z={class:`text-content-primary dark:text-content-primary font-medium truncate`},B={class:`text-content-secondary dark:text-content-muted text-sm font-mono`},V={key:0,class:`text-white/50 text-xs`},H={key:1,class:`text-white/50 text-xs`},U=u({__name:`DeleteNeighborModal`,props:{show:{type:Boolean},neighbor:{}},emits:[`close`,`delete`],setup(e,{emit:t}){let n=e,r=t,i=()=>{n.neighbor&&(r(`delete`,n.neighbor.id),a())},a=()=>{r(`close`)},o=e=>{e.target===e.currentTarget&&a()};return(t,n)=>e.show&&e.neighbor?(S(),x(`div`,{key:0,onClick:o,class:`fixed inset-0 bg-black/80 backdrop-blur-lg z-[99999] flex items-center justify-center p-4`,style:{"backdrop-filter":`blur(8px) saturate(180%)`,position:`fixed`,top:`0`,left:`0`,right:`0`,bottom:`0`}},[b(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10`,onClick:n[0]||=A(()=>{},[`stop`])},[b(`div`,{class:`flex items-center gap-3 mb-6`},[n[2]||=b(`svg`,{class:`w-6 h-6 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),n[3]||=b(`div`,null,[b(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Delete Neighbor `),b(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mt-1`},` Are you sure you want to delete this neighbor? `)],-1),b(`button`,{onClick:a,class:`ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...n[1]||=[b(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),b(`div`,I,[b(`div`,L,[b(`div`,R,[b(`div`,z,v(e.neighbor?.node_name||e.neighbor?.long_name||e.neighbor?.short_name||`Unknown`),1),b(`div`,B,` ID: `+v(e.neighbor?.node_num_hex||e.neighbor?.node_num||e.neighbor?.id||`N/A`),1),e.neighbor?.contact_type?(S(),x(`div`,V,v(e.neighbor.contact_type),1)):m(``,!0),e.neighbor?.hw_model?(S(),x(`div`,H,v(e.neighbor.hw_model),1)):m(``,!0)])])]),n[4]||=b(`div`,{class:`bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6`},[b(`div`,{class:`flex items-center gap-2 text-accent-red text-sm`},[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})]),b(`span`,null,`This action cannot be undone`)])],-1),b(`div`,{class:`flex gap-3`},[b(`button`,{onClick:a,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),b(`button`,{onClick:i,class:`flex-1 px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors font-medium`},` Delete `)])])])):m(``,!0)}}),W={class:`bg-gradient-to-r from-primary/20 to-accent-cyan/20 border-b border-stroke-subtle dark:border-stroke/10 px-6 py-4`},G={class:`flex items-center justify-between`},K={class:`flex items-center gap-3`},ee={key:0,class:`text-sm text-content-secondary dark:text-content-muted`},te={class:`p-6`},q={key:0,class:`text-center py-8`},ne={key:1,class:`text-center py-8`},re={class:`text-content-secondary dark:text-content-muted text-sm`},ie={key:2,class:`space-y-4`},ae={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},oe={class:`flex items-center justify-between mb-2`},se={class:`flex items-baseline gap-2`},ce={class:`text-3xl font-bold text-content-primary dark:text-content-primary`},le={class:`grid grid-cols-2 gap-3`},ue={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},de={class:`flex items-center gap-2 mb-2`},fe={class:`flex gap-0.5`},pe={class:`flex items-baseline gap-1`},me={class:`text-xl font-bold text-content-primary dark:text-content-primary`},he={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},ge={class:`flex items-baseline gap-1`},_e={class:`text-xl font-bold text-content-primary dark:text-content-primary`},ve={key:0,class:`flex items-start gap-3 bg-amber-500/10 border border-amber-500/30 rounded-[12px] p-3`},ye={class:`text-xs leading-relaxed`},be={class:`font-semibold text-amber-600 dark:text-amber-400 mb-0.5`},xe={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},Se={class:`relative`},Ce={class:`flex items-center gap-2 overflow-x-auto pb-2`},we={key:0,class:`relative flex items-center`},Te={key:0,class:`absolute left-1/2 -translate-x-1/2 animate-pulse`},Ee={class:`text-content-muted dark:text-content-muted text-xs mt-2 flex items-center justify-between`},De={key:0,class:`text-cyan-500 dark:text-primary animate-pulse`},Oe={class:`flex items-center justify-between text-xs text-content-muted dark:text-content-muted pt-2`},ke=E(u({__name:`PingResultModal`,props:{show:{type:Boolean},nodeName:{default:null},result:{default:null},error:{default:null},loading:{type:Boolean,default:!1}},emits:[`close`],setup(e,{emit:n}){let i=e,a=n,c=T(),{getSignalQuality:l}=F(),u=C(0),f=C(!1),_=g(()=>{let e=c.stats?.config?.radio?.spreading_factor??7,t=c.stats?.config?.radio?.bandwidth??125,n=c.stats?.config?.radio?.coding_rate??5;return 2**e/t*(8+4.25*(n-4)+20)}),w=g(()=>{if(!i.result)return{color:`text-gray-400`,label:`Unknown`};let e=i.result.rtt_ms,t=_.value,n=i.result.path.length,r=2*t*n+500*n;return e{if(!i.result)return{bars:0,color:`text-gray-400`};let e=l(i.result.rssi);return{bars:e.bars,color:e.color}}),O=g(()=>{if(!i.result)return 0;if(i.result.path_hash_mode!==void 0)return i.result.path_hash_mode;let e=i.result.path.reduce((e,t)=>{let n=t.replace(/^0x/i,``);return Math.max(e,n.length)},0);return e>4?2:e>2?1:0}),k=g(()=>O.value>0),j=g(()=>({0:`1-byte`,1:`2-byte`,2:`3-byte`})[O.value]??`1-byte`);p(()=>i.result,e=>{if(e&&!f.value){f.value=!0,u.value=0;let t=e.path.length,n=1500/(t*2),r=0,i=t*2-2,a=()=>{r<=i?(u.value=r/i,r++,setTimeout(a,n)):(f.value=!1,u.value=1)};setTimeout(a,100)}},{immediate:!0});let M=g(()=>{if(!i.result||!f.value)return-1;let e=i.result.path.length;if(e<=1)return-1;let t=u.value,n=.5;if(t<=n)return t/n*(e-1);{let r=(t-n)/n;return(e-1)*(1-r)}}),N=()=>{a(`close`)};return(n,i)=>(S(),o(d,{to:`body`},[h(D,{name:`modal`},{default:t(()=>[e.show?(S(),x(`div`,{key:0,class:`fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[99999] p-4`,onClick:A(N,[`self`])},[b(`div`,{class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/20 rounded-[20px] shadow-2xl w-full max-w-md overflow-hidden`,onClick:i[0]||=A(()=>{},[`stop`])},[b(`div`,W,[b(`div`,G,[b(`div`,K,[i[2]||=b(`div`,{class:`p-2 bg-cyan-400/20 dark:bg-primary/20 rounded-lg`},[b(`svg`,{class:`w-5 h-5 text-cyan-500 dark:text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})])],-1),b(`div`,null,[i[1]||=b(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary`},` Ping Result `,-1),e.nodeName?(S(),x(`p`,ee,v(e.nodeName),1)):m(``,!0)])]),b(`button`,{onClick:N,class:`p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary`},[...i[3]||=[b(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),b(`div`,te,[e.loading?(S(),x(`div`,q,[...i[4]||=[b(`div`,{class:`animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4`},null,-1),b(`p`,{class:`text-content-secondary dark:text-content-muted`},`Sending ping...`,-1),b(`p`,{class:`text-content-muted dark:text-content-muted text-sm mt-1`},` Waiting for response... `,-1)]])):e.error?(S(),x(`div`,ne,[i[5]||=b(`div`,{class:`p-3 bg-accent-red/10 rounded-full w-16 h-16 mx-auto mb-4 flex items-center justify-center`},[b(`svg`,{class:`w-8 h-8 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z`})])],-1),i[6]||=b(`h3`,{class:`text-accent-red font-semibold mb-2`},`Ping Failed`,-1),b(`p`,re,v(e.error),1)])):e.result?(S(),x(`div`,ie,[b(`div`,ae,[b(`div`,oe,[i[7]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Round-Trip Time`,-1),b(`span`,{class:s([`text-xs font-medium px-2 py-1 rounded-full`,w.value.color,`bg-current/10`])},v(w.value.label),3)]),b(`div`,se,[b(`span`,ce,v(e.result.rtt_ms.toFixed(2)),1),i[8]||=b(`span`,{class:`text-content-secondary dark:text-content-muted`},`ms`,-1)])]),b(`div`,le,[b(`div`,ue,[b(`div`,de,[i[9]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`RSSI`,-1),b(`div`,fe,[(S(),x(y,null,r(5,e=>b(`div`,{key:e,class:s([`w-1 h-3 rounded-sm`,e<=E.value.bars?E.value.color:`bg-stroke-subtle dark:bg-stroke/10`])},null,2)),64))])]),b(`div`,pe,[b(`span`,me,v(e.result.rssi),1),i[10]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`dBm`,-1)])]),b(`div`,he,[i[12]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-2`},`SNR`,-1),b(`div`,ge,[b(`span`,_e,v(e.result.snr_db),1),i[11]||=b(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`dB`,-1)])])]),k.value?(S(),x(`div`,ve,[i[14]||=b(`svg`,{class:`w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z`})],-1),b(`div`,ye,[b(`p`,be,v(j.value)+` path hashes active `,1),i[13]||=b(`p`,{class:`text-content-secondary dark:text-content-muted`},` This result uses multi-byte path hashes. The repeater being traced must be running firmware that supports multi-byte path hashes. Repeaters on older firmware will not respond to or correctly route these trace packets. `,-1)])])):m(``,!0),b(`div`,xe,[i[17]||=b(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3`},` Network Path `,-1),b(`div`,Se,[b(`div`,Ce,[(S(!0),x(y,null,r(e.result.path,(n,r)=>(S(),x(`div`,{key:r,class:`flex items-center gap-2 flex-shrink-0 relative`},[b(`div`,{class:s([`bg-cyan-400/20 dark:bg-primary/20 text-cyan-600 dark:text-primary border border-cyan-400/40 dark:border-primary/30 px-3 py-1.5 rounded-lg text-sm font-mono transition-all duration-300`,f.value&&Math.floor(M.value)===r?`ring-2 ring-cyan-400/50 dark:ring-primary/50 scale-105`:``])},v(n),3),r[f.value&&M.value>=r&&M.valuenew Date(e*1e3).toLocaleString(),T=e=>e?`${e} dBm`:`N/A`,E=e=>e?`${e.toFixed(1)} dB`:`N/A`,O=e=>({0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`})[e||0]||`Unknown`,k=e=>({Unknown:`Unknown`,"Chat Node":`Chat Node`,Repeater:`Repeater`,"Room Server":`Room Server`,"Hybrid Node":`Hybrid Node`})[e]||e,j=e=>({Unknown:`text-gray-600 dark:text-gray-400`,"Chat Node":`text-blue-600 dark:text-blue-400`,Repeater:`text-emerald-600 dark:text-emerald-400`,"Room Server":`text-purple-600 dark:text-purple-400`,"Hybrid Node":`text-amber-600 dark:text-amber-400`})[e]||`text-gray-600 dark:text-gray-400`,M=async()=>{if(!c.neighbor?.latitude||!c.neighbor?.longitude)return;let e=`${c.neighbor.latitude.toFixed(6)}, ${c.neighbor.longitude.toFixed(6)}`;try{await navigator.clipboard.writeText(e),a.value=`Copied!`,setTimeout(()=>{a.value=`Copy`},2e3)}catch(e){console.error(`Failed to copy coordinates:`,e),a.value=`Failed`,setTimeout(()=>{a.value=`Copy`},2e3)}},N=g(()=>{if(!c.neighbor?.latitude||!c.neighbor?.longitude||!c.baseLatitude||!c.baseLongitude)return null;let e=(c.neighbor.latitude-c.baseLatitude)*Math.PI/180,t=(c.neighbor.longitude-c.baseLongitude)*Math.PI/180,n=Math.sin(e/2)*Math.sin(e/2)+Math.cos(c.baseLatitude*Math.PI/180)*Math.cos(c.neighbor.latitude*Math.PI/180)*Math.sin(t/2)*Math.sin(t/2);return 6371*(2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n)))}),P=g(()=>c.neighbor?.latitude!==null&&c.neighbor?.longitude!==null&&c.neighbor?.latitude!==0&&c.neighbor?.longitude!==0&&Math.abs(c.neighbor?.latitude??0)<=90&&Math.abs(c.neighbor?.longitude??0)<=180),I=()=>{if(!u.value||!c.neighbor||!P.value)return;f&&=(f.remove(),null);let e=document.documentElement.classList.contains(`dark`);f=J.default.map(u.value,{center:[c.neighbor.latitude,c.neighbor.longitude],zoom:13,zoomControl:!0,attributionControl:!1});let t=e?`https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png`;J.default.tileLayer(t,{maxZoom:19,attribution:`© OpenStreetMap © CARTO`}).addTo(f);let n=J.default.divIcon({className:`custom-marker`,html:`
${c.neighbor.node_name?.charAt(0)||`?`}
`,iconSize:[32,32],iconAnchor:[16,16]});if(J.default.marker([c.neighbor.latitude,c.neighbor.longitude],{icon:n}).addTo(f).bindPopup(`${c.neighbor.node_name||`Unknown`}
${c.neighbor.pubkey.slice(0,8)}...`),c.baseLatitude!==null&&c.baseLongitude!==null&&c.baseLatitude!==0&&c.baseLongitude!==0&&Math.abs(c.baseLatitude)<=90&&Math.abs(c.baseLongitude)<=180){let e=J.default.divIcon({className:`custom-marker`,html:`
B
`,iconSize:[32,32],iconAnchor:[16,16]});J.default.marker([c.baseLatitude,c.baseLongitude],{icon:e}).addTo(f).bindPopup(`Base Station`),J.default.polyline([[c.baseLatitude,c.baseLongitude],[c.neighbor.latitude,c.neighbor.longitude]],{color:`#3b82f6`,weight:2,opacity:.6,dashArray:`5, 10`}).addTo(f);let t=J.default.latLngBounds([c.baseLatitude,c.baseLongitude],[c.neighbor.latitude,c.neighbor.longitude]);f.fitBounds(t,{padding:[50,50]})}},L=e=>{e.key===`Escape`&&l(`close`)},R=e=>{e.target===e.currentTarget&&l(`close`)};p(()=>c.isOpen,e=>{e?(document.body.style.overflow=`hidden`,setTimeout(()=>{P.value&&I()},100)):(document.body.style.overflow=``,f&&=(f.remove(),null))},{immediate:!0});let z=g(()=>c.neighbor?.rssi?i(c.neighbor.rssi):null);return(n,i)=>(S(),o(d,{to:`body`},[h(D,{name:`modal`,appear:``},{default:t(()=>[e.isOpen&&e.neighbor?(S(),x(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 overflow-hidden`,onClick:R,onKeydown:L,tabindex:`0`},[i[20]||=b(`div`,{class:`absolute inset-0 bg-black/60 backdrop-blur-md pointer-events-none`},null,-1),b(`div`,{class:`relative w-full max-w-4xl max-h-[90vh] flex flex-col`,onClick:i[2]||=A(()=>{},[`stop`])},[b(`div`,Ae,[b(`div`,je,[b(`div`,Me,[b(`h2`,Ne,v(e.neighbor.node_name||`Unknown Node`),1),b(`p`,Pe,v(e.neighbor.pubkey),1)]),b(`div`,Fe,[b(`button`,{onClick:i[0]||=e=>l(`close`),class:`w-8 h-8 flex items-center justify-center rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors duration-200 text-gray-700 dark:text-white hover:text-gray-900 dark:hover:text-white`},[...i[3]||=[b(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),b(`div`,Ie,[b(`div`,Le,[i[8]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Basic Information `,-1),b(`div`,Re,[b(`div`,ze,[i[4]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Contact Type `,-1),b(`div`,{class:s([`font-medium`,j(e.neighbor.contact_type)])},v(k(e.neighbor.contact_type)),3)]),b(`div`,Be,[i[5]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Route Type `,-1),b(`div`,Ve,v(O(e.neighbor.route_type)),1)]),b(`div`,He,[i[6]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Zero Hop `,-1),b(`div`,{class:s([`font-medium`,e.neighbor.zero_hop?`text-green-600 dark:text-green-400`:`text-gray-600 dark:text-gray-400`])},v(e.neighbor.zero_hop?`Yes`:`No`),3)]),b(`div`,Ue,[i[7]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Advert Count `,-1),b(`div`,We,v(e.neighbor.advert_count.toLocaleString()),1)])])]),b(`div`,Ge,[i[12]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Signal Quality `,-1),b(`div`,Ke,[b(`div`,qe,[i[9]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` RSSI `,-1),b(`div`,Je,v(T(e.neighbor.rssi)),1)]),b(`div`,Ye,[i[10]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` SNR `,-1),b(`div`,Xe,v(E(e.neighbor.snr)),1)]),z.value?(S(),x(`div`,Ze,[i[11]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Signal Strength `,-1),b(`div`,Qe,[b(`div`,$e,[(S(),x(y,null,r(4,e=>b(`div`,{key:e,class:s([`w-1 h-3 rounded-sm`,e<=z.value.bars?z.value.color:`bg-gray-300 dark:bg-gray-700`])},null,2)),64))]),b(`span`,{class:s([`text-sm font-medium`,z.value.color])},v(z.value.quality),3)])])):m(``,!0)])]),b(`div`,et,[i[15]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Timeline `,-1),b(`div`,tt,[b(`div`,nt,[i[13]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` First Seen `,-1),b(`div`,rt,v(w(e.neighbor.first_seen)),1)]),b(`div`,it,[i[14]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Last Seen `,-1),b(`div`,at,v(w(e.neighbor.last_seen)),1)])])]),P.value?(S(),x(`div`,ot,[i[19]||=b(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Location `,-1),b(`div`,st,[b(`div`,ct,[i[16]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Latitude `,-1),b(`div`,lt,v(e.neighbor.latitude?.toFixed(6)),1)]),b(`div`,ut,[i[17]||=b(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Longitude `,-1),b(`div`,dt,v(e.neighbor.longitude?.toFixed(6)),1)]),b(`div`,ft,[b(`div`,pt,v(N.value===null?`Coordinates`:`Distance`),1),N.value===null?(S(),x(`button`,{key:1,onClick:M,class:`w-full px-3 py-1.5 bg-primary hover:bg-primary/90 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium rounded-lg transition-colors flex items-center justify-center gap-1.5`},[i[18]||=b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),_(` `+v(a.value),1)])):(S(),x(`div`,mt,v(N.value.toFixed(2))+` km `,1))])]),b(`div`,{ref_key:`mapContainer`,ref:u,class:`w-full h-96 rounded-[12px] overflow-hidden border border-stroke-subtle dark:border-white/10`},null,512)])):m(``,!0)]),b(`div`,ht,[b(`button`,{onClick:i[1]||=e=>l(`close`),class:`w-full px-4 py-2.5 bg-primary hover:bg-primary/90 dark:bg-gray-700 dark:hover:bg-gray-600 text-white font-medium rounded-lg transition-colors`},` Close `)])])])],32)):m(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-2fb1fa15`]]),_t=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],vt=1,Y=8,yt=class e{static from(t){if(!(t instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==vt)throw Error(`Got v${i} data when expected v${vt}.`);let a=_t[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,t)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=_t.indexOf(this.ArrayType),a=e*2*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,Y,e),this.coords=new this.ArrayType(this.data,Y+o+s,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(Y+a+o+s),this.ids=new this.IndexArrayType(this.data,Y,e),this.coords=new this.ArrayType(this.data,Y+o+s,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(vt<<4)+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return bt(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)Ct(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];Ct(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}};function bt(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;xt(e,t,o,r,i,a),bt(e,t,n,r,o-1,1-a),bt(e,t,n,o+1,i,1-a)}function xt(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);xt(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(X(e,t,r,n),t[2*i+a]>o&&X(e,t,r,i);so;)c--}t[2*r+a]===o?X(e,t,r,c):(c++,X(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function X(e,t,n,r){St(e,n,r),St(t,2*n,2*r),St(t,2*n+1,2*r+1)}function St(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Ct(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var wt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Tt=Math.fround||(e=>(t=>(e[0]=+t,e[0])))(new Float32Array(1)),Z=2,Q=3,Et=4,$=5,Dt=6,Ot=class{constructor(e){this.options=Object.assign(Object.create(wt),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t=n;e--){let n=+Date.now();o=this.trees[e]=this._createTree(this._cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,+Date.now()-n)}return t&&console.timeEnd(`total time`),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClusters([n,r,180,a],t),o=this.getClusters([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this._limitZoom(t)],s=o.range(jt(n),Mt(a),jt(i),Mt(r)),c=o.data,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+$]>1?kt(c,t,this.clusterProps):this.points[c[t+Q]])}return l}getChildren(e){let t=this._getOriginId(e),n=this._getOriginZoom(e),r=`No cluster with the specified id.`,i=this.trees[n];if(!i)throw Error(r);let a=i.data;if(t*this.stride>=a.length)throw Error(r);let o=this.options.radius/(this.options.extent*2**(n-1)),s=a[t*this.stride],c=a[t*this.stride+1],l=i.within(s,c,o),u=[];for(let t of l){let n=t*this.stride;a[n+Et]===e&&u.push(a[n+$]>1?kt(a,n,this.clusterProps):this.points[a[n+Q]])}if(u.length===0)throw Error(r);return u}getLeaves(e,t,n){t||=10,n||=0;let r=[];return this._appendLeaves(r,e,t,n,0),r}getTile(e,t,n){let r=this.trees[this._limitZoom(e)],i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={features:[]};return this._addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.data,t,n,i,u),t===0&&this._addTileFeatures(r.range(1-s/i,c,1,l),r.data,i,n,i,u),t===i-1&&this._addTileFeatures(r.range(0,c,s/i,l),r.data,-1,n,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){let n=this.getChildren(e);if(t++,n.length!==1)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a&&a.cluster?i+a.point_count<=r?i+=a.point_count:i=this._appendLeaves(e,a.cluster_id,n,r,i):i1,c,l,u;if(s)c=At(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+Q]];c=n.properties;let[r,i]=n.geometry.coordinates;l=jt(r),u=Mt(i)}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+Q]:this.points[t[e+Q]].id,f!==void 0&&(d.id=f),a.features.push(d)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.data,c=[],l=this.stride;for(let n=0;nt&&(p+=s[n+$])}if(p>f&&p>=a){let e=r*f,a=u*f,o,m=-1,h=((n/l|0)<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+Z]<=t)continue;s[c+Z]=t;let u=s[c+$];e+=s[c]*u,a+=s[c+1]*u,s[c+Et]=h,i&&(o||(o=this._map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(o)),i(o,this._map(s,c)))}s[n+Et]=h,c.push(e/p,a/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e1)for(let e of d){let n=e*l;if(!(s[n+Z]<=t)){s[n+Z]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+$]>1){let r=this.clusterProps[e[t+Dt]];return n?Object.assign({},r):r}let r=this.points[e[t+Q]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}};function kt(e,t,n){return{type:`Feature`,id:e[t+Q],properties:At(e,t,n),geometry:{type:`Point`,coordinates:[Nt(e[t]),Pt(e[t+1])]}}}function At(e,t,n){let r=e[t+$],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?`${Math.round(r/100)/10}k`:r,a=e[t+Dt],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+Q],point_count:r,point_count_abbreviated:i})}function jt(e){return e/360+.5}function Mt(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function Nt(e){return(e-.5)*360}function Pt(e){let t=(180-e*360)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var Ft={class:`map-container`},It={key:0,class:`flex items-center justify-center h-96 glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] shadow-sm dark:shadow-none`},Lt={class:`hidden sm:inline`},Rt={key:3,class:`map-legend`},zt={class:`legend-footer`},Bt={key:4,class:`map-attribution`},Vt=E(u({__name:`NetworkMap`,props:{adverts:{},baseLatitude:{default:null},baseLongitude:{default:null},showLegend:{type:Boolean,default:!0}},emits:[`update:showLegend`],setup(e,{expose:t,emit:r}){typeof window<`u`&&!window.chrome&&(window.chrome={runtime:{}});let o=e,s=r,l=()=>{s(`update:showLegend`,!o.showLegend)},u=C(),d=null,f=C(new Map),h=null,_=C(new Map),y=C([]),w=C(!0),T=C(60),E=C(14),D=C(document.documentElement.classList.contains(`dark`)),O=new MutationObserver(()=>{let e=document.documentElement.classList.contains(`dark`);e!==D.value&&(D.value=e,d&&I())}),k=g(()=>o.baseLatitude!==null&&o.baseLongitude!==null&&typeof o.baseLatitude==`number`&&typeof o.baseLongitude==`number`&&o.baseLatitude!==0&&o.baseLongitude!==0&&Math.abs(o.baseLatitude)<=90&&Math.abs(o.baseLongitude)<=180),A=e=>new Date(e*1e3).toLocaleString(),j=e=>e?`${e} dBm`:`N/A`,M=e=>e?`${e} dB`:`N/A`,N=e=>({0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`})[e||0]||`Unknown`,P=(e,t,n,r)=>{let i=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(a/2)*Math.sin(a/2);return 6371*(2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)))},F=()=>{d&&=(y.value.forEach(e=>{d&&e.remove()}),y.value.length=0,d.remove(),null),f.value.clear(),_.value.clear(),h=null},I=async()=>{let e=d?.getZoom()||11,t=d?.getCenter()||(k.value?[o.baseLatitude,o.baseLongitude]:[0,0]);F(),await a(),await z(),d&&d.setView(t,e)},L=e=>{let t=new Map;return e.filter(e=>e.latitude!==null&&e.longitude!==null).map(e=>{let n=e.latitude,r=e.longitude,i=`${n.toFixed(6)}_${r.toFixed(6)}`,a=t.get(i)||0;if(t.set(i,a+1),a>0){let e=.001,t=a*60*(Math.PI/180);n+=Math.sin(t)*e*(a*.5),r+=Math.cos(t)*e*(a*.5)}return{type:`Feature`,properties:{advert:{...e,jittered_latitude:n,jittered_longitude:r}},geometry:{type:`Point`,coordinates:[r,n]}}})},R=e=>{h=new Ot({radius:T.value,maxZoom:E.value,minPoints:2}),h.load(e)},z=async()=>{if(!u.value||!k.value){console.warn(`Cannot initialize map: missing container or coordinates`);return}F(),await a();let e=o.baseLatitude,t=o.baseLongitude;d=J.default.map(u.value,{center:[e,t],zoom:11,zoomControl:!0,attributionControl:!1,preferCanvas:!1});try{let e=D.value?`https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png`,t=D.value?`https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}{r}.png`,n=J.default.tileLayer(e,{maxZoom:19,attribution:`© OpenStreetMap contributors © CARTO`,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`}),r=J.default.tileLayer(t,{maxZoom:19,attribution:``,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`});n.addTo(d),r.addTo(d)}catch(e){console.warn(`Error loading tiles:`,e)}try{let n=(e,t=!1)=>{let n=t?16:12;return J.default.divIcon({className:`custom-div-icon`,html:`
`,iconSize:[n+4,n+4],iconAnchor:[(n+4)/2,(n+4)/2]})},r=e=>{let t=e<10?30:e<100?40:50;return J.default.divIcon({className:`custom-cluster-icon`,html:` -
- ${e} -
- `,iconSize:[t,t],iconAnchor:[t/2,t/2]})},i=n(`#ef4444`,!0);J.default.marker([e,t],{icon:i}).addTo(d).bindPopup(` -
- Base Station
- Base Station
- ${e.toFixed(6)}, ${t.toFixed(6)} -
- `);let a={Unknown:`#9CA3AF`,"Chat Node":`#60A5FA`,Repeater:`#A5E5B6`,"Room Server":`#EBA0FC`,"Hybrid Node":`#FFC246`},s=(e,t,n,r,i=0)=>{if(!d)return;let a=e.jittered_latitude||e.latitude,o=e.jittered_longitude||e.longitude;if(a===null||o===null)return;let s=e.route_type||0,c=r,l=3,u=.7,f;s===2?(c=`#A5E5B6`,l=4,u=.9):s===1?(c=`#FFC246`,f=`10, 5`,u=.8):s===3?(c=`#059669`,l=5,u=.95):s===0?(c=`#ea580c`,f=`12, 6`,u=.8):(c=`#9CA3AF`,f=`2, 5`,u=.6);let p=[t,n],m=[a,o],h=J.default.polyline([p,m],{color:c,weight:l,opacity:0,dashArray:f,className:`connection-line`}).addTo(d),g=J.default.polyline([p,p],{color:c,weight:l,opacity:0,dashArray:f,className:`connection-line animated-line`}).addTo(d);setTimeout(()=>{let i=0;g.setStyle({opacity:u+.2});let s=()=>{i++;let c=i/30,f=p[0]+(m[0]-p[0])*c,_=p[1]+(m[1]-p[1])*c;g.setLatLngs([p,[f,_]]),i<30?setTimeout(s,30):setTimeout(()=>{d&&g&&g.remove(),h.setStyle({opacity:u}),h.on(`mouseover`,()=>{h.setStyle({weight:l+2,opacity:Math.min(u+.3,1)})}),h.on(`mouseout`,()=>{h.setStyle({weight:l,opacity:u})});let i=P(t,n,a,o);h.bindPopup(` -
- Connection to ${e.node_name||`Unknown Node`}
- Distance: ${i.toFixed(2)} km
- Route: ${N(e.route_type)}
- Signal: ${j(e.rssi)} / ${M(e.snr)} -
- `),y.value.push(h)},200)};s()},i)},c=()=>{if(!d||!h)return;let i=d.getBounds(),o=Math.floor(d.getZoom());_.value.forEach(e=>{d&&e.remove()}),_.value.clear(),y.value.forEach(e=>{d&&e.remove()}),y.value.length=0,h.getClusters([i.getWest(),i.getSouth(),i.getEast(),i.getNorth()],o).forEach(i=>{let[o,c]=i.geometry.coordinates,l=i.properties;if(l.cluster){let n=J.default.marker([c,o],{icon:r(l.point_count||0)}).addTo(d);n.on(`click`,()=>{if(d&&h){let e=h.getClusterExpansionZoom(l.cluster_id);d.setView([c,o],e)}});let i=h.getLeaves(l.cluster_id,1/0).map(e=>`
- • ${e.properties.advert.node_name||`Unknown Node`} (${e.properties.advert.contact_type}) -
`).join(``);n.bindPopup(` -
- Cluster: ${l.point_count} nodes
-
- ${i} -
-
- Click to zoom in and separate nodes -
-
- `),_.value.set(`cluster-${l.cluster_id}`,n);let u=P(e,t,c,o),f=Math.min(Math.floor(u*5),200);s({node_name:`Cluster of ${l.point_count} nodes`,contact_type:`Cluster`,route_type:2,rssi:null,snr:null,jittered_latitude:c,jittered_longitude:o,latitude:c,longitude:o},e,t,`#AAE8E8`,f)}else{let r=l.advert,i=a[r.contact_type]||a.Unknown,u=n(i),p=c,m=o,h=P(e,t,p,m),g=J.default.marker([p,m],{icon:u}).addTo(d).bindPopup(` -
- ${r.node_name||`Unknown Node`}
- Type: ${r.contact_type}
- Distance: ${h.toFixed(2)} km
- Signal: ${j(r.rssi)} / ${M(r.snr)}
- Route: ${N(r.route_type)}
- Last Seen: ${A(r.last_seen)} - ${r.jittered_latitude?`
Position adjusted to separate overlapping nodes`:``} -
- `);f.value.set(r.pubkey,g),_.value.set(`node-${r.pubkey}`,g);let v=Math.min(Math.floor(h*5),200);s({...r,jittered_latitude:p,jittered_longitude:m},e,t,i,v)}})},l=(e,t)=>{let r=0;L(o.adverts).forEach(i=>{let o=i.properties.advert;if(o.latitude!==null&&o.longitude!==null){let i=a[o.contact_type]||a.Unknown,c=n(i),l=o.jittered_latitude||o.latitude,u=o.jittered_longitude||o.longitude,p=J.default.marker([l,u],{icon:c}).addTo(d).bindPopup(` -
- ${o.node_name||`Unknown Node`}
- Type: ${o.contact_type}
- Distance: ${P(e,t,l,u).toFixed(2)} km
- Signal: ${j(o.rssi)} / ${M(o.snr)}
- Route: ${N(o.route_type)}
- Last Seen: ${A(o.last_seen)} - ${o.jittered_latitude?`
Position adjusted to separate overlapping nodes`:``} -
- `);f.value.set(o.pubkey,p);let m=p.getElement();m&&(m.style.opacity=`0`,m.style.transition=`opacity 0.5s ease-out`),s(o,e,t,i,r),setTimeout(()=>{m&&(m.style.opacity=`1`)},r+1e3),r+=100}})};if(w.value&&o.adverts.length>0)try{R(L(o.adverts));let n=Math.min(14,d.getZoom());d.setZoom(n),setTimeout(()=>{try{c()}catch(n){console.warn(`Error updating clusters:`,n),l(e,t)}},100),d.on(`moveend`,()=>{try{c()}catch(e){console.warn(`Error updating clusters on move:`,e)}}),d.on(`zoomend`,()=>{try{c()}catch(e){console.warn(`Error updating clusters on zoom:`,e)}})}catch(n){console.warn(`Error initializing clustering:`,n),l(e,t)}else l(e,t);setTimeout(()=>{d&&d.invalidateSize()},1e3)}catch(e){console.error(`Error initializing map:`,e)}};return t({highlightNode:e=>{let t=f.value.get(e);if(t){let e=t.getElement();if(e){let t=e.querySelector(`div`);t&&t.classList.add(`marker-highlight`)}}},unhighlightNode:e=>{let t=f.value.get(e);if(t){let e=t.getElement();if(e){let t=e.querySelector(`div`);t&&t.classList.remove(`marker-highlight`)}}},initializeOpenStreetMap:z}),p(()=>o.adverts,()=>{d&&k.value&&setTimeout(()=>{z()},100)},{immediate:!1}),i(()=>{O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),k.value&&o.adverts.length>0&&setTimeout(()=>{z()},300)}),n(()=>{O.disconnect(),F()}),(t,n)=>(S(),x(`div`,Ft,[k.value?(S(),x(`div`,{key:1,ref_key:`mapContainer`,ref:u,class:`leaflet-map-container h-96 w-full glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] overflow-hidden shadow-sm dark:shadow-none`,style:{"min-height":`384px`,position:`relative`}},null,512)):(S(),x(`div`,It,[...n[0]||=[c(`

No valid coordinates available

Configure base station location to view map

`,1)]])),k.value&&e.adverts.length>0?(S(),x(`button`,{key:2,onClick:l,class:`absolute bottom-3 right-3 z-[1001] flex items-center gap-2 px-3 py-2 bg-black/40 border border-white/10 rounded-lg text-white/80 hover:bg-white/10 hover:text-white transition-colors text-sm backdrop-blur-sm`},[n[1]||=b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})],-1),b(`span`,Lt,v(e.showLegend?`Hide`:`Show`),1)])):m(``,!0),k.value&&e.adverts.length>0&&e.showLegend?(S(),x(`div`,Rt,[n[2]||=c(`
Node Types
Base Station
Chat Node
Repeater
Room Server
Hybrid Node
Route Types
Direct
Transport Direct
Flood
Transport Flood
`,2),b(`div`,zt,v(e.adverts.length)+` node`+v(e.adverts.length===1?``:`s`)+` visible `,1)])):m(``,!0),k.value?(S(),x(`div`,Bt,` © OpenStreetMap contributors © CARTO `)):m(``,!0)]))}}),[[`__scopeId`,`data-v-61a18eed`]]),Ht={class:`relative`,"data-menu-container":``},Ut=u({__name:`NeighborMenu`,props:{neighbor:{},canPing:{type:Boolean}},emits:[`ping`,`delete`,`show-details`],setup(e,{emit:t}){let r=window.__neighborMenuManager||{activeMenu:null,setActiveMenu:e=>{if(r.activeMenu&&r.activeMenu!==e)try{r.activeMenu.closeMenu()}catch(e){console.warn(`Error closing previous menu:`,e)}r.activeMenu=e}};window.__neighborMenuManager=r;let i=e,c=t,u=C(!1),f=C(),p=C({top:0,left:0}),h=()=>{u.value=!1,document.removeEventListener(`click`,w,!0),document.removeEventListener(`keydown`,T),r.activeMenu===g&&(r.activeMenu=null)},g={closeMenu:h},_=()=>{h(),c(`ping`,i.neighbor)},v=()=>{h(),c(`show-details`,i.neighbor)},y=()=>{h(),c(`delete`,i.neighbor)},w=e=>{e.target.closest(`[data-menu-container]`)||h()},T=e=>{e.key===`Escape`&&h()},E=async()=>{if(!u.value&&f.value){r.setActiveMenu(g);let e=f.value.getBoundingClientRect(),t=window.innerWidth,n=t<1024,i=e.left+144>t-16,o=e.left;n&&i&&(o=e.right-144),o=Math.max(8,o),p.value={top:e.bottom+4,left:o},u.value=!0,await a(),document.addEventListener(`click`,w,!0),document.addEventListener(`keydown`,T)}else h()};return n(()=>{h()}),(e,t)=>(S(),x(`div`,Ht,[b(`button`,{ref_key:`buttonRef`,ref:f,onClick:E,class:s([`p-1 rounded hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary/80`,{"bg-background-mute dark:bg-stroke/10 text-content-primary dark:text-content-primary/80":u.value}]),"data-menu-container":``},[...t[0]||=[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z`})],-1)]],2),(S(),o(d,{to:`body`},[u.value?(S(),x(`div`,{key:0,class:`fixed w-36 bg-white dark:bg-surface-elevated backdrop-blur-lg border border-stroke-subtle dark:border-white/20 rounded-[15px] shadow-2xl z-[999999]`,style:l({top:p.value.top+`px`,left:p.value.left+`px`}),"data-menu-container":``},[b(`div`,{class:`py-2`},[b(`button`,{onClick:v,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10`},[...t[1]||=[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),b(`span`,{class:`font-medium`},`Details`,-1)]]),b(`button`,{onClick:_,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10`},[...t[2]||=[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})],-1),b(`span`,{class:`font-medium`},`Ping`,-1)]]),b(`button`,{onClick:y,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-accent-red hover:bg-accent-red/10 transition-colors`},[...t[3]||=[b(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1),b(`span`,{class:`font-medium`},`Delete`,-1)]])])],4)):m(``,!0)]))]))}}),Wt={class:`glass-card/30 backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[12px] p-6 shadow-sm dark:shadow-none`},Gt={class:`flex items-center justify-between mb-4`},Kt={class:`flex items-center gap-3`},qt={class:`text-content-primary dark:text-content-primary text-lg font-semibold`},Jt={class:`bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary text-xs px-2 py-1 rounded-full`},Yt={key:0,class:`text-content-muted dark:text-content-muted`},Xt={key:0,class:`hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 p-1`},Zt={class:`hidden lg:block overflow-x-auto`},Qt={class:`w-full`},$t={class:`bg-background-mute dark:bg-transparent`},en={class:`flex items-center gap-1`},tn={class:`flex items-center gap-1`},nn={class:`flex items-center gap-1`},rn={class:`flex items-center gap-1`},an={class:`flex items-center gap-1`},on={class:`flex items-center gap-1`},sn={class:`flex items-center gap-1`},cn={class:`flex items-center gap-1`},ln={class:`flex items-center gap-1`},un={class:`bg-surface/50 dark:bg-transparent`},dn=[`onMouseenter`,`onMouseleave`],fn=[`onClick`,`title`],pn={key:0,class:`ml-1 text-xs`},mn={key:0,class:`flex items-center gap-3`},hn={class:`text-content-secondary dark:text-content-muted`},gn={class:`flex gap-1`},_n=[`onClick`],vn=[`onClick`],yn={key:1,class:`text-content-muted`},bn={class:`flex items-center gap-2`},xn={class:`flex items-end gap-0.5`},Sn={class:`flex items-center gap-2`},Cn=[`title`],wn=[`title`],Tn={class:`lg:hidden space-y-3`},En=[`onClick`],Dn={class:`flex items-center justify-between mb-3`},On={class:`flex items-center gap-3`},kn={class:`text-content-primary dark:text-content-primary font-medium text-base`},An={class:`flex items-center gap-2`},jn={class:`grid grid-cols-1 gap-3`},Mn={class:`grid grid-cols-2 gap-4`},Nn=[`onClick`,`title`],Pn={key:0,class:`ml-1 text-xs`},Fn={class:`flex items-center gap-2 justify-end`},In={class:`flex items-end gap-0.5`},Ln={class:`grid grid-cols-2 gap-4`},Rn={class:`flex items-center gap-2`},zn=[`title`],Bn={class:`text-content-primary dark:text-content-primary text-sm block text-right`},Vn={key:0,class:`border-t border-white/10 pt-3`},Hn={class:`flex items-center justify-between`},Un={class:`text-content-secondary dark:text-content-muted text-sm font-mono`},Wn={class:`flex gap-2`},Gn=[`onClick`],Kn=[`onClick`],qn={class:`grid grid-cols-3 gap-4 pt-3 border-t border-white/10`},Jn={class:`text-center`},Yn={class:`text-content-primary dark:text-content-primary text-sm font-medium`},Xn={class:`text-center`},Zn={class:`text-content-primary dark:text-content-primary text-sm font-medium`},Qn={class:`text-center`},$n=[`title`],er=u({__name:`NeighborTable`,props:{contactType:{},contactTypeKey:{},adverts:{},originalCount:{default:0},color:{},baseLatitude:{default:null},baseLongitude:{default:null},isCompactView:{type:Boolean,default:!1},isFirstTable:{type:Boolean,default:!1},showViewToggle:{type:Boolean,default:!1}},emits:[`highlight-node`,`unhighlight-node`,`menu-ping`,`menu-delete`,`show-details`,`toggle-view`],setup(e,{emit:t}){let n=C(null),{getSignalQuality:i}=F(),a=C(`advert_count`),o=C(`desc`),c=e,u=t,d=e=>new Date(e*1e3).toLocaleString(),f=e=>`${e.slice(0,4)}...${e.slice(-4)}`,p=e=>{switch(e){case 2:return{text:`Direct`,bgColor:`bg-green-100 dark:bg-green-500/20`,borderColor:`border-green-500 dark:border-green-400/30`,textColor:`text-green-600 dark:text-green-400`};case 3:return{text:`Transport Direct`,bgColor:`bg-green-100 dark:bg-green-600/20`,borderColor:`border-green-600/40 dark:border-green-500/30`,textColor:`text-green-700 dark:text-green-500`};case 1:return{text:`Flood`,bgColor:`bg-yellow-100 dark:bg-yellow-500/20`,borderColor:`border-yellow-500 dark:border-yellow-400/30`,textColor:`text-yellow-600 dark:text-yellow-400`};case 0:return{text:`Transport Flood`,bgColor:`bg-orange-100 dark:bg-orange-500/20`,borderColor:`border-orange-500 dark:border-orange-400/30`,textColor:`text-orange-600 dark:text-orange-400`};default:return{text:`Unknown`,bgColor:`bg-gray-500/20`,borderColor:`border-gray-400/30`,textColor:`text-gray-400`}}},w=e=>e?`${e} dBm`:`N/A`,T=e=>e?`${e} dB`:`N/A`,E=(e,t,n,r)=>{let i=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(a/2)*Math.sin(a/2);return 6371*(2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)))},D=e=>c.baseLatitude===null||c.baseLongitude===null||e.latitude===null||e.longitude===null?`N/A`:`${E(c.baseLatitude,c.baseLongitude,e.latitude,e.longitude).toFixed(1)} km`,O=async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);return t.value=e,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),!0}},k=e=>{let t=Date.now()-e*1e3,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`},A=e=>{let t=Date.now()-e*1e3,n=Math.floor(t/(1e3*60*60));return n<1?{color:`text-green-600 dark:text-green-400`}:n<26?{color:`text-yellow-600 dark:text-yellow-400`}:{color:`text-red-600 dark:text-red-400`}},j=async(e,t)=>{await O(`${e.toFixed(6)}, ${t.toFixed(6)}`)},M=(e,t)=>{let n=`https://www.google.com/maps?q=${e},${t}`;window.open(n,`_blank`)},N=async e=>{await O(e),n.value=e,setTimeout(()=>{n.value=null},2e3)},P=e=>{let t=i(e);return{bars:t.bars,color:t.color}},I=()=>c.isCompactView?`py-2 px-2`:`py-4 px-3`,L=()=>{u(`toggle-view`)},R=e=>{u(`highlight-node`,e)},z=e=>{u(`unhighlight-node`,e)},B=e=>{u(`menu-ping`,e)},V=e=>{u(`show-details`,e)},H=e=>{u(`menu-delete`,e)},U=e=>{a.value===e?o.value=o.value===`asc`?`desc`:`asc`:(a.value=e,o.value=typeof c.adverts[0]?.[e]==`number`?`desc`:`asc`)},W=g(()=>a.value?[...c.adverts].sort((e,t)=>{let n=e[a.value],r=t[a.value];if(n==null)return 1;if(r==null)return-1;let i=0;return typeof n==`string`&&typeof r==`string`?i=n.localeCompare(r):typeof n==`number`&&typeof r==`number`?i=n-r:typeof n==`boolean`&&typeof r==`boolean`&&(i=n===r?0:n?1:-1),o.value===`asc`?i:-i}):c.adverts);return(t,i)=>(S(),x(`div`,Wt,[b(`div`,Gt,[b(`div`,Kt,[b(`div`,{class:`w-3 h-3 rounded-full border border-white/20`,style:l({backgroundColor:e.color})},null,4),b(`h3`,qt,v(e.contactType),1),b(`span`,Jt,[_(v(e.adverts.length)+` `,1),e.originalCount>0&&e.adverts.lengthU(`node_name`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,en,[i[12]||=_(` Node Name `,-1),a.value===`node_name`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[11]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[1]||=e=>U(`pubkey`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,tn,[i[14]||=_(` Public Key `,-1),a.value===`pubkey`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[13]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5`)},` Location `,2),b(`th`,{class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5`)},` Distance `,2),b(`th`,{onClick:i[2]||=e=>U(`route_type`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,nn,[i[16]||=_(` Route Type `,-1),a.value===`route_type`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[15]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[3]||=e=>U(`zero_hop`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,rn,[i[18]||=_(` Zero Hop `,-1),a.value===`zero_hop`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[17]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[4]||=e=>U(`rssi`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,an,[i[20]||=_(` RSSI `,-1),a.value===`rssi`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[19]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[5]||=e=>U(`snr`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,on,[i[22]||=_(` SNR `,-1),a.value===`snr`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[21]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[6]||=e=>U(`last_seen`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,sn,[i[24]||=_(` Last Seen `,-1),a.value===`last_seen`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[23]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[7]||=e=>U(`first_seen`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,cn,[i[26]||=_(` First Seen `,-1),a.value===`first_seen`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[25]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2),b(`th`,{onClick:i[8]||=e=>U(`advert_count`),class:s(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${I().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[b(`div`,ln,[i[28]||=_(` Advert Count `,-1),a.value===`advert_count`?(S(),x(`svg`,{key:0,class:s([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[27]||=[b(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):m(``,!0)])],2)])]),b(`tbody`,un,[(S(!0),x(y,null,r(W.value,e=>(S(),x(`tr`,{key:e.id,class:`hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors`,onMouseenter:t=>R(e.pubkey),onMouseleave:t=>z(e.pubkey)},[b(`td`,{class:s(I())},[h(Ut,{neighbor:e,onPing:B,onShowDetails:V,onDelete:H},null,8,[`neighbor`])],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},v(e.node_name||`Unknown`),3),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm font-mono`)},[b(`button`,{onClick:t=>N(e.pubkey),class:s([`text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60`,n.value===e.pubkey?`text-green-600 dark:text-green-400 decoration-green-400/60`:``]),title:n.value===e.pubkey?`Copied!`:`Click to copy full public key`},[_(v(f(e.pubkey))+` `,1),n.value===e.pubkey?(S(),x(`span`,pn,`✓`)):m(``,!0)],10,fn)],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[e.latitude!==null&&e.longitude!==null?(S(),x(`div`,mn,[b(`span`,hn,v(e.latitude.toFixed(4))+`, `+v(e.longitude.toFixed(4)),1),b(`div`,gn,[b(`button`,{onClick:t=>j(e.latitude,e.longitude),class:`text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors cursor-pointer`,title:`Copy coordinates to clipboard`},[...i[29]||=[b(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`,stroke:`currentColor`,"stroke-width":`2`}),b(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,_n),b(`button`,{onClick:t=>M(e.latitude,e.longitude),class:`text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors cursor-pointer`,title:`Open in Google Maps`},[...i[30]||=[b(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`path`,{d:`M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z`,stroke:`currentColor`,"stroke-width":`2`}),b(`circle`,{cx:`12`,cy:`10`,r:`3`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,vn)])])):(S(),x(`span`,yn,`Unknown`))],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},v(D(e)),3),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[b(`span`,{class:s([`inline-block px-2 py-1 rounded-full text-xs border transition-colors`,p(e.route_type).bgColor,p(e.route_type).borderColor,p(e.route_type).textColor])},v(p(e.route_type).text),3)],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[b(`span`,{class:s([`inline-block px-2 py-1 rounded-full text-xs border transition-colors`,e.zero_hop?`bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400`:`bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400`])},v(e.zero_hop?`Zero Hop`:`Multi-Hop`),3)],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[b(`div`,bn,[b(`div`,xn,[(S(),x(y,null,r(5,t=>b(`div`,{key:t,class:s([`w-1 transition-colors`,t<=P(e.rssi).bars?P(e.rssi).color:`text-gray-600`]),style:l({height:`${4+t*2}px`})},[...i[31]||=[b(`div`,{class:`w-full h-full bg-current rounded-sm`},null,-1)]],6)),64))]),b(`span`,{class:s(P(e.rssi).color)},v(w(e.rssi)),3)])],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},v(T(e.snr)),3),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[b(`div`,Sn,[b(`div`,{class:s([`w-2 h-2 rounded-full`,A(e.last_seen).color===`text-green-600 dark:text-green-400`?`bg-green-400`:``,A(e.last_seen).color===`text-yellow-600 dark:text-yellow-400`?`bg-yellow-400`:``,A(e.last_seen).color===`text-red-600 dark:text-red-400`?`bg-red-400`:``])},null,2),b(`span`,{class:s([A(e.last_seen).color,`cursor-help`]),title:d(e.last_seen)},v(k(e.last_seen)),11,Cn)])],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm`)},[b(`span`,{title:d(e.first_seen),class:`cursor-help`},v(k(e.first_seen)),9,wn)],2),b(`td`,{class:s(`${I()} text-content-primary dark:text-content-primary text-sm text-center`)},v(e.advert_count),3)],40,dn))),128))])])]),b(`div`,Tn,[(S(!0),x(y,null,r(W.value,e=>(S(),x(`div`,{key:e.id,class:`bg-surface/50 dark:bg-transparent border border-stroke-subtle dark:border-white/10 rounded-lg p-4 hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors`,onClick:t=>R(e.pubkey)},[b(`div`,Dn,[b(`div`,On,[b(`h4`,kn,v(e.node_name||`Unknown Node`),1),b(`div`,An,[b(`span`,{class:s([`inline-block px-2 py-1 rounded-full text-xs border`,p(e.route_type).bgColor,p(e.route_type).borderColor,p(e.route_type).textColor])},v(p(e.route_type).text),3),b(`span`,{class:s([`inline-block px-2 py-1 rounded-full text-xs border`,e.zero_hop?`bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400`:`bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400`])},v(e.zero_hop?`Zero Hop`:`Multi-Hop`),3)])]),h(Ut,{neighbor:e,onPing:B,onShowDetails:V,onDelete:H},null,8,[`neighbor`])]),b(`div`,jn,[b(`div`,Mn,[b(`div`,null,[i[32]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Public Key`,-1),b(`button`,{onClick:t=>N(e.pubkey),class:s([`text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer font-mono text-sm underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60 break-all`,n.value===e.pubkey?`text-green-600 dark:text-green-400 decoration-green-400/60`:``]),title:n.value===e.pubkey?`Copied!`:`Click to copy full public key`},[_(v(f(e.pubkey))+` `,1),n.value===e.pubkey?(S(),x(`span`,Pn,`✓`)):m(``,!0)],10,Nn)]),b(`div`,null,[i[34]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Signal`,-1),b(`div`,Fn,[b(`div`,In,[(S(),x(y,null,r(5,t=>b(`div`,{key:t,class:s([`w-1.5 transition-colors`,t<=P(e.rssi).bars?P(e.rssi).color:`text-gray-600`]),style:l({height:`${6+t*2}px`})},[...i[33]||=[b(`div`,{class:`w-full h-full bg-current rounded-sm`},null,-1)]],6)),64))]),b(`span`,{class:s(`${P(e.rssi).color} text-sm font-medium`)},v(w(e.rssi)),3)])])]),b(`div`,Ln,[b(`div`,null,[i[35]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Last Seen`,-1),b(`div`,Rn,[b(`div`,{class:s([`w-2 h-2 rounded-full`,A(e.last_seen).color===`text-green-600 dark:text-green-400`?`bg-green-400`:``,A(e.last_seen).color===`text-yellow-600 dark:text-yellow-400`?`bg-yellow-400`:``,A(e.last_seen).color===`text-red-600 dark:text-red-400`?`bg-red-400`:``])},null,2),b(`span`,{class:s(`${A(e.last_seen).color} text-sm`),title:d(e.last_seen)},v(k(e.last_seen)),11,zn)])]),b(`div`,null,[i[36]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Distance`,-1),b(`span`,Bn,v(D(e)),1)])]),e.latitude!==null&&e.longitude!==null?(S(),x(`div`,Vn,[i[39]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Location`,-1),b(`div`,Hn,[b(`span`,Un,v(e.latitude.toFixed(4))+`, `+v(e.longitude.toFixed(4)),1),b(`div`,Wn,[b(`button`,{onClick:t=>j(e.latitude,e.longitude),class:`text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg`,title:`Copy coordinates`},[...i[37]||=[b(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`,stroke:`currentColor`,"stroke-width":`2`}),b(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,Gn),b(`button`,{onClick:t=>M(e.latitude,e.longitude),class:`text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors p-2 hover:bg-white/10 rounded-lg`,title:`Open in Maps`},[...i[38]||=[b(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`path`,{d:`M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z`,stroke:`currentColor`,"stroke-width":`2`}),b(`circle`,{cx:`12`,cy:`10`,r:`3`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,Kn)])])])):m(``,!0),b(`div`,qn,[b(`div`,Jn,[i[40]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`SNR`,-1),b(`span`,Yn,v(T(e.snr)),1)]),b(`div`,Xn,[i[41]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`Adverts`,-1),b(`span`,Zn,v(e.advert_count),1)]),b(`div`,Qn,[i[42]||=b(`div`,{class:`text-content-muted text-xs mb-1`},`First Seen`,-1),b(`span`,{class:`text-content-primary dark:text-content-primary text-sm`,title:d(e.first_seen)},v(k(e.first_seen)),9,$n)])])])],8,En))),128))])]))}}),tr={class:`space-y-6`},nr={key:0,class:`flex items-center justify-center py-12`},rr={key:1,class:`bg-red-50 dark:bg-accent-red/10 border border-red-300 dark:border-accent-red/20 rounded-[15px] p-6`},ir={class:`flex items-center gap-3`},ar={class:`text-red-500 dark:text-accent-red/80 text-sm`},or={key:0,class:``},sr={class:`flex items-center justify-between`},cr={class:`flex items-center gap-3`},lr={class:`hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 mb p-1`},ur={class:`flex items-center gap-2`},dr={key:0,class:`ml-1 bg-accent-cyan/20 text-accent-cyan border border-accent-cyan/30 text-xs px-1.5 py-0.5 rounded-full font-medium`},fr={class:`bg-background dark:bg-background/30 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mt-4 space-y-4`},pr={class:`grid grid-cols-1 md:grid-cols-3 gap-4`},mr={key:1,class:`text-center py-12`},hr={key:2,class:`text-center py-12`},gr=u({name:`NeighborsView`,__name:`Neighbors`,setup(e){let t=T(),n={0:`Unknown`,1:`Chat Node`,2:`Repeater`,3:`Room Server`,4:`Hybrid Node`},a={0:`#6b7280`,1:`#60a5fa`,2:`#34d399`,3:`#a855f7`,4:`#f59e0b`},o=C({}),l=C(!0),u=C(null),d=C(P(`neighbors_compactView`,!1)),E=C(P(`neighbors_showMapLegend`,typeof window<`u`?window.innerWidth>=1024:!0)),D=C(P(`neighbors_showFilters`,!1)),A=C(P(`neighbors_filters`,{zeroHop:`all`,routeType:`all`,searchText:``}));p(d,e=>N(`neighbors_compactView`,e)),p(E,e=>N(`neighbors_showMapLegend`,e)),p(D,e=>N(`neighbors_showFilters`,e)),p(A,e=>N(`neighbors_filters`,e),{deep:!0});let M=C(!1),F=C(!1),I=C(!1),L=C(null),R=C(null),z=C(null),B=C(null),V=C(!1),H=C(null),W=g(()=>{if(!B.value)return null;let e=B.value;return{id:e.id,pubkey:e.pubkey,node_name:e.node_name,contact_type:e.contact_type,latitude:e.latitude,longitude:e.longitude,rssi:e.rssi,snr:e.snr,route_type:e.route_type,last_seen:e.last_seen,first_seen:e.first_seen,advert_count:e.advert_count,timestamp:e.timestamp,is_repeater:e.is_repeater,is_new_neighbor:e.is_new_neighbor,zero_hop:e.zero_hop}}),G=g(()=>t.stats?.config?.repeater?.latitude),K=g(()=>t.stats?.config?.repeater?.longitude),ee=e=>e.filter(e=>{if(A.value.zeroHop!==`all`){let t=e.zero_hop;if(A.value.zeroHop===`true`&&!t||A.value.zeroHop===`false`&&t)return!1}if(A.value.routeType!==`all`){let t=e.route_type;if(A.value.routeType===`direct`&&t!==2||A.value.routeType===`transport_direct`&&t!==3||A.value.routeType===`flood`&&t!==1||A.value.routeType===`transport_flood`&&t!==0)return!1}if(A.value.searchText){let t=A.value.searchText.toLowerCase(),n=e.node_name?.toLowerCase()||``,r=e.pubkey.toLowerCase();if(!n.includes(t)&&!r.includes(t))return!1}return!0}),te=()=>{A.value={zeroHop:`all`,routeType:`all`,searchText:``}},q=g(()=>A.value.zeroHop!==`all`||A.value.routeType!==`all`||A.value.searchText!==``),ne=g(()=>{let e={};for(let[t,n]of Object.entries(o.value))e[t]=ee(n);return e}),re=g(()=>Object.entries(n).filter(([e])=>ne.value[e]?.length>0).sort(([e],[t])=>parseInt(e)-parseInt(t))),ie=g(()=>Object.values(o.value).flat().filter(e=>{let t=e.latitude,n=e.longitude;return t!=null&&t!==0&&n!=null&&n!==0&&typeof t==`number`&&typeof n==`number`&&!isNaN(t)&&!isNaN(n)&&e.zero_hop===!0})),ae=async e=>{try{let t=await w.get(`/adverts_by_contact_type?contact_type=${encodeURIComponent(e)}&hours=168`);return t.success&&Array.isArray(t.data)?t.data:[]}catch(t){return console.error(`Error fetching adverts for contact type ${e}:`,t),[]}},oe=async()=>{l.value=!0,u.value=null;try{o.value={};for(let[e,t]of Object.entries(n)){let n=await ae(t);n.length>0&&(o.value[e]=n)}}catch(e){console.error(`Error loading adverts:`,e),u.value=e instanceof Error?e.message:`Failed to load neighbor data`}finally{l.value=!1}},se=C(),ce=e=>{se.value?.highlightNode(e)},le=e=>{se.value?.unhighlightNode(e)},ue=async e=>{let n=e;L.value=null,R.value=null,I.value=!0,z.value=n.node_name||`Unknown Node`,F.value=!0;try{let e=t.stats?.config?.mesh?.path_hash_mode??0,r=(e===2?3:e===1?2:1)*2,i=`0x${parseInt(n.pubkey.substring(0,r),16).toString(16).padStart(r,`0`)}`,a=await w.pingNeighbor(i,10);a.success&&a.data?L.value=a.data:(R.value=a.error||`Unknown error occurred`,console.error(`Failed to ping neighbor:`,a.error))}catch(e){console.error(`Error pinging neighbor:`,e),R.value=e instanceof Error?e.message:`Unknown error occurred`}finally{I.value=!1}},de=()=>{F.value=!1,L.value=null,R.value=null,z.value=null},fe=e=>{B.value=e,M.value=!0},pe=e=>{H.value=e,V.value=!0},me=()=>{V.value=!1,H.value=null},he=()=>{M.value=!1,B.value=null},ge=async e=>{try{await w.deleteAdvert(e),await oe(),he()}catch(e){console.error(`Error deleting neighbor:`,e)}};return i(async()=>{await oe()}),(e,t)=>(S(),x(`div`,tr,[l.value?(S(),x(`div`,nr,[...t[7]||=[b(`div`,{class:`text-center`},[b(`div`,{class:`animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4`}),b(`p`,{class:`text-content-secondary dark:text-content-muted`},`Loading neighbor data...`)],-1)]])):u.value?(S(),x(`div`,rr,[b(`div`,ir,[t[9]||=b(`svg`,{class:`w-5 h-5 text-red-600 dark:text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),b(`div`,null,[t[8]||=b(`h3`,{class:`text-red-600 dark:text-accent-red font-medium`},`Error Loading Neighbors`,-1),b(`p`,ar,v(u.value),1)])])])):(S(),x(y,{key:2},[h(Vt,{ref_key:`networkMapRef`,ref:se,adverts:ie.value,"base-latitude":G.value,"base-longitude":K.value,"show-legend":E.value,"onUpdate:showLegend":t[0]||=e=>E.value=e},null,8,[`adverts`,`base-latitude`,`base-longitude`,`show-legend`]),Object.keys(o.value).length>0?(S(),x(`div`,or,[b(`div`,sr,[t[14]||=b(`span`,{class:`text-content-primary dark:text-content-primary text-lg font-semibold`},null,-1),b(`div`,cr,[b(`div`,lr,[b(`button`,{onClick:t[1]||=e=>d.value=!1,class:s([`p-2 rounded-md transition-colors`,d.value?`text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10`:`bg-primary/20 text-primary border border-primary/30`]),title:`Comfortable view`},[...t[10]||=[b(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`rect`,{x:`3`,y:`3`,width:`18`,height:`6`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),b(`rect`,{x:`3`,y:`12`,width:`18`,height:`6`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],2),b(`button`,{onClick:t[2]||=e=>d.value=!0,class:s([`p-2 rounded-md transition-colors`,d.value?`bg-primary/20 text-primary border border-primary/30`:`text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10`]),title:`Compact view`},[...t[11]||=[b(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[b(`rect`,{x:`3`,y:`3`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),b(`rect`,{x:`3`,y:`10`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),b(`rect`,{x:`3`,y:`17`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],2)]),b(`div`,ur,[b(`button`,{onClick:t[3]||=e=>D.value=!D.value,class:s([`px-3 py-1.5 text-xs rounded-lg transition-colors border`,q.value?`bg-primary/20 text-primary border-primary/30`:`bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20`])},[t[12]||=b(`svg`,{class:`w-4 h-4 inline mr-1`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[b(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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.707v6.586a1 1 0 01-1.447.894l-4-2A1 1 0 717 18.586V13.414a1 1 0 00-.293-.707L.293 6.293A1 1 0 010 5.586V3a1 1 0 011-1z`})],-1),t[13]||=_(` Filters `,-1),q.value?(S(),x(`span`,dr,` Active `)):m(``,!0)],2),q.value?(S(),x(`button`,{key:0,onClick:te,class:`px-3 py-1.5 text-xs rounded-lg bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20 transition-colors`},` Clear Filters `)):m(``,!0)])])]),f(b(`div`,fr,[b(`div`,pr,[b(`div`,null,[t[16]||=b(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Zero Hop`,-1),f(b(`select`,{"onUpdate:modelValue":t[4]||=e=>A.value.zeroHop=e,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none`},[...t[15]||=[b(`option`,{value:`all`},`All Nodes`,-1),b(`option`,{value:`true`},`Zero Hop Only`,-1),b(`option`,{value:`false`},`Multi-Hop Only`,-1)]],512),[[O,A.value.zeroHop]])]),b(`div`,null,[t[18]||=b(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Route Type`,-1),f(b(`select`,{"onUpdate:modelValue":t[5]||=e=>A.value.routeType=e,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none`},[...t[17]||=[c(``,5)]],512),[[O,A.value.routeType]])]),b(`div`,null,[t[19]||=b(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Search`,-1),f(b(`input`,{"onUpdate:modelValue":t[6]||=e=>A.value.searchText=e,type:`text`,placeholder:`Node name or pubkey...`,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none placeholder-gray-400 dark:placeholder-white/40`},null,512),[[k,A.value.searchText]])])])],512),[[j,D.value]])])):m(``,!0),(S(!0),x(y,null,r(re.value,([e,t])=>(S(),x(`div`,{key:e,class:`space-y-6`},[h(er,{"contact-type":t,"contact-type-key":e,adverts:ne.value[e],"original-count":o.value[e]?.length||0,color:a[parseInt(e)],"base-latitude":G.value,"base-longitude":K.value,"is-compact-view":d.value,"is-first-table":!1,"show-view-toggle":!1,onHighlightNode:ce,onUnhighlightNode:le,onMenuPing:ue,onMenuDelete:fe,onShowDetails:pe},null,8,[`contact-type`,`contact-type-key`,`adverts`,`original-count`,`color`,`base-latitude`,`base-longitude`,`is-compact-view`])]))),128)),re.value.length===0&&Object.keys(o.value).length===0?(S(),x(`div`,mr,[t[20]||=c(`

No Neighbors Found

No mesh neighbors have been discovered in your area yet.

`,3),b(`button`,{onClick:oe,class:`mt-4 px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors`},` Refresh `)])):re.value.length===0&&q.value?(S(),x(`div`,hr,[t[21]||=c(`

No neighbors match your filters

Try adjusting your filter criteria to see more results.

`,3),b(`button`,{onClick:te,class:`px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors`},` Clear Filters `)])):m(``,!0)],64)),h(U,{show:M.value,neighbor:W.value,onClose:he,onDelete:ge},null,8,[`show`,`neighbor`]),h(ke,{show:F.value,"node-name":z.value,result:L.value,error:R.value,loading:I.value,onClose:de},null,8,[`show`,`node-name`,`result`,`error`,`loading`]),h(gt,{"is-open":V.value,neighbor:H.value,"base-latitude":G.value,"base-longitude":K.value,onClose:me},null,8,[`is-open`,`neighbor`,`base-latitude`,`base-longitude`])]))}});export{gr as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Neighbors-Cfo189NY.css b/repeater/web/html/assets/Neighbors-Cfo189NY.css deleted file mode 100644 index e379b7de..00000000 --- a/repeater/web/html/assets/Neighbors-Cfo189NY.css +++ /dev/null @@ -1 +0,0 @@ -.modal-enter-active[data-v-dacea749],.modal-leave-active[data-v-dacea749]{transition:opacity .2s}.modal-enter-from[data-v-dacea749],.modal-leave-to[data-v-dacea749]{opacity:0}.modal-enter-active>div[data-v-dacea749],.modal-leave-active>div[data-v-dacea749]{transition:transform .2s}.modal-enter-from>div[data-v-dacea749],.modal-leave-to>div[data-v-dacea749]{transform:scale(.95)}.packet-enter-active[data-v-dacea749],.packet-leave-active[data-v-dacea749]{transition:all .15s}.packet-enter-from[data-v-dacea749],.packet-leave-to[data-v-dacea749]{opacity:0;transform:translate(-50%)scale(.5)}.custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar{width:8px}.custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar-track{background:0 0}.custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar-thumb{background:#0003;border-radius:4px}.dark .custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar-thumb{background:#fff3}.custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar-thumb:hover{background:#0000004d}.dark .custom-scrollbar[data-v-2fb1fa15]::-webkit-scrollbar-thumb:hover{background:#ffffff4d}.modal-enter-active[data-v-2fb1fa15],.modal-leave-active[data-v-2fb1fa15]{transition:opacity .3s}.modal-enter-active>div[data-v-2fb1fa15],.modal-leave-active>div[data-v-2fb1fa15]{transition:transform .3s,opacity .3s}.modal-enter-from[data-v-2fb1fa15],.modal-leave-to[data-v-2fb1fa15]{opacity:0}.modal-enter-from>div[data-v-2fb1fa15],.modal-leave-to>div[data-v-2fb1fa15]{opacity:0;transform:scale(.95)}.leaflet-container{background:0 0}.custom-marker{background:0 0!important;border:none!important}.map-container[data-v-61a18eed]{background:0 0;border-radius:15px;position:relative;overflow:hidden}.leaflet-map-container[data-v-61a18eed]{-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);background:linear-gradient(135deg,#09090bcc 0%,#0009 100%)}.map-legend[data-v-61a18eed]{color:#fff;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:1000;background:#0006;border:1px solid #ffffff1a;border-radius:15px;min-width:150px;max-width:180px;padding:12px;font-size:12px;position:absolute;top:10px;right:10px;box-shadow:0 8px 32px #0000004d}.legend-title[data-v-61a18eed]{color:#fff;margin-bottom:10px;font-size:13px;font-weight:700}.legend-section[data-v-61a18eed]{margin-bottom:10px}.legend-section[data-v-61a18eed]:last-of-type{margin-bottom:8px}.legend-subtitle[data-v-61a18eed]{color:#fffc;text-transform:uppercase;letter-spacing:.5px;margin-bottom:6px;font-size:11px;font-weight:600}.legend-footer[data-v-61a18eed]{color:#fff9;text-align:center;border-top:1px solid #ffffff1a;margin-top:10px;padding-top:8px;font-size:10px}.legend-items[data-v-61a18eed]{flex-direction:column;gap:4px;display:flex}.legend-item[data-v-61a18eed]{align-items:center;gap:6px;display:flex}.legend-icon[data-v-61a18eed]{border:1px solid #fffc;border-radius:50%;flex-shrink:0;width:8px;height:8px;box-shadow:0 1px 2px #0003}.legend-icon.cluster-icon[data-v-61a18eed]{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);border:1px solid #aae8e8;border-radius:50%;width:16px;height:16px}.legend-line[data-v-61a18eed]{border-radius:1px;flex-shrink:0;width:16px;height:2px;position:relative}.legend-line-dashed[data-v-61a18eed]{background-color:#0000!important;background-image:repeating-linear-gradient(90deg,currentColor 0 4px,#0000 4px 8px)!important}.legend-line-dashed[style*=\#FFC246][data-v-61a18eed]{color:#ffc246!important}.legend-line-dashed[style*=\#ea580c][data-v-61a18eed]{color:#ea580c!important}.marker-highlight{z-index:1000!important;border-radius:50%!important;animation:1s ease-in-out infinite marker-glow-61a18eed!important;position:relative!important;transform:scale(1.2)!important;box-shadow:0 0 0 3px #a5e5b6,0 0 8px #a5e5b6,0 0 16px #a5e5b6!important}@keyframes marker-glow-61a18eed{0%,to{filter:brightness();box-shadow:0 0 0 3px #a5e5b6,0 0 8px #a5e5b6,0 0 16px #a5e5b6}50%{filter:brightness(1.3);box-shadow:0 0 0 5px #a5e5b6,0 0 12px #a5e5b6,0 0 24px #a5e5b6}}@keyframes pulse-highlight-61a18eed{0%{box-shadow:0 0 #3b82f6b3}70%{box-shadow:0 0 0 8px #3b82f600}to{box-shadow:0 0 #3b82f600}}.leaflet-popup-content-wrapper{color:#fff!important;-webkit-backdrop-filter:blur(20px)!important;backdrop-filter:blur(20px)!important;background:#0006!important;border:1px solid #ffffff1a!important;border-radius:15px!important;box-shadow:0 8px 32px #0000004d!important}.leaflet-popup-tip{background:#0006!important;border:1px solid #ffffff1a!important}.leaflet-popup-close-button{color:#fff9!important;font-size:18px!important}.leaflet-popup-close-button:hover{color:#fff!important}.custom-div-icon,.custom-cluster-icon{background:0 0!important;border:none!important}.custom-cluster-icon div{cursor:pointer!important;transition:all .3s!important}.custom-cluster-icon:hover div{transform:scale(1.1)!important;box-shadow:0 6px 16px #aae8e880!important}.leaflet-control-zoom{overflow:hidden;-webkit-backdrop-filter:blur(20px)!important;backdrop-filter:blur(20px)!important;border:1px solid #ffffff1a!important;border-radius:15px!important}.leaflet-control-zoom a{color:#fff!important;background-color:#0006!important;border-bottom:1px solid #ffffff1a!important;transition:all .2s!important}.leaflet-control-zoom a:hover{color:#fff!important;background-color:#ffffff1a!important}.leaflet-control-attribution{color:#9ca3af!important;background-color:#1f2937cc!important;border-top:1px solid #4b55634d!important;border-radius:4px!important;padding:4px 8px!important;font-size:11px!important}.leaflet-control-attribution a{text-decoration:none;color:#60a5fa!important}.leaflet-control-attribution a:hover{text-decoration:underline;color:#93c5fd!important}.leaflet-bottom.leaflet-left .leaflet-control-attribution{margin-bottom:10px!important;margin-left:10px!important}.map-attribution[data-v-61a18eed]{color:#fff9;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:1000;background:#0006;border:1px solid #ffffff1a;border-radius:15px;padding:4px 8px;font-size:10px;position:absolute;bottom:10px;left:10px}@media (width<=640px){.leaflet-control-attribution{display:none!important}} diff --git a/repeater/web/html/assets/Neighbors-DSCosrf5.js b/repeater/web/html/assets/Neighbors-DSCosrf5.js new file mode 100644 index 00000000..4146dab6 --- /dev/null +++ b/repeater/web/html/assets/Neighbors-DSCosrf5.js @@ -0,0 +1,65 @@ +import{r as e}from"./chunk-DECur_0Z.js";import{B as t,Ct as n,D as r,E as i,R as a,S as o,St as s,V as c,Y as l,c as u,f as d,g as f,i as p,j as m,k as h,l as g,m as _,nt as v,o as y,p as b,r as x,s as S,u as C,xt as w}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{c as T,o as E,s as D,t as O,u as k}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as A}from"./api-3gMnsCKh.js";import{t as j}from"./system-DbBvxitf.js";import{n as M,r as N,t as P}from"./dataService-DelZA92b.js";import{t as F}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as I}from"./Spinner-CcYauG9D.js";import{t as L}from"./leaflet-src-rW8DhqPH.js";/* empty css */import{a as R,i as z,l as B,o as V,r as ee,s as H,u as U}from"./formatters-CHyWlnnq.js";import{n as W,t as G}from"./preferences-CkCjR0CQ.js";import{t as K}from"./useSignalQuality-BurD4HtO.js";var q={class:`modal-card max-w-md`},J={class:`bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mb-6`},te={class:`flex items-center gap-3`},ne={class:`flex-1 min-w-0`},re={class:`text-content-primary dark:text-content-primary font-medium truncate`},ie={class:`text-content-secondary dark:text-content-muted text-sm font-mono`},ae={key:0,class:`text-white/50 text-xs`},oe={key:1,class:`text-white/50 text-xs`},se=f({__name:`DeleteNeighborModal`,props:{show:{type:Boolean},neighbor:{}},emits:[`close`,`delete`],setup(e,{emit:t}){let r=e,i=t,a=()=>{r.neighbor&&(i(`delete`,r.neighbor.id),o())},o=()=>{i(`close`)};return(t,r)=>(h(),u(p,{to:`body`},[e.show&&e.neighbor?(h(),C(`div`,{key:0,onClick:r[0]||=k(e=>o(),[`self`]),class:`modal-backdrop-heavy`},[S(`div`,q,[S(`div`,{class:`flex items-center gap-3 mb-6`},[r[2]||=S(`svg`,{class:`w-6 h-6 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),r[3]||=S(`div`,null,[S(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Delete Neighbor `),S(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mt-1`},` Are you sure you want to delete this neighbor? `)],-1),S(`button`,{onClick:o,class:`ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...r[1]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),S(`div`,J,[S(`div`,te,[S(`div`,ne,[S(`div`,re,n(e.neighbor?.node_name||e.neighbor?.long_name||e.neighbor?.short_name||`Unknown`),1),S(`div`,ie,` ID: `+n(e.neighbor?.node_num_hex||e.neighbor?.node_num||e.neighbor?.id||`N/A`),1),e.neighbor?.contact_type?(h(),C(`div`,ae,n(e.neighbor.contact_type),1)):g(``,!0),e.neighbor?.hw_model?(h(),C(`div`,oe,n(e.neighbor.hw_model),1)):g(``,!0)])])]),r[4]||=S(`div`,{class:`bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6`},[S(`div`,{class:`flex items-center gap-2 text-accent-red text-sm`},[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})]),S(`span`,null,`This action cannot be undone`)])],-1),S(`div`,{class:`flex gap-3`},[S(`button`,{onClick:o,class:`flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),S(`button`,{onClick:a,class:`modal-btn-danger`},` Delete `)])])])):g(``,!0)]))}}),ce={class:`bg-gradient-to-r from-primary/20 to-accent-cyan/20 border-b border-stroke-subtle dark:border-stroke/10 px-6 py-4`},le={class:`flex items-center justify-between`},ue={class:`flex items-center gap-3`},Y={key:0,class:`text-sm text-content-secondary dark:text-content-muted`},de={class:`p-6`},fe={key:0,class:`text-center py-8`},pe={key:1,class:`text-center py-8`},me={class:`text-content-secondary dark:text-content-muted text-sm`},he={key:2,class:`space-y-4`},ge={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},_e={class:`flex items-center justify-between mb-2`},ve={class:`flex items-baseline gap-2`},ye={class:`text-3xl font-bold text-content-primary dark:text-content-primary`},be={class:`grid grid-cols-2 gap-3`},xe={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},Se={class:`flex items-center gap-2 mb-2`},Ce={class:`flex gap-0.5`},we={class:`flex items-baseline gap-1`},Te={class:`text-xl font-bold text-content-primary dark:text-content-primary`},Ee={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},De={class:`flex items-baseline gap-1`},Oe={class:`text-xl font-bold text-content-primary dark:text-content-primary`},ke={key:0,class:`flex items-start gap-3 bg-amber-500/10 border border-amber-500/30 rounded-[12px] p-3`},Ae={class:`text-xs leading-relaxed`},je={class:`font-semibold text-amber-600 dark:text-amber-400 mb-0.5`},Me={class:`bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4`},Ne={class:`relative`},Pe={class:`flex items-center gap-2 overflow-x-auto pb-2`},Fe={key:0,class:`relative flex items-center`},Ie={key:0,class:`absolute left-1/2 -translate-x-1/2 animate-pulse`},Le={class:`text-content-muted dark:text-content-muted text-xs mt-2 flex items-center justify-between`},Re={key:0,class:`text-cyan-500 dark:text-primary animate-pulse`},ze={class:`flex items-center justify-between text-xs text-content-muted dark:text-content-muted pt-2`},Be=F(f({__name:`PingResultModal`,props:{show:{type:Boolean},nodeName:{default:null},result:{default:null},error:{default:null},loading:{type:Boolean,default:!1}},emits:[`close`],setup(e,{emit:r}){let i=e,o=r,s=j(),{getSignalQuality:c}=K(),d=l(0),f=l(!1),v=y(()=>{let e=s.stats?.config?.radio?.spreading_factor??7,t=s.stats?.config?.radio?.bandwidth??125,n=s.stats?.config?.radio?.coding_rate??5;return 2**e/t*(8+4.25*(n-4)+20)}),b=y(()=>{if(!i.result)return{color:`text-gray-400`,label:`Unknown`};let e=i.result.rtt_ms,t=v.value,n=i.result.path.length,r=2*t*n+500*n;return e{if(!i.result)return{bars:0,color:`text-gray-400`};let e=c(i.result.rssi);return{bars:e.bars,color:e.color}}),E=y(()=>{if(!i.result)return 0;if(i.result.path_hash_mode!==void 0)return i.result.path_hash_mode;let e=i.result.path.reduce((e,t)=>{let n=t.replace(/^0x/i,``);return Math.max(e,n.length)},0);return e>4?2:e>2?1:0}),D=y(()=>E.value>0),A=y(()=>({0:`1-byte`,1:`2-byte`,2:`3-byte`})[E.value]??`1-byte`);a(()=>i.result,e=>{if(e&&!f.value){f.value=!0,d.value=0;let t=e.path.length,n=1500/(t*2),r=0,i=t*2-2,a=()=>{r<=i?(d.value=r/i,r++,setTimeout(a,n)):(f.value=!1,d.value=1)};setTimeout(a,100)}},{immediate:!0});let M=y(()=>{if(!i.result||!f.value)return-1;let e=i.result.path.length;if(e<=1)return-1;let t=d.value,n=.5;if(t<=n)return t/n*(e-1);{let r=(t-n)/n;return(e-1)*(1-r)}}),N=()=>{o(`close`)};return(r,i)=>(h(),u(p,{to:`body`},[_(O,{name:`modal`},{default:t(()=>[e.show?(h(),C(`div`,{key:0,class:`fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[300] p-4`,onClick:k(N,[`self`])},[S(`div`,{class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/20 rounded-[20px] shadow-2xl w-full max-w-md overflow-hidden`,onClick:i[0]||=k(()=>{},[`stop`])},[S(`div`,ce,[S(`div`,le,[S(`div`,ue,[i[2]||=S(`div`,{class:`p-2 bg-cyan-400/20 dark:bg-primary/20 rounded-lg`},[S(`svg`,{class:`w-5 h-5 text-cyan-500 dark:text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})])],-1),S(`div`,null,[i[1]||=S(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary`},` Ping Result `,-1),e.nodeName?(h(),C(`p`,Y,n(e.nodeName),1)):g(``,!0)])]),S(`button`,{onClick:N,class:`p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary`},[...i[3]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),S(`div`,de,[e.loading?(h(),C(`div`,fe,[_(I,{size:`lg`,class:`mx-auto mb-4`}),i[4]||=S(`p`,{class:`text-content-secondary dark:text-content-muted`},`Sending ping...`,-1),i[5]||=S(`p`,{class:`text-content-muted dark:text-content-muted text-sm mt-1`},` Waiting for response... `,-1)])):e.error?(h(),C(`div`,pe,[i[6]||=S(`div`,{class:`p-3 bg-accent-red/10 rounded-full w-16 h-16 mx-auto mb-4 flex items-center justify-center`},[S(`svg`,{class:`w-8 h-8 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z`})])],-1),i[7]||=S(`h3`,{class:`text-accent-red font-semibold mb-2`},`Ping Failed`,-1),S(`p`,me,n(e.error),1)])):e.result?(h(),C(`div`,he,[S(`div`,ge,[S(`div`,_e,[i[8]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`Round-Trip Time`,-1),S(`span`,{class:w([`text-xs font-medium px-2 py-1 rounded-full`,b.value.color,`bg-current/10`])},n(b.value.label),3)]),S(`div`,ve,[S(`span`,ye,n(e.result.rtt_ms.toFixed(2)),1),i[9]||=S(`span`,{class:`text-content-secondary dark:text-content-muted`},`ms`,-1)])]),S(`div`,be,[S(`div`,xe,[S(`div`,Se,[i[10]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`RSSI`,-1),S(`div`,Ce,[(h(),C(x,null,m(5,e=>S(`div`,{key:e,class:w([`w-1 h-3 rounded-sm`,e<=T.value.bars?T.value.color:`bg-stroke-subtle dark:bg-stroke/10`])},null,2)),64))])]),S(`div`,we,[S(`span`,Te,n(e.result.rssi),1),i[11]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`dBm`,-1)])]),S(`div`,Ee,[i[13]||=S(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-2`},`SNR`,-1),S(`div`,De,[S(`span`,Oe,n(e.result.snr_db),1),i[12]||=S(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`dB`,-1)])])]),D.value?(h(),C(`div`,ke,[i[15]||=S(`svg`,{class:`w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z`})],-1),S(`div`,Ae,[S(`p`,je,n(A.value)+` path hashes active `,1),i[14]||=S(`p`,{class:`text-content-secondary dark:text-content-muted`},` This result uses multi-byte path hashes. The repeater being traced must be running firmware that supports multi-byte path hashes. Repeaters on older firmware will not respond to or correctly route these trace packets. `,-1)])])):g(``,!0),S(`div`,Me,[i[18]||=S(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-3`},` Network Path `,-1),S(`div`,Ne,[S(`div`,Pe,[(h(!0),C(x,null,m(e.result.path,(r,a)=>(h(),C(`div`,{key:a,class:`flex items-center gap-2 flex-shrink-0 relative`},[S(`div`,{class:w([`bg-cyan-400/20 dark:bg-primary/20 text-cyan-600 dark:text-primary border border-cyan-400/40 dark:border-primary/30 px-3 py-1.5 rounded-lg text-sm font-mono transition-all duration-300`,f.value&&Math.floor(M.value)===a?`ring-2 ring-cyan-400/50 dark:ring-primary/50 scale-105`:``])},n(r),3),a[f.value&&M.value>=a&&M.value({Unknown:`Unknown`,"Chat Node":`Chat Node`,Repeater:`Repeater`,"Room Server":`Room Server`,"Hybrid Node":`Hybrid Node`})[e]||e,E=e=>({Unknown:`text-gray-600 dark:text-gray-400`,"Chat Node":`text-blue-600 dark:text-blue-400`,Repeater:`text-emerald-600 dark:text-emerald-400`,"Room Server":`text-purple-600 dark:text-purple-400`,"Hybrid Node":`text-amber-600 dark:text-amber-400`})[e]||`text-gray-600 dark:text-gray-400`,D=async()=>{if(!s.neighbor?.latitude||!s.neighbor?.longitude)return;let e=`${s.neighbor.latitude.toFixed(6)}, ${s.neighbor.longitude.toFixed(6)}`;try{await navigator.clipboard.writeText(e),o.value=`Copied!`,setTimeout(()=>{o.value=`Copy`},2e3)}catch(e){console.error(`Failed to copy coordinates:`,e),o.value=`Failed`,setTimeout(()=>{o.value=`Copy`},2e3)}},A=y(()=>{if(!s.neighbor?.latitude||!s.neighbor?.longitude||!s.baseLatitude||!s.baseLongitude)return null;let e=(s.neighbor.latitude-s.baseLatitude)*Math.PI/180,t=(s.neighbor.longitude-s.baseLongitude)*Math.PI/180,n=Math.sin(e/2)*Math.sin(e/2)+Math.cos(s.baseLatitude*Math.PI/180)*Math.cos(s.neighbor.latitude*Math.PI/180)*Math.sin(t/2)*Math.sin(t/2);return 6371*(2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n)))}),j=y(()=>s.neighbor?.latitude!==null&&s.neighbor?.longitude!==null&&s.neighbor?.latitude!==0&&s.neighbor?.longitude!==0&&Math.abs(s.neighbor?.latitude??0)<=90&&Math.abs(s.neighbor?.longitude??0)<=180),M=()=>{if(!d.value||!s.neighbor||!j.value)return;f&&=(f.remove(),null);let e=document.documentElement.classList.contains(`dark`);f=X.default.map(d.value,{center:[s.neighbor.latitude,s.neighbor.longitude],zoom:13,zoomControl:!0,attributionControl:!1});let t=e?`https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png`;X.default.tileLayer(t,{maxZoom:19,attribution:`© OpenStreetMap © CARTO`}).addTo(f);let n=X.default.divIcon({className:`custom-marker`,html:`
${s.neighbor.node_name?.charAt(0)||`?`}
`,iconSize:[32,32],iconAnchor:[16,16]});if(X.default.marker([s.neighbor.latitude,s.neighbor.longitude],{icon:n}).addTo(f).bindPopup(`${s.neighbor.node_name||`Unknown`}
${s.neighbor.pubkey.slice(0,8)}...`),s.baseLatitude!==null&&s.baseLongitude!==null&&s.baseLatitude!==0&&s.baseLongitude!==0&&Math.abs(s.baseLatitude)<=90&&Math.abs(s.baseLongitude)<=180){let e=X.default.divIcon({className:`custom-marker`,html:`
B
`,iconSize:[32,32],iconAnchor:[16,16]});X.default.marker([s.baseLatitude,s.baseLongitude],{icon:e}).addTo(f).bindPopup(`Base Station`),X.default.polyline([[s.baseLatitude,s.baseLongitude],[s.neighbor.latitude,s.neighbor.longitude]],{color:`#3b82f6`,weight:2,opacity:.6,dashArray:`5, 10`}).addTo(f);let t=X.default.latLngBounds([s.baseLatitude,s.baseLongitude],[s.neighbor.latitude,s.neighbor.longitude]);f.fitBounds(t,{padding:[50,50]})}},N=e=>{e.key===`Escape`&&c(`close`)},P=e=>{e.target===e.currentTarget&&c(`close`)};a(()=>s.isOpen,e=>{e?(document.body.style.overflow=`hidden`,setTimeout(()=>{j.value&&M()},100)):(document.body.style.overflow=``,f&&=(f.remove(),null))},{immediate:!0});let F=y(()=>s.neighbor?i(s.neighbor.rssi):null),I=[`h-1.5`,`h-2`,`h-2.5`,`h-3`,`h-3.5`];return(r,i)=>(h(),u(p,{to:`body`},[_(O,{name:`modal`,appear:``},{default:t(()=>[e.isOpen&&e.neighbor?(h(),C(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 overflow-hidden`,onClick:P,onKeydown:N,tabindex:`0`},[i[21]||=S(`div`,{class:`absolute inset-0 bg-black/60 backdrop-blur-md pointer-events-none`},null,-1),S(`div`,{class:`relative w-full max-w-4xl max-h-[90vh] flex flex-col`,onClick:i[2]||=k(()=>{},[`stop`])},[S(`div`,Ve,[S(`div`,He,[S(`div`,Ue,[S(`h2`,We,n(e.neighbor.node_name||`Unknown Node`),1),S(`p`,Ge,n(e.neighbor.pubkey),1)]),S(`div`,Ke,[S(`button`,{onClick:i[0]||=e=>c(`close`),class:`w-8 h-8 flex items-center justify-center rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors duration-200 text-gray-700 dark:text-white hover:text-gray-900 dark:hover:text-white`},[...i[3]||=[S(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])]),S(`div`,qe,[S(`div`,Je,[i[8]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Basic Information `,-1),S(`div`,Ye,[S(`div`,Xe,[i[4]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Contact Type `,-1),S(`div`,{class:w([`font-medium`,E(e.neighbor.contact_type)])},n(T(e.neighbor.contact_type)),3)]),S(`div`,Ze,[i[5]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Route Type `,-1),S(`div`,Qe,n(v(V)(e.neighbor.route_type)),1)]),S(`div`,$e,[i[6]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Zero Hop `,-1),S(`div`,{class:w([`font-medium`,e.neighbor.zero_hop?`text-green-600 dark:text-green-400`:`text-gray-600 dark:text-gray-400`])},n(e.neighbor.zero_hop?`Yes`:`No`),3)]),S(`div`,et,[i[7]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Advert Count `,-1),S(`div`,tt,n(e.neighbor.advert_count.toLocaleString()),1)])])]),S(`div`,nt,[i[13]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Signal Quality `,-1),S(`div`,rt,[S(`div`,it,[i[9]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` RSSI `,-1),S(`div`,at,n(v(R)(e.neighbor.rssi)),1)]),S(`div`,ot,[i[10]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` SNR `,-1),S(`div`,st,n(v(H)(e.neighbor.snr)),1)]),F.value?(h(),C(`div`,ct,[i[12]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Signal Strength `,-1),S(`div`,lt,[S(`div`,ut,[(h(),C(x,null,m(5,e=>S(`div`,{key:e,class:w([`w-1 transition-colors`,I[e-1],e<=F.value.bars?F.value.color:`text-gray-600 dark:text-gray-700`])},[...i[11]||=[S(`div`,{class:`w-full h-full bg-current rounded-sm`},null,-1)]],2)),64))]),S(`span`,{class:w([`text-sm font-medium`,F.value.color])},n(F.value.quality),3)])])):g(``,!0)])]),S(`div`,dt,[i[16]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Timeline `,-1),S(`div`,ft,[S(`div`,pt,[i[14]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` First Seen `,-1),S(`div`,mt,n(v(B)(e.neighbor.first_seen)),1)]),S(`div`,ht,[i[15]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Last Seen `,-1),S(`div`,gt,n(v(B)(e.neighbor.last_seen)),1)])])]),j.value?(h(),C(`div`,_t,[i[20]||=S(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary mb-4`},` Location `,-1),S(`div`,vt,[S(`div`,yt,[i[17]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Latitude `,-1),S(`div`,bt,n(e.neighbor.latitude?.toFixed(6)),1)]),S(`div`,xt,[i[18]||=S(`div`,{class:`text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1`},` Longitude `,-1),S(`div`,St,n(e.neighbor.longitude?.toFixed(6)),1)]),S(`div`,Ct,[S(`div`,wt,n(A.value===null?`Coordinates`:`Distance`),1),A.value===null?(h(),C(`button`,{key:1,onClick:D,class:`w-full px-3 py-1.5 rounded-lg text-sm font-medium transition-colors flex items-center justify-center gap-1.5 bg-primary/20 hover:bg-primary/30 border border-primary/50 text-primary`},[i[19]||=S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})],-1),b(` `+n(o.value),1)])):(h(),C(`div`,Tt,n(`${A.value.toFixed(2)} km`),1))])]),S(`div`,{ref_key:`mapContainer`,ref:d,class:`w-full h-96 rounded-[12px] overflow-hidden border border-stroke-subtle dark:border-white/10`},null,512)])):g(``,!0)]),S(`div`,Et,[S(`button`,{onClick:i[1]||=e=>c(`close`),class:`w-full px-4 py-2.5 rounded-lg font-medium transition-colors bg-primary/20 hover:bg-primary/30 border border-primary/50 text-primary`},` Close `)])])])],32)):g(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-dc69b1d1`]]),Ot=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],kt=1,At=8,jt=class e{static from(t){if(!(t instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==kt)throw Error(`Got v${i} data when expected v${kt}.`);let a=Ot[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,t)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=Ot.indexOf(this.ArrayType),a=e*2*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,At,e),this.coords=new this.ArrayType(this.data,At+o+s,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(At+a+o+s),this.ids=new this.IndexArrayType(this.data,At,e),this.coords=new this.ArrayType(this.data,At+o+s,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(kt<<4)+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Mt(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)It(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];It(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}};function Mt(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;Nt(e,t,o,r,i,a),Mt(e,t,n,r,o-1,1-a),Mt(e,t,n,o+1,i,1-a)}function Nt(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);Nt(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(Pt(e,t,r,n),t[2*i+a]>o&&Pt(e,t,r,i);so;)c--}t[2*r+a]===o?Pt(e,t,r,c):(c++,Pt(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function Pt(e,t,n,r){Ft(e,n,r),Ft(t,2*n,2*r),Ft(t,2*n+1,2*r+1)}function Ft(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function It(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var Lt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Rt=Math.fround||(e=>(t=>(e[0]=+t,e[0])))(new Float32Array(1)),Z=2,Q=3,zt=4,$=5,Bt=6,Vt=class{constructor(e){this.options=Object.assign(Object.create(Lt),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t=n;e--){let n=+Date.now();o=this.trees[e]=this._createTree(this._cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,+Date.now()-n)}return t&&console.timeEnd(`total time`),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClusters([n,r,180,a],t),o=this.getClusters([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this._limitZoom(t)],s=o.range(Wt(n),Gt(a),Wt(i),Gt(r)),c=o.data,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+$]>1?Ht(c,t,this.clusterProps):this.points[c[t+Q]])}return l}getChildren(e){let t=this._getOriginId(e),n=this._getOriginZoom(e),r=`No cluster with the specified id.`,i=this.trees[n];if(!i)throw Error(r);let a=i.data;if(t*this.stride>=a.length)throw Error(r);let o=this.options.radius/(this.options.extent*2**(n-1)),s=a[t*this.stride],c=a[t*this.stride+1],l=i.within(s,c,o),u=[];for(let t of l){let n=t*this.stride;a[n+zt]===e&&u.push(a[n+$]>1?Ht(a,n,this.clusterProps):this.points[a[n+Q]])}if(u.length===0)throw Error(r);return u}getLeaves(e,t,n){t||=10,n||=0;let r=[];return this._appendLeaves(r,e,t,n,0),r}getTile(e,t,n){let r=this.trees[this._limitZoom(e)],i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={features:[]};return this._addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.data,t,n,i,u),t===0&&this._addTileFeatures(r.range(1-s/i,c,1,l),r.data,i,n,i,u),t===i-1&&this._addTileFeatures(r.range(0,c,s/i,l),r.data,-1,n,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){let n=this.getChildren(e);if(t++,n.length!==1)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a&&a.cluster?i+a.point_count<=r?i+=a.point_count:i=this._appendLeaves(e,a.cluster_id,n,r,i):i1,c,l,u;if(s)c=Ut(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+Q]];c=n.properties;let[r,i]=n.geometry.coordinates;l=Wt(r),u=Gt(i)}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+Q]:this.points[t[e+Q]].id,f!==void 0&&(d.id=f),a.features.push(d)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.data,c=[],l=this.stride;for(let n=0;nt&&(p+=s[n+$])}if(p>f&&p>=a){let e=r*f,a=u*f,o,m=-1,h=((n/l|0)<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+Z]<=t)continue;s[c+Z]=t;let u=s[c+$];e+=s[c]*u,a+=s[c+1]*u,s[c+zt]=h,i&&(o||(o=this._map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(o)),i(o,this._map(s,c)))}s[n+zt]=h,c.push(e/p,a/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e1)for(let e of d){let n=e*l;if(!(s[n+Z]<=t)){s[n+Z]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+$]>1){let r=this.clusterProps[e[t+Bt]];return n?Object.assign({},r):r}let r=this.points[e[t+Q]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}};function Ht(e,t,n){return{type:`Feature`,id:e[t+Q],properties:Ut(e,t,n),geometry:{type:`Point`,coordinates:[Kt(e[t]),qt(e[t+1])]}}}function Ut(e,t,n){let r=e[t+$],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?`${Math.round(r/100)/10}k`:r,a=e[t+Bt],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+Q],point_count:r,point_count_abbreviated:i})}function Wt(e){return e/360+.5}function Gt(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function Kt(e){return(e-.5)*360}function qt(e){let t=(180-e*360)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var Jt={class:`map-container`},Yt={key:0,class:`flex items-center justify-center h-96 glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] shadow-sm dark:shadow-none`},Xt={key:0,class:`flex items-center gap-2 text-content-secondary dark:text-content-muted`},Zt={key:1,class:`text-center text-content-primary dark:text-content-primary`},Qt={class:`hidden sm:inline`},$t={key:3,class:`map-legend`},en={class:`legend-footer`},tn={key:4,class:`map-attribution`},nn=F(f({__name:`NetworkMap`,props:{adverts:{},baseLatitude:{default:null},baseLongitude:{default:null},statsLoading:{type:Boolean,default:!1},showLegend:{type:Boolean,default:!0}},emits:[`update:showLegend`],setup(e,{expose:t,emit:s}){typeof window<`u`&&!window.chrome&&(window.chrome={runtime:{}});let c=e,u=s,f=()=>{u(`update:showLegend`,!c.showLegend)},p=l(),m=null,v=l(new Map),b=null,x=l(new Map),w=l([]),T=l(!0),E=l(60),D=l(14),O=l(document.documentElement.classList.contains(`dark`)),k=new MutationObserver(()=>{let e=document.documentElement.classList.contains(`dark`);e!==O.value&&(O.value=e,m&&N())}),A=y(()=>c.baseLatitude!==null&&c.baseLongitude!==null&&typeof c.baseLatitude==`number`&&typeof c.baseLongitude==`number`&&c.baseLatitude!==0&&c.baseLongitude!==0&&Math.abs(c.baseLatitude)<=90&&Math.abs(c.baseLongitude)<=180),j=(e,t,n,r)=>{let i=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(a/2)*Math.sin(a/2);return 6371*(2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)))},M=()=>{m&&=(w.value.forEach(e=>{m&&e.remove()}),w.value.length=0,m.remove(),null),v.value.clear(),x.value.clear(),b=null},N=async()=>{let e=m?.getZoom()||11,t=m?.getCenter()||(A.value?[c.baseLatitude,c.baseLongitude]:[0,0]);M(),await o(),await L(),m&&m.setView(t,e)},P=e=>{let t=new Map;return e.filter(e=>e.latitude!==null&&e.longitude!==null).map(e=>{let n=e.latitude,r=e.longitude,i=`${n.toFixed(6)}_${r.toFixed(6)}`,a=t.get(i)||0;if(t.set(i,a+1),a>0){let e=.001,t=a*60*(Math.PI/180);n+=Math.sin(t)*e*(a*.5),r+=Math.cos(t)*e*(a*.5)}return{type:`Feature`,properties:{advert:{...e,jittered_latitude:n,jittered_longitude:r}},geometry:{type:`Point`,coordinates:[r,n]}}})},F=e=>{b=new Vt({radius:E.value,maxZoom:D.value,minPoints:2}),b.load(e)},L=async()=>{if(!p.value||!A.value){console.warn(`Cannot initialize map: missing container or coordinates`);return}M(),await o();let e=c.baseLatitude,t=c.baseLongitude;m=X.default.map(p.value,{center:[e,t],zoom:11,zoomControl:!0,attributionControl:!1,preferCanvas:!1});try{let e=O.value?`https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png`,t=O.value?`https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png`:`https://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}{r}.png`,n=X.default.tileLayer(e,{maxZoom:19,attribution:`© OpenStreetMap contributors © CARTO`,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`}),r=X.default.tileLayer(t,{maxZoom:19,attribution:``,errorTileUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==`});n.addTo(m),r.addTo(m)}catch(e){console.warn(`Error loading tiles:`,e)}try{let n=(e,t=!1)=>{let n=t?16:12;return X.default.divIcon({className:`custom-div-icon`,html:`
`,iconSize:[n+4,n+4],iconAnchor:[(n+4)/2,(n+4)/2]})},r=e=>{let t=e<10?30:e<100?40:50;return X.default.divIcon({className:`custom-cluster-icon`,html:` +
+ ${e} +
+ `,iconSize:[t,t],iconAnchor:[t/2,t/2]})},i=n(`#ef4444`,!0);X.default.marker([e,t],{icon:i}).addTo(m).bindPopup(` +
+ Base Station
+ Base Station
+ ${e.toFixed(6)}, ${t.toFixed(6)} +
+ `);let a={Unknown:`#9CA3AF`,"Chat Node":`#60A5FA`,Repeater:`#A5E5B6`,"Room Server":`#EBA0FC`,"Hybrid Node":`#FFC246`},o=(e,t,n,r,i=0)=>{if(!m||e.zero_hop!==!0)return;let a=e.jittered_latitude||e.latitude,o=e.jittered_longitude||e.longitude;if(a===null||o===null)return;let s=e.route_type||0,c=r,l=3,u=.7,d;s===2?(c=`#A5E5B6`,l=4,u=.9):s===1?(c=`#FFC246`,d=`10, 5`,u=.8):s===3?(c=`#059669`,l=5,u=.95):s===0?(c=`#ea580c`,d=`12, 6`,u=.8):(c=`#9CA3AF`,d=`2, 5`,u=.6);let f=[t,n],p=[a,o],h=X.default.polyline([f,p],{color:c,weight:l,opacity:0,dashArray:d,className:`connection-line`}).addTo(m),g=X.default.polyline([f,f],{color:c,weight:l,opacity:0,dashArray:d,className:`connection-line animated-line`}).addTo(m);setTimeout(()=>{let i=0;g.setStyle({opacity:u+.2});let s=()=>{i++;let c=i/30,d=f[0]+(p[0]-f[0])*c,_=f[1]+(p[1]-f[1])*c;g.setLatLngs([f,[d,_]]),i<30?setTimeout(s,30):setTimeout(()=>{m&&g&&g.remove(),h.setStyle({opacity:u}),h.on(`mouseover`,()=>{h.setStyle({weight:l+2,opacity:Math.min(u+.3,1)})}),h.on(`mouseout`,()=>{h.setStyle({weight:l,opacity:u})});let i=j(t,n,a,o);h.bindPopup(` +
+ Connection to ${e.node_name||`Unknown Node`}
+ Distance: ${i.toFixed(2)} km
+ Route: ${V(e.route_type)}
+ Signal: ${R(e.rssi)} / ${H(e.snr)} +
+ `),w.value.push(h)},200)};s()},i)},s=()=>{if(!m||!b)return;let i=m.getBounds(),s=Math.floor(m.getZoom());x.value.forEach(e=>{m&&e.remove()}),x.value.clear(),w.value.forEach(e=>{m&&e.remove()}),w.value.length=0,b.getClusters([i.getWest(),i.getSouth(),i.getEast(),i.getNorth()],s).forEach(i=>{let[s,c]=i.geometry.coordinates,l=i.properties;if(l.cluster){let n=X.default.marker([c,s],{icon:r(l.point_count||0)}).addTo(m);n.on(`click`,()=>{if(m&&b){let e=b.getClusterExpansionZoom(l.cluster_id);m.setView([c,s],e)}});let i=b.getLeaves(l.cluster_id,1/0).map(e=>`
+ • ${e.properties.advert.node_name||`Unknown Node`} (${e.properties.advert.contact_type}) +
`).join(``);n.bindPopup(` +
+ Cluster: ${l.point_count} nodes
+
+ ${i} +
+
+ Click to zoom in and separate nodes +
+
+ `),x.value.set(`cluster-${l.cluster_id}`,n);let u=j(e,t,c,s),d=Math.min(Math.floor(u*5),200);o({node_name:`Cluster of ${l.point_count} nodes`,contact_type:`Cluster`,route_type:2,rssi:null,snr:null,jittered_latitude:c,jittered_longitude:s,latitude:c,longitude:s},e,t,`#AAE8E8`,d)}else{let r=l.advert,i=a[r.contact_type]||a.Unknown,u=n(i),d=c,f=s,p=j(e,t,d,f),h=X.default.marker([d,f],{icon:u}).addTo(m).bindPopup(` +
+ ${r.node_name||`Unknown Node`}
+ Type: ${r.contact_type}
+ Distance: ${p.toFixed(2)} km
+ Signal: ${R(r.rssi)} / ${H(r.snr)}
+ Route: ${V(r.route_type)}
+ Last Seen: ${B(r.last_seen)} + ${r.jittered_latitude?`
Position adjusted to separate overlapping nodes`:``} +
+ `);v.value.set(r.pubkey,h),x.value.set(`node-${r.pubkey}`,h);let g=Math.min(Math.floor(p*5),200);o({...r,jittered_latitude:d,jittered_longitude:f},e,t,i,g)}})},l=(e,t)=>{let r=0;P(c.adverts).forEach(i=>{let s=i.properties.advert;if(s.latitude!==null&&s.longitude!==null){let i=a[s.contact_type]||a.Unknown,c=n(i),l=s.jittered_latitude||s.latitude,u=s.jittered_longitude||s.longitude,d=X.default.marker([l,u],{icon:c}).addTo(m).bindPopup(` +
+ ${s.node_name||`Unknown Node`}
+ Type: ${s.contact_type}
+ Distance: ${j(e,t,l,u).toFixed(2)} km
+ Signal: ${R(s.rssi)} / ${H(s.snr)}
+ Route: ${V(s.route_type)}
+ Last Seen: ${B(s.last_seen)} + ${s.jittered_latitude?`
Position adjusted to separate overlapping nodes`:``} +
+ `);v.value.set(s.pubkey,d);let f=d.getElement();f&&(f.style.opacity=`0`,f.style.transition=`opacity 0.5s ease-out`),o(s,e,t,i,r),setTimeout(()=>{f&&(f.style.opacity=`1`)},r+1e3),r+=100}})};if(T.value&&c.adverts.length>0)try{F(P(c.adverts));let n=Math.min(14,m.getZoom());m.setZoom(n),setTimeout(()=>{try{s()}catch(n){console.warn(`Error updating clusters:`,n),l(e,t)}},100),m.on(`moveend`,()=>{try{s()}catch(e){console.warn(`Error updating clusters on move:`,e)}}),m.on(`zoomend`,()=>{try{s()}catch(e){console.warn(`Error updating clusters on zoom:`,e)}})}catch(n){console.warn(`Error initializing clustering:`,n),l(e,t)}else l(e,t);setTimeout(()=>{m&&m.invalidateSize()},1e3)}catch(e){console.error(`Error initializing map:`,e)}};return t({highlightNode:e=>{let t=v.value.get(e);if(t){let e=t.getElement();if(e){let t=e.querySelector(`div`);t&&t.classList.add(`marker-highlight`)}}},unhighlightNode:e=>{let t=v.value.get(e);if(t){let e=t.getElement();if(e){let t=e.querySelector(`div`);t&&t.classList.remove(`marker-highlight`)}}},initializeOpenStreetMap:L}),a(()=>c.adverts,()=>{m&&A.value&&setTimeout(()=>{L()},100)},{immediate:!1}),a(A,e=>{e&&c.adverts.length>0&&!m&&o(()=>L())}),i(()=>{k.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),A.value&&c.adverts.length>0&&setTimeout(()=>{L()},300)}),r(()=>{k.disconnect(),M()}),(t,r)=>(h(),C(`div`,Jt,[A.value?(h(),C(`div`,{key:1,ref_key:`mapContainer`,ref:p,class:`leaflet-map-container h-96 w-full glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] overflow-hidden shadow-sm dark:shadow-none`,style:{"min-height":`384px`,position:`relative`}},null,512)):(h(),C(`div`,Yt,[c.statsLoading?(h(),C(`div`,Xt,[_(I,{size:`xs`}),r[0]||=S(`p`,{class:`text-xs sm:text-sm`},`Fetching base station location…`,-1)])):(h(),C(`div`,Zt,[...r[1]||=[S(`svg`,{class:`w-8 h-8 mx-auto mb-2 text-content-muted dark:text-content-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[S(`path`,{d:`M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z`})],-1),S(`p`,{class:`text-sm text-content-primary dark:text-content-primary`},` No valid coordinates available `,-1),S(`p`,{class:`text-xs text-content-secondary dark:text-content-muted`},` Configure base station location to view map `,-1)]]))])),A.value&&e.adverts.length>0?(h(),C(`button`,{key:2,onClick:f,class:`absolute bottom-3 right-3 z-[200] flex items-center gap-2 px-3 py-2 bg-black/40 border border-white/10 rounded-lg text-white/80 hover:bg-white/10 hover:text-white transition-colors text-sm backdrop-blur-sm`},[r[2]||=S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})],-1),S(`span`,Qt,n(e.showLegend?`Hide`:`Show`),1)])):g(``,!0),A.value&&e.adverts.length>0&&e.showLegend?(h(),C(`div`,$t,[r[3]||=d(`
Node Types
Base Station
Chat Node
Repeater
Room Server
Hybrid Node
Route Types
Direct
Transport Direct
Flood
Transport Flood
`,2),S(`div`,en,n(e.adverts.length)+` node`+n(e.adverts.length===1?``:`s`)+` visible `,1)])):g(``,!0),A.value?(h(),C(`div`,tn,` © OpenStreetMap contributors © CARTO `)):g(``,!0)]))}}),[[`__scopeId`,`data-v-47bae275`]]),rn={class:`relative`,"data-menu-container":``},an=f({__name:`NeighborMenu`,props:{neighbor:{},canPing:{type:Boolean}},emits:[`ping`,`delete`,`show-details`],setup(e,{emit:t}){let n=window.__neighborMenuManager||{activeMenu:null,setActiveMenu:e=>{if(n.activeMenu&&n.activeMenu!==e)try{n.activeMenu.closeMenu()}catch(e){console.warn(`Error closing previous menu:`,e)}n.activeMenu=e}};window.__neighborMenuManager=n;let i=e,a=t,c=l(!1),d=l(),f=l(),m=l({top:0,left:0}),_=()=>{c.value=!1,document.removeEventListener(`click`,T,!0),document.removeEventListener(`keydown`,E),n.activeMenu===v&&(n.activeMenu=null)},v={closeMenu:_},y=()=>{_(),a(`ping`,i.neighbor)},b=()=>{_(),a(`show-details`,i.neighbor)},x=()=>{_(),a(`delete`,i.neighbor)},T=e=>{e.target.closest(`[data-menu-container]`)||_()},E=e=>{e.key===`Escape`&&_()},D=async()=>{if(!c.value&&d.value){n.setActiveMenu(v);let e=d.value.getBoundingClientRect(),t=window.innerWidth,r=t<1024,i=e.left+144>t-16,a=e.left;if(r&&i&&(a=e.right-144),a=Math.max(8,a),m.value={top:e.bottom+4,left:a},c.value=!0,await o(),f.value){let t=f.value.offsetHeight;e.bottom+4+t>window.innerHeight-8&&(m.value={top:e.top-t-4,left:a})}document.addEventListener(`click`,T,!0),document.addEventListener(`keydown`,E)}else _()};return r(()=>{_()}),(e,t)=>(h(),C(`div`,rn,[S(`button`,{ref_key:`buttonRef`,ref:d,onClick:D,class:w([`p-1 rounded hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary/80`,{"bg-background-mute dark:bg-stroke/10 text-content-primary dark:text-content-primary/80":c.value}]),"data-menu-container":``},[...t[0]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z`})],-1)]],2),(h(),u(p,{to:`body`},[c.value?(h(),C(`div`,{key:0,ref_key:`menuRef`,ref:f,class:`fixed w-36 bg-white dark:bg-surface-elevated backdrop-blur-lg border border-stroke-subtle dark:border-white/20 rounded-[15px] shadow-2xl z-[450]`,style:s({top:m.value.top+`px`,left:m.value.left+`px`}),"data-menu-container":``},[S(`div`,{class:`py-2`},[S(`button`,{onClick:b,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10`},[...t[1]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),S(`span`,{class:`font-medium`},`Details`,-1)]]),S(`button`,{onClick:y,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10`},[...t[2]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})],-1),S(`span`,{class:`font-medium`},`Ping`,-1)]]),S(`button`,{onClick:x,class:`flex items-center gap-3 w-full px-4 py-3 text-sm text-accent-red hover:bg-accent-red/10 transition-colors`},[...t[3]||=[S(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1),S(`span`,{class:`font-medium`},`Delete`,-1)]])])],4)):g(``,!0)]))]))}}),on={class:`glass-card/30 backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[12px] p-6 shadow-sm dark:shadow-none`},sn={class:`flex items-center justify-between mb-4`},cn={class:`flex items-center gap-3`},ln={class:`text-content-primary dark:text-content-primary text-lg font-semibold`},un={class:`bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary text-xs px-2 py-1 rounded-full`},dn={key:0,class:`text-content-muted dark:text-content-muted`},fn={key:0,class:`hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 p-1`},pn={class:`hidden lg:block overflow-x-auto`},mn={class:`w-full`},hn={class:`bg-background-mute dark:bg-transparent`},gn={class:`flex items-center gap-1`},_n={class:`flex items-center gap-1`},vn={class:`flex items-center gap-1`},yn={class:`flex items-center gap-1`},bn={class:`flex items-center gap-1`},xn={class:`flex items-center gap-1`},Sn={class:`flex items-center gap-1`},Cn={class:`flex items-center gap-1`},wn={class:`flex items-center gap-1`},Tn={class:`bg-surface/50 dark:bg-transparent`},En=[`onMouseenter`,`onMouseleave`,`onClick`],Dn=[`onClick`,`title`],On={key:0,class:`ml-1 text-xs`},kn={key:0,class:`flex items-center gap-3`},An={class:`text-content-secondary dark:text-content-muted`},jn={class:`flex gap-1`},Mn=[`onClick`],Nn=[`onClick`],Pn={key:1,class:`text-content-muted`},Fn={class:`flex items-center gap-2`},In={class:`flex items-end gap-0.5`},Ln={class:`flex items-center gap-2`},Rn=[`title`],zn=[`title`],Bn={class:`lg:hidden space-y-3`},Vn=[`onClick`],Hn={class:`flex items-center justify-between mb-3`},Un={class:`flex items-center gap-3`},Wn={class:`text-content-primary dark:text-content-primary font-medium text-base`},Gn={class:`flex items-center gap-2`},Kn={class:`grid grid-cols-1 gap-3`},qn={class:`grid grid-cols-2 gap-4`},Jn=[`onClick`,`title`],Yn={key:0,class:`ml-1 text-xs`},Xn={class:`flex items-center gap-2 justify-end`},Zn={class:`flex items-end gap-0.5`},Qn={class:`grid grid-cols-2 gap-4`},$n={class:`flex items-center gap-2`},er=[`title`],tr={class:`text-content-primary dark:text-content-primary text-sm block text-right`},nr={key:0,class:`border-t border-white/10 pt-3`},rr={class:`flex items-center justify-between`},ir={class:`text-content-secondary dark:text-content-muted text-sm font-mono`},ar={class:`flex gap-2`},or=[`onClick`],sr=[`onClick`],cr={class:`grid grid-cols-3 gap-4 pt-3 border-t border-white/10`},lr={class:`text-center`},ur={class:`text-content-primary dark:text-content-primary text-sm font-medium`},dr={class:`text-center`},fr={class:`text-content-primary dark:text-content-primary text-sm font-medium`},pr={class:`text-center`},mr=[`title`],hr=f({__name:`NeighborTable`,props:{contactType:{},contactTypeKey:{},adverts:{},originalCount:{default:0},color:{},baseLatitude:{default:null},baseLongitude:{default:null},isCompactView:{type:Boolean,default:!1},isFirstTable:{type:Boolean,default:!1},showViewToggle:{type:Boolean,default:!1}},emits:[`highlight-node`,`unhighlight-node`,`menu-ping`,`menu-delete`,`show-details`,`toggle-view`],setup(e,{emit:t}){let r=l(null),{getSignalQuality:i}=K(),a=l(`advert_count`),o=l(`desc`),c=e,u=t,d=(e,t,n,r)=>{let i=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(a/2)*Math.sin(a/2);return 6371*(2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)))},f=e=>c.baseLatitude===null||c.baseLongitude===null||e.latitude===null||e.longitude===null?`N/A`:ee(d(c.baseLatitude,c.baseLongitude,e.latitude,e.longitude)),p=async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);return t.value=e,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),!0}},T=e=>{let t=Date.now()-e*1e3,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`},E=e=>{let t=Date.now()-e*1e3,n=Math.floor(t/(1e3*60*60));return n<1?{color:`text-green-600 dark:text-green-400`}:n<26?{color:`text-yellow-600 dark:text-yellow-400`}:{color:`text-red-600 dark:text-red-400`}},D=async(e,t)=>{await p(`${e.toFixed(6)}, ${t.toFixed(6)}`)},O=(e,t)=>{let n=`https://www.google.com/maps?q=${e},${t}`;window.open(n,`_blank`)},A=async e=>{await p(e),r.value=e,setTimeout(()=>{r.value=null},2e3)},j=e=>{let t=i(e);return{bars:t.bars,color:t.color}},M=[`h-1.5`,`h-2`,`h-2.5`,`h-3`,`h-3.5`],N=[`h-2`,`h-2.5`,`h-3`,`h-3.5`,`h-4`],P=()=>c.isCompactView?`py-2 px-2`:`py-4 px-3`,F=()=>{u(`toggle-view`)},I=e=>{u(`highlight-node`,e)},L=e=>{u(`unhighlight-node`,e)},V=e=>{u(`menu-ping`,e)},W=e=>{u(`show-details`,e)},G=e=>{u(`menu-delete`,e)},q=e=>{a.value===e?o.value=o.value===`asc`?`desc`:`asc`:(a.value=e,o.value=typeof c.adverts[0]?.[e]==`number`?`desc`:`asc`)},J=y(()=>a.value?[...c.adverts].sort((e,t)=>{let n=e[a.value],r=t[a.value];if(n==null)return 1;if(r==null)return-1;let i=0;return typeof n==`string`&&typeof r==`string`?i=n.localeCompare(r):typeof n==`number`&&typeof r==`number`?i=n-r:typeof n==`boolean`&&typeof r==`boolean`&&(i=n===r?0:n?1:-1),o.value===`asc`?i:-i}):c.adverts);return(t,i)=>(h(),C(`div`,on,[S(`div`,sn,[S(`div`,cn,[S(`div`,{class:`w-3 h-3 rounded-full border border-white/20`,style:s({backgroundColor:e.color})},null,4),S(`h3`,ln,n(e.contactType),1),S(`span`,un,[b(n(e.adverts.length)+` `,1),e.originalCount>0&&e.adverts.lengthq(`node_name`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,gn,[i[13]||=b(` Node Name `,-1),a.value===`node_name`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[12]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[1]||=e=>q(`pubkey`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,_n,[i[15]||=b(` Public Key `,-1),a.value===`pubkey`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[14]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5`)},` Location `,2),S(`th`,{class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5`)},` Distance `,2),S(`th`,{onClick:i[2]||=e=>q(`route_type`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,vn,[i[17]||=b(` Route Type `,-1),a.value===`route_type`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[16]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[3]||=e=>q(`zero_hop`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,yn,[i[19]||=b(` Zero Hop `,-1),a.value===`zero_hop`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[18]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[4]||=e=>q(`rssi`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,bn,[i[21]||=b(` RSSI `,-1),a.value===`rssi`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[20]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[5]||=e=>q(`snr`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,xn,[i[23]||=b(` SNR `,-1),a.value===`snr`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[22]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[6]||=e=>q(`last_seen`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,Sn,[i[25]||=b(` Last Seen `,-1),a.value===`last_seen`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[24]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[7]||=e=>q(`first_seen`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,Cn,[i[27]||=b(` First Seen `,-1),a.value===`first_seen`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[26]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2),S(`th`,{onClick:i[8]||=e=>q(`advert_count`),class:w(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${P().split(` `)[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[S(`div`,wn,[i[29]||=b(` Advert Count `,-1),a.value===`advert_count`?(h(),C(`svg`,{key:0,class:w([`w-3 h-3`,o.value===`asc`?``:`rotate-180`]),fill:`currentColor`,viewBox:`0 0 20 20`},[...i[28]||=[S(`path`,{"fill-rule":`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,"clip-rule":`evenodd`},null,-1)]],2)):g(``,!0)])],2)])]),S(`tbody`,Tn,[(h(!0),C(x,null,m(J.value,e=>(h(),C(`tr`,{key:e.id,class:`hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors cursor-pointer`,onMouseenter:t=>I(e.pubkey),onMouseleave:t=>L(e.pubkey),onClick:t=>W(e)},[S(`td`,{class:w(P()),onClick:i[9]||=k(()=>{},[`stop`])},[_(an,{neighbor:e,onPing:V,onShowDetails:W,onDelete:G},null,8,[`neighbor`])],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},n(e.node_name||`Unknown`),3),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm font-mono`)},[S(`button`,{onClick:k(t=>A(e.pubkey),[`stop`]),class:w([`text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60`,r.value===e.pubkey?`text-green-600 dark:text-green-400 decoration-green-400/60`:``]),title:r.value===e.pubkey?`Copied!`:`Click to copy full public key`},[b(n(v(z)(e.pubkey))+` `,1),r.value===e.pubkey?(h(),C(`span`,On,`✓`)):g(``,!0)],10,Dn)],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[e.latitude!==null&&e.longitude!==null?(h(),C(`div`,kn,[S(`span`,An,n(e.latitude.toFixed(4))+`, `+n(e.longitude.toFixed(4)),1),S(`div`,jn,[S(`button`,{onClick:k(t=>D(e.latitude,e.longitude),[`stop`]),class:`text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors cursor-pointer`,title:`Copy coordinates to clipboard`},[...i[30]||=[S(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`,stroke:`currentColor`,"stroke-width":`2`}),S(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,Mn),S(`button`,{onClick:k(t=>O(e.latitude,e.longitude),[`stop`]),class:`text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors cursor-pointer`,title:`Open in Google Maps`},[...i[31]||=[S(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`path`,{d:`M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z`,stroke:`currentColor`,"stroke-width":`2`}),S(`circle`,{cx:`12`,cy:`10`,r:`3`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,Nn)])])):(h(),C(`span`,Pn,`Unknown`))],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},n(f(e)),3),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[S(`span`,{class:w([`inline-block px-2 py-1 rounded-full text-xs border transition-colors`,v(U)(e.route_type).bgColor,v(U)(e.route_type).borderColor,v(U)(e.route_type).textColor])},n(v(U)(e.route_type).text),3)],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[S(`span`,{class:w([`inline-block px-2 py-1 rounded-full text-xs border transition-colors`,e.zero_hop?`bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400`:`bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400`])},n(e.zero_hop?`Zero Hop`:`Multi-Hop`),3)],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[S(`div`,Fn,[S(`div`,In,[(h(),C(x,null,m(5,t=>S(`div`,{key:t,class:w([`w-1 transition-colors`,M[t-1],t<=j(e.rssi).bars?j(e.rssi).color:`text-gray-600`])},[...i[32]||=[S(`div`,{class:`w-full h-full bg-current rounded-sm`},null,-1)]],2)),64))]),S(`span`,{class:w(j(e.rssi).color)},n(v(R)(e.rssi)),3)])],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},n(v(H)(e.snr)),3),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[S(`div`,Ln,[S(`div`,{class:w([`w-2 h-2 rounded-full`,E(e.last_seen).color===`text-green-600 dark:text-green-400`?`bg-green-400`:``,E(e.last_seen).color===`text-yellow-600 dark:text-yellow-400`?`bg-yellow-400`:``,E(e.last_seen).color===`text-red-600 dark:text-red-400`?`bg-red-400`:``])},null,2),S(`span`,{class:w([E(e.last_seen).color,`cursor-help`]),title:v(B)(e.last_seen)},n(T(e.last_seen)),11,Rn)])],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm`)},[S(`span`,{title:v(B)(e.first_seen),class:`cursor-help`},n(T(e.first_seen)),9,zn)],2),S(`td`,{class:w(`${P()} text-content-primary dark:text-content-primary text-sm text-center`)},n(e.advert_count),3)],40,En))),128))])])]),S(`div`,Bn,[(h(!0),C(x,null,m(J.value,e=>(h(),C(`div`,{key:e.id,class:`bg-surface/50 dark:bg-transparent border border-stroke-subtle dark:border-white/10 rounded-lg p-4 hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors`,onClick:t=>I(e.pubkey)},[S(`div`,Hn,[S(`div`,Un,[S(`h4`,Wn,n(e.node_name||`Unknown Node`),1),S(`div`,Gn,[S(`span`,{class:w([`inline-block px-2 py-1 rounded-full text-xs border`,v(U)(e.route_type).bgColor,v(U)(e.route_type).borderColor,v(U)(e.route_type).textColor])},n(v(U)(e.route_type).text),3),S(`span`,{class:w([`inline-block px-2 py-1 rounded-full text-xs border`,e.zero_hop?`bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400`:`bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400`])},n(e.zero_hop?`Zero Hop`:`Multi-Hop`),3)])]),_(an,{neighbor:e,onPing:V,onShowDetails:W,onDelete:G},null,8,[`neighbor`])]),S(`div`,Kn,[S(`div`,qn,[S(`div`,null,[i[33]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Public Key`,-1),S(`button`,{onClick:t=>A(e.pubkey),class:w([`text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer font-mono text-sm underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60 break-all`,r.value===e.pubkey?`text-green-600 dark:text-green-400 decoration-green-400/60`:``]),title:r.value===e.pubkey?`Copied!`:`Click to copy full public key`},[b(n(v(z)(e.pubkey))+` `,1),r.value===e.pubkey?(h(),C(`span`,Yn,`✓`)):g(``,!0)],10,Jn)]),S(`div`,null,[i[35]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Signal`,-1),S(`div`,Xn,[S(`div`,Zn,[(h(),C(x,null,m(5,t=>S(`div`,{key:t,class:w([`w-1.5 transition-colors`,N[t-1],t<=j(e.rssi).bars?j(e.rssi).color:`text-gray-600`])},[...i[34]||=[S(`div`,{class:`w-full h-full bg-current rounded-sm`},null,-1)]],2)),64))]),S(`span`,{class:w(`${j(e.rssi).color} text-sm font-medium`)},n(v(R)(e.rssi)),3)])])]),S(`div`,Qn,[S(`div`,null,[i[36]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Last Seen`,-1),S(`div`,$n,[S(`div`,{class:w([`w-2 h-2 rounded-full`,E(e.last_seen).color===`text-green-600 dark:text-green-400`?`bg-green-400`:``,E(e.last_seen).color===`text-yellow-600 dark:text-yellow-400`?`bg-yellow-400`:``,E(e.last_seen).color===`text-red-600 dark:text-red-400`?`bg-red-400`:``])},null,2),S(`span`,{class:w(`${E(e.last_seen).color} text-sm`),title:v(B)(e.last_seen)},n(T(e.last_seen)),11,er)])]),S(`div`,null,[i[37]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Distance`,-1),S(`span`,tr,n(f(e)),1)])]),e.latitude!==null&&e.longitude!==null?(h(),C(`div`,nr,[i[40]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Location`,-1),S(`div`,rr,[S(`span`,ir,n(e.latitude.toFixed(4))+`, `+n(e.longitude.toFixed(4)),1),S(`div`,ar,[S(`button`,{onClick:t=>D(e.latitude,e.longitude),class:`text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg`,title:`Copy coordinates`},[...i[38]||=[S(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`,stroke:`currentColor`,"stroke-width":`2`}),S(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,or),S(`button`,{onClick:t=>O(e.latitude,e.longitude),class:`text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors p-2 hover:bg-white/10 rounded-lg`,title:`Open in Maps`},[...i[39]||=[S(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`path`,{d:`M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z`,stroke:`currentColor`,"stroke-width":`2`}),S(`circle`,{cx:`12`,cy:`10`,r:`3`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],8,sr)])])])):g(``,!0),S(`div`,cr,[S(`div`,lr,[i[41]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`SNR`,-1),S(`span`,ur,n(v(H)(e.snr)),1)]),S(`div`,dr,[i[42]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`Adverts`,-1),S(`span`,fr,n(e.advert_count),1)]),S(`div`,pr,[i[43]||=S(`div`,{class:`text-content-muted text-xs mb-1`},`First Seen`,-1),S(`span`,{class:`text-content-primary dark:text-content-primary text-sm`,title:v(B)(e.first_seen)},n(T(e.first_seen)),9,mr)])])])],8,Vn))),128))])]))}}),gr={class:`space-y-6`},_r={key:0,class:`flex items-center justify-center py-12`},vr={class:`text-center`},yr={key:1,class:`bg-red-50 dark:bg-accent-red/10 border border-red-300 dark:border-accent-red/20 rounded-[15px] p-6`},br={class:`flex items-center gap-3`},xr={class:`text-red-500 dark:text-accent-red/80 text-sm`},Sr={key:0,class:``},Cr={class:`flex items-center justify-between`},wr={class:`flex items-center gap-3`},Tr={class:`hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 mb p-1`},Er={class:`flex items-center gap-2`},Dr=[`value`,`disabled`],Or=[`value`],kr={class:`flex items-center gap-2`},Ar={key:0,class:`ml-1 bg-accent-cyan/20 text-accent-cyan border border-accent-cyan/30 text-xs px-1.5 py-0.5 rounded-full font-medium`},jr={class:`bg-background dark:bg-background/30 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mt-4 space-y-4`},Mr={class:`grid grid-cols-1 md:grid-cols-3 gap-4`},Nr={key:1,class:`text-center py-12`},Pr={key:2,class:`text-center py-12`},Fr=f({name:`NeighborsView`,__name:`Neighbors`,setup(e){let t=j(),r=N(),o=P(),s=M,u={0:`#6b7280`,1:`#60a5fa`,2:`#34d399`,3:`#a855f7`,4:`#f59e0b`},f=y(()=>r.advertsByType),p=y(()=>r.isLoading),v=l(null),O=l(r.currentHours),k=[{label:`2 Days`,value:48},{label:`7 Days`,value:168},{label:`14 Days`,value:336},{label:`30 Days`,value:720}],F=async e=>{O.value=e,await r.fetchAll(e)},L=l(G(`neighbors_compactView`,!1)),R=l(G(`neighbors_showMapLegend`,typeof window<`u`?window.innerWidth>=1024:!0)),z=l(G(`neighbors_showAllMapContacts`,!1)),B=l(G(`neighbors_showFilters`,!1)),V=l(G(`neighbors_filters`,{zeroHop:`true`,routeType:`all`,searchText:``}));a(L,e=>W(`neighbors_compactView`,e)),a(R,e=>W(`neighbors_showMapLegend`,e)),a(z,e=>W(`neighbors_showAllMapContacts`,e)),a(B,e=>W(`neighbors_showFilters`,e)),a(V,e=>W(`neighbors_filters`,e),{deep:!0});let ee=l(!1),H=l(!1),U=l(!1),K=l(null),q=l(null),J=l(null),te=l(null),ne=l(!1),re=l(null),ie=y(()=>{if(!te.value)return null;let e=te.value;return{id:e.id,pubkey:e.pubkey,node_name:e.node_name,contact_type:e.contact_type,latitude:e.latitude,longitude:e.longitude,rssi:e.rssi,snr:e.snr,route_type:e.route_type,last_seen:e.last_seen,first_seen:e.first_seen,advert_count:e.advert_count,timestamp:e.timestamp,is_repeater:e.is_repeater,is_new_neighbor:e.is_new_neighbor,zero_hop:e.zero_hop}}),ae=y(()=>t.stats?.config?.repeater?.latitude),oe=y(()=>t.stats?.config?.repeater?.longitude),ce=y(()=>t.stats===null&&t.isLoading),le=e=>e.filter(e=>{if(V.value.zeroHop!==`all`){let t=e.zero_hop;if(V.value.zeroHop===`true`&&!t||V.value.zeroHop===`false`&&t)return!1}if(V.value.routeType!==`all`){let t=e.route_type;if(V.value.routeType===`direct`&&t!==2||V.value.routeType===`transport_direct`&&t!==3||V.value.routeType===`flood`&&t!==1||V.value.routeType===`transport_flood`&&t!==0)return!1}if(V.value.searchText){let t=V.value.searchText.toLowerCase(),n=e.node_name?.toLowerCase()||``,r=e.pubkey.toLowerCase();if(!n.includes(t)&&!r.includes(t))return!1}return!0}),ue=()=>{V.value={zeroHop:`all`,routeType:`all`,searchText:``}},Y=y(()=>V.value.zeroHop!==`all`||V.value.routeType!==`all`||V.value.searchText!==``),de=y(()=>{let e={};for(let[t,n]of Object.entries(f.value))e[t]=le(n);return e}),fe=y(()=>Object.entries(s).filter(([e])=>de.value[e]?.length>0).sort(([e],[t])=>parseInt(e)-parseInt(t))),pe=y(()=>Object.values(f.value).flat().filter(e=>{let t=e.latitude,n=e.longitude;return t!=null&&t!==0&&n!=null&&n!==0&&typeof t==`number`&&typeof n==`number`&&!isNaN(t)&&!isNaN(n)&&(z.value||e.zero_hop===!0)})),me=()=>r.fetchAll(O.value),he=l(),ge=e=>{he.value?.highlightNode(e)},_e=e=>{he.value?.unhighlightNode(e)},ve=async e=>{let n=e;K.value=null,q.value=null,U.value=!0,J.value=n.node_name||`Unknown Node`,H.value=!0;try{let e=t.stats?.config?.mesh?.path_hash_mode??0,r=(e===2?3:e===1?2:1)*2,i=`0x${parseInt(n.pubkey.substring(0,r),16).toString(16).padStart(r,`0`)}`,a=await A.pingNeighbor(i,10);a.success&&a.data?K.value=a.data:(q.value=a.error||`Unknown error occurred`,console.error(`Failed to ping neighbor:`,a.error))}catch(e){console.error(`Error pinging neighbor:`,e),q.value=e instanceof Error?e.message:`Unknown error occurred`}finally{U.value=!1}},ye=()=>{H.value=!1,K.value=null,q.value=null,J.value=null},be=e=>{te.value=e,ee.value=!0},xe=e=>{re.value=e,ne.value=!0},Se=()=>{ne.value=!1,re.value=null},Ce=()=>{ee.value=!1,te.value=null},we=async e=>{try{await A.deleteAdvert(e),await r.fetchAll(O.value),Ce()}catch(e){console.error(`Error deleting neighbor:`,e)}};return i(()=>{o.ensure(`neighbors`)}),(e,t)=>(h(),C(`div`,gr,[p.value?(h(),C(`div`,_r,[S(`div`,vr,[_(I,{size:`lg`,class:`mx-auto mb-4`}),t[9]||=S(`p`,{class:`text-content-secondary dark:text-content-muted`},`Loading neighbor data...`,-1)])])):v.value?(h(),C(`div`,yr,[S(`div`,br,[t[11]||=S(`svg`,{class:`w-5 h-5 text-red-600 dark:text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})],-1),S(`div`,null,[t[10]||=S(`h3`,{class:`text-red-600 dark:text-accent-red font-medium`},`Error Loading Neighbors`,-1),S(`p`,xr,n(v.value),1)])])])):(h(),C(x,{key:2},[_(nn,{ref_key:`networkMapRef`,ref:he,adverts:pe.value,"base-latitude":ae.value,"base-longitude":oe.value,"stats-loading":ce.value,"show-legend":R.value,"onUpdate:showLegend":t[0]||=e=>R.value=e},null,8,[`adverts`,`base-latitude`,`base-longitude`,`stats-loading`,`show-legend`]),Object.keys(f.value).length>0?(h(),C(`div`,Sr,[S(`div`,Cr,[t[16]||=S(`span`,{class:`text-content-primary dark:text-content-primary text-lg font-semibold`},null,-1),S(`div`,wr,[S(`div`,Tr,[S(`button`,{onClick:t[1]||=e=>L.value=!1,class:w([`p-2 rounded-md transition-colors`,L.value?`text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10`:`bg-primary/20 text-primary border border-primary/30`]),title:`Comfortable view`},[...t[12]||=[S(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`rect`,{x:`3`,y:`3`,width:`18`,height:`6`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),S(`rect`,{x:`3`,y:`12`,width:`18`,height:`6`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],2),S(`button`,{onClick:t[2]||=e=>L.value=!0,class:w([`p-2 rounded-md transition-colors`,L.value?`bg-primary/20 text-primary border border-primary/30`:`text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10`]),title:`Compact view`},[...t[13]||=[S(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[S(`rect`,{x:`3`,y:`3`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),S(`rect`,{x:`3`,y:`10`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),S(`rect`,{x:`3`,y:`17`,width:`18`,height:`4`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`})],-1)]],2)]),S(`div`,Er,[S(`select`,{value:O.value,onChange:t[3]||=e=>F(+e.target.value),disabled:p.value,class:`text-xs px-2 py-1.5 rounded-lg bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border border-stroke-subtle dark:border-stroke/20 focus:outline-none focus:border-primary/50 disabled:opacity-50`},[(h(),C(x,null,m(k,e=>S(`option`,{key:e.value,value:e.value},n(e.label),9,Or)),64))],40,Dr)]),S(`div`,kr,[S(`button`,{onClick:t[4]||=e=>z.value=!z.value,class:w([`px-3 py-1.5 text-xs rounded-lg transition-colors border`,z.value?`bg-primary/20 text-primary border-primary/30`:`bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20`])},` Map: `+n(z.value?`All Contacts`:`Zero Hop`),3),S(`button`,{onClick:t[5]||=e=>B.value=!B.value,class:w([`px-3 py-1.5 text-xs rounded-lg transition-colors border`,Y.value?`bg-primary/20 text-primary border-primary/30`:`bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20`])},[t[14]||=S(`svg`,{class:`w-4 h-4 inline mr-1`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[S(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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.707v6.586a1 1 0 01-1.447.894l-4-2A1 1 0 717 18.586V13.414a1 1 0 00-.293-.707L.293 6.293A1 1 0 010 5.586V3a1 1 0 011-1z`})],-1),t[15]||=b(` Filters `,-1),Y.value?(h(),C(`span`,Ar,` Active `)):g(``,!0)],2),Y.value?(h(),C(`button`,{key:0,onClick:ue,class:`px-3 py-1.5 text-xs rounded-lg bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20 transition-colors`},` Clear Filters `)):g(``,!0)])])]),c(S(`div`,jr,[S(`div`,Mr,[S(`div`,null,[t[18]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Zero Hop`,-1),c(S(`select`,{"onUpdate:modelValue":t[6]||=e=>V.value.zeroHop=e,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none`},[...t[17]||=[S(`option`,{value:`all`},`All Nodes`,-1),S(`option`,{value:`true`},`Zero Hop Only`,-1),S(`option`,{value:`false`},`Multi-Hop Only`,-1)]],512),[[E,V.value.zeroHop]])]),S(`div`,null,[t[20]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Route Type`,-1),c(S(`select`,{"onUpdate:modelValue":t[7]||=e=>V.value.routeType=e,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none`},[...t[19]||=[d(``,5)]],512),[[E,V.value.routeType]])]),S(`div`,null,[t[21]||=S(`label`,{class:`block text-xs font-medium text-content-secondary dark:text-content-muted mb-1`},`Search`,-1),c(S(`input`,{"onUpdate:modelValue":t[8]||=e=>V.value.searchText=e,type:`text`,placeholder:`Node name or pubkey...`,class:`w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none placeholder-gray-400 dark:placeholder-white/40`},null,512),[[D,V.value.searchText]])])])],512),[[T,B.value]])])):g(``,!0),(h(!0),C(x,null,m(fe.value,([e,t])=>(h(),C(`div`,{key:e,class:`space-y-6`},[_(hr,{"contact-type":t,"contact-type-key":e,adverts:de.value[e],"original-count":f.value[e]?.length||0,color:u[parseInt(e)],"base-latitude":ae.value,"base-longitude":oe.value,"is-compact-view":L.value,"is-first-table":!1,"show-view-toggle":!1,onHighlightNode:ge,onUnhighlightNode:_e,onMenuPing:ve,onMenuDelete:be,onShowDetails:xe},null,8,[`contact-type`,`contact-type-key`,`adverts`,`original-count`,`color`,`base-latitude`,`base-longitude`,`is-compact-view`])]))),128)),fe.value.length===0&&Object.keys(f.value).length===0?(h(),C(`div`,Nr,[t[22]||=d(`

No Neighbors Found

No mesh neighbors have been discovered in your area yet.

`,3),S(`button`,{onClick:me,class:`mt-4 px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors`},` Refresh `)])):fe.value.length===0&&Y.value?(h(),C(`div`,Pr,[t[23]||=d(`

No neighbors match your filters

Try adjusting your filter criteria to see more results.

`,3),S(`button`,{onClick:ue,class:`px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors`},` Clear Filters `)])):g(``,!0)],64)),_(se,{show:ee.value,neighbor:ie.value,onClose:Ce,onDelete:we},null,8,[`show`,`neighbor`]),_(Be,{show:H.value,"node-name":J.value,result:K.value,error:q.value,loading:U.value,onClose:ye},null,8,[`show`,`node-name`,`result`,`error`,`loading`]),_(Dt,{"is-open":ne.value,neighbor:re.value,"base-latitude":ae.value,"base-longitude":oe.value,onClose:Se},null,8,[`is-open`,`neighbor`,`base-latitude`,`base-longitude`])]))}});export{Fr as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/RFNoiseFloor-DUdjGsyD.js b/repeater/web/html/assets/RFNoiseFloor-DUdjGsyD.js new file mode 100644 index 00000000..6c106f7e --- /dev/null +++ b/repeater/web/html/assets/RFNoiseFloor-DUdjGsyD.js @@ -0,0 +1 @@ +import{o as e}from"./index-DTUpsCzx.js";export{e as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/RFNoiseFloor-DhLKjd9G.js b/repeater/web/html/assets/RFNoiseFloor-DhLKjd9G.js deleted file mode 100644 index fe69da09..00000000 --- a/repeater/web/html/assets/RFNoiseFloor-DhLKjd9G.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./index-BFltqMtv.js";export{e as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/RoomServers-Cngso7KV.js b/repeater/web/html/assets/RoomServers-Cngso7KV.js deleted file mode 100644 index 4dc1f86c..00000000 --- a/repeater/web/html/assets/RoomServers-Cngso7KV.js +++ /dev/null @@ -1 +0,0 @@ -import{E as e,S as t,dt as n,f as r,g as i,j as a,k as ee,l as o,m as s,p as c,pt as l,r as u,s as d,u as f,w as p,z as m}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as h}from"./api-CbM6k1ZB.js";import{f as g,h as _,m as v}from"./index-BFltqMtv.js";import{t as te}from"./ConfirmDialog-PLW-eI8u.js";import{t as ne}from"./MessageDialog-CEzYMZ-3.js";import{n as re,t as ie}from"./preferences-Bv8i60GL.js";var ae={class:`p-6 space-y-6`},oe={class:`relative overflow-hidden rounded-[20px] p-6 mb-6 glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10`},se={class:`relative flex items-center justify-between`},ce={key:0,class:`grid grid-cols-1 md:grid-cols-3 gap-4`},le={class:`group relative overflow-hidden glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5 hover:scale-[1.02] transition-all duration-300 cursor-pointer`},ue={class:`relative flex items-center justify-between`},de={class:`text-3xl font-bold text-content-primary dark:text-content-primary mb-1`},fe={class:`group relative overflow-hidden glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5 hover:scale-[1.02] transition-all duration-300 cursor-pointer`},pe={class:`relative flex items-center justify-between`},me={class:`text-3xl font-bold text-primary mb-1`},he={class:`group relative overflow-hidden glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5 hover:scale-[1.02] transition-all duration-300 cursor-pointer`},ge={class:`relative flex items-center justify-between`},_e={key:0,class:`w-6 h-6 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ve={key:1,class:`w-6 h-6 text-accent-yellow`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ye={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},be={key:0,class:`flex items-center justify-center py-12`},xe={key:1,class:`flex items-center justify-center py-12`},Se={class:`text-center`},Ce={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},we={key:2,class:`space-y-4`},Te={class:`relative flex items-start justify-between`},Ee={class:`flex-1`},De={class:`flex items-center gap-3 mb-4`},Oe={class:`relative`},ke={key:0,class:`absolute inset-0 bg-accent-green/50 rounded-full animate-ping`},Ae={class:`text-xl font-bold text-content-primary dark:text-content-primary group-hover:text-primary transition-colors`},je={key:0,class:`text-content-muted dark:text-content-muted text-sm`},Me={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3`},Ne={class:`text-content-primary dark:text-content-primary/90 ml-2`},Pe={class:`flex items-center gap-2`},y={key:0,class:`text-content-primary dark:text-content-primary/90 font-mono ml-2 text-xs`},Fe={key:1,class:`text-content-muted dark:text-content-muted ml-2 text-xs`},Ie=[`onClick`],Le={class:`text-content-primary dark:text-content-primary/90 ml-2`},Re={key:0},ze={class:`text-content-primary dark:text-content-primary/90 ml-2`},Be={key:0,class:`text-accent-green`},Ve={key:1,class:`text-content-muted dark:text-content-muted`},He={key:2,class:`text-primary`},Ue={key:0,class:`text-xs text-content-muted dark:text-content-muted font-mono`},We={class:`ml-4 flex flex-wrap gap-2`},Ge=[`onClick`,`disabled`,`title`],Ke=[`onClick`,`disabled`,`title`],qe=[`onClick`],Je=[`onClick`],Ye={key:3,class:`text-center py-12 text-content-secondary dark:text-content-muted`},Xe={key:1,class:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`},Ze={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},Qe={class:`space-y-4`},$e={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},et={key:0},tt={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},nt={class:`grid grid-cols-2 gap-4`},rt={class:`grid grid-cols-2 gap-4`},it={key:2,class:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`},at={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto`},ot={class:`space-y-4`},st=[`value`],ct={class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},lt={key:0},ut={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},dt={class:`grid grid-cols-2 gap-4`},ft={class:`grid grid-cols-2 gap-4`},pt={key:0,class:`fixed inset-0 bg-black/70 backdrop-blur-md flex items-center justify-center z-50 p-4`},mt={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[20px] p-6 max-w-4xl w-full h-[85vh] flex flex-col shadow-2xl`},ht={class:`relative overflow-hidden rounded-[15px] mb-6 p-5 bg-white/50 dark:bg-white/5 border border-stroke-subtle dark:border-white/10`},gt={class:`relative flex items-center justify-between`},_t={class:`flex items-center gap-4`},vt={class:`text-content-secondary dark:text-content-muted text-sm flex items-center gap-2`},yt={class:`text-primary font-semibold`},bt={class:`flex items-center gap-2`},xt={class:`bg-primary/30 px-1.5 py-0.5 rounded-full text-[10px]`},St={class:`flex-1 overflow-y-auto mb-4 space-y-3`},Ct={key:0,class:`flex items-center justify-center py-12`},wt={key:1,class:`flex items-center justify-center py-12`},Tt={class:`text-center`},Et={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},Dt={key:2,class:`space-y-3`},Ot={class:`relative flex items-start justify-between gap-3`},kt={class:`flex-1 min-w-0`},At={class:`flex items-center gap-2 mb-3`},jt={class:`flex items-center gap-2 flex-wrap`},Mt={key:0,class:`text-primary text-sm font-bold`},Nt={key:1,class:`text-primary/80 text-xs font-mono bg-primary/10 px-2 py-1 rounded-md border border-primary/20`},Pt={key:2,class:`text-content-muted dark:text-content-muted text-xs`},Ft={class:`text-content-secondary dark:text-content-muted text-xs flex items-center gap-1`},It={key:3,class:`text-content-muted dark:text-content-muted/50 text-[10px] font-mono bg-background-mute dark:bg-white/5 px-1.5 py-0.5 rounded`},Lt={class:`text-content-primary dark:text-content-primary/90 text-sm leading-relaxed break-words whitespace-pre-wrap bg-gray-50 dark:bg-white/5 p-3 rounded-[10px] border border-stroke-subtle dark:border-white/5`},Rt=[`onClick`],zt={key:0,class:`text-center pt-4`},Bt={key:1,class:`text-center pt-4`},Vt={key:3,class:`flex items-center justify-center h-full`},Ht={class:`relative overflow-hidden rounded-[15px] border-t border-stroke-subtle dark:border-white/20 pt-4 mt-4`},Ut={class:`relative space-y-3`},Wt={class:`flex gap-3`},Gt={class:`flex-1 relative`},Kt=[`onKeydown`],qt=[`disabled`],Jt={key:1,class:`fixed inset-0 bg-black/70 backdrop-blur-md flex items-center justify-center z-[60] p-4`},Yt={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-3xl w-full max-h-[80vh] flex flex-col`},Xt={class:`flex items-center justify-between mb-4 pb-4 border-b border-stroke-subtle dark:border-white/10`},Zt={class:`text-content-secondary dark:text-content-primary/70 text-sm mt-1`},Qt={class:`text-primary`},b={class:`flex-1 overflow-y-auto space-y-3`},$t={key:0,class:`text-center py-12`},en={class:`space-y-2`},tn={class:`flex items-center justify-between`},nn={class:`flex items-center gap-2`},rn={class:`text-content-primary dark:text-content-primary font-semibold`},an={class:`flex items-center gap-2`},on={class:`text-content-secondary dark:text-content-muted text-xs`},sn=[`onClick`],cn={class:`space-y-1 text-xs`},ln={class:`flex items-center gap-2`},un={class:`text-primary font-mono bg-primary/10 px-2 py-0.5 rounded`},dn={class:`flex items-center gap-2`},fn={class:`text-primary font-mono bg-primary/10 px-2 py-0.5 rounded text-[10px] break-all`},pn={class:`flex items-center justify-between text-xs text-content-secondary dark:text-content-muted`},mn={class:`flex items-center gap-4`},hn={key:0},gn={key:1},_n={key:0},x=i({name:`RoomServersView`,__name:`RoomServers`,setup(i){let x=m(!1),S=m(null),C=m(null),w=m(!1),T=m(!1),E=m(null),D=m(!1),O=m(!1),k=m(new Set),A=m(!1),j=m(``),M=m(!1),N=m({message:``,variant:`success`}),P=m(!1),F=m(``),I=m(``),L=m([]),R=m(!1),z=m(null),B=m(``),V=m(ie(`roomServers_messagesLimit`,50)),H=m(0),U=m(!0);ee(V,e=>re(`roomServers_messagesLimit`,e));let W=m([]),G=m(!1),K=m({name:``,identity_key:``,type:`room_server`,settings:{node_name:``,latitude:0,longitude:0,admin_password:``,guest_password:``}});t(async()=>{await q()});async function q(){x.value=!0,S.value=null;try{let e=await h.getIdentities();e.success?C.value=e.data:S.value=e.error||`Failed to load identities`}catch(e){S.value=e instanceof Error?e.message:`Failed to load identities`}finally{x.value=!1}}async function vn(){try{let e=await h.createIdentity(K.value);e.success?(w.value=!1,Y(),await q(),J(e.message||`Identity created successfully!`,`success`)):J(`Failed to create identity: ${e.error}`,`error`)}catch(e){J(`Error creating identity: ${e}`,`error`)}}async function yn(){try{let e=await h.updateIdentity(E.value);e.success?(T.value=!1,E.value=null,await q(),J(e.message||`Identity updated successfully!`,`success`)):J(`Failed to update identity: ${e.error}`,`error`)}catch(e){J(`Error updating identity: ${e}`,`error`)}}function bn(e){j.value=e,A.value=!0}async function xn(){let e=j.value;A.value=!1;try{let t=await h.deleteIdentity(e);t.success?(await q(),J(t.message||`Identity deleted successfully!`,`success`)):J(`Failed to delete identity: ${t.error}`,`error`)}catch(e){J(`Error deleting identity: ${e}`,`error`)}finally{j.value=``}}function J(e,t){N.value={message:e,variant:t},M.value=!0}async function Sn(e){try{let t=await h.sendRoomServerAdvert(e);t.success?J(t.message||`Advert sent for '${e}'!`,`success`):J(`Failed to send advert: ${t.error}`,`error`)}catch(e){J(`Error sending advert: ${e}`,`error`)}}function Cn(e){E.value=JSON.parse(JSON.stringify(e)),E.value.settings||(E.value.settings={}),E.value.settings.admin_password||(E.value.settings.admin_password=``),E.value.settings.guest_password||(E.value.settings.guest_password=``),O.value=!1,T.value=!0}function Y(){K.value={name:``,identity_key:``,type:`room_server`,settings:{node_name:``,latitude:0,longitude:0,admin_password:``,guest_password:``}},D.value=!1}function X(){w.value=!1,T.value=!1,E.value=null,D.value=!1,O.value=!1,Y()}function wn(e){k.value.has(e)?k.value.delete(e):k.value.add(e)}async function Tn(e){F.value=e,P.value=!0,H.value=0,U.value=!0,I.value=C.value?.configured.find(t=>t.name===e)?.hash||``,await Z(),await Q(!0)}async function Z(){try{let e=await h.getACLClients({identity_hash:I.value,identity_name:F.value});e.success&&e.data&&(W.value=e.data.clients||[])}catch(e){console.error(`Failed to fetch ACL clients:`,e)}}async function Q(e=!1){e&&(H.value=0,L.value=[]),R.value=!0,z.value=null;try{let t=await h.getRoomMessages({room_name:F.value,limit:V.value,offset:H.value});if(t.success&&t.data){let n=t.data.messages||[];e?L.value=n:L.value=[...L.value,...n],U.value=n.length===V.value}else z.value=t.error||`Failed to load messages`}catch(e){z.value=e instanceof Error?e.message:`Failed to load messages`}finally{R.value=!1}}async function En(){H.value+=V.value,await Q(!1)}async function $(){if(B.value.trim())try{let e=await h.postRoomMessage({room_name:F.value,message:B.value,author_pubkey:`server`});e.success?(B.value=``,await Q(!0)):J(`Failed to send message: ${e.error}`,`error`)}catch(e){J(`Error sending message: ${e}`,`error`)}}async function Dn(e){if(confirm(`Are you sure you want to delete this message?`))try{let t=await h.deleteRoomMessage({room_name:F.value,message_id:e});t.success?(await Q(!0),J(`Message deleted successfully`,`success`)):J(`Failed to delete message: ${t.error}`,`error`)}catch(e){J(`Error deleting message: ${e}`,`error`)}}function On(){P.value=!1,F.value=``,I.value=``,L.value=[],B.value=``,z.value=null,W.value=[]}function kn(e){return e?new Date(e*1e3).toLocaleString():`Unknown`}async function An(e,t){if(confirm(`Are you sure you want to remove this client from the ACL?`))try{let n=await h.removeACLClient({public_key:e,identity_hash:t});n.success?(await Z(),J(`Client removed successfully`,`success`)):J(`Failed to remove client: ${n.error}`,`error`)}catch(e){J(`Error removing client: ${e}`,`error`)}}return(t,i)=>(p(),f(u,null,[d(`div`,ae,[d(`div`,oe,[i[26]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/20 via-secondary/10 to-accent-purple/20 opacity-50`},null,-1),i[27]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-tl from-accent-green/10 via-transparent to-primary/10 animate-pulse`},null,-1),d(`div`,se,[i[25]||=r(`

Room Servers

Manage room server identities and messages

`,1),d(`button`,{onClick:i[0]||=e=>w.value=!0,class:`group relative px-6 py-3 bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary rounded-[12px] border border-primary/50 transition-all hover:scale-105 hover:shadow-lg hover:shadow-primary/20`},[...i[24]||=[d(`span`,{class:`flex items-center gap-2`},[d(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})]),c(` Add Room Server `)],-1)]])])]),C.value&&C.value.total_configured>0?(p(),f(`div`,ce,[d(`div`,le,[i[30]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-br from-white/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),d(`div`,ue,[d(`div`,null,[i[28]||=d(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Total Configured `,-1),d(`div`,de,l(C.value.total_configured),1)]),i[29]||=d(`div`,{class:`bg-background-mute dark:bg-white/10 p-3 rounded-[12px] group-hover:bg-background-mute dark:group-hover:bg-stroke/20 transition-colors`},[d(`svg`,{class:`w-6 h-6 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10`})])],-1)])]),d(`div`,fe,[i[33]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),d(`div`,pe,[d(`div`,null,[i[31]||=d(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Currently Registered `,-1),d(`div`,me,l(C.value.total_registered),1)]),i[32]||=d(`div`,{class:`bg-primary/20 p-3 rounded-[12px] group-hover:bg-primary/30 transition-colors`},[d(`svg`,{class:`w-6 h-6 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})])],-1)])]),d(`div`,he,[i[37]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-br from-accent-green/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),d(`div`,ge,[d(`div`,null,[i[34]||=d(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Status `,-1),d(`div`,{class:n([`text-3xl font-bold`,C.value.total_registered===C.value.total_configured?`text-accent-green`:`text-accent-yellow`])},l(C.value.total_registered===C.value.total_configured?`Synced`:`Out of Sync`),3)]),d(`div`,{class:n([`p-3 rounded-[12px] transition-colors`,C.value.total_registered===C.value.total_configured?`bg-accent-green/20 group-hover:bg-accent-green/30`:`bg-accent-yellow/20 group-hover:bg-accent-yellow/30`])},[C.value.total_registered===C.value.total_configured?(p(),f(`svg`,_e,[...i[35]||=[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(p(),f(`svg`,ve,[...i[36]||=[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2)])])])):o(``,!0),d(`div`,ye,[x.value?(p(),f(`div`,be,[...i[38]||=[d(`div`,{class:`text-center`},[d(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full mx-auto mb-4`}),d(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading room servers... `)],-1)]])):S.value?(p(),f(`div`,xe,[d(`div`,Se,[i[39]||=d(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load room servers`,-1),d(`div`,Ce,l(S.value),1),d(`button`,{onClick:q,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Retry `)])])):C.value&&C.value.configured.length>0?(p(),f(`div`,we,[(p(!0),f(u,null,e(C.value.configured,e=>(p(),f(`div`,{key:e.name,class:`group relative overflow-hidden glass-card backdrop-blur-xl rounded-[15px] p-5 border border-stroke-subtle dark:border-white/10 hover:border-primary/30 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300`},[i[46]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-r from-primary/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),d(`div`,Te,[d(`div`,Ee,[d(`div`,De,[d(`div`,Oe,[e.registered?(p(),f(`div`,ke)):o(``,!0),d(`div`,{class:n([`relative w-3 h-3 rounded-full`,e.registered?`bg-accent-green`:`bg-accent-red`])},null,2)]),d(`h3`,Ae,l(e.name),1),d(`span`,{class:n([`px-3 py-1 text-xs font-semibold rounded-full`,e.registered?`bg-accent-green/20 text-accent-green border border-accent-green/30`:`bg-accent-red/20 text-accent-red border border-accent-red/30`])},l(e.registered?`● Active`:`○ Inactive`),3),e.hash?(p(),f(`span`,je,l(e.hash),1)):o(``,!0)]),d(`div`,Me,[d(`div`,null,[i[40]||=d(`span`,{class:`text-content-muted dark:text-content-muted`},`Node Name:`,-1),d(`span`,Ne,l(e.settings?.node_name||`Not set`),1)]),d(`div`,Pe,[i[41]||=d(`span`,{class:`text-content-muted dark:text-content-muted`},`Identity Key:`,-1),k.value.has(e.name)?(p(),f(`span`,y,l(e.identity_key),1)):(p(),f(`span`,Fe,` •••••••••••••••• `)),d(`button`,{onClick:t=>wn(e.name),class:`text-primary/70 hover:text-primary text-xs underline`},l(k.value.has(e.name)?`Hide`:`Show`),9,Ie)]),d(`div`,null,[i[42]||=d(`span`,{class:`text-content-muted dark:text-content-muted`},`Location:`,-1),d(`span`,Le,l(e.settings?.latitude||0)+`, `+l(e.settings?.longitude||0),1)]),e.settings?.admin_password||e.settings?.guest_password?(p(),f(`div`,Re,[i[43]||=d(`span`,{class:`text-content-muted dark:text-content-muted`},`Passwords:`,-1),d(`span`,ze,[e.settings?.admin_password?(p(),f(`span`,Be,`Admin`)):o(``,!0),e.settings?.admin_password&&e.settings?.guest_password?(p(),f(`span`,Ve,` / `)):o(``,!0),e.settings?.guest_password?(p(),f(`span`,He,`Guest`)):o(``,!0)])])):o(``,!0)]),e.address?(p(),f(`div`,Ue,` Address: `+l(e.address),1)):o(``,!0)]),d(`div`,We,[d(`button`,{onClick:t=>Tn(e.name),disabled:!e.registered,class:n([`group px-4 py-2 rounded-[10px] text-xs font-medium transition-all duration-200 flex items-center gap-2`,e.registered?`bg-secondary/20 hover:bg-secondary/30 text-secondary border border-secondary/30 hover:scale-105 hover:shadow-lg hover:shadow-secondary/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`]),title:e.registered?`Manage messages for this room`:`Room server must be active to manage messages`},[...i[44]||=[d(`svg`,{class:`w-4 h-4 group-hover:rotate-12 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z`})],-1),c(` Messages `,-1)]],10,Ge),d(`button`,{onClick:t=>Sn(e.name),disabled:!e.registered,class:n([`group px-4 py-2 rounded-[10px] text-xs font-medium transition-all duration-200 flex items-center gap-2`,e.registered?`bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/30 hover:scale-105 hover:shadow-lg hover:shadow-accent-green/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`]),title:e.registered?`Send advert for this room server`:`Room server must be active to send advert`},[...i[45]||=[d(`svg`,{class:`w-4 h-4 group-hover:scale-110 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 10V3L4 14h7v7l9-11h-7z`})],-1),c(` Send Advert `,-1)]],10,Ke),d(`button`,{onClick:t=>Cn(e),class:`px-3 py-1 bg-primary/20 hover:bg-primary/30 text-primary rounded text-xs transition-colors`},` Edit `,8,qe),d(`button`,{onClick:t=>bn(e.name),class:`px-3 py-1 bg-accent-red/20 hover:bg-accent-red/30 text-accent-red rounded text-xs transition-colors`},` Delete `,8,Je)])])]))),128))])):(p(),f(`div`,Ye,[i[47]||=d(`svg`,{class:`w-16 h-16 mx-auto mb-4 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4`})],-1),i[48]||=d(`p`,{class:`text-lg mb-2`},`No room servers configured`,-1),i[49]||=d(`p`,{class:`text-sm mb-4`},`Add your first room server to get started`,-1),d(`button`,{onClick:i[1]||=e=>w.value=!0,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` + Add Room Server `)]))]),w.value?(p(),f(`div`,Xe,[d(`div`,Ze,[i[60]||=d(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Add Room Server `,-1),d(`div`,Qe,[d(`div`,null,[i[50]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Name *`,-1),a(d(`input`,{"onUpdate:modelValue":i[2]||=e=>K.value.name=e,type:`text`,placeholder:`e.g., MainBBS`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.name]])]),d(`div`,null,[d(`label`,$e,[i[51]||=c(` Identity Key (Optional) `,-1),d(`button`,{onClick:i[3]||=e=>D.value=!D.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},l(D.value?`Hide`:`Show/Edit`),1)]),D.value?(p(),f(`div`,et,[a(d(`input`,{"onUpdate:modelValue":i[4]||=e=>K.value.identity_key=e,type:`text`,placeholder:`Leave empty to auto-generate`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.identity_key]]),i[52]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Leave empty to automatically generate a secure key `,-1)])):(p(),f(`div`,tt,` Will be auto-generated if not provided `))]),d(`div`,null,[i[53]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),a(d(`input`,{"onUpdate:modelValue":i[5]||=e=>K.value.settings.node_name=e,type:`text`,placeholder:`Display name for the room server`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.settings.node_name]])]),d(`div`,nt,[d(`div`,null,[i[54]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Latitude`,-1),a(d(`input`,{"onUpdate:modelValue":i[6]||=e=>K.value.settings.latitude=e,type:`number`,step:`0.000001`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.settings.latitude,void 0,{number:!0}]])]),d(`div`,null,[i[55]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Longitude`,-1),a(d(`input`,{"onUpdate:modelValue":i[7]||=e=>K.value.settings.longitude=e,type:`number`,step:`0.000001`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.settings.longitude,void 0,{number:!0}]])])]),d(`div`,rt,[d(`div`,null,[i[56]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Admin Password (Optional)`,-1),a(d(`input`,{"onUpdate:modelValue":i[8]||=e=>K.value.settings.admin_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.settings.admin_password]]),i[57]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Full access to room server `,-1)]),d(`div`,null,[i[58]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Guest Password (Optional)`,-1),a(d(`input`,{"onUpdate:modelValue":i[9]||=e=>K.value.settings.guest_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,K.value.settings.guest_password]]),i[59]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Read-only access `,-1)])])]),d(`div`,{class:`flex justify-end gap-3 mt-6`},[d(`button`,{onClick:X,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),d(`button`,{onClick:vn,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` Create `)])])])):o(``,!0),T.value&&E.value?(p(),f(`div`,it,[d(`div`,at,[i[72]||=d(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-4`},` Edit Room Server `,-1),d(`div`,ot,[d(`div`,null,[i[61]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Current Name`,-1),d(`input`,{value:E.value.name,disabled:``,type:`text`,class:`w-full bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-muted dark:text-content-muted cursor-not-allowed`},null,8,st)]),d(`div`,null,[i[62]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`New Name (optional)`,-1),a(d(`input`,{"onUpdate:modelValue":i[10]||=e=>E.value.new_name=e,type:`text`,placeholder:`Leave empty to keep current name`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.new_name]])]),d(`div`,null,[d(`label`,ct,[i[63]||=c(` Identity Key (Optional) `,-1),d(`button`,{onClick:i[11]||=e=>O.value=!O.value,type:`button`,class:`ml-2 text-primary/70 hover:text-primary text-xs underline`},l(O.value?`Hide`:`Show/Edit`),1)]),O.value?(p(),f(`div`,lt,[a(d(`input`,{"onUpdate:modelValue":i[12]||=e=>E.value.identity_key=e,type:`text`,placeholder:`Leave empty to keep current key`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary font-mono text-sm placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.identity_key]]),i[64]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Leave empty to keep the current identity key `,-1)])):(p(),f(`div`,ut,` Click "Show/Edit" to change the identity key `))]),d(`div`,null,[i[65]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Node Name`,-1),a(d(`input`,{"onUpdate:modelValue":i[13]||=e=>E.value.settings.node_name=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.settings.node_name]])]),d(`div`,dt,[d(`div`,null,[i[66]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Latitude`,-1),a(d(`input`,{"onUpdate:modelValue":i[14]||=e=>E.value.settings.latitude=e,type:`number`,step:`0.000001`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.settings.latitude,void 0,{number:!0}]])]),d(`div`,null,[i[67]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Longitude`,-1),a(d(`input`,{"onUpdate:modelValue":i[15]||=e=>E.value.settings.longitude=e,type:`number`,step:`0.000001`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.settings.longitude,void 0,{number:!0}]])])]),d(`div`,ft,[d(`div`,null,[i[68]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Admin Password`,-1),a(d(`input`,{"onUpdate:modelValue":i[16]||=e=>E.value.settings.admin_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.settings.admin_password]]),i[69]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Full access to room server `,-1)]),d(`div`,null,[i[70]||=d(`label`,{class:`block text-content-secondary dark:text-content-primary/70 text-sm mb-2`},`Guest Password`,-1),a(d(`input`,{"onUpdate:modelValue":i[17]||=e=>E.value.settings.guest_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:border-primary/50 transition-colors`},null,512),[[g,E.value.settings.guest_password]]),i[71]||=d(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Read-only access `,-1)])])]),d(`div`,{class:`flex justify-end gap-3 mt-6`},[d(`button`,{onClick:X,class:`px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg transition-colors`},` Cancel `),d(`button`,{onClick:yn,class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg border border-primary/50 transition-colors`},` Update `)])])])):o(``,!0)]),s(te,{show:A.value,title:`Delete Room Server`,message:`Are you sure you want to delete '${j.value}'? This action cannot be undone.`,"confirm-text":`Delete`,"cancel-text":`Cancel`,variant:`danger`,onClose:i[18]||=e=>A.value=!1,onConfirm:xn},null,8,[`show`,`message`]),s(ne,{show:M.value,message:N.value.message,variant:N.value.variant,onClose:i[19]||=e=>M.value=!1},null,8,[`show`,`message`,`variant`]),P.value?(p(),f(`div`,pt,[d(`div`,mt,[d(`div`,ht,[i[79]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-r from-secondary/20 via-primary/20 to-accent-purple/20`},null,-1),i[80]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-br from-transparent via-white/5 to-transparent`},null,-1),d(`div`,gt,[d(`div`,_t,[i[75]||=r(`
`,1),d(`div`,null,[i[74]||=d(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary mb-1`},` Room Messages `,-1),d(`p`,vt,[i[73]||=d(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z`})],-1),d(`span`,yt,l(F.value),1)])])]),d(`div`,bt,[d(`button`,{onClick:i[20]||=e=>G.value=!0,class:`group px-3 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-[10px] text-xs font-medium transition-all hover:scale-105 border border-primary/30 flex items-center gap-2`,title:`View active sessions`},[i[76]||=d(`svg`,{class:`w-4 h-4 group-hover:scale-110 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1),i[77]||=d(`span`,{class:`hidden sm:inline`},`Sessions`,-1),d(`span`,xt,l(W.value.length),1)]),d(`button`,{onClick:On,class:`p-2 text-content-secondary dark:text-content-primary/70 hover:text-content-primary dark:hover:text-content-primary hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-[10px] transition-all`},[...i[78]||=[d(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])])]),d(`div`,St,[R.value&&L.value.length===0?(p(),f(`div`,Ct,[...i[81]||=[d(`div`,{class:`text-center`},[d(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full mx-auto mb-4`}),d(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading messages... `)],-1)]])):z.value?(p(),f(`div`,wt,[d(`div`,Tt,[i[82]||=d(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load messages`,-1),d(`div`,Et,l(z.value),1),d(`button`,{onClick:i[21]||=e=>Q(!0),class:`px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors`},` Retry `)])])):L.value.length>0?(p(),f(`div`,Dt,[(p(!0),f(u,null,e(L.value,(e,t)=>(p(),f(`div`,{key:e.id||t,class:`group relative overflow-hidden glass-card backdrop-blur-xl rounded-[12px] p-4 border border-stroke-subtle dark:border-white/10 hover:border-secondary/30 transition-all duration-300 hover:shadow-lg hover:shadow-secondary/10`},[i[87]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-r from-secondary/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),d(`div`,Ot,[d(`div`,kt,[d(`div`,At,[d(`div`,jt,[i[84]||=d(`div`,{class:`w-6 h-6 rounded-full bg-gradient-to-br from-primary/30 to-secondary/30 flex items-center justify-center`},[d(`svg`,{class:`w-3 h-3 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`})])],-1),e.author_name?(p(),f(`span`,Mt,l(e.author_name),1)):o(``,!0),e.author_pubkey?(p(),f(`span`,Nt,l(e.author_pubkey.substring(0,8))+`... `,1)):(p(),f(`span`,Pt,` Anonymous `)),i[85]||=d(`span`,{class:`text-content-muted dark:text-content-muted/60 text-xs`},`•`,-1),d(`span`,Ft,[i[83]||=d(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),c(` `+l(kn(e.timestamp)),1)]),e.id?(p(),f(`span`,It,` #`+l(e.id),1)):o(``,!0)])]),d(`div`,Lt,l(e.message_text),1)]),d(`button`,{onClick:t=>Dn(e.id),class:`group/delete flex-shrink-0 p-2 bg-accent-red/10 hover:bg-accent-red/20 text-accent-red rounded-[8px] transition-all hover:scale-110 border border-accent-red/20`,title:`Delete this message`},[...i[86]||=[d(`svg`,{class:`w-4 h-4 group-hover/delete:rotate-12 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,Rt)])]))),128)),U.value&&!R.value?(p(),f(`div`,zt,[d(`button`,{onClick:En,class:`group px-6 py-2.5 bg-gradient-to-r from-gray-100 dark:from-white/5 to-gray-200 dark:to-white/10 hover:from-gray-200 dark:hover:from-white/10 hover:to-gray-300 dark:hover:to-white/15 text-content-primary dark:text-content-primary rounded-[10px] transition-all hover:scale-105 text-sm font-medium border border-stroke-subtle dark:border-stroke/10 flex items-center gap-2 mx-auto`},[...i[88]||=[d(`svg`,{class:`w-4 h-4 group-hover:translate-y-1 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),c(` Load More Messages `,-1)]])])):R.value?(p(),f(`div`,Bt,[...i[89]||=[d(`div`,{class:`flex items-center justify-center gap-2 text-content-secondary dark:text-content-muted text-sm`},[d(`div`,{class:`animate-spin w-4 h-4 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full`}),c(` Loading... `)],-1)]])):o(``,!0)])):(p(),f(`div`,Vt,[...i[90]||=[r(`

No messages yet

Be the first to start the conversation

`,1)]]))]),d(`div`,Ht,[i[93]||=d(`div`,{class:`absolute inset-0 bg-gradient-to-t from-primary/5 to-transparent pointer-events-none`},null,-1),d(`div`,Ut,[d(`div`,Wt,[d(`div`,Gt,[a(d(`textarea`,{"onUpdate:modelValue":i[22]||=e=>B.value=e,onKeydown:[v(_($,[`ctrl`]),[`enter`]),v(_($,[`meta`]),[`enter`])],placeholder:`Type your message... (Ctrl+Enter to send)`,rows:`3`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-3 text-content-primary dark:text-content-primary text-sm placeholder-gray-500 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 focus:bg-white dark:focus:bg-white/10 transition-all resize-none`},null,40,Kt),[[g,B.value]])]),d(`button`,{onClick:$,disabled:!B.value.trim(),class:n([`group px-6 py-3 rounded-[12px] transition-all duration-200 flex items-center justify-center gap-2 font-medium`,B.value.trim()?`bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary border border-primary/50 hover:scale-105 hover:shadow-lg hover:shadow-primary/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`])},[...i[91]||=[d(`svg`,{class:`w-5 h-5 group-hover:translate-x-1 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 19l9 2-9-18-9 18 9-2zm0 0v-8`})],-1),d(`span`,{class:`hidden sm:inline`},`Send`,-1)]],10,qt)]),i[92]||=d(`p`,{class:`text-content-secondary dark:text-content-muted/60 text-xs flex items-center gap-2`},[d(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})]),c(` Press Ctrl+Enter to send message quickly `)],-1)])])])])):o(``,!0),G.value?(p(),f(`div`,Jt,[d(`div`,Yt,[d(`div`,Xt,[d(`div`,null,[i[95]||=d(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary`},` Active Sessions `,-1),d(`p`,Zt,[i[94]||=c(` Room: `,-1),d(`span`,Qt,l(F.value),1)])]),d(`button`,{onClick:i[23]||=e=>G.value=!1,class:`text-content-secondary dark:text-content-primary/70 hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...i[96]||=[d(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),d(`div`,b,[W.value.length===0?(p(),f(`div`,$t,[...i[97]||=[d(`div`,{class:`text-content-secondary dark:text-content-muted`},`No active sessions found`,-1)]])):o(``,!0),(p(!0),f(u,null,e(W.value,(e,t)=>(p(),f(`div`,{key:e.public_key_full||t,class:`glass-card backdrop-blur-xl rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10`},[d(`div`,en,[d(`div`,tn,[d(`div`,nn,[d(`span`,rn,l(e.identity_name||`Unknown`),1),d(`span`,{class:n([`px-2 py-0.5 text-xs font-medium rounded`,e.permissions===`admin`?`bg-accent-green/20 text-accent-green`:`bg-secondary/20 text-secondary`])},l(e.permissions),3)]),d(`div`,an,[d(`span`,on,l(e.identity_type),1),d(`button`,{onClick:t=>An(e.public_key_full,e.identity_hash),class:`px-2 py-1 bg-accent-red/20 hover:bg-accent-red/30 text-accent-red rounded text-xs transition-colors`,title:`Remove client from ACL`},` Remove `,8,sn)])]),d(`div`,cn,[d(`div`,ln,[i[98]||=d(`span`,{class:`text-content-secondary dark:text-content-muted`},`Short Key:`,-1),d(`code`,un,l(e.public_key),1)]),d(`div`,dn,[i[99]||=d(`span`,{class:`text-content-secondary dark:text-content-muted`},`Full Key:`,-1),d(`code`,fn,l(e.public_key_full),1)])]),d(`div`,pn,[d(`div`,mn,[e.address?(p(),f(`span`,hn,`📍 `+l(e.address),1)):o(``,!0),e.last_login_success?(p(),f(`span`,gn,`Last Login: `+l(new Date(e.last_login_success*1e3).toLocaleString()),1)):o(``,!0)]),e.last_activity?(p(),f(`span`,_n,`Active: `+l(Math.floor((Date.now()/1e3-e.last_activity)/60))+`m ago`,1)):o(``,!0)])])]))),128))])])])):o(``,!0)],64))}});export{x as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/RoomServers-DBObY362.js b/repeater/web/html/assets/RoomServers-DBObY362.js new file mode 100644 index 00000000..34842fc2 --- /dev/null +++ b/repeater/web/html/assets/RoomServers-DBObY362.js @@ -0,0 +1 @@ +import{B as e,Ct as t,E as n,R as r,V as i,Y as a,c as o,f as ee,g as te,i as s,j as c,k as l,l as u,m as d,o as f,p,r as m,s as h,u as g,xt as _}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{l as ne,s as v,t as re,u as y}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as b}from"./api-3gMnsCKh.js";import{t as ie}from"./system-DbBvxitf.js";import{t as ae}from"./Spinner-CcYauG9D.js";import{n as oe}from"./index-DTUpsCzx.js";import{t as se}from"./ConfirmDialog-DBlDmP2I.js";import{t as ce}from"./MessageDialog-bhwyqS5K.js";import{t as le}from"./LocationPicker-KRjSN9TZ.js";import{n as ue,t as de}from"./preferences-CkCjR0CQ.js";var fe={class:`p-6 space-y-6`},pe={key:0,class:`grid grid-cols-1 md:grid-cols-3 gap-4`},me={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},he={class:`flex items-center justify-between`},ge={class:`text-3xl font-bold text-content-primary dark:text-content-primary mb-1`},_e={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},ve={class:`flex items-center justify-between`},ye={class:`text-3xl font-bold text-primary mb-1`},be={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-5`},xe={class:`flex items-center justify-between`},Se={key:0,class:`w-6 h-6 text-accent-green`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Ce={key:1,class:`w-6 h-6 text-accent-yellow`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},we={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6`},Te={key:0,class:`flex items-center justify-center py-12`},Ee={class:`text-center`},De={key:1,class:`flex items-center justify-center py-12`},Oe={class:`text-center`},ke={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},Ae={key:2,class:`space-y-4`},je={class:`flex items-start justify-between`},Me={class:`flex-1`},Ne={class:`flex items-center gap-3 mb-4`},Pe={class:`relative`},Fe={key:0,class:`absolute inset-0 bg-accent-green/50 rounded-full animate-ping`},Ie={class:`text-xl font-bold text-content-primary dark:text-content-primary`},Le={key:0,class:`text-content-muted dark:text-content-muted text-sm`},Re={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3`},ze={class:`text-content-primary dark:text-content-primary/90 ml-2`},Be={class:`flex items-center gap-2`},Ve={key:0,class:`text-content-primary dark:text-content-primary/90 font-mono ml-2 text-xs`},He={key:1,class:`text-content-muted dark:text-content-muted ml-2 text-xs`},Ue=[`onClick`],We={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ge={key:0},Ke={class:`text-content-primary dark:text-content-primary/90 ml-2`},qe={key:0,class:`text-accent-green`},Je={key:1,class:`text-content-muted dark:text-content-muted`},Ye={key:2,class:`text-primary`},Xe={key:0,class:`text-xs text-content-muted dark:text-content-muted font-mono`},Ze={class:`ml-4 flex flex-wrap gap-2`},Qe=[`onClick`,`disabled`,`title`],$e=[`onClick`,`disabled`,`title`],et=[`onClick`],tt=[`onClick`],nt={key:3,class:`text-center py-12 text-content-secondary dark:text-content-muted`},rt={class:`modal-card max-w-2xl w-full max-h-[90vh] overflow-y-auto`},it={class:`modal-field-label-row`},at={key:0},ot={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},st={class:`grid grid-cols-2 gap-5`},ct={class:`grid grid-cols-2 gap-5`},lt={class:`modal-card max-w-2xl w-full max-h-[90vh] overflow-y-auto`},ut={class:`modal-field-label-row`},dt={key:0},ft={key:1,class:`text-content-secondary dark:text-content-muted text-sm`},pt={class:`grid grid-cols-2 gap-5`},mt={class:`grid grid-cols-2 gap-5`},ht={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[20px] p-6 max-w-4xl w-full h-[85vh] flex flex-col shadow-2xl`},gt={class:`relative overflow-hidden rounded-[15px] mb-6 p-5 bg-white/50 dark:bg-white/5 border border-stroke-subtle dark:border-white/10`},_t={class:`relative flex items-center justify-between`},vt={class:`flex items-center gap-4`},yt={class:`text-content-secondary dark:text-content-muted text-sm flex items-center gap-2`},bt={class:`text-primary font-semibold`},xt={class:`flex items-center gap-2`},St={class:`bg-primary/30 px-1.5 py-0.5 rounded-full text-[10px]`},Ct={class:`flex-1 overflow-y-auto mb-4 space-y-3`},wt={key:0,class:`flex items-center justify-center py-12`},Tt={class:`text-center`},Et={key:1,class:`flex items-center justify-center py-12`},Dt={class:`text-center`},Ot={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},kt={key:2,class:`space-y-3`},At={class:`relative flex items-start justify-between gap-3`},jt={class:`flex-1 min-w-0`},Mt={class:`flex items-center gap-2 mb-3`},Nt={class:`flex items-center gap-2 flex-wrap`},Pt={key:0,class:`text-primary text-sm font-bold`},Ft={key:1,class:`text-primary/80 text-xs font-mono bg-primary/10 px-2 py-1 rounded-md border border-primary/20`},It={key:2,class:`text-content-muted dark:text-content-muted text-xs`},Lt={class:`text-content-secondary dark:text-content-muted text-xs flex items-center gap-1`},Rt={key:3,class:`text-content-muted dark:text-content-muted/50 text-[10px] font-mono bg-background-mute dark:bg-white/5 px-1.5 py-0.5 rounded`},zt={class:`text-content-primary dark:text-content-primary/90 text-sm leading-relaxed break-words whitespace-pre-wrap bg-gray-50 dark:bg-white/5 p-3 rounded-[10px] border border-stroke-subtle dark:border-white/5`},Bt=[`onClick`],Vt={key:0,class:`text-center pt-4`},Ht={key:1,class:`text-center pt-4`},Ut={class:`flex items-center justify-center gap-2 text-content-secondary dark:text-content-muted text-sm`},Wt={key:3,class:`flex items-center justify-center h-full`},Gt={class:`relative overflow-hidden rounded-[15px] border-t border-stroke-subtle dark:border-white/20 pt-4 mt-4`},Kt={class:`relative space-y-3`},qt={class:`flex gap-3`},Jt={class:`flex-1 relative`},Yt=[`onKeydown`],Xt=[`disabled`],Zt={key:0,class:`fixed inset-0 bg-black/70 backdrop-blur-md flex items-center justify-center z-[350] p-4`},Qt={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-6 max-w-3xl w-full max-h-[80vh] flex flex-col`},$t={class:`flex items-center justify-between mb-4 pb-4 border-b border-stroke-subtle dark:border-white/10`},en={class:`text-content-secondary dark:text-content-primary/70 text-sm mt-1`},tn={class:`text-primary`},nn={class:`flex-1 overflow-y-auto space-y-3`},rn={key:0,class:`text-center py-12`},an={class:`space-y-2`},on={class:`flex items-center justify-between`},sn={class:`flex items-center gap-2`},cn={class:`text-content-primary dark:text-content-primary font-semibold`},ln={class:`flex items-center gap-2`},un={class:`text-content-secondary dark:text-content-muted text-xs`},dn=[`onClick`],fn={class:`space-y-1 text-xs`},pn={class:`flex items-center gap-2`},mn={class:`text-primary font-mono bg-primary/10 px-2 py-0.5 rounded`},hn={class:`flex items-center gap-2`},gn={class:`text-primary font-mono bg-primary/10 px-2 py-0.5 rounded text-[10px] break-all`},_n={class:`flex items-center justify-between text-xs text-content-secondary dark:text-content-muted`},vn={class:`flex items-center gap-4`},yn={key:0},bn={key:1},xn={key:0},x=te({name:`RoomServersView`,__name:`RoomServers`,setup(te){let x=ie(),Sn=f(()=>x.stats?.config?.repeater?.latitude??0),Cn=f(()=>x.stats?.config?.repeater?.longitude??0),S=a(!1),C=a(!1),w=a(!1),T=a(null),E=a(null),D=a(!1),O=a(!1),k=a(!1),A=a(null),j=a(``),M=a(!1),N=a(!1),P=a(new Set),wn=f(()=>E.value?.configured?.filter(e=>e.registered).length??0),Tn=f(()=>E.value?.configured?.length??0),F=f(()=>wn.value===Tn.value),I=a(!1),L=a(``),En=a(!1),Dn=a({message:``,variant:`success`}),R=a(!1),z=a(``),On=a(``),B=a([]),V=a(!1),H=a(null),U=a(``),W=a(de(`roomServers_messagesLimit`,50)),G=a(0),K=a(!0);r(W,e=>ue(`roomServers_messagesLimit`,e));let q=a([]),kn=a(!1),J=a({name:``,identity_key:``,type:`room_server`,settings:{node_name:``,latitude:0,longitude:0,admin_password:``,guest_password:``}});n(async()=>{await Y()});async function Y(){w.value=!0,T.value=null;try{let e=await b.getIdentities();e.success?E.value=e.data:T.value=e.error||`Failed to load identities`}catch(e){T.value=e instanceof Error?e.message:`Failed to load identities`}finally{w.value=!1}}function An(e){e.latitude=Math.round(e.latitude*1e6)/1e6,e.longitude=Math.round(e.longitude*1e6)/1e6}async function jn(){An(J.value.settings);try{let e=await b.createIdentity(J.value);e.success?(D.value=!1,await Y(),k.value=!0):X(`Failed to create identity: ${e.error}`,`error`)}catch(e){X(`Error creating identity: ${e}`,`error`)}}async function Mn(){let e={...A.value,settings:{...A.value.settings}};An(e.settings),e.name===j.value?delete e.new_name:(e.new_name=e.name,e.name=j.value);try{let t=await b.updateIdentity(e);t.success?(O.value=!1,A.value=null,await Y(),k.value=!0):X(`Failed to update identity: ${t.error}`,`error`)}catch(e){X(`Error updating identity: ${e}`,`error`)}}function Nn(e){L.value=e,I.value=!0}async function Pn(){let e=L.value;I.value=!1;try{let t=await b.deleteIdentity(e);t.success?(await Y(),X(t.message||`Identity deleted successfully!`,`success`)):X(`Failed to delete identity: ${t.error}`,`error`)}catch(e){X(`Error deleting identity: ${e}`,`error`)}finally{L.value=``}}function X(e,t){Dn.value={message:e,variant:t},En.value=!0}async function Fn(e){try{let t=await b.sendRoomServerAdvert(e);t.success?X(t.message||`Advert sent for '${e}'!`,`success`):X(`Failed to send advert: ${t.error}`,`error`)}catch(e){X(`Error sending advert: ${e}`,`error`)}}function In(e){A.value=JSON.parse(JSON.stringify(e)),j.value=A.value.name,delete A.value.new_name,A.value.settings||(A.value.settings={}),A.value.settings.admin_password||(A.value.settings.admin_password=``),A.value.settings.guest_password||(A.value.settings.guest_password=``),A.value.settings.latitude??(A.value.settings.latitude=0),A.value.settings.longitude??(A.value.settings.longitude=0),N.value=!1,O.value=!0}function Ln(){J.value={name:``,identity_key:``,type:`room_server`,settings:{node_name:``,latitude:Sn.value,longitude:Cn.value,admin_password:``,guest_password:``}},M.value=!1}function Rn(){Ln(),D.value=!0}function zn(e){J.value.settings.latitude=e.latitude,J.value.settings.longitude=e.longitude}function Bn(e){A.value&&(A.value.settings.latitude=e.latitude,A.value.settings.longitude=e.longitude)}function Z(){D.value=!1,O.value=!1,A.value=null,M.value=!1,N.value=!1}function Vn(e){P.value.has(e)?P.value.delete(e):P.value.add(e)}async function Hn(e){z.value=e,R.value=!0,G.value=0,K.value=!0,On.value=E.value?.configured.find(t=>t.name===e)?.hash||``,await Un(),await Q(!0)}async function Un(){try{let e=await b.getACLClients({identity_hash:On.value,identity_name:z.value});e.success&&e.data&&(q.value=e.data.clients||[])}catch(e){console.error(`Failed to fetch ACL clients:`,e)}}async function Q(e=!1){e&&(G.value=0,B.value=[]),V.value=!0,H.value=null;try{let t=await b.getRoomMessages({room_name:z.value,limit:W.value,offset:G.value});if(t.success&&t.data){let n=t.data.messages||[];e?B.value=n:B.value=[...B.value,...n],K.value=n.length===W.value}else H.value=t.error||`Failed to load messages`}catch(e){H.value=e instanceof Error?e.message:`Failed to load messages`}finally{V.value=!1}}async function Wn(){G.value+=W.value,await Q(!1)}async function $(){if(U.value.trim())try{let e=await b.postRoomMessage({room_name:z.value,message:U.value,author_pubkey:`server`});e.success?(U.value=``,await Q(!0)):X(`Failed to send message: ${e.error}`,`error`)}catch(e){X(`Error sending message: ${e}`,`error`)}}async function Gn(e){if(confirm(`Are you sure you want to delete this message?`))try{let t=await b.deleteRoomMessage({room_name:z.value,message_id:e});t.success?(await Q(!0),X(`Message deleted successfully`,`success`)):X(`Failed to delete message: ${t.error}`,`error`)}catch(e){X(`Error deleting message: ${e}`,`error`)}}function Kn(){R.value=!1,z.value=``,On.value=``,B.value=[],U.value=``,H.value=null,q.value=[]}function qn(e){return e?new Date(e*1e3).toLocaleString():`Unknown`}async function Jn(e,t){if(confirm(`Are you sure you want to remove this client from the ACL?`))try{let n=await b.removeACLClient({public_key:e,identity_hash:t});n.success?(await Un(),X(`Client removed successfully`,`success`)):X(`Failed to remove client: ${n.error}`,`error`)}catch(e){X(`Error removing client: ${e}`,`error`)}}return(n,r)=>(l(),g(m,null,[h(`div`,fe,[h(`div`,{class:`relative overflow-hidden rounded-[20px] p-6 mb-6 glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10`},[r[30]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-br from-primary/20 via-secondary/10 to-accent-purple/20 opacity-50`},null,-1),r[31]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-tl from-accent-green/10 via-transparent to-primary/10 animate-pulse`},null,-1),h(`div`,{class:`relative flex items-center justify-between`},[r[29]||=ee(`

Room Servers

Manage room server identities and messages

`,1),h(`button`,{onClick:Rn,class:`group relative px-6 py-3 bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary rounded-[12px] border border-primary/50 transition-all hover:scale-105 hover:shadow-lg hover:shadow-primary/20`},[...r[28]||=[h(`span`,{class:`flex items-center gap-2`},[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})]),p(` Add Room Server `)],-1)]])])]),E.value&&E.value.total_configured>0?(l(),g(`div`,pe,[h(`div`,me,[h(`div`,he,[h(`div`,null,[r[32]||=h(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Total Configured `,-1),h(`div`,ge,t(Tn.value),1)]),r[33]||=h(`div`,{class:`bg-background-mute dark:bg-white/10 p-3 rounded-[12px]`},[h(`svg`,{class:`w-6 h-6 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10`})])],-1)])]),h(`div`,_e,[h(`div`,ve,[h(`div`,null,[r[34]||=h(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Currently Registered `,-1),h(`div`,ye,t(wn.value),1)]),r[35]||=h(`div`,{class:`bg-primary/20 p-3 rounded-[12px]`},[h(`svg`,{class:`w-6 h-6 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})])],-1)])]),h(`div`,be,[h(`div`,xe,[h(`div`,null,[r[36]||=h(`div`,{class:`text-content-secondary dark:text-content-muted text-xs font-medium mb-2 uppercase tracking-wide`},` Status `,-1),h(`div`,{class:_([`text-3xl font-bold`,F.value?`text-accent-green`:`text-accent-yellow`])},t(F.value?`Synced`:`Out of Sync`),3)]),h(`div`,{class:_([`p-3 rounded-[12px]`,F.value?`bg-accent-green/20`:`bg-accent-yellow/20`])},[F.value?(l(),g(`svg`,Se,[...r[37]||=[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]])):(l(),g(`svg`,Ce,[...r[38]||=[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`},null,-1)]]))],2)])])])):u(``,!0),h(`div`,we,[w.value?(l(),g(`div`,Te,[h(`div`,Ee,[d(ae,{class:`mx-auto mb-4`}),r[39]||=h(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading room servers... `,-1)])])):T.value?(l(),g(`div`,De,[h(`div`,Oe,[r[40]||=h(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load room servers`,-1),h(`div`,ke,t(T.value),1),h(`button`,{onClick:Y,class:`btn-primary`},` Retry `)])])):E.value&&E.value.configured.length>0?(l(),g(`div`,Ae,[(l(!0),g(m,null,c(E.value.configured,e=>(l(),g(`div`,{key:e.name,class:`glass-card backdrop-blur-xl rounded-[15px] p-5 border border-stroke-subtle dark:border-white/10`},[h(`div`,je,[h(`div`,Me,[h(`div`,Ne,[h(`div`,Pe,[e.registered?(l(),g(`div`,Fe)):u(``,!0),h(`div`,{class:_([`relative w-3 h-3 rounded-full`,e.registered?`bg-accent-green`:`bg-accent-red`])},null,2)]),h(`h3`,Ie,t(e.name),1),h(`span`,{class:_([`px-3 py-1 text-xs font-semibold rounded-full`,e.registered?`bg-accent-green/20 text-accent-green border border-accent-green/30`:`bg-accent-red/20 text-accent-red border border-accent-red/30`])},t(e.registered?`● Active`:`○ Inactive`),3),e.hash?(l(),g(`span`,Le,t(e.hash),1)):u(``,!0)]),h(`div`,Re,[h(`div`,null,[r[41]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Node Name:`,-1),h(`span`,ze,t(e.settings?.node_name||`Not set`),1)]),h(`div`,Be,[r[42]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Identity Key:`,-1),P.value.has(e.name)?(l(),g(`span`,Ve,t(e.identity_key),1)):(l(),g(`span`,He,` •••••••••••••••• `)),h(`button`,{onClick:t=>Vn(e.name),class:`text-primary/70 hover:text-primary text-xs underline`},t(P.value.has(e.name)?`Hide`:`Show`),9,Ue)]),h(`div`,null,[r[43]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Location:`,-1),h(`span`,We,t(e.settings?.latitude||0)+`, `+t(e.settings?.longitude||0),1)]),e.settings?.admin_password||e.settings?.guest_password?(l(),g(`div`,Ge,[r[44]||=h(`span`,{class:`text-content-muted dark:text-content-muted`},`Passwords:`,-1),h(`span`,Ke,[e.settings?.admin_password?(l(),g(`span`,qe,`Admin`)):u(``,!0),e.settings?.admin_password&&e.settings?.guest_password?(l(),g(`span`,Je,` / `)):u(``,!0),e.settings?.guest_password?(l(),g(`span`,Ye,`Guest`)):u(``,!0)])])):u(``,!0)]),e.address?(l(),g(`div`,Xe,` Address: `+t(e.address),1)):u(``,!0)]),h(`div`,Ze,[h(`button`,{onClick:t=>Hn(e.name),disabled:!e.registered,class:_([`group px-4 py-2 rounded-[10px] text-xs font-medium transition-all duration-200 flex items-center gap-2`,e.registered?`bg-secondary/20 hover:bg-secondary/30 text-secondary border border-secondary/30 hover:scale-105 hover:shadow-lg hover:shadow-secondary/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`]),title:e.registered?`Manage messages for this room`:`Room server must be active to manage messages`},[...r[45]||=[h(`svg`,{class:`w-4 h-4 group-hover:rotate-12 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z`})],-1),p(` Messages `,-1)]],10,Qe),h(`button`,{onClick:t=>Fn(e.name),disabled:!e.registered,class:_([`group px-4 py-2 rounded-[10px] text-xs font-medium transition-all duration-200 flex items-center gap-2`,e.registered?`bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/30 hover:scale-105 hover:shadow-lg hover:shadow-accent-green/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`]),title:e.registered?`Send advert for this room server`:`Room server must be active to send advert`},[...r[46]||=[h(`svg`,{class:`w-4 h-4 group-hover:scale-110 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 10V3L4 14h7v7l9-11h-7z`})],-1),p(` Send Advert `,-1)]],10,$e),h(`button`,{onClick:t=>In(e),class:`btn-primary-xs`},` Edit `,8,et),h(`button`,{onClick:t=>Nn(e.name),class:`btn-danger-xs`},` Delete `,8,tt)])])]))),128))])):(l(),g(`div`,nt,[r[47]||=h(`svg`,{class:`w-16 h-16 mx-auto mb-4 text-content-muted dark:text-content-muted/60`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4`})],-1),r[48]||=h(`p`,{class:`text-lg mb-2`},`No room servers configured`,-1),r[49]||=h(`p`,{class:`text-sm mb-4`},`Add your first room server to get started`,-1),h(`button`,{onClick:Rn,class:`btn-primary`},` + Add Room Server `)]))]),(l(),o(s,{to:`body`},[d(re,{"enter-active-class":`transition-opacity duration-200`,"enter-from-class":`opacity-0`,"leave-active-class":`transition-opacity duration-200`,"leave-to-class":`opacity-0`},{default:e(()=>[D.value?(l(),g(`div`,{key:0,class:`modal-backdrop`,onClick:y(Z,[`self`])},[h(`div`,rt,[h(`div`,{class:`flex items-center justify-between mb-7`},[r[51]||=h(`div`,null,[h(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Add Room Server `),h(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mt-1`},` Configure a new room server identity `)],-1),h(`button`,{onClick:Z,class:`text-content-secondary dark:text-white/60 hover:text-content-primary dark:hover:text-white transition-colors`},[...r[50]||=[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),h(`form`,{onSubmit:y(jn,[`prevent`]),class:`modal-form`},[h(`div`,null,[r[52]||=h(`label`,{class:`modal-field-label`},[p(`Name `),h(`span`,{class:`text-red-500`},`*`)],-1),i(h(`input`,{"onUpdate:modelValue":r[0]||=e=>J.value.name=e,type:`text`,placeholder:`e.g., MainBBS`,class:`modal-input`},null,512),[[v,J.value.name]])]),h(`div`,null,[h(`div`,it,[r[53]||=h(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted`},`Identity Key (Optional)`,-1),h(`button`,{onClick:r[1]||=e=>M.value=!M.value,type:`button`,class:`text-primary/70 hover:text-primary text-xs underline`},t(M.value?`Hide`:`Show/Edit`),1)]),M.value?(l(),g(`div`,at,[i(h(`input`,{"onUpdate:modelValue":r[2]||=e=>J.value.identity_key=e,type:`text`,placeholder:`Leave empty to auto-generate`,class:`modal-input font-mono`},null,512),[[v,J.value.identity_key]]),r[54]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Leave empty to automatically generate a secure key `,-1)])):(l(),g(`div`,ot,` Will be auto-generated if not provided `))]),h(`div`,null,[r[55]||=h(`label`,{class:`modal-field-label`},`Node Name`,-1),i(h(`input`,{"onUpdate:modelValue":r[3]||=e=>J.value.settings.node_name=e,type:`text`,placeholder:`Display name for the room server`,class:`modal-input`},null,512),[[v,J.value.settings.node_name]])]),h(`div`,null,[r[59]||=h(`label`,{class:`modal-field-label`},`Location`,-1),h(`button`,{type:`button`,onClick:r[4]||=e=>S.value=!0,class:`flex items-center gap-1.5 px-2.5 py-1 mb-3 text-xs bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-secondary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors`,title:`Pick location on map`},[...r[56]||=[h(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),p(` Pick on Map `,-1)]]),h(`div`,st,[h(`div`,null,[r[57]||=h(`label`,{class:`modal-field-label`},`Latitude`,-1),i(h(`input`,{"onUpdate:modelValue":r[5]||=e=>J.value.settings.latitude=e,type:`number`,step:`0.000001`,class:`modal-input`},null,512),[[v,J.value.settings.latitude,void 0,{number:!0}]])]),h(`div`,null,[r[58]||=h(`label`,{class:`modal-field-label`},`Longitude`,-1),i(h(`input`,{"onUpdate:modelValue":r[6]||=e=>J.value.settings.longitude=e,type:`number`,step:`0.000001`,class:`modal-input`},null,512),[[v,J.value.settings.longitude,void 0,{number:!0}]])])])]),h(`div`,ct,[h(`div`,null,[r[60]||=h(`label`,{class:`modal-field-label`},`Admin Password (Optional)`,-1),i(h(`input`,{"onUpdate:modelValue":r[7]||=e=>J.value.settings.admin_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`modal-input`},null,512),[[v,J.value.settings.admin_password]]),r[61]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},`Full access to room server`,-1)]),h(`div`,null,[r[62]||=h(`label`,{class:`modal-field-label`},`Guest Password (Optional)`,-1),i(h(`input`,{"onUpdate:modelValue":r[8]||=e=>J.value.settings.guest_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`modal-input`},null,512),[[v,J.value.settings.guest_password]]),r[63]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},`Read-only access`,-1)])]),h(`div`,{class:`modal-actions`},[h(`button`,{type:`button`,onClick:Z,class:`modal-btn-cancel`},`Cancel`),r[64]||=h(`button`,{type:`submit`,class:`modal-btn-primary`},`Create`,-1)])],32)])])):u(``,!0)]),_:1})])),d(le,{"is-open":S.value,latitude:J.value.settings.latitude,longitude:J.value.settings.longitude,onClose:r[9]||=e=>S.value=!1,onSelect:zn},null,8,[`is-open`,`latitude`,`longitude`]),(l(),o(s,{to:`body`},[d(re,{"enter-active-class":`transition-opacity duration-200`,"enter-from-class":`opacity-0`,"leave-active-class":`transition-opacity duration-200`,"leave-to-class":`opacity-0`},{default:e(()=>[O.value&&A.value?(l(),g(`div`,{key:0,class:`modal-backdrop`,onClick:y(Z,[`self`])},[h(`div`,lt,[h(`div`,{class:`flex items-center justify-between mb-7`},[r[66]||=h(`div`,null,[h(`h3`,{class:`text-xl font-semibold text-content-primary dark:text-content-primary`},` Edit Room Server `),h(`p`,{class:`text-content-secondary dark:text-content-muted text-sm mt-1`},` Update room server identity `)],-1),h(`button`,{onClick:Z,class:`text-content-secondary dark:text-white/60 hover:text-content-primary dark:hover:text-white transition-colors`},[...r[65]||=[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),h(`form`,{onSubmit:y(Mn,[`prevent`]),class:`modal-form`},[h(`div`,null,[r[67]||=h(`label`,{class:`modal-field-label`},[p(`Name `),h(`span`,{class:`text-red-500`},`*`)],-1),i(h(`input`,{"onUpdate:modelValue":r[10]||=e=>A.value.name=e,type:`text`,class:`modal-input`},null,512),[[v,A.value.name]])]),h(`div`,null,[h(`div`,ut,[r[68]||=h(`span`,{class:`text-xs font-medium text-content-secondary dark:text-content-muted`},`Identity Key (Optional)`,-1),h(`button`,{onClick:r[11]||=e=>N.value=!N.value,type:`button`,class:`text-primary/70 hover:text-primary text-xs underline`},t(N.value?`Hide`:`Show/Edit`),1)]),N.value?(l(),g(`div`,dt,[i(h(`input`,{"onUpdate:modelValue":r[12]||=e=>A.value.identity_key=e,type:`text`,placeholder:`Leave empty to keep current key`,class:`modal-input font-mono`},null,512),[[v,A.value.identity_key]]),r[69]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},` Leave empty to keep the current identity key `,-1)])):(l(),g(`div`,ft,` Click "Show/Edit" to change the identity key `))]),h(`div`,null,[r[70]||=h(`label`,{class:`modal-field-label`},`Node Name`,-1),i(h(`input`,{"onUpdate:modelValue":r[13]||=e=>A.value.settings.node_name=e,type:`text`,class:`modal-input`},null,512),[[v,A.value.settings.node_name]])]),h(`div`,null,[r[74]||=h(`label`,{class:`modal-field-label`},`Location`,-1),h(`button`,{type:`button`,onClick:r[14]||=e=>C.value=!0,class:`flex items-center gap-1.5 px-2.5 py-1 mb-3 text-xs bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-secondary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors`,title:`Pick location on map`},[...r[71]||=[h(`svg`,{class:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z`}),h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 11a3 3 0 11-6 0 3 3 0 016 0z`})],-1),p(` Pick on Map `,-1)]]),h(`div`,pt,[h(`div`,null,[r[72]||=h(`label`,{class:`modal-field-label`},`Latitude`,-1),i(h(`input`,{"onUpdate:modelValue":r[15]||=e=>A.value.settings.latitude=e,type:`number`,step:`0.000001`,class:`modal-input`},null,512),[[v,A.value.settings.latitude,void 0,{number:!0}]])]),h(`div`,null,[r[73]||=h(`label`,{class:`modal-field-label`},`Longitude`,-1),i(h(`input`,{"onUpdate:modelValue":r[16]||=e=>A.value.settings.longitude=e,type:`number`,step:`0.000001`,class:`modal-input`},null,512),[[v,A.value.settings.longitude,void 0,{number:!0}]])])])]),h(`div`,mt,[h(`div`,null,[r[75]||=h(`label`,{class:`modal-field-label`},`Admin Password (Optional)`,-1),i(h(`input`,{"onUpdate:modelValue":r[17]||=e=>A.value.settings.admin_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`modal-input`},null,512),[[v,A.value.settings.admin_password]]),r[76]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},`Full access to room server`,-1)]),h(`div`,null,[r[77]||=h(`label`,{class:`modal-field-label`},`Guest Password (Optional)`,-1),i(h(`input`,{"onUpdate:modelValue":r[18]||=e=>A.value.settings.guest_password=e,type:`password`,placeholder:`Leave empty for no password`,class:`modal-input`},null,512),[[v,A.value.settings.guest_password]]),r[78]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-1`},`Read-only access`,-1)])]),h(`div`,{class:`modal-actions`},[h(`button`,{type:`button`,onClick:Z,class:`modal-btn-cancel`},`Cancel`),r[79]||=h(`button`,{type:`submit`,class:`modal-btn-primary`},`Update`,-1)])],32)])])):u(``,!0)]),_:1})])),d(le,{"is-open":C.value,latitude:A.value?.settings?.latitude,longitude:A.value?.settings?.longitude,onClose:r[19]||=e=>C.value=!1,onSelect:Bn},null,8,[`is-open`,`latitude`,`longitude`])]),d(se,{show:I.value,title:`Delete Room Server`,message:`Are you sure you want to delete '${L.value}'? This action cannot be undone.`,"confirm-text":`Delete`,"cancel-text":`Cancel`,variant:`danger`,onClose:r[20]||=e=>I.value=!1,onConfirm:Pn},null,8,[`show`,`message`]),d(ce,{show:En.value,message:Dn.value.message,variant:Dn.value.variant,onClose:r[21]||=e=>En.value=!1},null,8,[`show`,`message`,`variant`]),d(oe,{modelValue:k.value,"onUpdate:modelValue":r[22]||=e=>k.value=e,message:`Room server settings have been saved. A service restart is required for the changes to take effect.`},null,8,[`modelValue`]),(l(),o(s,{to:`body`},[R.value?(l(),g(`div`,{key:0,class:`fixed inset-0 bg-black/70 backdrop-blur-lg flex items-center justify-center z-[300] p-4`,onClick:r[26]||=y(e=>R.value=!1,[`self`])},[h(`div`,ht,[h(`div`,gt,[r[86]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-r from-secondary/20 via-primary/20 to-accent-purple/20`},null,-1),r[87]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-br from-transparent via-white/5 to-transparent`},null,-1),h(`div`,_t,[h(`div`,vt,[r[82]||=h(`div`,{class:`relative`},[h(`div`,{class:`absolute inset-0 bg-secondary/40 blur-xl rounded-full`}),h(`div`,{class:`relative bg-secondary/20 p-3 rounded-[12px] border border-secondary/30`},[h(`svg`,{class:`w-6 h-6 text-secondary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z`})])])],-1),h(`div`,null,[r[81]||=h(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary mb-1`},` Room Messages `,-1),h(`p`,yt,[r[80]||=h(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z`})],-1),h(`span`,bt,t(z.value),1)])])]),h(`div`,xt,[h(`button`,{onClick:r[23]||=e=>kn.value=!0,class:`group px-3 py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-[10px] text-xs font-medium transition-all hover:scale-105 border border-primary/30 flex items-center gap-2`,title:`View active sessions`},[r[83]||=h(`svg`,{class:`w-4 h-4 group-hover:scale-110 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1),r[84]||=h(`span`,{class:`hidden sm:inline`},`Sessions`,-1),h(`span`,St,t(q.value.length),1)]),h(`button`,{onClick:Kn,class:`p-2 text-content-secondary dark:text-content-primary/70 hover:text-content-primary dark:hover:text-content-primary hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-[10px] transition-all`},[...r[85]||=[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])])])]),h(`div`,Ct,[V.value&&B.value.length===0?(l(),g(`div`,wt,[h(`div`,Tt,[d(ae,{class:`mx-auto mb-4`}),r[88]||=h(`div`,{class:`text-content-secondary dark:text-content-primary/70`},` Loading messages... `,-1)])])):H.value?(l(),g(`div`,Et,[h(`div`,Dt,[r[89]||=h(`div`,{class:`text-red-600 dark:text-red-400 mb-2`},`Failed to load messages`,-1),h(`div`,Ot,t(H.value),1),h(`button`,{onClick:r[24]||=e=>Q(!0),class:`btn-primary`},` Retry `)])])):B.value.length>0?(l(),g(`div`,kt,[(l(!0),g(m,null,c(B.value,(e,n)=>(l(),g(`div`,{key:e.id||n,class:`group relative overflow-hidden glass-card backdrop-blur-xl rounded-[12px] p-4 border border-stroke-subtle dark:border-white/10 hover:border-secondary/30 transition-all duration-300 hover:shadow-lg hover:shadow-secondary/10`},[r[94]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-r from-secondary/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity`},null,-1),h(`div`,At,[h(`div`,jt,[h(`div`,Mt,[h(`div`,Nt,[r[91]||=h(`div`,{class:`w-6 h-6 rounded-full bg-gradient-to-br from-primary/30 to-secondary/30 flex items-center justify-center`},[h(`svg`,{class:`w-3 h-3 text-content-secondary dark:text-content-primary/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`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`})])],-1),e.author_name?(l(),g(`span`,Pt,t(e.author_name),1)):u(``,!0),e.author_pubkey?(l(),g(`span`,Ft,t(e.author_pubkey.substring(0,8))+`... `,1)):(l(),g(`span`,It,` Anonymous `)),r[92]||=h(`span`,{class:`text-content-muted dark:text-content-muted/60 text-xs`},`•`,-1),h(`span`,Lt,[r[90]||=h(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})],-1),p(` `+t(qn(e.timestamp)),1)]),e.id?(l(),g(`span`,Rt,` #`+t(e.id),1)):u(``,!0)])]),h(`div`,zt,t(e.message_text),1)]),h(`button`,{onClick:t=>Gn(e.id),class:`group/delete flex-shrink-0 p-2 bg-accent-red/10 hover:bg-accent-red/20 text-accent-red rounded-[8px] transition-all hover:scale-110 border border-accent-red/20`,title:`Delete this message`},[...r[93]||=[h(`svg`,{class:`w-4 h-4 group-hover/delete:rotate-12 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,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`})],-1)]],8,Bt)])]))),128)),K.value&&!V.value?(l(),g(`div`,Vt,[h(`button`,{onClick:Wn,class:`group px-6 py-2.5 bg-gradient-to-r from-gray-100 dark:from-white/5 to-gray-200 dark:to-white/10 hover:from-gray-200 dark:hover:from-white/10 hover:to-gray-300 dark:hover:to-white/15 text-content-primary dark:text-content-primary rounded-[10px] transition-all hover:scale-105 text-sm font-medium border border-stroke-subtle dark:border-stroke/10 flex items-center gap-2 mx-auto`},[...r[95]||=[h(`svg`,{class:`w-4 h-4 group-hover:translate-y-1 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),p(` Load More Messages `,-1)]])])):V.value?(l(),g(`div`,Ht,[h(`div`,Ut,[d(ae,{size:`sm`}),r[96]||=p(` Loading... `,-1)])])):u(``,!0)])):(l(),g(`div`,Wt,[...r[97]||=[h(`div`,{class:`text-center py-12`},[h(`div`,{class:`relative mb-6`},[h(`div`,{class:`absolute inset-0 bg-secondary/20 blur-3xl rounded-full`}),h(`div`,{class:`relative bg-gradient-to-br from-secondary/20 to-primary/20 p-6 rounded-[20px] inline-block border border-stroke-subtle dark:border-white/10`},[h(`svg`,{class:`w-16 h-16 text-content-muted dark:text-content-muted/70`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z`})])])]),h(`p`,{class:`text-xl font-bold text-content-primary dark:text-content-primary mb-2`},` No messages yet `),h(`p`,{class:`text-sm text-content-secondary dark:text-content-muted`},` Be the first to start the conversation `)],-1)]]))]),h(`div`,Gt,[r[100]||=h(`div`,{class:`absolute inset-0 bg-gradient-to-t from-primary/5 to-transparent pointer-events-none`},null,-1),h(`div`,Kt,[h(`div`,qt,[h(`div`,Jt,[i(h(`textarea`,{"onUpdate:modelValue":r[25]||=e=>U.value=e,onKeydown:[ne(y($,[`ctrl`]),[`enter`]),ne(y($,[`meta`]),[`enter`])],placeholder:`Type your message... (Ctrl+Enter to send)`,rows:`3`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-3 text-content-primary dark:text-content-primary text-sm placeholder-gray-500 dark:placeholder-white/30 focus:outline-none focus:border-primary/50 focus:bg-white dark:focus:bg-white/10 transition-all resize-none`},null,40,Yt),[[v,U.value]])]),h(`button`,{onClick:$,disabled:!U.value.trim(),class:_([`group px-6 py-3 rounded-[12px] transition-all duration-200 flex items-center justify-center gap-2 font-medium`,U.value.trim()?`bg-gradient-to-r from-primary/30 to-secondary/30 hover:from-primary/40 hover:to-secondary/40 text-content-primary dark:text-content-primary border border-primary/50 hover:scale-105 hover:shadow-lg hover:shadow-primary/20`:`bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/60 cursor-not-allowed border border-stroke-subtle dark:border-stroke/10`])},[...r[98]||=[h(`svg`,{class:`w-5 h-5 group-hover:translate-x-1 transition-transform`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 19l9 2-9-18-9 18 9-2zm0 0v-8`})],-1),h(`span`,{class:`hidden sm:inline`},`Send`,-1)]],10,Xt)]),r[99]||=h(`p`,{class:`text-content-secondary dark:text-content-muted/60 text-xs flex items-center gap-2`},[h(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})]),p(` Press Ctrl+Enter to send message quickly `)],-1)])])])])):u(``,!0)])),(l(),o(s,{to:`body`},[kn.value?(l(),g(`div`,Zt,[h(`div`,Qt,[h(`div`,$t,[h(`div`,null,[r[102]||=h(`h2`,{class:`text-xl font-bold text-content-primary dark:text-content-primary`},` Active Sessions `,-1),h(`p`,en,[r[101]||=p(` Room: `,-1),h(`span`,tn,t(z.value),1)])]),h(`button`,{onClick:r[27]||=e=>kn.value=!1,class:`text-content-secondary dark:text-content-primary/70 hover:text-content-primary dark:hover:text-content-primary transition-colors`},[...r[103]||=[h(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),h(`div`,nn,[q.value.length===0?(l(),g(`div`,rn,[...r[104]||=[h(`div`,{class:`text-content-secondary dark:text-content-muted`},`No active sessions found`,-1)]])):u(``,!0),(l(!0),g(m,null,c(q.value,(e,n)=>(l(),g(`div`,{key:e.public_key_full||n,class:`glass-card backdrop-blur-xl rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10`},[h(`div`,an,[h(`div`,on,[h(`div`,sn,[h(`span`,cn,t(e.identity_name||`Unknown`),1),h(`span`,{class:_([`px-2 py-0.5 text-xs font-medium rounded`,e.permissions===`admin`?`bg-accent-green/20 text-accent-green`:`bg-secondary/20 text-secondary`])},t(e.permissions),3)]),h(`div`,ln,[h(`span`,un,t(e.identity_type),1),h(`button`,{onClick:t=>Jn(e.public_key_full,e.identity_hash),class:`px-2 py-1 bg-accent-red/20 hover:bg-accent-red/30 text-accent-red rounded text-xs transition-colors`,title:`Remove client from ACL`},` Remove `,8,dn)])]),h(`div`,fn,[h(`div`,pn,[r[105]||=h(`span`,{class:`text-content-secondary dark:text-content-muted`},`Short Key:`,-1),h(`code`,mn,t(e.public_key),1)]),h(`div`,hn,[r[106]||=h(`span`,{class:`text-content-secondary dark:text-content-muted`},`Full Key:`,-1),h(`code`,gn,t(e.public_key_full),1)])]),h(`div`,_n,[h(`div`,vn,[e.address?(l(),g(`span`,yn,`📍 `+t(e.address),1)):u(``,!0),e.last_login_success?(l(),g(`span`,bn,`Last Login: `+t(new Date(e.last_login_success*1e3).toLocaleString()),1)):u(``,!0)]),e.last_activity?(l(),g(`span`,xn,`Active: `+t(Math.floor((Date.now()/1e3-e.last_activity)/60))+`m ago`,1)):u(``,!0)])])]))),128))])])])):u(``,!0)]))],64))}});export{x as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Sensors-C31-xdDY.js b/repeater/web/html/assets/Sensors-C31-xdDY.js new file mode 100644 index 00000000..ed5b89c0 --- /dev/null +++ b/repeater/web/html/assets/Sensors-C31-xdDY.js @@ -0,0 +1 @@ +import{Ct as e,g as t,j as n,k as r,l as i,o as a,r as o,s,u as c,xt as l}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{t as u}from"./system-DbBvxitf.js";import{t as d}from"./index-DTUpsCzx.js";var f={class:`space-y-4`},p={class:`glass-card rounded-[15px] p-4 sm:p-6`},m={class:`mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4`},h={class:`text-xs uppercase tracking-wide text-content-muted`},g={class:`mt-2 text-lg font-semibold text-content-heading dark:text-white`},_={key:0,class:`glass-card rounded-[15px] p-5 text-content-muted`},v={class:`flex flex-wrap items-center justify-between gap-3`},y={class:`text-lg font-semibold text-content-heading dark:text-white`},b={class:`text-sm text-content-muted`},x={class:`mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2`},S={class:`text-sm`},C={class:`ml-2 text-content-heading dark:text-white`},w={key:0,class:`text-sm`},T={class:`ml-2 text-red-600 dark:text-red-300`},E={class:`mt-4 overflow-x-auto rounded-[12px] border border-stroke-subtle dark:border-white/10`},D={class:`min-w-full text-sm`},O={class:`px-3 py-2 font-medium text-content-heading dark:text-white`},k={class:`px-3 py-2 text-content-muted break-all`},A={key:0},j={key:1,class:`glass-card rounded-[15px] p-5 text-content-muted`},M=t({name:`SensorsView`,__name:`Sensors`,setup(t){let M=u(),N=a(()=>M.stats?.sensors??null),P=a(()=>N.value?.readings??[]),F=a(()=>{let e=N.value;return e?[{label:`Enabled`,value:e.enabled?`Yes`:`No`},{label:`Running`,value:e.running?`Yes`:`No`},{label:`Configured / Loaded`,value:`${e.configured??0} / ${e.loaded??0}`},{label:`Poll Interval`,value:typeof e.poll_interval_seconds==`number`?`${e.poll_interval_seconds.toFixed(1)}s`:`n/a`}]:[{label:`Enabled`,value:`n/a`},{label:`Running`,value:`n/a`},{label:`Configured`,value:`n/a`},{label:`Poll Interval`,value:`n/a`}]}),I=e=>{if(e==null)return`n/a`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):`n/a`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}},L=e=>{if(!e)return`n/a`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},R=async()=>{await M.fetchStats()};return d(async()=>{await M.fetchStats()},{intervalMs:1e4,immediate:!0}),(t,a)=>(r(),c(`div`,f,[s(`div`,p,[s(`div`,{class:`flex items-start justify-between gap-4`},[a[0]||=s(`div`,null,[s(`h1`,{class:`text-xl sm:text-2xl font-semibold text-content-heading dark:text-white`},`Sensors`),s(`p`,{class:`mt-1 text-sm text-content-muted`},` Live sensor summary from the existing stats API. `)],-1),s(`button`,{class:`rounded-[10px] border border-stroke-subtle dark:border-white/10 px-3 py-2 text-sm hover:bg-black/5 dark:hover:bg-white/5`,onClick:R},` Refresh `)]),s(`div`,m,[(r(!0),c(o,null,n(F.value,t=>(r(),c(`div`,{key:t.label,class:`rounded-[12px] border border-stroke-subtle dark:border-white/10 p-3`},[s(`p`,h,e(t.label),1),s(`p`,g,e(t.value),1)]))),128))])]),N.value?i(``,!0):(r(),c(`div`,_,` Sensor data is not available yet. Ensure the repeater has started and stats are loading. `)),(r(!0),c(o,null,n(P.value,(t,u)=>(r(),c(`div`,{key:`${t.name||`sensor`}-${u}`,class:`glass-card rounded-[15px] p-4 sm:p-5`},[s(`div`,v,[s(`div`,null,[s(`h2`,y,e(t.name||`Sensor ${u+1}`),1),s(`p`,b,`Type: `+e(t.type||`unknown`),1)]),s(`span`,{class:l([`rounded-full px-3 py-1 text-xs font-semibold`,t.ok?`bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`])},e(t.ok?`OK`:`Error`),3)]),s(`div`,x,[s(`div`,S,[a[1]||=s(`span`,{class:`text-content-muted`},`Timestamp:`,-1),s(`span`,C,e(L(t.timestamp)),1)]),t.error?(r(),c(`div`,w,[a[2]||=s(`span`,{class:`text-content-muted`},`Error:`,-1),s(`span`,T,e(t.error),1)])):i(``,!0)]),s(`div`,E,[s(`table`,D,[a[4]||=s(`thead`,{class:`bg-black/5 dark:bg-white/5`},[s(`tr`,null,[s(`th`,{class:`px-3 py-2 text-left text-content-muted`},`Field`),s(`th`,{class:`px-3 py-2 text-left text-content-muted`},`Value`)])],-1),s(`tbody`,null,[(r(!0),c(o,null,n(t.data||{},(t,n)=>(r(),c(`tr`,{key:String(n),class:`border-t border-stroke-subtle dark:border-white/10`},[s(`td`,O,e(n),1),s(`td`,k,e(I(t)),1)]))),128)),!t.data||Object.keys(t.data).length===0?(r(),c(`tr`,A,[...a[3]||=[s(`td`,{class:`px-3 py-3 text-content-muted`,colspan:`2`},`No fields in payload`,-1)]])):i(``,!0)])])])]))),128)),N.value&&P.value.length===0?(r(),c(`div`,j,` Sensors are configured but no readings are available yet. `)):i(``,!0)]))}});export{M as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Sessions-DhR0b50N.js b/repeater/web/html/assets/Sessions-DhR0b50N.js deleted file mode 100644 index 7b411316..00000000 --- a/repeater/web/html/assets/Sessions-DhR0b50N.js +++ /dev/null @@ -1 +0,0 @@ -import{E as e,S as t,dt as n,g as r,j as ee,l as i,o as a,p as te,pt as o,r as s,s as c,u as l,w as u,z as d}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as f}from"./api-CbM6k1ZB.js";import{d as ne}from"./index-BFltqMtv.js";var re={class:`p-6 space-y-6`},ie={key:0,class:`grid grid-cols-1 md:grid-cols-4 gap-4`},ae={class:`glass-card rounded-[15px] p-4`},oe={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},se={class:`glass-card rounded-[15px] p-4`},ce={class:`text-2xl font-bold text-cyan-500 dark:text-primary`},le={class:`glass-card rounded-[15px] p-4`},ue={class:`text-2xl font-bold text-green-700 dark:text-green-500 dark:text-accent-green`},de={class:`glass-card rounded-[15px] p-4`},fe={class:`text-2xl font-bold text-yellow-500 dark:text-secondary`},pe={class:`glass-card rounded-[15px] p-6`},me={class:`flex flex-wrap border-b border-stroke-subtle dark:border-stroke/10 mb-6`},he=[`onClick`],p={class:`flex items-center gap-2`},m={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},h={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},g={key:2,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},_={class:`min-h-[400px]`},v={key:0,class:`flex items-center justify-center py-12`},y={key:1,class:`flex items-center justify-center py-12`},b={class:`text-center`},x={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},S={key:2,class:`space-y-4`},C={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},w={key:1,class:`space-y-4`},T={class:`flex items-start justify-between`},E={class:`flex-1 min-w-0`},D={class:`flex items-center gap-2 flex-wrap mb-3`},O={class:`text-lg font-semibold text-content-primary dark:text-content-primary truncate`},k={class:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`},A={key:0,class:`flex items-center gap-1.5`},j={class:`text-content-secondary dark:text-content-muted`},M={key:1,class:`flex items-center gap-1.5`},N={class:`text-content-secondary dark:text-content-muted`},P={key:2,class:`text-content-secondary dark:text-content-muted font-mono text-xs`},F={key:3,class:`text-content-muted dark:text-content-muted font-mono text-xs`},I={key:0,class:`text-content-muted dark:text-content-muted text-xs mt-2 mb-0`},L={class:`grid grid-cols-2 md:grid-cols-4 gap-4 mt-4`},R={class:`text-content-primary dark:text-content-primary font-medium`},ge={class:`text-cyan-500 dark:text-primary font-medium`},z={class:`mt-3 flex items-center gap-2`},_e={key:3,class:`space-y-4`},ve={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},ye={key:1,class:`overflow-x-auto`},be={class:`w-full`},xe={class:`py-3`},Se={class:`font-mono text-sm text-content-primary dark:text-content-primary`},Ce={class:`py-3`},we={class:`font-mono text-xs text-content-secondary dark:text-content-muted`},Te={class:`py-3`},Ee={class:`text-sm text-content-primary dark:text-content-primary`},De={class:`text-xs text-content-muted dark:text-content-muted`},Oe={class:`py-3`},ke={class:`py-3`},Ae={class:`text-sm text-content-secondary dark:text-content-muted`},je={class:`py-3`},Me=[`onClick`],Ne={key:4,class:`space-y-4`},Pe={class:`mb-4`},Fe=[`value`],Ie={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},Le={key:1,class:`grid grid-cols-1 gap-4`},Re={class:`flex items-start justify-between`},ze={class:`flex-1`},Be={class:`flex items-center gap-3 mb-3`},Ve={class:`text-content-primary dark:text-content-primary font-mono text-sm`},He={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm`},Ue={class:`text-content-primary dark:text-content-primary/90 font-mono ml-2`},We={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ge={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ke={class:`text-content-primary dark:text-content-primary/90 ml-2`},qe=[`onClick`],Je={class:`flex justify-end`},Ye=[`disabled`],B=r({name:`SessionsView`,__name:`Sessions`,setup(r){let B=d(`overview`),V=d(!1),H=d(!1),U=d(null),W=d(null),G=d([]),K=d(null),q=d(null),Xe=[{id:`overview`,label:`Overview`,icon:`overview`},{id:`clients`,label:`Authenticated Clients`,icon:`clients`},{id:`identities`,label:`By Identity`,icon:`identities`}];t(async()=>{await J(),V.value=!0});async function J(){H.value=!0,U.value=null;try{let e=await f.getACLInfo();e.success&&(W.value=e.data);let t=await f.getACLClients();t.success&&t.data&&(G.value=t.data.clients||[]);let n=await f.getACLStats();n.success&&(K.value=n.data)}catch(e){U.value=e instanceof Error?e.message:`Failed to load ACL data`,console.error(`Error fetching ACL data:`,e)}finally{H.value=!1}}async function Y(e,t){if(confirm(`Are you sure you want to remove this client from the ACL?`))try{let n=await f.removeACLClient({public_key:e,identity_hash:t});n.success?await J():alert(`Failed to remove client: ${n.error}`)}catch(e){alert(`Error removing client: ${e}`)}}function X(e){return e?new Date(e*1e3).toLocaleString():`Never`}function Ze(e){B.value=e}let Z=a(()=>q.value?G.value.filter(e=>e.identity_name===q.value):G.value),Q=a(()=>W.value&&W.value.acls||[]);function Qe(e){return e?.type===`companion`}function $e(e){return e===`repeater`?`bg-cyan-500/20 dark:bg-primary/20 text-cyan-700 dark:text-primary`:e===`companion`?`bg-violet-500/20 dark:bg-violet-400/20 text-violet-700 dark:text-violet-300`:`bg-yellow-100 dark:bg-yellow-500/20 dark:bg-secondary/20 text-yellow-700 dark:text-secondary`}function $(e){return e==null?`N/A`:typeof e==`boolean`?e?`✓`:`✗`:String(e)}return(t,r)=>(u(),l(`div`,re,[r[22]||=c(`div`,null,[c(`h1`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` Sessions & Access Control `),c(`p`,{class:`text-content-secondary dark:text-content-muted mt-2`},` Manage authenticated clients and access control lists `),c(`p`,{class:`text-content-muted dark:text-content-muted text-sm mt-1`},` Repeater, room servers, and companion identities; companions do not accept client logins. `)],-1),K.value?(u(),l(`div`,ie,[c(`div`,ae,[r[1]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},` Total Identities `,-1),c(`div`,oe,o(K.value.total_identities),1)]),c(`div`,se,[r[2]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},` Authenticated Clients `,-1),c(`div`,ce,o(K.value.total_clients),1)]),c(`div`,le,[r[3]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},`Admin Clients`,-1),c(`div`,ue,o(K.value.admin_clients),1)]),c(`div`,de,[r[4]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},`Guest Clients`,-1),c(`div`,fe,o(K.value.guest_clients),1)])])):i(``,!0),c(`div`,pe,[c(`div`,me,[(u(),l(s,null,e(Xe,e=>c(`button`,{key:e.id,onClick:t=>Ze(e.id),class:n([`px-4 py-2 text-sm font-medium transition-colors duration-200 border-b-2 mr-6 mb-2`,B.value===e.id?`text-cyan-500 dark:text-primary border-cyan-500 dark:border-primary`:`text-content-secondary dark:text-content-muted border-transparent hover:text-content-primary dark:hover:text-content-primary hover:border-stroke-subtle dark:hover:border-stroke/30`])},[c(`div`,p,[e.icon===`overview`?(u(),l(`svg`,m,[...r[5]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z`},null,-1)]])):e.icon===`clients`?(u(),l(`svg`,h,[...r[6]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z`},null,-1)]])):e.icon===`identities`?(u(),l(`svg`,g,[...r[7]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 6H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V8a2 2 0 00-2-2h-5m-4 0V5a2 2 0 114 0v1m-4 0a2 2 0 104 0m-5 8a2 2 0 100-4 2 2 0 000 4zm0 0c1.306 0 2.417.835 2.83 2M9 14a3.001 3.001 0 00-2.83 2M15 11h3m-3 4h2`},null,-1)]])):i(``,!0),te(` `+o(e.label),1)])],10,he)),64))]),c(`div`,_,[H.value&&!V.value?(u(),l(`div`,v,[...r[8]||=[c(`div`,{class:`text-center`},[c(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full mx-auto mb-4`}),c(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading ACL data...`)],-1)]])):U.value?(u(),l(`div`,y,[c(`div`,b,[r[9]||=c(`div`,{class:`text-red-500 dark:text-red-400 mb-2`},`Failed to load ACL data`,-1),c(`div`,x,o(U.value),1),c(`button`,{onClick:J,class:`px-4 py-2 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors`},` Retry `)])])):B.value===`overview`?(u(),l(`div`,S,[Q.value.length===0?(u(),l(`div`,C,` No identities configured `)):(u(),l(`div`,w,[(u(!0),l(s,null,e(Q.value,e=>(u(),l(`div`,{key:e.hash,class:`glass-card rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10 hover:border-cyan-400 dark:hover:border-primary/30 transition-colors`},[c(`div`,T,[c(`div`,E,[c(`div`,D,[c(`h3`,O,o(e.name),1),c(`span`,{class:n([`px-2 py-0.5 text-xs font-medium rounded shrink-0`,$e(e.type)])},o(e.type),3)]),Qe(e)?(u(),l(s,{key:0},[c(`div`,k,[e.registered===void 0?i(``,!0):(u(),l(`span`,A,[c(`span`,{class:n([`w-2 h-2 rounded-full shrink-0`,e.registered?`bg-accent-green`:`bg-accent-red`]),"aria-hidden":``},null,2),c(`span`,j,`Registered: `+o(e.registered?`Active`:`Inactive`),1)])),e.active===void 0?i(``,!0):(u(),l(`span`,M,[c(`span`,{class:n([`w-2 h-2 rounded-full shrink-0`,e.active?`bg-accent-green`:`bg-accent-red`]),"aria-hidden":``},null,2),c(`span`,N,`Bridge: `+o(e.active?`Connected`:`Disconnected`),1)])),e.client_ip?(u(),l(`span`,P,` Client: `+o(e.client_ip),1)):i(``,!0),e.hash?(u(),l(`span`,F,` Hash: `+o(e.hash),1)):i(``,!0)]),e.last_seen==null?i(``,!0):(u(),l(`p`,I,` Last seen: `+o(X(e.last_seen)),1))],64)):(u(),l(s,{key:1},[c(`div`,L,[c(`div`,null,[r[10]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Max Clients `,-1),c(`div`,R,o($(e.max_clients)),1)]),c(`div`,null,[r[11]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Authenticated `,-1),c(`div`,ge,o($(e.authenticated_clients)),1)]),c(`div`,null,[r[12]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Admin Password `,-1),c(`div`,{class:n(e.has_admin_password?`text-green-700 dark:text-green-500 dark:text-accent-green`:`text-red-500 dark:text-accent-red`)},o(e.has_admin_password==null?`N/A`:e.has_admin_password?`✓ Set`:`✗ Not Set`),3)]),c(`div`,null,[r[13]||=c(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Guest Password `,-1),c(`div`,{class:n(e.has_guest_password?`text-green-700 dark:text-green-500 dark:text-accent-green`:`text-red-500 dark:text-accent-red`)},o(e.has_guest_password==null?`N/A`:e.has_guest_password?`✓ Set`:`✗ Not Set`),3)])]),c(`div`,z,[r[14]||=c(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`Read-Only Access:`,-1),c(`span`,{class:n(e.allow_read_only?`text-green-700 dark:text-green-500 dark:text-accent-green`:`text-red-500 dark:text-accent-red`)},o(e.allow_read_only==null?`N/A`:e.allow_read_only?`Allowed`:`Disabled`),3)])],64))])])]))),128))]))])):B.value===`clients`?(u(),l(`div`,_e,[G.value.length===0?(u(),l(`div`,ve,` No authenticated clients `)):(u(),l(`div`,ye,[c(`table`,be,[r[15]||=c(`thead`,null,[c(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Client `),c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Address `),c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Identity `),c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Permissions `),c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Last Activity `),c(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Actions `)])],-1),c(`tbody`,null,[(u(!0),l(s,null,e(G.value,e=>(u(),l(`tr`,{key:e.public_key_full,class:`border-b border-stroke-subtle dark:border-white/5 hover:bg-gray-100/50 dark:hover:bg-white/5 transition-colors`},[c(`td`,xe,[c(`div`,Se,o(e.public_key),1)]),c(`td`,Ce,[c(`div`,we,o(e.address),1)]),c(`td`,Te,[c(`div`,Ee,o(e.identity_name),1),c(`div`,De,o(e.identity_hash),1)]),c(`td`,Oe,[c(`span`,{class:n([`px-2 py-1 text-xs font-medium rounded`,e.permissions===`admin`?`bg-green-100 dark:bg-green-500/20 dark:bg-accent-green/20 text-green-700 dark:text-accent-green`:`bg-yellow-100 dark:bg-yellow-500/20 dark:bg-secondary/20 text-yellow-700 dark:text-secondary`])},o(e.permissions),3)]),c(`td`,ke,[c(`div`,Ae,o(X(e.last_activity)),1)]),c(`td`,je,[c(`button`,{onClick:t=>Y(e.public_key_full,e.identity_hash),class:`px-3 py-1 bg-red-100 dark:bg-red-500/20 dark:bg-accent-red/20 hover:bg-red-500/30 dark:hover:bg-accent-red/30 text-red-600 dark:text-accent-red rounded text-xs transition-colors`},` Remove `,8,Me)])]))),128))])])]))])):B.value===`identities`?(u(),l(`div`,Ne,[c(`div`,Pe,[r[17]||=c(`label`,{class:`block text-content-secondary dark:text-content-muted text-sm mb-2`},`Filter by Identity`,-1),ee(c(`select`,{"onUpdate:modelValue":r[0]||=e=>q.value=e,class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-cyan-500 dark:focus:border-primary/50 transition-colors`},[r[16]||=c(`option`,{value:null},`All Identities`,-1),(u(!0),l(s,null,e(Q.value,e=>(u(),l(`option`,{key:e.name,value:e.name},o(e.name)+` (`+o(e.authenticated_clients??0)+` clients) `,9,Fe))),128))],512),[[ne,q.value]])]),Z.value.length===0?(u(),l(`div`,Ie,` No clients for selected identity `)):(u(),l(`div`,Le,[(u(!0),l(s,null,e(Z.value,e=>(u(),l(`div`,{key:e.public_key_full,class:`glass-card rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10`},[c(`div`,Re,[c(`div`,ze,[c(`div`,Be,[c(`span`,{class:n([`px-2 py-1 text-xs font-medium rounded`,e.permissions===`admin`?`bg-green-100 dark:bg-green-500/20 dark:bg-accent-green/20 text-green-700 dark:text-accent-green`:`bg-yellow-100 dark:bg-yellow-500/20 dark:bg-secondary/20 text-yellow-700 dark:text-secondary`])},o(e.permissions),3),c(`span`,Ve,o(e.public_key),1)]),c(`div`,He,[c(`div`,null,[r[18]||=c(`span`,{class:`text-content-secondary dark:text-content-muted`},`Address:`,-1),c(`span`,Ue,o(e.address),1)]),c(`div`,null,[r[19]||=c(`span`,{class:`text-content-secondary dark:text-content-muted`},`Identity:`,-1),c(`span`,We,o(e.identity_name)+` (`+o(e.identity_hash)+`)`,1)]),c(`div`,null,[r[20]||=c(`span`,{class:`text-content-secondary dark:text-content-muted`},`Last Activity:`,-1),c(`span`,Ge,o(X(e.last_activity)),1)]),c(`div`,null,[r[21]||=c(`span`,{class:`text-content-secondary dark:text-content-muted`},`Last Login:`,-1),c(`span`,Ke,o(X(e.last_login_success)),1)])])]),c(`button`,{onClick:t=>Y(e.public_key_full,e.identity_hash),class:`ml-4 px-3 py-1 bg-red-100 dark:bg-red-500/20 dark:bg-accent-red/20 hover:bg-red-500/30 dark:hover:bg-accent-red/30 text-red-600 dark:text-accent-red rounded text-xs transition-colors`},` Remove `,8,qe)])]))),128))]))])):i(``,!0)])]),c(`div`,Je,[c(`button`,{onClick:J,disabled:H.value,class:`px-4 py-2 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-primary rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors disabled:opacity-50`},o(H.value?`Refreshing...`:`Refresh Data`),9,Ye)])]))}});export{B as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Sessions-XCAfIBGI.js b/repeater/web/html/assets/Sessions-XCAfIBGI.js new file mode 100644 index 00000000..daaea426 --- /dev/null +++ b/repeater/web/html/assets/Sessions-XCAfIBGI.js @@ -0,0 +1 @@ +import{Ct as e,E as t,V as n,Y as r,g as ee,j as i,k as a,l as o,m as te,o as s,p as ne,r as c,s as l,u,xt as d}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{o as re}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as f}from"./api-3gMnsCKh.js";import{t as ie}from"./Spinner-CcYauG9D.js";var ae={class:`p-6 space-y-6`},oe={key:0,class:`grid grid-cols-1 md:grid-cols-4 gap-4`},se={class:`glass-card rounded-[15px] p-4`},ce={class:`text-2xl font-bold text-content-primary dark:text-content-primary`},le={class:`glass-card rounded-[15px] p-4`},ue={class:`text-2xl font-bold text-primary`},de={class:`glass-card rounded-[15px] p-4`},fe={class:`text-2xl font-bold text-accent-green`},pe={class:`glass-card rounded-[15px] p-4`},me={class:`text-2xl font-bold text-secondary`},he={class:`glass-card rounded-[15px] p-6`},p={class:`flex flex-wrap border-b border-stroke-subtle dark:border-stroke/10 mb-6`},m=[`onClick`],h={class:`flex items-center gap-2`},g={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},_={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},v={key:2,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},y={class:`min-h-[400px]`},b={key:0,class:`flex items-center justify-center py-12`},x={class:`text-center`},S={key:1,class:`flex items-center justify-center py-12`},C={class:`text-center`},w={class:`text-content-secondary dark:text-content-muted text-sm mb-4`},T={key:2,class:`space-y-4`},E={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},D={key:1,class:`space-y-4`},O={class:`flex items-start justify-between`},k={class:`flex-1 min-w-0`},A={class:`flex items-center gap-2 flex-wrap mb-3`},j={class:`text-lg font-semibold text-content-primary dark:text-content-primary truncate`},M={class:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`},N={key:0,class:`flex items-center gap-1.5`},P={class:`text-content-secondary dark:text-content-muted`},F={key:1,class:`flex items-center gap-1.5`},I={class:`text-content-secondary dark:text-content-muted`},L={key:2,class:`text-content-secondary dark:text-content-muted font-mono text-xs`},R={key:3,class:`text-content-muted dark:text-content-muted font-mono text-xs`},ge={key:0,class:`text-content-muted dark:text-content-muted text-xs mt-2 mb-0`},_e={class:`grid grid-cols-2 md:grid-cols-4 gap-4 mt-4`},ve={class:`text-content-primary dark:text-content-primary font-medium`},ye={class:`text-primary font-medium`},be={class:`mt-3 flex items-center gap-2`},xe={key:3,class:`space-y-4`},Se={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},Ce={key:1,class:`overflow-x-auto`},we={class:`w-full`},z={class:`py-3`},Te={class:`font-mono text-sm text-content-primary dark:text-content-primary`},Ee={class:`py-3`},De={class:`font-mono text-xs text-content-secondary dark:text-content-muted`},Oe={class:`py-3`},ke={class:`text-sm text-content-primary dark:text-content-primary`},Ae={class:`text-xs text-content-muted dark:text-content-muted`},je={class:`py-3`},Me={class:`py-3`},Ne={class:`text-sm text-content-secondary dark:text-content-muted`},Pe={class:`py-3`},Fe=[`onClick`],Ie={key:4,class:`space-y-4`},Le={class:`mb-4`},Re=[`value`],ze={key:0,class:`text-center py-12 text-content-secondary dark:text-content-muted`},Be={key:1,class:`grid grid-cols-1 gap-4`},Ve={class:`flex items-start justify-between`},He={class:`flex-1`},Ue={class:`flex items-center gap-3 mb-3`},We={class:`text-content-primary dark:text-content-primary font-mono text-sm`},Ge={class:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm`},Ke={class:`text-content-primary dark:text-content-primary/90 font-mono ml-2`},qe={class:`text-content-primary dark:text-content-primary/90 ml-2`},Je={class:`text-content-primary dark:text-content-primary/90 ml-2`},Ye={class:`text-content-primary dark:text-content-primary/90 ml-2`},Xe=[`onClick`],Ze={class:`flex justify-end`},Qe=[`disabled`],B=ee({name:`SessionsView`,__name:`Sessions`,setup(ee){let B=r(`overview`),V=r(!1),H=r(!1),U=r(null),W=r(null),G=r([]),K=r(null),q=r(null),$e=[{id:`overview`,label:`Overview`,icon:`overview`},{id:`clients`,label:`Authenticated Clients`,icon:`clients`},{id:`identities`,label:`By Identity`,icon:`identities`}];t(async()=>{await J(),V.value=!0});async function J(){H.value=!0,U.value=null;try{let e=await f.getACLInfo();e.success&&(W.value=e.data);let t=await f.getACLClients();t.success&&t.data&&(G.value=t.data.clients||[]);let n=await f.getACLStats();n.success&&(K.value=n.data)}catch(e){U.value=e instanceof Error?e.message:`Failed to load ACL data`,console.error(`Error fetching ACL data:`,e)}finally{H.value=!1}}async function Y(e,t){if(confirm(`Are you sure you want to remove this client from the ACL?`))try{let n=await f.removeACLClient({public_key:e,identity_hash:t});n.success?await J():alert(`Failed to remove client: ${n.error}`)}catch(e){alert(`Error removing client: ${e}`)}}function X(e){return e?new Date(e*1e3).toLocaleString():`Never`}function et(e){B.value=e}let Z=s(()=>q.value?G.value.filter(e=>e.identity_name===q.value):G.value),Q=s(()=>W.value&&W.value.acls||[]);function tt(e){return e?.type===`companion`}function nt(e){return e===`repeater`?`bg-primary/20 text-primary`:e===`companion`?`bg-accent-purple/20 text-accent-purple`:`bg-secondary/20 text-secondary`}function $(e){return e==null?`N/A`:typeof e==`boolean`?e?`✓`:`✗`:String(e)}return(t,r)=>(a(),u(`div`,ae,[r[22]||=l(`div`,null,[l(`h1`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` Sessions & Access Control `),l(`p`,{class:`text-content-secondary dark:text-content-muted mt-2`},` Manage authenticated clients and access control lists `),l(`p`,{class:`text-content-muted dark:text-content-muted text-sm mt-1`},` Repeater, room servers, and companion identities; companions do not accept client logins. `)],-1),K.value?(a(),u(`div`,oe,[l(`div`,se,[r[1]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},` Total Identities `,-1),l(`div`,ce,e(K.value.total_identities),1)]),l(`div`,le,[r[2]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},` Authenticated Clients `,-1),l(`div`,ue,e(K.value.total_clients),1)]),l(`div`,de,[r[3]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},`Admin Clients`,-1),l(`div`,fe,e(K.value.admin_clients),1)]),l(`div`,pe,[r[4]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-sm mb-1`},`Guest Clients`,-1),l(`div`,me,e(K.value.guest_clients),1)])])):o(``,!0),l(`div`,he,[l(`div`,p,[(a(),u(c,null,i($e,t=>l(`button`,{key:t.id,onClick:e=>et(t.id),class:d([`px-4 py-2 text-sm font-medium transition-colors duration-200 border-b-2 mr-6 mb-2`,B.value===t.id?`text-primary border-primary`:`text-content-secondary dark:text-content-muted border-transparent hover:text-content-primary dark:hover:text-content-primary hover:border-stroke-subtle dark:hover:border-stroke/30`])},[l(`div`,h,[t.icon===`overview`?(a(),u(`svg`,g,[...r[5]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z`},null,-1)]])):t.icon===`clients`?(a(),u(`svg`,_,[...r[6]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z`},null,-1)]])):t.icon===`identities`?(a(),u(`svg`,v,[...r[7]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 6H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V8a2 2 0 00-2-2h-5m-4 0V5a2 2 0 114 0v1m-4 0a2 2 0 104 0m-5 8a2 2 0 100-4 2 2 0 000 4zm0 0c1.306 0 2.417.835 2.83 2M9 14a3.001 3.001 0 00-2.83 2M15 11h3m-3 4h2`},null,-1)]])):o(``,!0),ne(` `+e(t.label),1)])],10,m)),64))]),l(`div`,y,[H.value&&!V.value?(a(),u(`div`,b,[l(`div`,x,[te(ie,{class:`mx-auto mb-4`}),r[8]||=l(`div`,{class:`text-content-secondary dark:text-content-muted`},`Loading ACL data...`,-1)])])):U.value?(a(),u(`div`,S,[l(`div`,C,[r[9]||=l(`div`,{class:`text-accent-red mb-2`},`Failed to load ACL data`,-1),l(`div`,w,e(U.value),1),l(`button`,{onClick:J,class:`btn-primary`},` Retry `)])])):B.value===`overview`?(a(),u(`div`,T,[Q.value.length===0?(a(),u(`div`,E,` No identities configured `)):(a(),u(`div`,D,[(a(!0),u(c,null,i(Q.value,t=>(a(),u(`div`,{key:t.hash,class:`glass-card rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10 hover:border-primary/30 transition-colors`},[l(`div`,O,[l(`div`,k,[l(`div`,A,[l(`h3`,j,e(t.name),1),l(`span`,{class:d([`px-2 py-0.5 text-xs font-medium rounded shrink-0`,nt(t.type)])},e(t.type),3)]),tt(t)?(a(),u(c,{key:0},[l(`div`,M,[t.registered===void 0?o(``,!0):(a(),u(`span`,N,[l(`span`,{class:d([`w-2 h-2 rounded-full shrink-0`,t.registered?`bg-accent-green`:`bg-accent-red`]),"aria-hidden":``},null,2),l(`span`,P,`Registered: `+e(t.registered?`Active`:`Inactive`),1)])),t.active===void 0?o(``,!0):(a(),u(`span`,F,[l(`span`,{class:d([`w-2 h-2 rounded-full shrink-0`,t.active?`bg-accent-green`:`bg-accent-red`]),"aria-hidden":``},null,2),l(`span`,I,`Bridge: `+e(t.active?`Connected`:`Disconnected`),1)])),t.client_ip?(a(),u(`span`,L,` Client: `+e(t.client_ip),1)):o(``,!0),t.hash?(a(),u(`span`,R,` Hash: `+e(t.hash),1)):o(``,!0)]),t.last_seen==null?o(``,!0):(a(),u(`p`,ge,` Last seen: `+e(X(t.last_seen)),1))],64)):(a(),u(c,{key:1},[l(`div`,_e,[l(`div`,null,[r[10]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Max Clients `,-1),l(`div`,ve,e($(t.max_clients)),1)]),l(`div`,null,[r[11]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Authenticated `,-1),l(`div`,ye,e($(t.authenticated_clients)),1)]),l(`div`,null,[r[12]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Admin Password `,-1),l(`div`,{class:d(t.has_admin_password?`text-accent-green`:`text-accent-red`)},e(t.has_admin_password==null?`N/A`:t.has_admin_password?`✓ Set`:`✗ Not Set`),3)]),l(`div`,null,[r[13]||=l(`div`,{class:`text-content-secondary dark:text-content-muted text-xs mb-1`},` Guest Password `,-1),l(`div`,{class:d(t.has_guest_password?`text-accent-green`:`text-accent-red`)},e(t.has_guest_password==null?`N/A`:t.has_guest_password?`✓ Set`:`✗ Not Set`),3)])]),l(`div`,be,[r[14]||=l(`span`,{class:`text-content-secondary dark:text-content-muted text-xs`},`Read-Only Access:`,-1),l(`span`,{class:d(t.allow_read_only?`text-accent-green`:`text-accent-red`)},e(t.allow_read_only==null?`N/A`:t.allow_read_only?`Allowed`:`Disabled`),3)])],64))])])]))),128))]))])):B.value===`clients`?(a(),u(`div`,xe,[G.value.length===0?(a(),u(`div`,Se,` No authenticated clients `)):(a(),u(`div`,Ce,[l(`table`,we,[r[15]||=l(`thead`,null,[l(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Client `),l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Address `),l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Identity `),l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Permissions `),l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Last Activity `),l(`th`,{class:`text-left text-content-secondary dark:text-content-muted text-sm font-medium pb-3`},` Actions `)])],-1),l(`tbody`,null,[(a(!0),u(c,null,i(G.value,t=>(a(),u(`tr`,{key:t.public_key_full,class:`border-b border-stroke-subtle dark:border-white/5 hover:bg-gray-100/50 dark:hover:bg-white/5 transition-colors`},[l(`td`,z,[l(`div`,Te,e(t.public_key),1)]),l(`td`,Ee,[l(`div`,De,e(t.address),1)]),l(`td`,Oe,[l(`div`,ke,e(t.identity_name),1),l(`div`,Ae,e(t.identity_hash),1)]),l(`td`,je,[l(`span`,{class:d([`px-2 py-1 text-xs font-medium rounded`,t.permissions===`admin`?`bg-accent-green/20 text-accent-green`:`bg-secondary/20 text-secondary`])},e(t.permissions),3)]),l(`td`,Me,[l(`div`,Ne,e(X(t.last_activity)),1)]),l(`td`,Pe,[l(`button`,{onClick:e=>Y(t.public_key_full,t.identity_hash),class:`btn-danger-xs`},` Remove `,8,Fe)])]))),128))])])]))])):B.value===`identities`?(a(),u(`div`,Ie,[l(`div`,Le,[r[17]||=l(`label`,{class:`block text-content-secondary dark:text-content-muted text-sm mb-2`},`Filter by Identity`,-1),n(l(`select`,{"onUpdate:modelValue":r[0]||=e=>q.value=e,class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-2 text-content-primary dark:text-content-primary focus:outline-none focus:border-primary/50 transition-colors`},[r[16]||=l(`option`,{value:null},`All Identities`,-1),(a(!0),u(c,null,i(Q.value,t=>(a(),u(`option`,{key:t.name,value:t.name},e(t.name)+` (`+e(t.authenticated_clients??0)+` clients) `,9,Re))),128))],512),[[re,q.value]])]),Z.value.length===0?(a(),u(`div`,ze,` No clients for selected identity `)):(a(),u(`div`,Be,[(a(!0),u(c,null,i(Z.value,t=>(a(),u(`div`,{key:t.public_key_full,class:`glass-card rounded-[10px] p-4 border border-stroke-subtle dark:border-white/10`},[l(`div`,Ve,[l(`div`,He,[l(`div`,Ue,[l(`span`,{class:d([`px-2 py-1 text-xs font-medium rounded`,t.permissions===`admin`?`bg-accent-green/20 text-accent-green`:`bg-secondary/20 text-secondary`])},e(t.permissions),3),l(`span`,We,e(t.public_key),1)]),l(`div`,Ge,[l(`div`,null,[r[18]||=l(`span`,{class:`text-content-secondary dark:text-content-muted`},`Address:`,-1),l(`span`,Ke,e(t.address),1)]),l(`div`,null,[r[19]||=l(`span`,{class:`text-content-secondary dark:text-content-muted`},`Identity:`,-1),l(`span`,qe,e(t.identity_name)+` (`+e(t.identity_hash)+`)`,1)]),l(`div`,null,[r[20]||=l(`span`,{class:`text-content-secondary dark:text-content-muted`},`Last Activity:`,-1),l(`span`,Je,e(X(t.last_activity)),1)]),l(`div`,null,[r[21]||=l(`span`,{class:`text-content-secondary dark:text-content-muted`},`Last Login:`,-1),l(`span`,Ye,e(X(t.last_login_success)),1)])])]),l(`button`,{onClick:e=>Y(t.public_key_full,t.identity_hash),class:`ml-4 btn-danger-xs`},` Remove `,8,Xe)])]))),128))]))])):o(``,!0)])]),l(`div`,Ze,[l(`button`,{onClick:J,disabled:H.value,class:`btn-primary`},e(H.value?`Refreshing...`:`Refresh Data`),9,Qe)])]))}});export{B as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Setup-BFlxpW4p.css b/repeater/web/html/assets/Setup-BFlxpW4p.css new file mode 100644 index 00000000..9010914f --- /dev/null +++ b/repeater/web/html/assets/Setup-BFlxpW4p.css @@ -0,0 +1 @@ +.glass-card[data-v-969cd812]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#ffffff0d;border:1px solid #ffffff1a}.modal-enter-active[data-v-969cd812],.modal-leave-active[data-v-969cd812]{transition:opacity .3s}.modal-enter-from[data-v-969cd812],.modal-leave-to[data-v-969cd812]{opacity:0}.modal-enter-active .glass-card[data-v-969cd812],.modal-leave-active .glass-card[data-v-969cd812]{transition:transform .3s}.modal-enter-from .glass-card[data-v-969cd812],.modal-leave-to .glass-card[data-v-969cd812]{transform:scale(.9)}.slide-enter-active[data-v-969cd812],.slide-leave-active[data-v-969cd812]{transition:all .3s}.slide-enter-from[data-v-969cd812],.slide-leave-to[data-v-969cd812]{opacity:0;transform:translateY(-10px)}@keyframes float-slow-969cd812{0%,to{opacity:.8;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.6;transform:translate(20px,-20px)scale(1.05)rotate(-24.22deg)}}@keyframes float-slower-969cd812{0%,to{opacity:.75;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.5;transform:translate(-30px,20px)scale(1.08)rotate(-24.22deg)}}@keyframes float-slowest-969cd812{0%,to{opacity:.8;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.55;transform:translate(25px,25px)scale(1.1)rotate(-24.22deg)}}.animate-pulse-slow[data-v-969cd812]{will-change:transform, opacity;animation:15s ease-in-out infinite float-slow-969cd812}.animate-pulse-slower[data-v-969cd812]{will-change:transform, opacity;animation:18s ease-in-out infinite float-slower-969cd812}.animate-pulse-slowest[data-v-969cd812]{will-change:transform, opacity;animation:20s ease-in-out infinite float-slowest-969cd812} diff --git a/repeater/web/html/assets/Setup-CaLinAtC.js b/repeater/web/html/assets/Setup-CaLinAtC.js new file mode 100644 index 00000000..ee0e3ab5 --- /dev/null +++ b/repeater/web/html/assets/Setup-CaLinAtC.js @@ -0,0 +1 @@ +import{B as e,Ct as t,E as n,R as r,S as ee,St as te,V as i,Y as a,c as o,f as ne,g as re,j as s,k as c,l,m as u,nt as d,o as f,p,r as m,s as h,u as g,xt as _}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{i as ie,o as v,s as y,t as b,u as ae}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as oe}from"./api-3gMnsCKh.js";import{t as x}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as se}from"./Spinner-CcYauG9D.js";import{n as ce,r as le}from"./index-DTUpsCzx.js";import{n as S,r as ue,t as de}from"./TxPowerNoticeModal-DLQEpbGj.js";var fe=S(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),pe=S(`usb`,[[`circle`,{cx:`10`,cy:`7`,r:`1`,key:`dypaad`}],[`circle`,{cx:`4`,cy:`20`,r:`1`,key:`22iqad`}],[`path`,{d:`M4.7 19.3 19 5`,key:`1enqfc`}],[`path`,{d:`m21 3-3 1 2 2Z`,key:`d3ov82`}],[`path`,{d:`M9.26 7.68 5 12l2 5`,key:`1esawj`}],[`path`,{d:`m10 14 5 2 3.5-3.5`,key:`v8oal5`}],[`path`,{d:`m18 12 1-1 1 1-1 1Z`,key:`1bh22v`}]]),me=S(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),he={class:`min-h-screen bg-background dark:bg-background overflow-hidden relative flex items-center justify-center p-4`},ge={class:`absolute top-4 right-4 z-20`},_e={class:`w-full max-w-4xl relative z-10`},ve={class:`mb-8`},ye={class:`flex justify-between mb-2`},C={class:`text-content-secondary dark:text-content-muted text-sm`},w={class:`text-content-secondary dark:text-content-muted text-sm`},T={class:`h-2 bg-stroke-subtle dark:bg-stroke/10 rounded-full overflow-hidden`},E={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[20px] p-6 sm:p-8 md:p-12`},D={class:`flex justify-center mb-8`},O={class:`flex gap-2`},k={class:`mb-8`},A={class:`text-2xl sm:text-3xl font-bold text-content-primary dark:text-content-primary mb-2 text-center`},j={key:0,class:`space-y-6 mt-8`},M={key:1,class:`space-y-6 mt-8`},N={class:`max-w-md mx-auto`},P={key:2,class:`space-y-6 mt-8`},be={class:`grid grid-cols-1 md:grid-cols-3 gap-4 max-w-5xl mx-auto`},xe=[`onClick`],Se={class:`font-semibold text-lg text-content-primary dark:text-content-primary mb-2`},Ce={class:`text-sm text-content-secondary dark:text-content-muted`},we={key:3,class:`mt-8`},Te={key:0,class:`text-center text-content-secondary dark:text-content-muted`},Ee={key:1,class:`text-center text-content-secondary dark:text-content-muted`},De={key:2,class:`text-center text-content-secondary dark:text-content-muted`},Oe={key:3,class:`max-w-3xl mx-auto space-y-8`},ke={class:`flex items-center gap-3 mb-4`},Ae={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},je={key:1},Me={class:`grid grid-cols-1 md:grid-cols-2 gap-3 pl-10`},Ne=[`onClick`],Pe={class:`flex items-start justify-between gap-2`},Fe={class:`font-medium text-content-primary dark:text-content-primary mb-1`},Ie={class:`text-sm text-content-secondary dark:text-content-muted`},Le={key:0,class:`text-primary flex-shrink-0 mt-0.5`},Re={key:0},ze={key:0,class:`pl-10`},Be={class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] p-5 space-y-4`},Ve={class:`space-y-2`},He={class:`flex gap-2`},Ue=[`disabled`],We=[`value`],Ge=[`value`],Ke=[`disabled`],qe={class:`flex items-center gap-2 text-xs text-content-secondary dark:text-content-muted`},Je={key:1,class:`text-xs text-red-600 dark:text-red-400`},Ye={key:1,class:`pl-10`},Xe={class:`bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] p-5 space-y-4`},Ze={class:`grid grid-cols-2 gap-4`},Qe={key:4,class:`space-y-6 mt-8`},$e={key:0,class:`text-center text-content-secondary dark:text-content-muted`},et={key:1,class:`text-center text-content-secondary dark:text-content-muted`},tt={key:2,class:`max-w-5xl mx-auto`},nt={class:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-4`},rt=[`onClick`],it={class:`relative z-10`},at={class:`font-medium text-content-primary dark:text-content-primary mb-1 flex items-start justify-between gap-2`},ot={class:`flex items-center gap-2`},st={class:`text-2xl`},ct={key:0,class:`text-primary flex-shrink-0`},lt={class:`text-xs text-content-secondary dark:text-content-muted mb-3`},ut={class:`grid grid-cols-2 gap-2 text-xs`},dt={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},ft={class:`text-content-primary dark:text-content-primary/80 font-medium`},pt={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},mt={class:`text-content-primary dark:text-content-primary/80 font-medium`},ht={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},gt={class:`text-content-primary dark:text-content-primary/80 font-medium`},_t={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},vt={class:`text-content-primary dark:text-content-primary/80 font-medium`},yt={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1 col-span-2`},bt={class:`text-content-primary dark:text-content-primary/80 font-medium`},xt={class:`border-t border-stroke-subtle dark:border-stroke/10 pt-6`},St={class:`flex items-center justify-between mb-2`},Ct={key:0,class:`text-primary`},wt={key:0,class:`mt-4 grid grid-cols-2 gap-4`},Tt={class:`col-span-2 sm:col-span-1`},Et={key:5,class:`space-y-6 mt-8`},Dt={class:`max-w-md mx-auto space-y-4`},Ot={key:0,class:`text-red-600 dark:text-red-400 text-sm`},kt={key:0,class:`mb-6 bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-600 dark:text-red-200`},At={class:`flex justify-between gap-4`},jt={key:1},Mt=[`disabled`],Nt={key:1},Pt={key:2},Ft={key:3},It={key:4,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Lt={class:`text-2xl font-bold text-content-primary dark:text-content-primary text-center mb-4`},Rt={class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},F=x(re({name:`SetupView`,__name:`Setup`,setup(re){let x=ue(),S=a(!1),F=a(``),I=a(``),zt=a(`error`),L=a(!1),R=a([]),z=a(!1),B=a(``),V=a(!1),H=a(!1),U=a(!1),W=a(!1),G=a(null),K=f(()=>{if(x.useCustomRadio){let e=Number(x.customRadio.tx_power);return Number.isFinite(e)?e:null}let e=Number(x.selectedRadioPreset?.tx_power??14);return Number.isFinite(e)?e:14});function Bt(){return x.selectedHardware?.key?.toLowerCase()??``}function Vt(){let e=Bt();return e===`kiss`||e===`pymc_usb`}async function q(){z.value=!0,B.value=``;try{let e=await oe.getSerialPorts();e.success&&Array.isArray(e.data)?R.value=e.data:(R.value=[],B.value=e.error||`Could not load USB serial devices`)}catch(e){let t=e;R.value=[],B.value=t.message||`Could not load USB serial devices`}finally{z.value=!1}}let Ht=e=>{let t=e.toLowerCase();return t.includes(`australia`)?`🇦🇺`:t.includes(`eu`)||t.includes(`uk`)?`🇪🇺`:t.includes(`czech`)?`🇨🇿`:t.includes(`new zealand`)?`🇳🇿`:t.includes(`portugal`)?`🇵🇹`:t.includes(`switzerland`)?`🇨🇭`:t.includes(`usa`)||t.includes(`canada`)?`🇺🇸`:t.includes(`vietnam`)?`🇻🇳`:`🌍`};n(async()=>{await Promise.all([x.fetchHardwareOptions(),x.fetchRadioPresets(),q()])}),r(()=>x.selectedHardware?.key,()=>{Vt()?q():V.value=!1}),r([()=>x.useCustomRadio,()=>x.selectedRadioPreset?.title,()=>x.customRadio.tx_power],()=>{W.value=!1,U.value=!1});let J=f(()=>x.currentStep/x.totalSteps*100),Ut=[{key:`gpio`,title:`HAT GPIO Based Device`,description:`Direct SPI/GPIO connected HATs and board-integrated radios.`},{key:`usb`,title:`USB Connection`,description:`USB-attached modems including CH341 and pyMC USB modem.`},{key:`network`,title:`Network Wi-Fi Based`,description:`Remote modem reached over LAN/Wi-Fi using pyMC TCP.`}];function Y(e){let t=e.key.toLowerCase();if(t===`kiss`)return`usb`;let n=String(e.config?.connection_type||``).toLowerCase();return n===`usb`||n===`network`||n===`gpio`?n:t.includes(`ch341`)||t===`pymc_usb`?`usb`:t===`pymc_tcp`?`network`:`gpio`}let X=f(()=>{let e=x.selectedHardwareConnection;return e?x.hardwareOptions.filter(t=>Y(t)===e):[]});function Wt(e){x.selectedHardwareConnection=e,x.selectedHardware&&!X.value.some(e=>e.key===x.selectedHardware?.key)&&(x.selectedHardware=null)}function Z(){ee(()=>{G.value?.scrollIntoView({behavior:`smooth`,block:`center`})})}async function Q(){if(x.currentStep===5&&x.canGoNext&&!W.value&&K.value!==null){H.value=!0;return}if(x.isLastStep){let e=await x.completeSetup();e.success?L.value=!0:(zt.value=`error`,F.value=`Setup Failed`,I.value=e.error||`An unknown error occurred`,S.value=!0)}else x.nextStep()}function Gt(){H.value=!1,U.value=!1}async function Kt(){U.value&&(W.value=!0,H.value=!1,await Q())}function qt(){x.previousStep()}function $(){S.value=!1}let Jt=[`Welcome`,`Repeater Name`,`Connection Type`,`Hardware & Connection`,`Radio Configuration`,`Security Setup`];return(n,r)=>(c(),g(`div`,he,[h(`div`,ge,[u(le)]),r[61]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slow -top-[79px] left-[575px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),r[62]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-75 animate-pulse-slower -top-[94px] -left-[92px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),r[63]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slowest top-[373px] left-[246px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),h(`div`,_e,[h(`div`,ve,[h(`div`,ye,[h(`span`,C,`Step `+t(d(x).currentStep)+` of `+t(d(x).totalSteps),1),h(`span`,w,t(Math.round(J.value))+`% Complete`,1)]),h(`div`,T,[h(`div`,{class:`h-full bg-gradient-to-r from-primary to-primary/80 transition-all duration-500`,style:te({width:`${J.value}%`})},null,4)])]),h(`div`,E,[h(`div`,D,[h(`div`,O,[(c(!0),g(m,null,s(d(x).totalSteps,e=>(c(),g(`div`,{key:e,class:_([`w-10 h-10 rounded-full flex items-center justify-center text-sm font-medium transition-all`,e===d(x).currentStep?`bg-primary text-white`:e

Welcome to your pyMC Repeater! Let's get you set up in just a few steps.

You'll configure:

  • Repeater name and identification
  • Hardware board selection
  • Radio frequency and settings
  • Admin password for secure access
`,1)]])):d(x).currentStep===2?(c(),g(`div`,M,[r[22]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Choose a unique name for your repeater. This will be used for identification on the mesh network. `,-1),h(`div`,N,[r[20]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Repeater Name`,-1),i(h(`input`,{"onUpdate:modelValue":r[0]||=e=>d(x).nodeName=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`e.g., pyRpt0001`,maxlength:`32`},null,512),[[y,d(x).nodeName]]),r[21]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-2`},` Use letters, numbers, hyphens, or underscores (3-32 characters) `,-1)])])):d(x).currentStep===3?(c(),g(`div`,P,[r[23]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Choose how your radio hardware connects to this repeater. `,-1),h(`div`,be,[(c(),g(m,null,s(Ut,e=>h(`button`,{key:e.key,onClick:t=>Wt(e.key),class:_([`p-6 rounded-[16px] border transition-all duration-300 text-left backdrop-blur-sm min-h-[220px] flex flex-col`,d(x).selectedHardwareConnection===e.key?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,{class:_([`mb-5 w-16 h-16 rounded-2xl flex items-center justify-center border transition-all duration-300`,d(x).selectedHardwareConnection===e.key?`bg-primary/20 border-primary/40 shadow-md shadow-primary/20`:`bg-white/60 dark:bg-white/10 border-stroke-subtle dark:border-stroke/20`])},[e.key===`gpio`?(c(),o(d(fe),{key:0,class:`w-9 h-9 text-primary`,"stroke-width":1.8})):e.key===`usb`?(c(),o(d(pe),{key:1,class:`w-9 h-9 text-primary`,"stroke-width":1.8})):(c(),o(d(me),{key:2,class:`w-9 h-9 text-primary`,"stroke-width":1.8}))],2),h(`div`,Se,t(e.title),1),h(`div`,Ce,t(e.description),1)],10,xe)),64))])])):d(x).currentStep===4?(c(),g(`div`,we,[d(x).isLoading?(c(),g(`div`,Te,` Loading hardware options... `)):d(x).selectedHardwareConnection?X.value.length===0?(c(),g(`div`,De,` No hardware options available for this connection type `)):(c(),g(`div`,Oe,[h(`div`,null,[h(`div`,ke,[h(`div`,{class:_([`w-7 h-7 rounded-full flex items-center justify-center text-sm font-semibold flex-shrink-0 transition-all`,(d(x).selectedHardware,`bg-primary text-white`)])},[d(x).selectedHardware?(c(),g(`svg`,Ae,[...r[24]||=[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`},null,-1)]])):(c(),g(`span`,je,`1`))],2),r[25]||=h(`h3`,{class:`font-semibold text-content-primary dark:text-content-primary`},`Select your hardware board`,-1)]),h(`div`,Me,[(c(!0),g(m,null,s(X.value,e=>(c(),g(`button`,{key:e.key,onClick:t=>{d(x).selectedHardware=e,Z()},class:_([`p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm`,d(x).selectedHardware?.key===e.key?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,Pe,[h(`div`,null,[h(`div`,Fe,t(e.name),1),h(`div`,Ie,t(e.description||e.key),1)]),d(x).selectedHardware?.key===e.key?(c(),g(`div`,Le,[...r[26]||=[h(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 20 20`},[h(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,"clip-rule":`evenodd`})],-1)]])):l(``,!0)])],10,Ne))),128))])]),u(b,{name:`slide`},{default:e(()=>[d(x).selectedHardware&&(d(x).selectedHardware.key.toLowerCase()===`kiss`||d(x).selectedHardware.key.toLowerCase()===`pymc_usb`||d(x).selectedHardware.key.toLowerCase()===`pymc_tcp`)?(c(),g(`div`,Re,[r[36]||=h(`div`,{class:`flex items-center gap-3 mb-4`},[h(`div`,{class:`w-7 h-7 rounded-full bg-primary text-white flex items-center justify-center text-sm font-semibold flex-shrink-0`},` 2 `),h(`h3`,{class:`font-semibold text-content-primary dark:text-content-primary`},` Configure the connection to your modem `)],-1),d(x).selectedHardware.key.toLowerCase()===`kiss`||d(x).selectedHardware.key.toLowerCase()===`pymc_usb`?(c(),g(`div`,ze,[h(`div`,Be,[h(`div`,null,[r[28]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-1.5`},` Serial Port `,-1),h(`div`,Ve,[h(`div`,He,[i(h(`select`,{"onUpdate:modelValue":r[1]||=e=>d(x).usbPort=e,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all font-mono`,disabled:V.value},[d(x).usbPort&&!R.value.some(e=>e.device===d(x).usbPort)?(c(),g(`option`,{key:0,value:d(x).usbPort},t(d(x).usbPort)+` (current) `,9,We)):l(``,!0),(c(!0),g(m,null,s(R.value,e=>(c(),g(`option`,{key:e.device,value:e.device},t(e.description||e.device),9,Ge))),128))],8,Ue),[[v,d(x).usbPort]]),h(`button`,{type:`button`,class:`px-3 py-2 rounded-lg border border-stroke-subtle dark:border-stroke/10 text-sm text-content-primary dark:text-content-primary bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 disabled:opacity-50`,disabled:z.value,onClick:q},t(z.value?`...`:`Refresh`),9,Ke)]),h(`label`,qe,[i(h(`input`,{"onUpdate:modelValue":r[2]||=e=>V.value=e,type:`checkbox`},null,512),[[ie,V.value]]),r[27]||=p(` Enter custom device path `,-1)]),V.value?i((c(),g(`input`,{key:0,"onUpdate:modelValue":r[3]||=e=>d(x).usbPort=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all font-mono`,placeholder:`/dev/ttyACM0`},null,512)),[[y,d(x).usbPort]]):l(``,!0),B.value?(c(),g(`p`,Je,t(B.value),1)):l(``,!0)]),r[29]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-2`},[p(` The USB-CDC device path for your modem. If you have the pyMC udev rule installed it may appear as `),h(`span`,{class:`font-mono`},`/dev/lora-modem`),p(`. `)],-1)])])])):d(x).selectedHardware.key.toLowerCase()===`pymc_tcp`?(c(),g(`div`,Ye,[h(`div`,Xe,[h(`div`,null,[r[30]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-1.5`},[p(` Modem Hostname or IP Address `),h(`span`,{class:`text-red-500`},`*`)],-1),i(h(`input`,{"onUpdate:modelValue":r[4]||=e=>d(x).tcpHost=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all font-mono`,placeholder:`pymc-3e2834.local`},null,512),[[y,d(x).tcpHost]]),r[31]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-2`},` mDNS hostname, LAN IP, or domain name of the pyMC Wi-Fi modem. `,-1)]),h(`div`,Ze,[h(`div`,null,[r[32]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-1.5`},` Port `,-1),i(h(`input`,{"onUpdate:modelValue":r[5]||=e=>d(x).tcpPort=e,type:`number`,min:`1`,max:`65535`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`5055`},null,512),[[y,d(x).tcpPort,void 0,{number:!0}]]),r[33]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-2`},`Default is 5055.`,-1)]),h(`div`,null,[r[34]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-1.5`},[p(` Auth Token `),h(`span`,{class:`font-normal text-content-muted ml-1`},`(optional)`)],-1),i(h(`input`,{"onUpdate:modelValue":r[6]||=e=>d(x).tcpToken=e,type:`password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`Leave blank if none`},null,512),[[y,d(x).tcpToken]]),r[35]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-2`},`Must match the token set in the modem firmware.`,-1)])])])])):l(``,!0)])):l(``,!0)]),_:1})])):(c(),g(`div`,Ee,` Choose a connection type first `))])):d(x).currentStep===5?(c(),g(`div`,Qe,[r[54]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Choose a radio configuration preset for your region or create a custom configuration `,-1),d(x).isLoading?(c(),g(`div`,$e,` Loading radio presets... `)):d(x).radioPresets.length===0?(c(),g(`div`,et,` No radio presets available `)):(c(),g(`div`,tt,[h(`div`,nt,[(c(!0),g(m,null,s(d(x).radioPresets,e=>(c(),g(`button`,{key:e.title,onClick:t=>{d(x).selectedRadioPreset=e,d(x).useCustomRadio=!1,Z()},class:_([`p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm relative overflow-hidden`,!d(x).useCustomRadio&&d(x).selectedRadioPreset?.title===e.title?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,it,[h(`div`,at,[h(`span`,ot,[h(`span`,st,t(Ht(e.title)),1),h(`span`,null,t(e.title),1)]),!d(x).useCustomRadio&&d(x).selectedRadioPreset?.title===e.title?(c(),g(`div`,ct,[...r[37]||=[h(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 20 20`},[h(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,"clip-rule":`evenodd`})],-1)]])):l(``,!0)]),h(`div`,lt,t(e.description),1),h(`div`,ut,[h(`div`,dt,[r[38]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`Freq`,-1),h(`div`,ft,t(e.frequency),1)]),h(`div`,pt,[r[39]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`BW`,-1),h(`div`,mt,t(e.bandwidth),1)]),h(`div`,ht,[r[40]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`SF`,-1),h(`div`,gt,t(e.spreading_factor),1)]),h(`div`,_t,[r[41]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`CR`,-1),h(`div`,vt,t(e.coding_rate),1)]),h(`div`,yt,[r[42]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`TX Power`,-1),h(`div`,bt,t(e.tx_power||`14`)+` dBm `,1)])])])],10,rt))),128))]),h(`div`,xt,[h(`button`,{onClick:r[7]||=e=>{d(x).useCustomRadio=!d(x).useCustomRadio,d(x).useCustomRadio&&(d(x).selectedRadioPreset=null)},class:_([`w-full p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm`,d(x).useCustomRadio?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,St,[r[44]||=h(`div`,{class:`font-medium text-content-primary dark:text-content-primary flex items-center gap-2`},[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4`})]),p(` Custom Configuration `)],-1),d(x).useCustomRadio?(c(),g(`div`,Ct,[...r[43]||=[h(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 20 20`},[h(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,"clip-rule":`evenodd`})],-1)]])):l(``,!0)]),r[45]||=h(`div`,{class:`text-xs text-content-secondary dark:text-content-muted`},` Manually configure frequency, bandwidth, spreading factor, and coding rate `,-1)],2),u(b,{name:`slide`},{default:e(()=>[d(x).useCustomRadio?(c(),g(`div`,wt,[h(`div`,null,[r[46]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Frequency (MHz)`,-1),i(h(`input`,{"onUpdate:modelValue":r[8]||=e=>d(x).customRadio.frequency=e,type:`number`,step:`0.1`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`915.0`},null,512),[[y,d(x).customRadio.frequency]])]),h(`div`,null,[r[47]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Bandwidth (kHz)`,-1),i(h(`input`,{"onUpdate:modelValue":r[9]||=e=>d(x).customRadio.bandwidth=e,type:`number`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`125`},null,512),[[y,d(x).customRadio.bandwidth]])]),h(`div`,null,[r[49]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Spreading Factor`,-1),i(h(`select`,{"onUpdate:modelValue":r[10]||=e=>d(x).customRadio.spreading_factor=e,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`},[...r[48]||=[h(`option`,{value:`7`},`7`,-1),h(`option`,{value:`8`},`8`,-1),h(`option`,{value:`9`},`9`,-1),h(`option`,{value:`10`},`10`,-1),h(`option`,{value:`11`},`11`,-1),h(`option`,{value:`12`},`12`,-1)]],512),[[v,d(x).customRadio.spreading_factor]])]),h(`div`,null,[r[51]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Coding Rate`,-1),i(h(`select`,{"onUpdate:modelValue":r[11]||=e=>d(x).customRadio.coding_rate=e,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`},[...r[50]||=[h(`option`,{value:`5`},`4/5`,-1),h(`option`,{value:`6`},`4/6`,-1),h(`option`,{value:`7`},`4/7`,-1),h(`option`,{value:`8`},`4/8`,-1)]],512),[[v,d(x).customRadio.coding_rate]])]),h(`div`,Tt,[r[52]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`TX Power (dBm)`,-1),i(h(`input`,{"onUpdate:modelValue":r[12]||=e=>d(x).customRadio.tx_power=e,type:`number`,min:`-9`,max:`22`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`14`},null,512),[[y,d(x).customRadio.tx_power]]),r[53]||=h(`p`,{class:`text-content-muted dark:text-content-muted text-xs mt-2`},`SX1262 range: -9 to +22 dBm`,-1)])])):l(``,!0)]),_:1})])]))])):d(x).currentStep===6?(c(),g(`div`,Et,[r[58]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Set a secure admin password to protect your repeater `,-1),h(`div`,Dt,[h(`div`,null,[r[55]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Admin Password`,-1),i(h(`input`,{"onUpdate:modelValue":r[13]||=e=>d(x).adminPassword=e,type:`password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`Enter password (min 6 characters)`,minlength:`6`},null,512),[[y,d(x).adminPassword]])]),h(`div`,null,[r[56]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Confirm Password`,-1),i(h(`input`,{"onUpdate:modelValue":r[14]||=e=>d(x).confirmPassword=e,type:`password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`Confirm password`},null,512),[[y,d(x).confirmPassword]])]),d(x).adminPassword&&d(x).confirmPassword&&d(x).adminPassword!==d(x).confirmPassword?(c(),g(`div`,Ot,` Passwords do not match `)):l(``,!0),r[57]||=h(`div`,{class:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-3 text-sm text-yellow-800 dark:text-yellow-200`},[h(`strong`,null,`Important:`),p(` Remember this password - you'll need it to access the dashboard. `)],-1)])])):l(``,!0)]),d(x).error?(c(),g(`div`,kt,t(d(x).error),1)):l(``,!0),h(`div`,At,[d(x).canGoBack?(c(),g(`button`,{key:0,onClick:qt,class:`px-6 py-3 rounded-[12px] bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 text-content-primary dark:text-content-primary hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20 transition-all duration-300 font-medium`},` Back `)):(c(),g(`div`,jt)),h(`button`,{ref_key:`nextActionButtonRef`,ref:G,onClick:Q,disabled:!d(x).canGoNext||d(x).isSubmitting,class:_([`px-8 py-3 rounded-[12px] font-semibold transition-all duration-300 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed`,d(x).canGoNext&&!d(x).isSubmitting?`bg-primary hover:bg-primary/90 text-white border border-primary hover:border-primary/80`:`bg-background-mute dark:bg-stroke/5 text-content-muted dark:text-content-muted border border-stroke-subtle dark:border-stroke/10`])},[d(x).isSubmitting?(c(),o(se,{key:0,size:`sm`,color:`white`})):l(``,!0),d(x).isSubmitting?(c(),g(`span`,Nt,`Setting up...`)):d(x).isLastStep?(c(),g(`span`,Pt,`Complete Setup`)):(c(),g(`span`,Ft,`Next`)),!d(x).isSubmitting&&!d(x).isLastStep?(c(),g(`svg`,It,[...r[59]||=[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]])):l(``,!0)],10,Mt)])])]),u(de,{show:H.value,confirmed:U.value,"selected-tx-power":K.value,"action-label":`I Understand, Continue`,"onUpdate:show":r[15]||=e=>e?H.value=!0:Gt(),"onUpdate:confirmed":r[16]||=e=>U.value=e,onConfirm:Kt},null,8,[`show`,`confirmed`,`selected-tx-power`]),u(b,{name:`modal`},{default:e(()=>[S.value?(c(),g(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm`,onClick:$},[h(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl max-w-md w-full p-8 rounded-[24px] border border-stroke-subtle dark:border-white/20 shadow-[0_8px_32px_0_rgba(0,0,0,0.37)]`,onClick:r[17]||=ae(()=>{},[`stop`])},[r[60]||=h(`div`,{class:`flex justify-center mb-6`},[h(`div`,{class:`w-16 h-16 rounded-full bg-red-100 dark:bg-red-500/20 flex items-center justify-center`},[h(`svg`,{class:`w-8 h-8 text-red-600 dark:text-red-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})])])],-1),h(`h3`,Lt,t(F.value),1),h(`p`,Rt,t(I.value),1),h(`button`,{onClick:$,class:`w-full px-6 py-3 rounded-lg font-medium transition-colors bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red`},` Close `)])])):l(``,!0)]),_:1}),u(ce,{modelValue:L.value,"onUpdate:modelValue":r[18]||=e=>L.value=e,"start-immediately":!0,message:`Setup complete. The service is restarting. This may take up to a minute.`},null,8,[`modelValue`])]))}}),[[`__scopeId`,`data-v-969cd812`]]);export{F as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Setup-DiRq9fgD.css b/repeater/web/html/assets/Setup-DiRq9fgD.css deleted file mode 100644 index 3a9839eb..00000000 --- a/repeater/web/html/assets/Setup-DiRq9fgD.css +++ /dev/null @@ -1 +0,0 @@ -.glass-card[data-v-a201f2f2]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#ffffff0d;border:1px solid #ffffff1a}.modal-enter-active[data-v-a201f2f2],.modal-leave-active[data-v-a201f2f2]{transition:opacity .3s}.modal-enter-from[data-v-a201f2f2],.modal-leave-to[data-v-a201f2f2]{opacity:0}.modal-enter-active .glass-card[data-v-a201f2f2],.modal-leave-active .glass-card[data-v-a201f2f2]{transition:transform .3s}.modal-enter-from .glass-card[data-v-a201f2f2],.modal-leave-to .glass-card[data-v-a201f2f2]{transform:scale(.9)}.slide-enter-active[data-v-a201f2f2],.slide-leave-active[data-v-a201f2f2]{transition:all .3s}.slide-enter-from[data-v-a201f2f2],.slide-leave-to[data-v-a201f2f2]{opacity:0;transform:translateY(-10px)}@keyframes float-slow-a201f2f2{0%,to{opacity:.8;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.6;transform:translate(20px,-20px)scale(1.05)rotate(-24.22deg)}}@keyframes float-slower-a201f2f2{0%,to{opacity:.75;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.5;transform:translate(-30px,20px)scale(1.08)rotate(-24.22deg)}}@keyframes float-slowest-a201f2f2{0%,to{opacity:.8;transform:translate(0)scale(1)rotate(-24.22deg)}50%{opacity:.55;transform:translate(25px,25px)scale(1.1)rotate(-24.22deg)}}.animate-pulse-slow[data-v-a201f2f2]{will-change:transform, opacity;animation:15s ease-in-out infinite float-slow-a201f2f2}.animate-pulse-slower[data-v-a201f2f2]{will-change:transform, opacity;animation:18s ease-in-out infinite float-slower-a201f2f2}.animate-pulse-slowest[data-v-a201f2f2]{will-change:transform, opacity;animation:20s ease-in-out infinite float-slowest-a201f2f2} diff --git a/repeater/web/html/assets/Setup-DvdSE7ue.js b/repeater/web/html/assets/Setup-DvdSE7ue.js deleted file mode 100644 index fd7586e6..00000000 --- a/repeater/web/html/assets/Setup-DvdSE7ue.js +++ /dev/null @@ -1 +0,0 @@ -import{A as e,E as t,K as n,S as r,dt as i,f as a,ft as o,g as s,j as c,l,m as u,o as d,p as f,pt as p,r as m,s as h,u as g,w as _,x as v,z as y}from"./runtime-core.esm-bundler-HnidnMFy.js";import{i as b,o as x}from"./vue-router-Cr0wB7EX.js";import{t as S}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{c as C,d as w,f as T,h as ee,t as te}from"./index-BFltqMtv.js";var ne=x(`setup`,()=>{let e=y(1),t=y(5),n=y(`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`),r=y(null),i=y(null),a=y(``),o=y(``),s=y(!1),c=y({frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`}),l=y([]),u=y([]),f=y(!1),p=y(!1),m=y(null),h=d(()=>{switch(e.value){case 1:return!0;case 2:return n.value.trim().length>0;case 3:return r.value!==null;case 4:return s.value?c.value.frequency&&c.value.spreading_factor&&c.value.bandwidth&&c.value.coding_rate:i.value!==null;case 5:return a.value.length>=6&&a.value===o.value;default:return!1}}),g=d(()=>e.value>1),_=d(()=>e.value===t.value);async function v(){f.value=!0,m.value=null;try{let e=await(await fetch(`/api/hardware_options`)).json();if(e.error)throw Error(e.error);l.value=e.hardware||[]}catch(e){m.value=e instanceof Error?e.message:`Failed to load hardware options`,console.error(`Error fetching hardware options:`,e)}finally{f.value=!1}}async function b(){f.value=!0,m.value=null;try{let e=await(await fetch(`/api/radio_presets`)).json();if(e.error)throw Error(e.error);u.value=e.presets||[]}catch(e){m.value=e instanceof Error?e.message:`Failed to load radio presets`,console.error(`Error fetching radio presets:`,e)}finally{f.value=!1}}async function x(){if(!h.value)return{success:!1,error:`Please complete all required fields`};p.value=!0,m.value=null;try{let e=s.value?{title:`Custom Configuration`,description:`Custom radio settings`,frequency:c.value.frequency,spreading_factor:c.value.spreading_factor,bandwidth:c.value.bandwidth,coding_rate:c.value.coding_rate}:i.value,t=await(await fetch(`/api/setup_wizard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({node_name:n.value.trim(),hardware_key:r.value?.key,radio_preset:e,admin_password:a.value})})).json();if(!t.success)throw Error(t.error||`Setup failed`);return{success:!0,data:t}}catch(e){let t=e instanceof Error?e.message:`Failed to complete setup`;return m.value=t,{success:!1,error:t}}finally{p.value=!1}}function S(){h.value&&e.value=1&&n<=t.value&&(e.value=n)}function T(){e.value=1,n.value=`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`,r.value=null,i.value=null,s.value=!1,c.value={frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`},a.value=``,o.value=``,m.value=null}return{currentStep:e,totalSteps:t,nodeName:n,selectedHardware:r,selectedRadioPreset:i,useCustomRadio:s,customRadio:c,adminPassword:a,confirmPassword:o,hardwareOptions:l,radioPresets:u,isLoading:f,isSubmitting:p,error:m,canGoNext:h,canGoBack:g,isLastStep:_,fetchHardwareOptions:v,fetchRadioPresets:b,completeSetup:x,nextStep:S,previousStep:C,goToStep:w,reset:T}}),re={class:`min-h-screen bg-background dark:bg-background overflow-hidden relative flex items-center justify-center p-4`},ie={class:`absolute top-4 right-4 z-20`},ae={class:`w-full max-w-4xl relative z-10`},oe={class:`mb-8`},se={class:`flex justify-between mb-2`},ce={class:`text-content-secondary dark:text-content-muted text-sm`},E={class:`text-content-secondary dark:text-content-muted text-sm`},D={class:`h-2 bg-stroke-subtle dark:bg-stroke/10 rounded-full overflow-hidden`},O={class:`bg-white dark:bg-surface-elevated backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[20px] p-6 sm:p-8 md:p-12`},k={class:`flex justify-center mb-8`},A={class:`flex gap-2`},j={class:`mb-8`},M={class:`text-2xl sm:text-3xl font-bold text-content-primary dark:text-content-primary mb-2 text-center`},N={key:0,class:`space-y-6 mt-8`},P={key:1,class:`space-y-6 mt-8`},F={class:`max-w-md mx-auto`},I={key:2,class:`space-y-6 mt-8`},L={key:0,class:`text-center text-content-secondary dark:text-content-muted`},R={key:1,class:`text-center text-content-secondary dark:text-content-muted`},z={key:2,class:`grid grid-cols-1 md:grid-cols-2 gap-4 max-w-3xl mx-auto`},B=[`onClick`],V={class:`font-medium text-content-primary dark:text-content-primary mb-1`},H={class:`text-sm text-content-secondary dark:text-content-muted`},U={key:3,class:`space-y-6 mt-8`},W={key:0,class:`text-center text-content-secondary dark:text-content-muted`},G={key:1,class:`text-center text-content-secondary dark:text-content-muted`},le={key:2,class:`max-w-5xl mx-auto`},ue={class:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-4`},de=[`onClick`],fe={class:`relative z-10`},pe={class:`font-medium text-content-primary dark:text-content-primary mb-1 flex items-start justify-between gap-2`},me={class:`flex items-center gap-2`},he={class:`text-2xl`},ge={key:0,class:`text-primary flex-shrink-0`},_e={class:`text-xs text-content-secondary dark:text-content-muted mb-3`},ve={class:`grid grid-cols-2 gap-2 text-xs`},ye={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},be={class:`text-content-primary dark:text-content-primary/80 font-medium`},xe={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},Se={class:`text-content-primary dark:text-content-primary/80 font-medium`},Ce={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},K={class:`text-content-primary dark:text-content-primary/80 font-medium`},we={class:`bg-gray-50 dark:bg-white/5 rounded px-2 py-1`},Te={class:`text-content-primary dark:text-content-primary/80 font-medium`},Ee={class:`border-t border-stroke-subtle dark:border-stroke/10 pt-6`},De={class:`flex items-center justify-between mb-2`},Oe={key:0,class:`text-primary`},ke={key:0,class:`mt-4 grid grid-cols-2 gap-4`},Ae={key:4,class:`space-y-6 mt-8`},je={class:`max-w-md mx-auto space-y-4`},Me={key:0,class:`text-red-600 dark:text-red-400 text-sm`},Ne={key:0,class:`mb-6 bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-600 dark:text-red-200`},Pe={class:`flex justify-between gap-4`},Fe={key:1},Ie=[`disabled`],Le={key:0,class:`w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin`},Re={key:1},ze={key:2},Be={key:3},Ve={key:4,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},He={class:`flex justify-center mb-6`},Ue={key:0,class:`w-16 h-16 rounded-full bg-green-100 dark:bg-green-500/20 flex items-center justify-center`},We={key:1,class:`w-16 h-16 rounded-full bg-red-100 dark:bg-red-500/20 flex items-center justify-center`},Ge={class:`text-2xl font-bold text-content-primary dark:text-content-primary text-center mb-4`},Ke={class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},q=S(s({name:`SetupView`,__name:`Setup`,setup(s){let x=ne(),S=b(),q=y(!1),J=y(``),Y=y(``),X=y(`success`),Z=null,qe=e=>{let t=e.toLowerCase();return t.includes(`australia`)?`🇦🇺`:t.includes(`eu`)||t.includes(`uk`)?`🇪🇺`:t.includes(`czech`)?`🇨🇿`:t.includes(`new zealand`)?`🇳🇿`:t.includes(`portugal`)?`🇵🇹`:t.includes(`switzerland`)?`🇨🇭`:t.includes(`usa`)||t.includes(`canada`)?`🇺🇸`:t.includes(`vietnam`)?`🇻🇳`:`🌍`};r(async()=>{await Promise.all([x.fetchHardwareOptions(),x.fetchRadioPresets()])});let Q=d(()=>x.currentStep/x.totalSteps*100);async function Je(){if(x.isLastStep){let e=await x.completeSetup();e.success?(X.value=`success`,J.value=`Setup Complete!`,Y.value=`Your repeater has been configured successfully. The service is restarting now...`,q.value=!0,Xe()):(X.value=`error`,J.value=`Setup Failed`,Y.value=e.error||`An unknown error occurred`,q.value=!0)}else x.nextStep()}function Ye(){x.previousStep()}function $(){q.value=!1,X.value===`success`&&(Z||S.push(`/login`))}function Xe(){let e=0;function t(){e++,fetch(`/api/status`,{method:`GET`}).then(e=>{e.ok?(Z=null,q.value=!1,S.push(`/login`)):n()}).catch(()=>{n()})}function n(){e<30?Z=setTimeout(t,1e3):(Z=null,q.value=!1,S.push(`/login`))}Z=setTimeout(t,2e3)}v(()=>{Z&&=(clearTimeout(Z),null)});let Ze=[`Welcome`,`Repeater Name`,`Hardware Selection`,`Radio Configuration`,`Security Setup`];return(r,s)=>(_(),g(`div`,re,[h(`div`,ie,[u(te)]),s[36]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slow -top-[79px] left-[575px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),s[37]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-75 animate-pulse-slower -top-[94px] -left-[92px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),s[38]||=h(`div`,{class:`bg-gradient-light dark:bg-gradient-dark absolute rounded-full -rotate-[24.22deg] w-[705px] h-[512px] blur-[120px] opacity-80 animate-pulse-slowest top-[373px] left-[246px] mix-blend-multiply dark:mix-blend-screen pointer-events-none`},null,-1),h(`div`,ae,[h(`div`,oe,[h(`div`,se,[h(`span`,ce,`Step `+p(n(x).currentStep)+` of `+p(n(x).totalSteps),1),h(`span`,E,p(Math.round(Q.value))+`% Complete`,1)]),h(`div`,D,[h(`div`,{class:`h-full bg-gradient-to-r from-primary to-primary/80 transition-all duration-500`,style:o({width:`${Q.value}%`})},null,4)])]),h(`div`,O,[h(`div`,k,[h(`div`,A,[(_(!0),g(m,null,t(n(x).totalSteps,e=>(_(),g(`div`,{key:e,class:i([`w-10 h-10 rounded-full flex items-center justify-center text-sm font-medium transition-all`,e===n(x).currentStep?`bg-primary text-white`:e

Welcome to your pyMC Repeater! Let's get you set up in just a few steps.

You'll configure:

  • Repeater name and identification
  • Hardware board selection
  • Radio frequency and settings
  • Admin password for secure access
`,1)]])):n(x).currentStep===2?(_(),g(`div`,P,[s[12]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Choose a unique name for your repeater. This will be used for identification on the mesh network. `,-1),h(`div`,F,[s[10]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Repeater Name`,-1),c(h(`input`,{"onUpdate:modelValue":s[0]||=e=>n(x).nodeName=e,type:`text`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`e.g., pyRpt0001`,maxlength:`32`},null,512),[[T,n(x).nodeName]]),s[11]||=h(`p`,{class:`text-content-secondary dark:text-content-muted text-xs mt-2`},` Use letters, numbers, hyphens, or underscores (3-32 characters) `,-1)])])):n(x).currentStep===3?(_(),g(`div`,I,[s[13]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Select your hardware board type `,-1),n(x).isLoading?(_(),g(`div`,L,` Loading hardware options... `)):n(x).hardwareOptions.length===0?(_(),g(`div`,R,` No hardware options available `)):(_(),g(`div`,z,[(_(!0),g(m,null,t(n(x).hardwareOptions,e=>(_(),g(`button`,{key:e.key,onClick:t=>n(x).selectedHardware=e,class:i([`p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm`,n(x).selectedHardware?.key===e.key?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,V,p(e.name),1),h(`div`,H,p(e.description||e.key),1)],10,B))),128))]))])):n(x).currentStep===4?(_(),g(`div`,U,[s[28]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Choose a radio configuration preset for your region or create a custom configuration `,-1),n(x).isLoading?(_(),g(`div`,W,` Loading radio presets... `)):n(x).radioPresets.length===0?(_(),g(`div`,G,` No radio presets available `)):(_(),g(`div`,le,[h(`div`,ue,[(_(!0),g(m,null,t(n(x).radioPresets,e=>(_(),g(`button`,{key:e.title,onClick:t=>{n(x).selectedRadioPreset=e,n(x).useCustomRadio=!1},class:i([`p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm relative overflow-hidden`,!n(x).useCustomRadio&&n(x).selectedRadioPreset?.title===e.title?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,fe,[h(`div`,pe,[h(`span`,me,[h(`span`,he,p(qe(e.title)),1),h(`span`,null,p(e.title),1)]),!n(x).useCustomRadio&&n(x).selectedRadioPreset?.title===e.title?(_(),g(`div`,ge,[...s[14]||=[h(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 20 20`},[h(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,"clip-rule":`evenodd`})],-1)]])):l(``,!0)]),h(`div`,_e,p(e.description),1),h(`div`,ve,[h(`div`,ye,[s[15]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`Freq`,-1),h(`div`,be,p(e.frequency),1)]),h(`div`,xe,[s[16]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`BW`,-1),h(`div`,Se,p(e.bandwidth),1)]),h(`div`,Ce,[s[17]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`SF`,-1),h(`div`,K,p(e.spreading_factor),1)]),h(`div`,we,[s[18]||=h(`div`,{class:`text-content-muted dark:text-content-muted`},`CR`,-1),h(`div`,Te,p(e.coding_rate),1)])])])],10,de))),128))]),h(`div`,Ee,[h(`button`,{onClick:s[1]||=e=>{n(x).useCustomRadio=!n(x).useCustomRadio,n(x).useCustomRadio&&(n(x).selectedRadioPreset=null)},class:i([`w-full p-4 rounded-[12px] border transition-all duration-300 text-left backdrop-blur-sm`,n(x).useCustomRadio?`bg-gradient-to-r from-primary/20 to-primary/10 border-primary/50 shadow-lg shadow-primary/20`:`bg-background-mute dark:bg-white/5 border-stroke-subtle dark:border-stroke/10 hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20`])},[h(`div`,De,[s[20]||=h(`div`,{class:`font-medium text-content-primary dark:text-content-primary flex items-center gap-2`},[h(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4`})]),f(` Custom Configuration `)],-1),n(x).useCustomRadio?(_(),g(`div`,Oe,[...s[19]||=[h(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 20 20`},[h(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,"clip-rule":`evenodd`})],-1)]])):l(``,!0)]),s[21]||=h(`div`,{class:`text-xs text-content-secondary dark:text-content-muted`},` Manually configure frequency, bandwidth, spreading factor, and coding rate `,-1)],2),u(C,{name:`slide`},{default:e(()=>[n(x).useCustomRadio?(_(),g(`div`,ke,[h(`div`,null,[s[22]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Frequency (MHz)`,-1),c(h(`input`,{"onUpdate:modelValue":s[2]||=e=>n(x).customRadio.frequency=e,type:`number`,step:`0.1`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`915.0`},null,512),[[T,n(x).customRadio.frequency]])]),h(`div`,null,[s[23]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Bandwidth (kHz)`,-1),c(h(`input`,{"onUpdate:modelValue":s[3]||=e=>n(x).customRadio.bandwidth=e,type:`number`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`,placeholder:`125`},null,512),[[T,n(x).customRadio.bandwidth]])]),h(`div`,null,[s[25]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Spreading Factor`,-1),c(h(`select`,{"onUpdate:modelValue":s[4]||=e=>n(x).customRadio.spreading_factor=e,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`},[...s[24]||=[h(`option`,{value:`7`},`7`,-1),h(`option`,{value:`8`},`8`,-1),h(`option`,{value:`9`},`9`,-1),h(`option`,{value:`10`},`10`,-1),h(`option`,{value:`11`},`11`,-1),h(`option`,{value:`12`},`12`,-1)]],512),[[w,n(x).customRadio.spreading_factor]])]),h(`div`,null,[s[27]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Coding Rate`,-1),c(h(`select`,{"onUpdate:modelValue":s[5]||=e=>n(x).customRadio.coding_rate=e,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-[12px] px-4 py-2.5 text-content-primary dark:text-content-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-transparent transition-all`},[...s[26]||=[h(`option`,{value:`5`},`4/5`,-1),h(`option`,{value:`6`},`4/6`,-1),h(`option`,{value:`7`},`4/7`,-1),h(`option`,{value:`8`},`4/8`,-1)]],512),[[w,n(x).customRadio.coding_rate]])])])):l(``,!0)]),_:1})])]))])):n(x).currentStep===5?(_(),g(`div`,Ae,[s[32]||=h(`p`,{class:`text-content-secondary dark:text-content-primary/70 text-center mb-6`},` Set a secure admin password to protect your repeater `,-1),h(`div`,je,[h(`div`,null,[s[29]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Admin Password`,-1),c(h(`input`,{"onUpdate:modelValue":s[6]||=e=>n(x).adminPassword=e,type:`password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`Enter password (min 6 characters)`,minlength:`6`},null,512),[[T,n(x).adminPassword]])]),h(`div`,null,[s[30]||=h(`label`,{class:`block text-content-primary dark:text-content-primary/90 text-sm font-medium mb-2`},`Confirm Password`,-1),c(h(`input`,{"onUpdate:modelValue":s[7]||=e=>n(x).confirmPassword=e,type:`password`,class:`w-full bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg px-4 py-3 text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent`,placeholder:`Confirm password`},null,512),[[T,n(x).confirmPassword]])]),n(x).adminPassword&&n(x).confirmPassword&&n(x).adminPassword!==n(x).confirmPassword?(_(),g(`div`,Me,` Passwords do not match `)):l(``,!0),s[31]||=h(`div`,{class:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-3 text-sm text-yellow-800 dark:text-yellow-200`},[h(`strong`,null,`Important:`),f(` Remember this password - you'll need it to access the dashboard. `)],-1)])])):l(``,!0)]),n(x).error?(_(),g(`div`,Ne,p(n(x).error),1)):l(``,!0),h(`div`,Pe,[n(x).canGoBack?(_(),g(`button`,{key:0,onClick:Ye,class:`px-6 py-3 rounded-[12px] bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 text-content-primary dark:text-content-primary hover:bg-stroke-subtle dark:hover:bg-white/10 hover:border-stroke dark:hover:border-stroke/20 transition-all duration-300 font-medium`},` Back `)):(_(),g(`div`,Fe)),h(`button`,{onClick:Je,disabled:!n(x).canGoNext||n(x).isSubmitting,class:i([`px-8 py-3 rounded-[12px] font-semibold transition-all duration-300 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed`,n(x).canGoNext&&!n(x).isSubmitting?`bg-primary hover:bg-primary/90 text-white border border-primary hover:border-primary/80`:`bg-background-mute dark:bg-stroke/5 text-content-muted dark:text-content-muted border border-stroke-subtle dark:border-stroke/10`])},[n(x).isSubmitting?(_(),g(`div`,Le)):l(``,!0),n(x).isSubmitting?(_(),g(`span`,Re,`Setting up...`)):n(x).isLastStep?(_(),g(`span`,ze,`Complete Setup`)):(_(),g(`span`,Be,`Next`)),!n(x).isSubmitting&&!n(x).isLastStep?(_(),g(`svg`,Ve,[...s[33]||=[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 5l7 7-7 7`},null,-1)]])):l(``,!0)],10,Ie)])])]),u(C,{name:`modal`},{default:e(()=>[q.value?(_(),g(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm`,onClick:$},[h(`div`,{class:`bg-white dark:bg-surface-elevated backdrop-blur-xl max-w-md w-full p-8 rounded-[24px] border border-stroke-subtle dark:border-white/20 shadow-[0_8px_32px_0_rgba(0,0,0,0.37)]`,onClick:s[8]||=ee(()=>{},[`stop`])},[h(`div`,He,[X.value===`success`?(_(),g(`div`,Ue,[...s[34]||=[h(`svg`,{class:`w-8 h-8 text-green-600 dark:text-green-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})],-1)]])):(_(),g(`div`,We,[...s[35]||=[h(`svg`,{class:`w-8 h-8 text-red-600 dark:text-red-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[h(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]]))]),h(`h3`,Ge,p(J.value),1),h(`p`,Ke,p(Y.value),1),h(`button`,{onClick:$,class:i([`w-full px-6 py-3 rounded-lg font-medium transition-all`,X.value===`success`?`bg-primary hover:bg-primary/90 text-white`:`bg-accent-red hover:bg-accent-red/90 text-white`])},p(X.value===`success`?`Continue to Login`:`Close`),3)])])):l(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-a201f2f2`]]);export{q as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Spinner-CcYauG9D.js b/repeater/web/html/assets/Spinner-CcYauG9D.js new file mode 100644 index 00000000..77fbb70e --- /dev/null +++ b/repeater/web/html/assets/Spinner-CcYauG9D.js @@ -0,0 +1 @@ +import{g as e,k as t,u as n,xt as r}from"./runtime-core.esm-bundler-C5QBTNWE.js";var i=e({__name:`Spinner`,props:{size:{default:`md`},color:{default:`primary`}},setup(e){return(i,a)=>(t(),n(`div`,{class:r([`rounded-full animate-spin`,{"w-3 h-3 border-b":e.size===`xs`,"w-4 h-4 border-b-2":e.size===`sm`,"w-8 h-8 border-b-2":e.size===`md`,"w-12 h-12 border-b-2":e.size===`lg`,"border-primary":e.color===`primary`,"border-white":e.color===`white`,"border-current":e.color===`current`}])},null,2))}});export{i as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/Statistics-BeGVnnkk.js b/repeater/web/html/assets/Statistics-BeGVnnkk.js new file mode 100644 index 00000000..a1eb8a67 --- /dev/null +++ b/repeater/web/html/assets/Statistics-BeGVnnkk.js @@ -0,0 +1 @@ +import{B as e,Ct as t,E as n,J as r,K as i,Q as a,S as o,St as s,V as c,Y as l,g as u,j as d,k as f,l as p,m,o as ee,r as h,s as g,u as _,w as te}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{o as ne}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as re}from"./packets-KU2POtN6.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,i as ue,l as de,m as fe,n as v,o as pe,p as me,r as he,s as y,t as b,u as ge,v as _e,y as ve}from"./ChartCard-Dv7_dbhW.js";import{t as x}from"./chartjs-adapter-date-fns.esm-CUNlL-Mn.js";var ye={class:`p-3 sm:p-6 space-y-4 sm:space-y-6`},be={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3`},xe={class:`flex items-center gap-2 sm:gap-3`},Se=[`value`],Ce={class:`grid grid-cols-1 sm:grid-cols-3 gap-4`},we={class:`glass-card rounded-[15px] p-3 sm:p-6`},Te={class:`flex items-center gap-3 sm:gap-6 mb-3 sm:mb-4`},Ee={class:`flex items-center gap-2`},De={class:`flex items-center gap-2`},Oe={class:`grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6 items-stretch`},ke={class:`glass-card rounded-[15px] p-3 sm:p-6 flex flex-col`},Ae={class:`glass-card rounded-[15px] p-3 sm:p-6 flex flex-col`},je={class:`w-28 sm:w-32 text-sm text-content-primary dark:text-content-primary truncate`},Me={class:`flex-1 h-12 bg-background-mute dark:bg-stroke/10 rounded overflow-hidden`},Ne={class:`w-20 text-sm text-content-secondary dark:text-content-muted text-right tabular-nums`},S=20,C=u({name:`StatisticsView`,__name:`Statistics`,setup(u){y.register(pe,se,ce,ge,de,ue,oe,me,_e,ve,ie,he,ae,le,fe);let C=re(),w=e=>e>48?{unit:`day`,displayFormats:{day:`EEE MMM d`}}:e>24?{unit:`hour`,displayFormats:{hour:`EEE HH:mm`}}:{unit:`hour`,displayFormats:{hour:`HH:mm`}},T=r({packetRate:`Connecting...`,noiseFloor:`Connecting...`,routePie:`Connecting...`}),E=()=>{let e=document.documentElement.classList.contains(`dark`);return{gridColor:e?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,tickColor:e?`rgba(255, 255, 255, 0.7)`:`rgba(0, 0, 0, 0.7)`,legendColor:e?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`,titleColor:e?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`}},D={tx:`#F59E0B`,rx:`#C084FC`,noiseFloor:`#F59E0B`,noiseFloorFill:`rgba(245, 158, 11, 0.8)`,noiseFloorGrid:`rgba(245, 158, 11, 0.2)`,totalRx:`#AAE8E8`,totalTx:`#FFC246`,crcErrors:`#F59E0B`,packetTypes:[`#60A5FA`,`#34D399`,`#FBBF24`,`#A78BFA`,`#F87171`,`#06B6D4`,`#84CC16`,`#F472B6`,`#10B981`],routes:[`#3B82F6`,`#10B981`,`#F59E0B`,`#A78BFA`,`#F87171`]},O=l(24),Pe=[{value:1,label:`1 Hour`},{value:6,label:`6 Hours`},{value:12,label:`12 Hours`},{value:24,label:`24 Hours`},{value:48,label:`2 Days`},{value:168,label:`1 Week`}],k=l(null),A=l(null),j=l(null),M=l([]),N=l([]),P=l(!0),F=l(null),I=l({packetRate:!0,noiseFloor:!1,routePie:!0,sparklineMetrics:!0,sparklineCrc:!0}),L=l(null),R=l(null),z=l(null),B=l(null),V=l(null),H=l(null),U=l(null),W=l(null),G=l({totalRx:0,totalTx:0}),K=(e,t)=>{if(e.length===0)return[];let n=Math.round(t*60*60*1e3/72),r=new Map;return e.forEach(([e,t])=>{let i=e;e>0x38d7ea4c68000?i=e/1e3:e>1e9&&e<0xe8d4a51000&&(i=e*1e3);let a=Math.floor(i/n)*n;r.has(a)||r.set(a,[]),r.get(a).push(t)}),Array.from(r.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>e.reduce((e,t)=>e+t,0)/e.length)},q=ee(()=>{let e=[],t=[];if(k.value?.series){let n=k.value.series.find(e=>e.type===`rx_count`),r=k.value.series.find(e=>e.type===`tx_count`);n?.data&&(e=K(n.data.map(([e,t])=>[e,t>S?0:t]),O.value)),r?.data&&(t=K(r.data.map(([e,t])=>[e,t>S?0:t]),O.value))}return{totalPackets:e,transmittedPackets:t,droppedPackets:[],crcErrors:K(N.value.map(e=>[e.timestamp>0xe8d4a51000?e.timestamp:e.timestamp*1e3,e.count]),O.value)}}),J=async()=>{try{P.value=!0,F.value=null;let e=await v(`/packet_stats`,{hours:O.value});G.value={totalRx:e.data?.total_packets||0,totalTx:e.data?.transmitted_packets||0},P.value=!1}catch(e){F.value=e instanceof Error?e.message:`Failed to fetch data`,P.value=!1}Fe()},Fe=async()=>{I.value={packetRate:!0,noiseFloor:!0,routePie:!0,sparklineMetrics:!0,sparklineCrc:!0},C.metricsGraphData&&(k.value=C.metricsGraphData),C.crcErrorHistory.length>0&&(N.value=[...C.crcErrorHistory]),C.noiseFloorHistory.length>0&&(A.value={chart_data:C.noiseFloorHistory.map(e=>({timestamp:e.timestamp,noise_floor_dbm:e.noise_floor_dbm}))},$()),Y(),X(),Z(),Q()},Y=async()=>{T.packetRate=`Connecting...`,L.value=null;try{let e=await v(`/metrics_graph_data`,{hours:O.value,resolution:`average`,metrics:`rx_count,tx_count`},{onPhaseChange:e=>{T.packetRate=e===`receiving`?`Receiving data...`:`Connecting...`}});e?.success&&(k.value=e.data)}catch(e){L.value=e instanceof Error?e.message:`Failed to load`,k.value=null}finally{I.value.packetRate=!1,I.value.sparklineMetrics=!1,L.value||(await o(),Re())}},X=async()=>{T.routePie=`Connecting...`,R.value=null;try{let e=await v(`/route_stats`,{hours:O.value},{onPhaseChange:e=>{T.routePie=e===`receiving`?`Receiving data...`:`Connecting...`}});e?.success&&e.data&&(j.value=e.data)}catch(e){j.value=null,R.value=e instanceof Error?e.message:`Failed to load`}finally{I.value.routePie=!1}},Z=async()=>{T.noiseFloor=`Connecting...`,z.value=null;try{let e=O.value*120,t=await v(`/noise_floor_history`,{hours:O.value,limit:e},{idleTimeoutMs:3e4,onPhaseChange:e=>{T.noiseFloor=e===`receiving`?`Receiving data...`:`Connecting...`}});if(t.success&&t.data){let e=t.data.history||[];if(Array.isArray(e)&&e.length>0){let t=e;if(e.length>1500){let n=Math.ceil(e.length/1500);t=e.filter((e,t)=>t%n===0)}A.value={chart_data:t.map(e=>({timestamp:e.timestamp||Date.now()/1e3,noise_floor_dbm:e.noise_floor_dbm||e.noise_floor||-120}))},$()}}}catch(e){A.value={chart_data:[]},z.value=e instanceof Error?e.message:`Failed to load`}finally{I.value.noiseFloor=!1,z.value||(await o(),ze())}},Q=async()=>{B.value=null;try{let e=await v(`/crc_error_history`,{hours:O.value});e?.success&&e.data&&(N.value=e.data.history||[])}catch(e){N.value=[],B.value=e instanceof Error?e.message:`Failed to load`}finally{I.value.sparklineCrc=!1}},Ie=()=>{I.value={packetRate:!0,noiseFloor:!0,routePie:!0,sparklineMetrics:!0,sparklineCrc:!0},Le(),L.value=null,R.value=null,z.value=null,J()},$=()=>{M.value=[],A.value?.chart_data&&A.value.chart_data.length>0&&(M.value=A.value.chart_data.map(e=>({timestamp:e.timestamp*1e3,snr:null,rssi:null,noiseFloor:e.noise_floor_dbm})))},Le=()=>{try{V.value&&=(V.value.destroy(),null),H.value&&=(H.value.destroy(),null)}catch(e){console.error(`Error destroying charts:`,e)}},Re=()=>{if(!U.value)return;let e=U.value.getContext(`2d`);if(!e)return;let t=[],n=[];if(k.value?.series){let e=k.value.series.find(e=>e.type===`rx_count`),r=k.value.series.find(e=>e.type===`tx_count`);e?.data&&(t=e.data.map(([e,t])=>{let n=e;return n=e>0x38d7ea4c68000?e/1e3:e>0xe8d4a51000?e:e>1e9?e*1e3:Date.now(),{x:n,y:t>S?0:t*3600}})),r?.data&&(n=r.data.map(([e,t])=>{let n=e;return n=e>0x38d7ea4c68000?e/1e3:e>0xe8d4a51000?e:e>1e9?e*1e3:Date.now(),{x:n,y:t>S?0:t*3600}}))}if(t.length===0&&n.length===0){L.value=`No data available for the selected time range`;return}L.value=null,V.value&&=(V.value.destroy(),null);let r=Math.round(O.value*60*60*1e3/72),a=e=>{if(e.length===0)return[];let t=new Map;return e.forEach(e=>{let n=Math.floor(e.x/r)*r;t.has(n)||t.set(n,[]),t.get(n).push(e.y)}),Array.from(t.entries()).map(([e,t])=>({x:e,y:t.reduce((e,t)=>e+t,0)/t.length})).sort((e,t)=>e.x-t.x)},o=(e,t=3)=>{if(e.lengthe+t.y,0)/o.length;n.push({x:e[r].x,y:s})}return n},s=o(a(t)),c=o(a(n)),l=[...s.map(e=>e.y),...c.map(e=>e.y)],u=Math.min(...l),d=Math.max(...l),f=d-u||d*.1||.001,p=Math.max(0,u-f*.05),m=d+f*.05;try{let t=JSON.parse(JSON.stringify(s));V.value=i(new y(e,{type:`line`,data:{datasets:[{label:`TX/hr`,data:JSON.parse(JSON.stringify(c)),borderColor:D.tx,backgroundColor:D.tx,borderWidth:2,fill:`origin`,tension:.4,pointRadius:0,pointHoverRadius:3,order:1},{label:`RX/hr`,data:t,borderColor:D.rx,backgroundColor:D.rx,borderWidth:2,fill:`origin`,tension:.4,pointRadius:0,pointHoverRadius:3,order:2}]},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{display:!1},title:{display:!1},tooltip:{enabled:!0,backgroundColor:`rgba(0, 0, 0, 0.8)`,titleColor:`rgba(255, 255, 255, 0.9)`,bodyColor:`rgba(255, 255, 255, 0.8)`,borderColor:`rgba(255, 255, 255, 0.2)`,borderWidth:1,padding:12,displayColors:!0,callbacks:{title:function(e){let t=e[0]?.parsed?.x;return t==null?``:new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})},label:function(e){let t=e.dataset?.label||``,n=e.parsed?.y;return n==null?t:`${t}: ${n.toFixed(1)}`}}}},scales:{x:{type:`time`,time:w(O.value),min:Date.now()-O.value*3600*1e3,max:Date.now(),grid:{color:E().gridColor},ticks:{color:E().tickColor,maxTicksLimit:8}},y:{beginAtZero:!1,title:{display:!0,text:`Packets / Hour`,color:E().tickColor},grid:{color:E().gridColor},ticks:{color:E().tickColor,callback:function(e){return typeof e==`number`?e.toFixed(1):e}},min:p,max:m}}}}))}catch(e){console.error(`Error creating packet rate chart:`,e),L.value=`Failed to render chart`}},ze=()=>{if(!W.value)return;let e=W.value.getContext(`2d`);if(!e)return;let t=M.value.map(e=>({x:e.timestamp,y:e.noiseFloor})).filter(e=>e.y!==null&&e.y!==void 0),n=t.map(e=>e.y),r=n.length>0?Math.min(...n):-120,o=n.length>0?Math.max(...n):-110,s=o-r||1,c=r-s*.05,l=o+s*.05;if(H.value)try{let e=a(H.value),n=JSON.parse(JSON.stringify(t));e.data.datasets[0]&&(e.data.datasets[0].data=n),e.options?.scales?.x&&(e.options.scales.x.min=Date.now()-O.value*3600*1e3,e.options.scales.x.max=Date.now(),e.options.scales.x.time=w(O.value)),e.options?.scales?.y?.ticks&&(e.options.scales.y.ticks.color=E().tickColor),e.options?.plugins?.legend?.labels&&(e.options.plugins.legend.labels.color=E().legendColor),e.update();return}catch{H.value.destroy(),H.value=null}H.value=i(new y(e,{type:`scatter`,data:{datasets:[{label:`Noise Floor (dBm)`,data:JSON.parse(JSON.stringify(t)),borderWidth:0,backgroundColor:D.noiseFloorFill,pointRadius:3,pointHoverRadius:5,pointStyle:`circle`}]},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{display:!0,position:`top`,labels:{color:E().legendColor,usePointStyle:!0,padding:20}},tooltip:{enabled:!0,backgroundColor:`rgba(0, 0, 0, 0.8)`,titleColor:`rgba(255, 255, 255, 0.9)`,bodyColor:`rgba(255, 255, 255, 0.8)`,borderColor:`rgba(255, 255, 255, 0.2)`,borderWidth:1,padding:12,displayColors:!0,callbacks:{title:function(e){let t=e[0]?.parsed?.x;return t==null?``:new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})},label:function(e){let t=e.dataset?.label||``,n=e.parsed?.y;return n==null?t:`${t}: ${n.toFixed(1)} dBm`}}}},scales:{x:{type:`time`,time:w(O.value),min:Date.now()-O.value*3600*1e3,max:Date.now(),grid:{color:E().gridColor},ticks:{color:E().tickColor,maxTicksLimit:8}},y:{type:`linear`,display:!0,title:{display:!0,text:`Noise Floor (dBm)`,color:E().titleColor},grid:{color:D.noiseFloorGrid},ticks:{color:E().tickColor,callback:function(e){return typeof e==`number`?e.toFixed(1):e}},min:c,max:l}}}}))};return n(async()=>{await o(),J(),window.addEventListener(`resize`,()=>{setTimeout(()=>{a(V.value)?.resize(),a(H.value)?.resize()},100)})}),te(()=>{V.value?.destroy(),H.value?.destroy(),window.removeEventListener(`resize`,()=>{})}),(n,r)=>(f(),_(`div`,ye,[g(`div`,be,[r[8]||=g(`h2`,{class:`text-xl sm:text-2xl font-bold text-content-primary dark:text-content-primary`},` Statistics `,-1),g(`div`,xe,[r[7]||=g(`label`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Time Range:`,-1),c(g(`select`,{"onUpdate:modelValue":r[0]||=e=>O.value=e,onChange:Ie,class:`bg-white dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-2 sm:px-3 py-1.5 sm:py-2 text-content-primary dark:text-content-primary text-xs sm:text-sm focus:outline-hidden focus:border-primary dark:focus:border-accent-purple/50 transition-colors`},[(f(),_(h,null,d(Pe,e=>g(`option`,{key:e.value,value:e.value,class:`bg-surface text-content-primary`},t(e.label),9,Se)),64))],544),[[ne,O.value]])])]),g(`div`,Ce,[m(x,{title:`Total RX`,value:G.value.totalRx,color:D.totalRx,data:q.value.totalPackets,loading:I.value.sparklineMetrics,error:L.value,variant:`classic`,onRetry:r[1]||=()=>{I.value.sparklineMetrics=!0,I.value.packetRate=!0,L.value=null,Y()}},null,8,[`value`,`color`,`data`,`loading`,`error`]),m(x,{title:`Total TX`,value:G.value.totalTx,color:D.totalTx,data:q.value.transmittedPackets,loading:I.value.sparklineMetrics,error:L.value,variant:`classic`,onRetry:r[2]||=()=>{I.value.sparklineMetrics=!0,I.value.packetRate=!0,L.value=null,Y()}},null,8,[`value`,`color`,`data`,`loading`,`error`]),m(x,{title:`CRC Errors`,value:N.value.reduce((e,t)=>e+t.count,0),color:D.crcErrors,data:q.value.crcErrors,loading:I.value.sparklineCrc,error:B.value,variant:`classic`,onRetry:r[3]||=()=>{I.value.sparklineCrc=!0,B.value=null,Q()}},null,8,[`value`,`color`,`data`,`loading`,`error`])]),g(`div`,we,[r[12]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Performance Metrics `,-1),g(`div`,null,[r[11]||=g(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm uppercase tracking-wide mb-2`},` Packet Rate (RX/TX PER HOUR) `,-1),g(`div`,Te,[g(`div`,Ee,[g(`div`,{class:`w-3 h-3 rounded-full`,style:s({backgroundColor:D.rx})},null,4),r[9]||=g(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`RX/hr`,-1)]),g(`div`,De,[g(`div`,{class:`w-3 h-3 rounded-full`,style:s({backgroundColor:D.tx})},null,4),r[10]||=g(`span`,{class:`text-content-secondary dark:text-content-muted text-sm`},`TX/hr`,-1)])]),m(b,{class:`h-40 sm:h-48 rounded-lg p-2 sm:p-4`,"is-loading":I.value.packetRate,error:L.value,status:T.packetRate,onRetry:r[4]||=()=>{I.value.packetRate=!0,L.value=null,Y()}},{default:e(()=>[g(`canvas`,{ref_key:`packetRateCanvasRef`,ref:U,class:`w-full h-full relative z-10`},null,512)]),_:1},8,[`is-loading`,`error`,`status`])])]),g(`div`,Oe,[g(`div`,ke,[r[13]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Noise Floor Over Time `,-1),m(b,{class:`flex-1 min-h-[12rem] sm:min-h-[16rem] rounded-lg`,"is-loading":I.value.noiseFloor,error:z.value,status:T.noiseFloor,onRetry:r[5]||=()=>{I.value.noiseFloor=!0,z.value=null,Z()}},{default:e(()=>[g(`canvas`,{ref_key:`signalMetricsCanvasRef`,ref:W,class:`absolute inset-0 w-full h-full`},null,512)]),_:1},8,[`is-loading`,`error`,`status`])]),g(`div`,Ae,[r[14]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Route Distribution `,-1),m(b,{class:`flex-1 flex flex-col justify-evenly min-h-[8rem]`,"is-loading":I.value.routePie,error:R.value,status:T.routePie,onRetry:r[6]||=()=>{I.value.routePie=!0,R.value=null,X()}},{default:e(()=>[j.value?.route_totals?(f(!0),_(h,{key:0},d(j.value.route_totals,(e,n,r)=>(f(),_(`div`,{key:n,class:`flex items-center gap-3`},[g(`div`,je,t(n),1),g(`div`,Me,[g(`div`,{class:`h-full rounded transition-all duration-300`,style:s({width:`${e/Math.max(...Object.values(j.value.route_totals))*100}%`,backgroundColor:D.routes[r%D.routes.length]})},null,4)]),g(`div`,Ne,t(e.toLocaleString()),1)]))),128)):p(``,!0)]),_:1},8,[`is-loading`,`error`,`status`])])])]))}});export{C as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Statistics-CsAO5q_U.css b/repeater/web/html/assets/Statistics-CsAO5q_U.css deleted file mode 100644 index 692c9757..00000000 --- a/repeater/web/html/assets/Statistics-CsAO5q_U.css +++ /dev/null @@ -1 +0,0 @@ -.plotly-chart[data-v-54d032e1]{background:0 0!important} diff --git a/repeater/web/html/assets/Statistics-S4HgWYku.js b/repeater/web/html/assets/Statistics-S4HgWYku.js deleted file mode 100644 index e1912212..00000000 --- a/repeater/web/html/assets/Statistics-S4HgWYku.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./chunk-DECur_0Z.js";import{E as t,H as n,I as r,K as i,S as a,b as o,f as s,ft as c,g as l,j as u,k as d,l as f,m as p,o as m,pt as h,r as g,s as _,u as v,w as y,x as ee,z as b}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as x}from"./api-CbM6k1ZB.js";import{t as te}from"./packets-C-dzvp0W.js";import{t as ne}from"./websocket-nXR7EYbj.js";import{t as S}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{a as re,d as ie}from"./index-BFltqMtv.js";import{t as C}from"./plotly.min-Dl7ekyci.js";import{n as ae,t as oe}from"./preferences-Bv8i60GL.js";import{_ as se,a as w,c as ce,d as le,f as ue,g as de,h as fe,i as pe,l as me,m as he,n as ge,o as _e,r as ve,s as ye,t as be,u as xe}from"./chart-B1uYMRrx.js";import{t as T}from"./chartjs-adapter-date-fns.esm-DnBoPdP1.js";var E=e(C(),1),Se={class:`p-3 sm:p-6 space-y-4 sm:space-y-6`},Ce={class:`flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3`},we={class:`flex items-center gap-2 sm:gap-3`},Te=[`value`],Ee={class:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`},De={class:`glass-card rounded-[15px] p-3 sm:p-6`},Oe={class:`relative h-40 sm:h-48 rounded-lg p-2 sm:p-4`},ke={key:0,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 backdrop-blur-xs z-20`},Ae={key:1,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 z-20`},je={class:`grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6 items-stretch`},Me={class:`glass-card rounded-[15px] p-3 sm:p-6 flex flex-col`},Ne={class:`relative flex-1 min-h-[12rem] sm:min-h-[16rem] rounded-lg`},Pe={key:0,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 backdrop-blur-xs z-20`},Fe={class:`glass-card rounded-[15px] p-3 sm:p-6 flex flex-col`},Ie={class:`flex-1 flex flex-col justify-evenly`},Le={key:0,class:`flex items-center justify-center flex-1`},Re={key:1,class:`flex items-center justify-center flex-1`},ze={class:`w-28 sm:w-32 text-sm text-content-primary dark:text-content-primary truncate`},Be={class:`flex-1 h-12 bg-background-mute dark:bg-stroke/10 rounded overflow-hidden`},Ve={class:`w-20 text-sm text-content-secondary dark:text-content-muted text-right tabular-nums`},He={key:0,class:`glass-card rounded-[15px] p-6 sm:p-8 text-center`},Ue={key:1,class:`glass-card rounded-[15px] p-6 sm:p-8 text-center`},We={class:`text-content-secondary dark:text-content-muted text-sm`},D=S(l({name:`StatisticsView`,__name:`Statistics`,setup(e){w.register(pe,me,xe,ce,ye,ge,_e,le,de,se,fe,be,ve,he,ue);let l=te(),S=ne(),C=b(!1),D=()=>{let e=document.documentElement.classList.contains(`dark`);return{gridColor:e?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,tickColor:e?`rgba(255, 255, 255, 0.7)`:`rgba(0, 0, 0, 0.7)`,legendColor:e?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`,titleColor:e?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`}},O=b(oe(`statistics_selectedHours`,24)),Ge=[{value:1,label:`1 Hour`},{value:6,label:`6 Hours`},{value:12,label:`12 Hours`},{value:24,label:`24 Hours`},{value:48,label:`2 Days`},{value:168,label:`1 Week`}];d(O,e=>ae(`statistics_selectedHours`,e));let k=b(null),A=b(null),j=b([]),M=b(null),N=b([]),P=b([]),F=b(!0),I=b(null),L=b({packetRate:!0,packetType:!0,noiseFloor:!1,routePie:!0,sparklines:!0}),R=b(!1),z=b(!1),B=b(!1),V=b(null),H=b(null),U=b(null),W=b(null),G=b(null),K=b(null),q=b(null),J=m(()=>{let e=l.packetStats;return e?{totalRx:e.total_packets||0,totalTx:e.transmitted_packets||0}:{totalRx:0,totalTx:0}}),Y=(e,t)=>{if(e.length===0)return[];let n=Math.round(t*60*60*1e3/72),r=new Map;return e.forEach(([e,t])=>{let i=e;e>0x38d7ea4c68000?i=e/1e3:e>1e9&&e<0xe8d4a51000&&(i=e*1e3);let a=Math.floor(i/n)*n;r.has(a)||r.set(a,[]),r.get(a).push(t)}),Array.from(r.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>e.reduce((e,t)=>e+t,0)/e.length)},X=m(()=>{let e=[],t=[];if(k.value?.series){let n=k.value.series.find(e=>e.type===`rx_count`),r=k.value.series.find(e=>e.type===`tx_count`);n?.data&&(e=Y(n.data,O.value)),r?.data&&(t=Y(r.data,O.value))}return{totalPackets:e,transmittedPackets:t,droppedPackets:[],crcErrors:Y(P.value.map(e=>[e.timestamp>0xe8d4a51000?e.timestamp:e.timestamp*1e3,e.count]),O.value)}}),Z=async()=>{try{F.value=!0,I.value=null,await Promise.all([l.fetchPacketStats({hours:O.value}),l.fetchSystemStats()]),F.value=!1,Ke()}catch(e){I.value=e instanceof Error?e.message:`Failed to fetch data`,F.value=!1}},Ke=async()=>{L.value={packetRate:!0,packetType:!0,noiseFloor:!0,routePie:!0,sparklines:!0};let e=[qe(),Je(),Ye(),Xe(),Ze()];try{await Promise.allSettled(e),await o(),!W.value||!G.value?setTimeout(()=>{Q()},100):Q()}catch(e){console.error(`Error loading chart data:`,e)}},qe=async()=>{try{let e=await x.get(`/metrics_graph_data`,{hours:O.value,resolution:`average`,metrics:`rx_count,tx_count`});e?.success&&(k.value=e.data)}catch{k.value=null}},Je=async()=>{try{let e=await x.get(`/packet_type_graph_data`,{hours:O.value,resolution:`average`,types:`all`});e?.success&&e.data&&(j.value=e.data.series||[])}catch{j.value=[]}},Ye=async()=>{try{let e=await x.get(`/route_stats`,{hours:O.value});e?.success&&e.data&&(M.value=e.data)}catch{M.value=null}},Xe=async()=>{try{let e={hours:O.value},t=await x.get(`/noise_floor_history`,e);if(t.success&&t.data){let e=t.data.history||[];Array.isArray(e)&&e.length>0&&(A.value={chart_data:e.map(e=>({timestamp:e.timestamp||Date.now()/1e3,noise_floor_dbm:e.noise_floor_dbm||e.noise_floor||-120}))},$e())}}catch{A.value={chart_data:[]}}},Ze=async()=>{try{let e=await x.get(`/crc_error_history`,{hours:O.value});e?.success&&e.data&&(P.value=e.data.history||[])}catch{P.value=[]}},Qe=()=>{L.value={packetRate:!0,packetType:!0,noiseFloor:!0,routePie:!0,sparklines:!0},$(),R.value=!1,z.value=!1,B.value=!1,Z()},$e=()=>{N.value=[],A.value?.chart_data&&A.value.chart_data.length>0&&(N.value=A.value.chart_data.map(e=>({timestamp:e.timestamp*1e3,snr:null,rssi:null,noiseFloor:e.noise_floor_dbm})))},Q=()=>{if(!C.value){C.value=!0;try{et(),tt(),nt(),rt(),setTimeout(()=>{L.value={packetRate:!1,packetType:!1,noiseFloor:!1,routePie:!1,sparklines:!1},setTimeout(()=>{let e=n(V.value),t=n(H.value),r=n(U.value);e&&e.update(`none`),t&&t.update(`none`),r&&r.update(`none`)},50)},100)}catch(e){console.error(`Error creating/updating charts:`,e),$()}finally{C.value=!1}}},$=()=>{try{V.value&&=(V.value.destroy(),null),H.value&&=(H.value.destroy(),null),U.value&&=(U.value.destroy(),null),q.value&&E.default.purge(q.value)}catch(e){console.error(`Error destroying charts:`,e)}},et=()=>{if(!W.value)return;let e=W.value.getContext(`2d`);if(!e)return;let t=[],n=[];if(k.value?.series){let e=k.value.series.find(e=>e.type===`rx_count`),r=k.value.series.find(e=>e.type===`tx_count`);e?.data&&(t=e.data.map(([e,t])=>{let n=e;return n=e>0x38d7ea4c68000?e/1e3:e>0xe8d4a51000?e:e>1e9?e*1e3:Date.now(),{x:n,y:t}})),r?.data&&(n=r.data.map(([e,t])=>{let n=e;return n=e>0x38d7ea4c68000?e/1e3:e>0xe8d4a51000?e:e>1e9?e*1e3:Date.now(),{x:n,y:t}}))}if(t.length===0&&n.length===0){R.value=!0;return}R.value=!1,V.value&&=(V.value.destroy(),null);let i=Math.round(O.value*60*60*1e3/72),a=e=>{if(e.length===0)return[];let t=new Map;return e.forEach(e=>{let n=Math.floor(e.x/i)*i;t.has(n)||t.set(n,[]),t.get(n).push(e.y)}),Array.from(t.entries()).map(([e,t])=>({x:e,y:t.reduce((e,t)=>e+t,0)/t.length})).sort((e,t)=>e.x-t.x)},o=(e,t=3)=>{if(e.lengthe+t.y,0)/o.length;n.push({x:e[r].x,y:s})}return n},s=o(a(t)),c=o(a(n)),l=[...s.map(e=>e.y),...c.map(e=>e.y)],u=Math.min(...l),d=Math.max(...l),f=d-u||d*.1||.001,p=Math.max(0,u-f*.05),m=d+f*.05;try{let t=JSON.parse(JSON.stringify(s));V.value=r(new w(e,{type:`line`,data:{datasets:[{label:`TX/hr`,data:JSON.parse(JSON.stringify(c)),borderColor:`#F59E0B`,backgroundColor:`#F59E0B`,borderWidth:2,fill:`origin`,tension:.4,pointRadius:0,pointHoverRadius:3,order:1},{label:`RX/hr`,data:t,borderColor:`#C084FC`,backgroundColor:`#C084FC`,borderWidth:2,fill:`origin`,tension:.4,pointRadius:0,pointHoverRadius:3,order:2}]},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{display:!1},title:{display:!1},tooltip:{enabled:!0,backgroundColor:`rgba(0, 0, 0, 0.8)`,titleColor:`rgba(255, 255, 255, 0.9)`,bodyColor:`rgba(255, 255, 255, 0.8)`,borderColor:`rgba(255, 255, 255, 0.2)`,borderWidth:1,padding:12,displayColors:!0,callbacks:{title:function(e){let t=e[0]?.parsed?.x;return t==null?``:new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})},label:function(e){let t=e.dataset?.label||``,n=e.parsed?.y;return n==null?t:`${t}: ${n.toFixed(3)}`}}}},scales:{x:{type:`time`,time:{unit:`hour`,displayFormats:{hour:`HH:mm`}},min:Date.now()-O.value*3600*1e3,max:Date.now(),grid:{color:D().gridColor},ticks:{color:D().tickColor,maxTicksLimit:8}},y:{beginAtZero:!1,grid:{color:D().gridColor},ticks:{color:D().tickColor,callback:function(e){return typeof e==`number`?e.toFixed(3):e}},min:p,max:m}}}}))}catch(e){console.error(`Error creating packet rate chart:`,e),R.value=!0}},tt=()=>{if(!G.value)return;let e=G.value.getContext(`2d`);if(!e)return;let t=[],n=[],i=[`#60A5FA`,`#34D399`,`#FBBF24`,`#A78BFA`,`#F87171`,`#06B6D4`,`#84CC16`,`#F472B6`,`#10B981`];if(j.value.length>0)j.value.forEach(e=>{let r=e.data?e.data.reduce((e,t)=>e+t[1],0):0;r>0&&(t.push(e.name.replace(/\([^)]*\)/g,``).trim()),n.push(r))});else{z.value=!0;return}z.value=!1,H.value&&=(H.value.destroy(),null);try{let a=JSON.parse(JSON.stringify(t)),o=JSON.parse(JSON.stringify(n));H.value=r(new w(e,{type:`bar`,data:{labels:a,datasets:[{data:o,backgroundColor:i.slice(0,o.length),borderRadius:8,borderSkipped:!1}]},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},plugins:{legend:{display:!1}},scales:{x:{grid:{display:!1},ticks:{color:`rgba(255, 255, 255, 0.7)`,font:{size:10}}},y:{beginAtZero:!0,grid:{color:`rgba(255, 255, 255, 0.1)`},ticks:{color:`rgba(255, 255, 255, 0.7)`}}}}}))}catch(e){console.error(`Error creating packet type chart:`,e),z.value=!0}},nt=()=>{if(!K.value)return;let e=K.value.getContext(`2d`);if(!e)return;let t=N.value.map(e=>({x:e.timestamp,y:e.noiseFloor})).filter(e=>e.y!==null&&e.y!==void 0),i=t.map(e=>e.y),a=i.length>0?Math.min(...i):-120,o=i.length>0?Math.max(...i):-110,s=o-a||1,c=a-s*.05,l=o+s*.05;if(U.value)try{let e=n(U.value),r=JSON.parse(JSON.stringify(t));e.data.datasets[0]&&(e.data.datasets[0].data=r),e.options?.scales?.x&&(e.options.scales.x.min=Date.now()-O.value*3600*1e3,e.options.scales.x.max=Date.now()),e.update(`active`);return}catch{U.value.destroy(),U.value=null}U.value=r(new w(e,{type:`scatter`,data:{datasets:[{label:`Noise Floor (dBm)`,data:JSON.parse(JSON.stringify(t)),borderWidth:0,backgroundColor:`rgba(245, 158, 11, 0.8)`,pointRadius:3,pointHoverRadius:5,pointStyle:`circle`}]},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{display:!0,position:`top`,labels:{color:D().legendColor,usePointStyle:!0,padding:20}},tooltip:{enabled:!0,backgroundColor:`rgba(0, 0, 0, 0.8)`,titleColor:`rgba(255, 255, 255, 0.9)`,bodyColor:`rgba(255, 255, 255, 0.8)`,borderColor:`rgba(255, 255, 255, 0.2)`,borderWidth:1,padding:12,displayColors:!0,callbacks:{title:function(e){let t=e[0]?.parsed?.x;return t==null?``:new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})},label:function(e){let t=e.dataset?.label||``,n=e.parsed?.y;return n==null?t:`${t}: ${n.toFixed(1)} dBm`}}}},scales:{x:{type:`time`,time:{unit:`hour`,displayFormats:{hour:`HH:mm`}},min:Date.now()-O.value*3600*1e3,max:Date.now(),grid:{color:D().gridColor},ticks:{color:D().tickColor,maxTicksLimit:8}},y:{type:`linear`,display:!0,title:{display:!0,text:`Noise Floor (dBm)`,color:D().titleColor},grid:{color:`rgba(245, 158, 11, 0.2)`},ticks:{color:`#F59E0B`,callback:function(e){return typeof e==`number`?e.toFixed(1):e}},min:c,max:l}}}}))},rt=()=>{if(!q.value)return;if(!M.value||!M.value.route_totals){B.value=!0;return}B.value=!1;let e=M.value.route_totals,t=Object.keys(e),n=Object.values(e),r=[`#3B82F6`,`#10B981`,`#F59E0B`,`#A78BFA`,`#F87171`];try{let e=JSON.parse(JSON.stringify(t)),i=JSON.parse(JSON.stringify(n)),a=i.reduce((e,t)=>e+t,0),o=i.map(e=>e/a*100),s=e.map((e,t)=>({type:`bar`,name:e,x:[o[t]],y:[``],orientation:`h`,marker:{color:r[t%r.length]},text:o[t]>=5?`${e} ${o[t].toFixed(0)}%`:``,textposition:`inside`,textfont:{color:`white`,size:11},hoverinfo:`none`,insidetextanchor:`middle`}));E.default.newPlot(q.value,s,{paper_bgcolor:`rgba(0,0,0,0)`,plot_bgcolor:`rgba(0,0,0,0)`,font:{color:`rgba(255, 255, 255, 0.8)`,size:11},margin:{t:10,b:60,l:10,r:10},barmode:`stack`,showlegend:!0,legend:{orientation:`h`,x:0,y:-.3,xanchor:`left`,font:{color:`rgba(255, 255, 255, 0.8)`,size:10}},xaxis:{showgrid:!1,showticklabels:!1,zeroline:!1,range:[0,100]},yaxis:{showgrid:!1,showticklabels:!1,zeroline:!1},hovermode:!1,bargap:0},{responsive:!0,displayModeBar:!1,staticPlot:!0})}catch(e){console.error(`Error creating route treemap chart:`,e),B.value=!0}};return a(async()=>{await o(),Z(),window.addEventListener(`resize`,()=>{setTimeout(()=>{n(V.value)?.resize(),n(H.value)?.resize(),n(U.value)?.resize(),q.value&&E.default.Plots&&E.default.Plots.resize(q.value)},100)})}),ee(()=>{V.value?.destroy(),H.value?.destroy(),U.value?.destroy(),q.value&&E.default.purge(q.value),window.removeEventListener(`resize`,()=>{})}),re(Z,{intervalMs:3e4,enabled:()=>!S.isConnected,immediate:!1}),(e,n)=>(y(),v(`div`,Se,[_(`div`,Ce,[n[2]||=_(`h2`,{class:`text-xl sm:text-2xl font-bold text-content-primary dark:text-content-primary`},` Statistics `,-1),_(`div`,we,[n[1]||=_(`label`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},`Time Range:`,-1),u(_(`select`,{"onUpdate:modelValue":n[0]||=e=>O.value=e,onChange:Qe,class:`bg-white dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-2 sm:px-3 py-1.5 sm:py-2 text-content-primary dark:text-content-primary text-xs sm:text-sm focus:outline-hidden focus:border-primary dark:focus:border-accent-purple/50 transition-colors`},[(y(),v(g,null,t(Ge,e=>_(`option`,{key:e.value,value:e.value,class:`bg-white dark:bg-gray-800 text-content-primary dark:text-content-primary`},h(e.label),9,Te)),64))],544),[[ie,O.value]])])]),_(`div`,Ee,[p(T,{title:`Total RX`,value:J.value.totalRx,color:`#AAE8E8`,data:X.value.totalPackets,loading:L.value.sparklines,variant:`classic`},null,8,[`value`,`data`,`loading`]),p(T,{title:`Total TX`,value:J.value.totalTx,color:`#FFC246`,data:X.value.transmittedPackets,loading:L.value.sparklines,variant:`classic`},null,8,[`value`,`data`,`loading`]),p(T,{title:`CRC Errors`,value:P.value.reduce((e,t)=>e+t.count,0),color:`#F59E0B`,data:X.value.crcErrors,loading:L.value.sparklines,variant:`classic`},null,8,[`value`,`data`,`loading`]),p(T,{title:`Packet Hash Cache`,value:i(l).systemStats?.duplicate_cache_size??0,color:`#9F7AEA`,data:[],loading:!1,variant:`smooth`,subtitle:`Entries expire after ${(()=>{let e=i(l).systemStats?.cache_ttl??3600,t=Math.floor(e/60);return t>=60?`${Math.floor(t/60)}h`:`${t}m`})()}`},null,8,[`value`,`subtitle`])]),_(`div`,De,[n[6]||=_(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Performance Metrics `,-1),_(`div`,null,[n[5]||=s(`

Packet Rate (RX/TX PER HOUR)

RX/hr
TX/hr
`,2),_(`div`,Oe,[_(`canvas`,{ref_key:`packetRateCanvasRef`,ref:W,class:`w-full h-full relative z-10`},null,512),L.value.packetRate?(y(),v(`div`,ke,[...n[3]||=[_(`div`,{class:`text-center`},[_(`div`,{class:`animate-spin w-6 h-6 sm:w-8 sm:h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-purple-600 dark:border-t-purple-400 rounded-full mx-auto mb-2`}),_(`div`,{class:`text-content-secondary dark:text-content-muted text-[10px] sm:text-xs`},` Loading packet rate data... `)],-1)]])):f(``,!0),R.value&&!L.value.packetRate?(y(),v(`div`,Ae,[...n[4]||=[_(`div`,{class:`text-center`},[_(`div`,{class:`text-red-700 dark:text-red-400 text-sm font-semibold mb-1`},` No Data Available `),_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Packet rate data not found `)],-1)]])):f(``,!0)])])]),_(`div`,je,[_(`div`,Me,[n[8]||=_(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Noise Floor Over Time `,-1),_(`div`,Ne,[_(`canvas`,{ref_key:`signalMetricsCanvasRef`,ref:K,class:`w-full h-full`},null,512),L.value.noiseFloor?(y(),v(`div`,Pe,[...n[7]||=[_(`div`,{class:`text-center`},[_(`div`,{class:`animate-spin w-6 h-6 sm:w-8 sm:h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-amber-600 dark:border-t-amber-400 rounded-full mx-auto mb-2`}),_(`div`,{class:`text-content-secondary dark:text-content-muted text-[10px] sm:text-xs`},` Loading noise floor data... `)],-1)]])):f(``,!0)])]),_(`div`,Fe,[n[11]||=_(`h3`,{class:`text-content-primary dark:text-content-primary text-lg sm:text-xl font-semibold mb-3 sm:mb-4`},` Route Distribution `,-1),_(`div`,Ie,[L.value.routePie?(y(),v(`div`,Le,[...n[9]||=[_(`div`,{class:`text-center`},[_(`div`,{class:`animate-spin w-6 h-6 border-2 border-stroke-subtle dark:border-stroke/20 border-t-green-600 dark:border-t-green-400 rounded-full mx-auto mb-2`}),_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Loading route data... `)],-1)]])):B.value?(y(),v(`div`,Re,[...n[10]||=[_(`div`,{class:`text-center`},[_(`div`,{class:`text-red-700 dark:text-red-400 text-sm font-semibold mb-1`},` No Data Available `),_(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Route statistics not found `)],-1)]])):M.value?.route_totals?(y(!0),v(g,{key:2},t(M.value.route_totals,(e,t,n)=>(y(),v(`div`,{key:t,class:`flex items-center gap-3`},[_(`div`,ze,h(t),1),_(`div`,Be,[_(`div`,{class:`h-full rounded transition-all duration-300`,style:c({width:`${e/Math.max(...Object.values(M.value.route_totals))*100}%`,backgroundColor:[`#3B82F6`,`#10B981`,`#F59E0B`,`#A78BFA`,`#F87171`][n%5]})},null,4)]),_(`div`,Ve,h(e.toLocaleString()),1)]))),128)):f(``,!0)])])]),F.value?(y(),v(`div`,He,[...n[12]||=[_(`div`,{class:`text-content-secondary dark:text-content-muted mb-2 text-sm`},` Loading statistics... `,-1),_(`div`,{class:`animate-spin w-6 h-6 sm:w-8 sm:h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-content-primary dark:border-t-white/70 rounded-full mx-auto`},null,-1)]])):f(``,!0),I.value?(y(),v(`div`,Ue,[n[13]||=_(`div`,{class:`text-red-700 dark:text-red-400 mb-2 text-sm font-semibold`},` Failed to load statistics `,-1),_(`p`,We,h(I.value),1),_(`button`,{onClick:Z,class:`mt-4 px-4 py-2 bg-primary hover:bg-primary/90 dark:bg-primary dark:hover:bg-primary/80 text-white font-medium rounded-lg border border-primary/20 dark:border-primary/30 transition-colors shadow-sm`},` Retry `)])):f(``,!0)]))}}),[[`__scopeId`,`data-v-54d032e1`]]);export{D as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/SystemStats-4wDqjB6x.js b/repeater/web/html/assets/SystemStats-4wDqjB6x.js deleted file mode 100644 index ad0856bf..00000000 --- a/repeater/web/html/assets/SystemStats-4wDqjB6x.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/plotly.min-Dl7ekyci.js","assets/chunk-DECur_0Z.js"])))=>i.map(i=>d[i]); -import{r as e}from"./chunk-DECur_0Z.js";import{E as t,H as n,I as r,S as i,b as a,dt as o,g as s,l as c,m as l,o as u,pt as d,r as f,s as p,u as m,w as h,x as ee,z as g}from"./runtime-core.esm-bundler-HnidnMFy.js";import{a as _,t as v}from"./api-CbM6k1ZB.js";import{t as y}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{_ as te,a as b,c as ne,f as re,g as ie,h as ae,i as oe,l as se,m as ce,n as le,o as ue,r as de,s as fe,t as pe,u as me}from"./chart-B1uYMRrx.js";import{t as x}from"./chartjs-adapter-date-fns.esm-DnBoPdP1.js";var he={class:`p-6 space-y-6`},ge={class:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`},_e={class:`grid grid-cols-1 lg:grid-cols-2 gap-6`},ve={class:`glass-card rounded-[15px] p-6`},ye={class:`relative h-32 bg-gray-100/50 dark:bg-white/5 rounded-lg p-4 mb-4 chart-container`},be={key:0,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 backdrop-blur-sm z-20`},xe={key:1,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 z-20`},Se={key:0,class:`grid grid-cols-2 gap-4 text-sm`},Ce={class:`text-content-primary dark:text-content-primary font-semibold`},S={class:`text-content-primary dark:text-content-primary font-semibold`},C={class:`text-content-primary dark:text-content-primary font-semibold`},w={class:`text-content-primary dark:text-content-primary font-semibold`},T={class:`glass-card rounded-[15px] p-6`},E={class:`relative h-32 bg-gray-100/50 dark:bg-white/5 rounded-lg p-4 mb-4 chart-container`},D={key:0,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 backdrop-blur-sm z-20`},O={key:1,class:`absolute inset-0 flex items-center justify-center bg-white/50 dark:bg-white/5 z-20`},k={key:0,class:`grid grid-cols-2 gap-4 text-sm`},A={class:`text-content-primary dark:text-content-primary font-semibold`},we={class:`text-content-primary dark:text-content-primary font-semibold`},Te={class:`text-content-primary dark:text-content-primary font-semibold`},Ee={class:`text-content-primary dark:text-content-primary font-semibold`},De={class:`grid grid-cols-1 lg:grid-cols-2 gap-6`},Oe={class:`glass-card rounded-[15px] p-6`},ke={class:`relative h-48`},Ae={key:0,class:`grid grid-cols-3 gap-4 text-sm mt-4`},je={class:`text-center`},Me={class:`text-content-primary dark:text-content-primary font-semibold`},Ne={class:`text-center`},Pe={class:`font-semibold text-red-500 dark:text-red-400`},Fe={class:`text-center`},Ie={class:`font-semibold text-green-700 dark:text-green-400`},Le={class:`glass-card rounded-[15px] p-6`},Re={key:0,class:`space-y-4`},ze={class:`grid grid-cols-2 gap-4 text-sm`},Be={class:`text-content-primary dark:text-content-primary font-semibold`},Ve={class:`text-content-primary dark:text-content-primary font-semibold`},He={class:`text-content-primary dark:text-content-primary font-semibold`},Ue={class:`text-content-primary dark:text-content-primary font-semibold`},We={key:0,class:`pt-4 border-t border-stroke-subtle dark:border-stroke/10`},Ge={class:`grid grid-cols-2 gap-2 text-sm`},j={class:`text-content-secondary dark:text-content-muted`},Ke={class:`text-content-primary dark:text-content-primary font-semibold ml-1`},qe={class:`glass-card rounded-[15px] p-6`},Je={key:0,class:`overflow-x-auto`},Ye={class:`w-full text-sm`},Xe={class:`text-content-secondary dark:text-content-primary/80 py-2 transition-all duration-300`},Ze={class:`text-content-primary dark:text-content-primary font-semibold py-2 transition-all duration-300`},Qe={class:`text-center text-orange-500 dark:text-orange-400 py-2 transition-all duration-300`},$e={class:`text-center text-green-700 dark:text-green-400 py-2 transition-all duration-300`},et={class:`text-right text-content-secondary dark:text-content-primary/80 py-2 transition-all duration-300`},tt={key:0,class:`mt-4 text-center text-content-secondary dark:text-content-muted text-sm transition-all duration-300`},nt={key:1,class:`text-center text-content-secondary dark:text-content-muted py-8`},rt={key:0,class:`glass-card rounded-[15px] p-8 text-center`},it={key:1,class:`glass-card rounded-[15px] p-8 text-center`},at={class:`text-content-secondary dark:text-content-muted text-sm`},M=y(s({name:`SystemStatsView`,__name:`SystemStats`,setup(s){b.register(oe,se,me,ne,fe,le,ue,ie,te,ae,pe,de,ce,re);let y=g(null),M=g(!0),N=g(null),P=g(null),F=g(null),I=g([]),L=g(null),R=g({cpuChart:!0,memoryChart:!0,diskChart:!1,processChart:!0}),z=g(!1),B=g(!1),V=g(null),H=g(null),U=g(null),W=g(null),G=g(null),K=u(()=>P.value?{cpuUsage:P.value.cpu.usage_percent,memoryUsage:P.value.memory.usage_percent,diskUsage:P.value.disk.usage_percent,uptime:P.value.system.uptime}:{cpuUsage:0,memoryUsage:0,diskUsage:0,uptime:0}),q=u(()=>I.value.length===0?{cpu:[],memory:[],disk:[],network:[]}:{cpu:I.value.map(e=>e.cpu.usage_percent),memory:I.value.map(e=>e.memory.usage_percent),disk:I.value.map(e=>e.disk.usage_percent),network:I.value.map(e=>e.network.bytes_recv/1024/1024)}),J=e=>{let t=[`B`,`KB`,`MB`,`GB`,`TB`];if(e===0)return`0 B`;let n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/1024**n).toFixed(2))+` `+t[n]},ot=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`},st=async()=>{try{let e=await v.get(`/hardware_stats`);if(e?.success&&e.data){let t=e.data;if(P.value=t,I.value.length===0)for(let e=0;e<12;e++)I.value.push(JSON.parse(JSON.stringify(t)));else I.value.push(t),I.value.length>20&&I.value.shift()}}catch(e){console.error(`Failed to fetch hardware stats:`,e),N.value=`Failed to fetch hardware stats`}},ct=async()=>{try{let e=await v.get(`/hardware_processes`);e?.success&&e.data&&(L.value=F.value,F.value=e.data)}catch(e){console.error(`Failed to fetch process stats:`,e)}},Y=(e,t)=>{if(!L.value)return!1;let n=L.value.processes.find(t=>t.pid===e.pid);return n?n[t]!==e[t]:!0},X=async()=>{try{M.value=!0,N.value=null,await Promise.all([st(),ct()]),M.value=!1,await a(),Z()}catch(e){N.value=e instanceof Error?e.message:`Failed to fetch system data`,M.value=!1}},Z=()=>{P.value&&(lt(),ut(),dt())},lt=()=>{if(!U.value||!P.value){R.value.cpuChart=!1;return}let e=U.value.getContext(`2d`);if(!e){R.value.cpuChart=!1;return}let t=P.value.cpu.usage_percent,n=100-t;if(V.value)try{V.value.data.datasets[0].data=[t,n],V.value.update(`none`);return}catch(e){console.warn(`Failed to update CPU chart, recreating...`,e),V.value.destroy(),V.value=null}let i=document.documentElement.classList.contains(`dark`),a=i?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,o=i?`rgba(255, 255, 255, 0.2)`:`rgba(0, 0, 0, 0.2)`,s=i?`rgba(255, 255, 255, 0.6)`:`rgba(0, 0, 0, 0.6)`;try{V.value=r(new b(e,{type:`doughnut`,data:{labels:[`Used`,`Available`],datasets:[{data:[t,n],backgroundColor:[`#FFC246`,a],borderColor:[`#FFC246`,o],borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`70%`,animation:{animateRotate:!1,animateScale:!1,duration:0},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){return`${e.label}: ${e.parsed.toFixed(1)}%`}}}}},plugins:[{id:`centerText`,beforeDraw:function(e){let n=e.ctx;n.save();let r=(e.chartArea.left+e.chartArea.right)/2,i=(e.chartArea.top+e.chartArea.bottom)/2;n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=`#FFC246`,n.font=`bold 18px sans-serif`,n.fillText(`${t.toFixed(1)}%`,r,i-5),n.fillStyle=s,n.font=`10px sans-serif`,n.fillText(`CPU`,r,i+12),n.restore()}}]})),z.value=!1,R.value.cpuChart=!1}catch(e){console.error(`Error creating CPU chart:`,e),z.value=!0,R.value.cpuChart=!1}},ut=()=>{if(!W.value||!P.value){R.value.memoryChart=!1;return}let e=W.value.getContext(`2d`);if(!e){R.value.memoryChart=!1;return}let t=P.value.memory.usage_percent,n=100-t;if(H.value)try{H.value.data.datasets[0].data=[t,n],H.value.update(`none`);return}catch(e){console.warn(`Failed to update Memory chart, recreating...`,e),H.value.destroy(),H.value=null}let i=document.documentElement.classList.contains(`dark`),a=i?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,o=i?`rgba(255, 255, 255, 0.2)`:`rgba(0, 0, 0, 0.2)`,s=i?`rgba(255, 255, 255, 0.6)`:`rgba(0, 0, 0, 0.6)`;try{H.value=r(new b(e,{type:`doughnut`,data:{labels:[`Used`,`Available`],datasets:[{data:[t,n],backgroundColor:[`#A5E5B6`,a],borderColor:[`#A5E5B6`,o],borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`70%`,animation:{animateRotate:!1,animateScale:!1,duration:0},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){return`${e.label}: ${e.parsed.toFixed(1)}%`}}}}},plugins:[{id:`centerText`,beforeDraw:function(e){let n=e.ctx;n.save();let r=(e.chartArea.left+e.chartArea.right)/2,i=(e.chartArea.top+e.chartArea.bottom)/2;n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=`#A5E5B6`,n.font=`bold 18px sans-serif`,n.fillText(`${t.toFixed(1)}%`,r,i-5),n.fillStyle=s,n.font=`10px sans-serif`,n.fillText(`Memory`,r,i+12),n.restore()}}]})),B.value=!1,R.value.memoryChart=!1}catch(e){console.error(`Error creating Memory chart:`,e),B.value=!0,R.value.memoryChart=!1}},dt=()=>{if(!G.value||!P.value)return;let t=document.documentElement.classList.contains(`dark`)?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`;try{_(()=>import(`./plotly.min-Dl7ekyci.js`).then(t=>e(t.t(),1)).then(e=>{let n=e.default||e,r=P.value.disk,i=[{type:`pie`,labels:[`Used`,`Free`],values:[r.used,r.free],marker:{colors:[`#FB787B`,`#A5E5B6`]},hovertemplate:`%{label}
Size: %{value}
Percentage: %{percent}`,textinfo:`label+percent`,textposition:`auto`,hole:.4}],a={title:{text:``,font:{color:t}},paper_bgcolor:`rgba(0,0,0,0)`,plot_bgcolor:`rgba(0,0,0,0)`,font:{color:t,size:11},margin:{t:20,b:20,l:20,r:20},showlegend:!0,legend:{orientation:`h`,x:0,y:-.2,font:{color:t,size:10}}};n.newPlot(G.value,i,a,{responsive:!0,displayModeBar:!1,staticPlot:!1})}),__vite__mapDeps([0,1]))}catch(e){console.error(`Error creating disk chart:`,e)}},Q=()=>{try{if(V.value&&=(V.value.destroy(),null),H.value&&=(H.value.destroy(),null),G.value)try{_(()=>import(`./plotly.min-Dl7ekyci.js`).then(t=>e(t.t(),1)).then(e=>{let t=e?.default||e;t?.purge&&t.purge(G.value)}),__vite__mapDeps([0,1])).catch(()=>{})}catch{}}catch(e){console.error(`Error destroying charts:`,e)}},$=new MutationObserver(e=>{e.forEach(e=>{e.attributeName===`class`&&(Q(),a(()=>{Z()}))})});return i(async()=>{await a(),X(),y.value=window.setInterval(X,5e3),$.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),window.addEventListener(`resize`,()=>{setTimeout(()=>{n(V.value)?.resize(),n(H.value)?.resize();try{_(()=>import(`./plotly.min-Dl7ekyci.js`).then(t=>e(t.t(),1)).then(e=>{let t=e?.default||e;t?.Plots&&t.Plots.resize(G.value)}),__vite__mapDeps([0,1])).catch(()=>{})}catch{}},100)})}),ee(()=>{y.value&&clearInterval(y.value),$.disconnect(),Q(),window.removeEventListener(`resize`,()=>{})}),(e,n)=>(h(),m(`div`,he,[n[28]||=p(`div`,{class:`flex justify-between items-center`},[p(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` System Statistics `),p(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},` Updates every 5 seconds `)],-1),p(`div`,ge,[l(x,{title:`CPU Usage`,value:`${K.value.cpuUsage.toFixed(1)}%`,color:`#FFC246`,data:q.value.cpu},null,8,[`value`,`data`]),l(x,{title:`Memory Usage`,value:`${K.value.memoryUsage.toFixed(1)}%`,color:`#A5E5B6`,data:q.value.memory},null,8,[`value`,`data`]),l(x,{title:`Disk Usage`,value:`${K.value.diskUsage.toFixed(1)}%`,color:`#FB787B`,data:q.value.disk},null,8,[`value`,`data`]),l(x,{title:`Uptime`,value:ot(K.value.uptime),color:`#EBA0FC`,data:q.value.network},null,8,[`value`,`data`])]),p(`div`,_e,[p(`div`,ve,[n[6]||=p(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` CPU Performance `,-1),p(`div`,ye,[p(`canvas`,{ref_key:`cpuCanvasRef`,ref:U,class:`w-full h-full relative z-10`},null,512),R.value.cpuChart?(h(),m(`div`,be,[...n[0]||=[p(`div`,{class:`text-center`},[p(`div`,{class:`animate-spin w-6 h-6 border-2 border-stroke-subtle dark:border-stroke/20 border-t-orange-400 rounded-full mx-auto mb-2`}),p(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Loading CPU data... `)],-1)]])):c(``,!0),z.value&&!R.value.cpuChart?(h(),m(`div`,xe,[...n[1]||=[p(`div`,{class:`text-center`},[p(`div`,{class:`text-red-500 dark:text-red-400 text-sm mb-1`},`No Data Available`),p(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` CPU data not found `)],-1)]])):c(``,!0)]),P.value?(h(),m(`div`,Se,[p(`div`,null,[n[2]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`CPU Count`,-1),p(`div`,Ce,d(P.value.cpu.count)+` cores `,1)]),p(`div`,null,[n[3]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Frequency`,-1),p(`div`,S,d(P.value.cpu.frequency.toFixed(0))+` MHz `,1)]),p(`div`,null,[n[4]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Load (1m)`,-1),p(`div`,C,d(P.value.cpu.load_avg[`1min`].toFixed(2)),1)]),p(`div`,null,[n[5]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Load (5m)`,-1),p(`div`,w,d(P.value.cpu.load_avg[`5min`].toFixed(2)),1)])])):c(``,!0)]),p(`div`,T,[n[13]||=p(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Memory Usage `,-1),p(`div`,E,[p(`canvas`,{ref_key:`memoryCanvasRef`,ref:W,class:`w-full h-full relative z-10`},null,512),R.value.memoryChart?(h(),m(`div`,D,[...n[7]||=[p(`div`,{class:`text-center`},[p(`div`,{class:`animate-spin w-6 h-6 border-2 border-stroke-subtle dark:border-stroke/20 border-t-green-400 rounded-full mx-auto mb-2`}),p(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Loading memory data... `)],-1)]])):c(``,!0),B.value&&!R.value.memoryChart?(h(),m(`div`,O,[...n[8]||=[p(`div`,{class:`text-center`},[p(`div`,{class:`text-red-500 dark:text-red-400 text-sm mb-1`},`No Data Available`),p(`div`,{class:`text-content-secondary dark:text-content-muted text-xs`},` Memory data not found `)],-1)]])):c(``,!0)]),P.value?(h(),m(`div`,k,[p(`div`,null,[n[9]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Total`,-1),p(`div`,A,d(J(P.value.memory.total)),1)]),p(`div`,null,[n[10]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Used`,-1),p(`div`,we,d(J(P.value.memory.used)),1)]),p(`div`,null,[n[11]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Available`,-1),p(`div`,Te,d(J(P.value.memory.available)),1)]),p(`div`,null,[n[12]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Usage`,-1),p(`div`,Ee,d(P.value.memory.usage_percent.toFixed(1))+`% `,1)])])):c(``,!0)])]),p(`div`,De,[p(`div`,Oe,[n[17]||=p(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Storage Usage `,-1),p(`div`,ke,[p(`div`,{ref_key:`diskCanvasRef`,ref:G,class:`w-full h-full`},null,512)]),P.value?(h(),m(`div`,Ae,[p(`div`,je,[n[14]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Total`,-1),p(`div`,Me,d(J(P.value.disk.total)),1)]),p(`div`,Ne,[n[15]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Used`,-1),p(`div`,Pe,d(J(P.value.disk.used)),1)]),p(`div`,Fe,[n[16]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Free`,-1),p(`div`,Ie,d(J(P.value.disk.free)),1)])])):c(``,!0)]),p(`div`,Le,[n[23]||=p(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Network Statistics `,-1),P.value?(h(),m(`div`,Re,[p(`div`,ze,[p(`div`,null,[n[18]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Bytes Sent`,-1),p(`div`,Be,d(J(P.value.network.bytes_sent)),1)]),p(`div`,null,[n[19]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Bytes Received`,-1),p(`div`,Ve,d(J(P.value.network.bytes_recv)),1)]),p(`div`,null,[n[20]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Packets Sent`,-1),p(`div`,He,d(P.value.network.packets_sent.toLocaleString()),1)]),p(`div`,null,[n[21]||=p(`div`,{class:`text-content-secondary dark:text-content-muted`},`Packets Received`,-1),p(`div`,Ue,d(P.value.network.packets_recv.toLocaleString()),1)])]),P.value.temperatures&&Object.keys(P.value.temperatures).length>0?(h(),m(`div`,We,[n[22]||=p(`div`,{class:`text-content-secondary dark:text-content-muted mb-2`},` System Temperatures `,-1),p(`div`,Ge,[(h(!0),m(f,null,t(P.value.temperatures,(e,t)=>(h(),m(`div`,{key:t},[p(`span`,j,d(t)+`:`,1),p(`span`,Ke,d(e.toFixed(1))+`°C`,1)]))),128))])])):c(``,!0)])):c(``,!0)])]),p(`div`,qe,[n[25]||=p(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Top Processes `,-1),F.value?.processes&&F.value.processes.length>0?(h(),m(`div`,Je,[p(`table`,Ye,[n[24]||=p(`thead`,null,[p(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[p(`th`,{class:`text-left text-content-secondary dark:text-content-muted py-2`},`PID`),p(`th`,{class:`text-left text-content-secondary dark:text-content-muted py-2`},`Name`),p(`th`,{class:`text-center text-content-secondary dark:text-content-muted py-2`},`CPU %`),p(`th`,{class:`text-center text-content-secondary dark:text-content-muted py-2`},` Memory % `),p(`th`,{class:`text-right text-content-secondary dark:text-content-muted py-2`},`Memory`)])],-1),p(`tbody`,null,[(h(!0),m(f,null,t(F.value.processes.slice(0,10),e=>(h(),m(`tr`,{key:e.pid,class:`border-b border-stroke-subtle dark:border-white/5 process-row`},[p(`td`,Xe,d(e.pid),1),p(`td`,Ze,d(e.name),1),p(`td`,Qe,[p(`span`,{class:o([`cpu-value`,{"value-updated":Y(e,`cpu_percent`)}])},d(e.cpu_percent.toFixed(1))+`% `,3)]),p(`td`,$e,[p(`span`,{class:o([`memory-value`,{"value-updated":Y(e,`memory_percent`)}])},d(e.memory_percent.toFixed(1))+`% `,3)]),p(`td`,et,[p(`span`,{class:o({"value-updated":Y(e,`memory_mb`)})},d(e.memory_mb.toFixed(1))+` MB `,3)])]))),128))])]),F.value.total_processes?(h(),m(`div`,tt,` Showing top 10 of `+d(F.value.total_processes)+` total processes `,1)):c(``,!0)])):M.value?c(``,!0):(h(),m(`div`,nt,` No process data available `))]),M.value?(h(),m(`div`,rt,[...n[26]||=[p(`div`,{class:`text-content-secondary dark:text-content-muted mb-2`},` Loading system statistics... `,-1),p(`div`,{class:`animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-gray-900 dark:border-t-white/70 rounded-full mx-auto`},null,-1)]])):c(``,!0),N.value?(h(),m(`div`,it,[n[27]||=p(`div`,{class:`text-red-500 dark:text-red-400 mb-2`},`Failed to load system statistics`,-1),p(`p`,at,d(N.value),1),p(`button`,{onClick:X,class:`mt-4 px-4 py-2 bg-purple-500/20 dark:bg-accent-purple/20 hover:bg-purple-500/30 dark:hover:bg-accent-purple/30 text-content-primary dark:text-content-primary rounded-lg border border-purple-500/50 dark:border-accent-purple/50 transition-colors`},` Retry `)])):c(``,!0)]))}}),[[`__scopeId`,`data-v-fda01968`]]);export{M as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/SystemStats-Dnc1_s5j.css b/repeater/web/html/assets/SystemStats-Dnc1_s5j.css deleted file mode 100644 index 04344e0c..00000000 --- a/repeater/web/html/assets/SystemStats-Dnc1_s5j.css +++ /dev/null @@ -1 +0,0 @@ -.glass-card[data-v-fda01968]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#ffffffbf;border:1px solid #0000000f;box-shadow:0 2px 8px #0000000a}.dark .glass-card[data-v-fda01968]{box-shadow:none;background:#0000004d;border:1px solid #ffffff1a}.chart-updating[data-v-fda01968]{animation:.8s ease-in-out subtle-pulse-fda01968}@keyframes subtle-pulse-fda01968{0%{transform:scale(1)}50%{transform:scale(1.02)}to{transform:scale(1)}}.chart-container[data-v-fda01968]{transition:all .3s;position:relative}.chart-container[data-v-fda01968]:hover{background:#0000000a}.dark .chart-container[data-v-fda01968]:hover{background:#ffffff14}.process-row[data-v-fda01968]{transition:all .3s}.process-row[data-v-fda01968]:hover{background:#00000005;transform:translate(2px)}.dark .process-row[data-v-fda01968]:hover{background:#ffffff0d}.process-row-enter-active[data-v-fda01968],.process-row-leave-active[data-v-fda01968]{transition:all .4s}.process-row-enter-from[data-v-fda01968]{opacity:0;transform:translateY(-10px)scale(.95)}.process-row-leave-to[data-v-fda01968]{opacity:0;transform:translateY(10px)scale(.95)}.process-row-move[data-v-fda01968]{transition:transform .4s}.cpu-value[data-v-fda01968],.memory-value[data-v-fda01968]{border-radius:4px;padding:2px 6px;transition:all .3s}.cpu-value[data-v-fda01968]:hover,.memory-value[data-v-fda01968]:hover{background:#f59e0b1a;transform:scale(1.05)}@keyframes value-update-fda01968{0%{background:#f59e0b4d}to{background:0 0}}.value-updated[data-v-fda01968]{animation:.6s ease-out value-update-fda01968} diff --git a/repeater/web/html/assets/SystemStats-DzIGYJV7.css b/repeater/web/html/assets/SystemStats-DzIGYJV7.css new file mode 100644 index 00000000..67d302ee --- /dev/null +++ b/repeater/web/html/assets/SystemStats-DzIGYJV7.css @@ -0,0 +1 @@ +.chart-updating[data-v-d0fbc86b]{animation:.8s ease-in-out subtle-pulse-d0fbc86b}@keyframes subtle-pulse-d0fbc86b{0%{transform:scale(1)}50%{transform:scale(1.02)}to{transform:scale(1)}}.process-row[data-v-d0fbc86b]{transition:all .3s}.process-row[data-v-d0fbc86b]:hover{background:#00000005;transform:translate(2px)}.dark .process-row[data-v-d0fbc86b]:hover{background:#ffffff0d}.process-row-enter-active[data-v-d0fbc86b],.process-row-leave-active[data-v-d0fbc86b]{transition:all .4s}.process-row-enter-from[data-v-d0fbc86b]{opacity:0;transform:translateY(-10px)scale(.95)}.process-row-leave-to[data-v-d0fbc86b]{opacity:0;transform:translateY(10px)scale(.95)}.process-row-move[data-v-d0fbc86b]{transition:transform .4s}.cpu-value[data-v-d0fbc86b],.memory-value[data-v-d0fbc86b]{border-radius:4px;padding:2px 6px;transition:all .3s}.cpu-value[data-v-d0fbc86b]:hover,.memory-value[data-v-d0fbc86b]:hover{background:color-mix(in srgb, var(--color-secondary) 10%, transparent);transform:scale(1.05)}@keyframes value-update-d0fbc86b{0%{background:color-mix(in srgb, var(--color-secondary) 30%, transparent)}to{background:0 0}}.value-updated[data-v-d0fbc86b]{animation:.6s ease-out value-update-d0fbc86b} diff --git a/repeater/web/html/assets/SystemStats-sG4byBWD.js b/repeater/web/html/assets/SystemStats-sG4byBWD.js new file mode 100644 index 00000000..6eefab8f --- /dev/null +++ b/repeater/web/html/assets/SystemStats-sG4byBWD.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/plotly.min-BmxIBpZZ.js","assets/chunk-DECur_0Z.js"])))=>i.map(i=>d[i]); +import{r as e}from"./chunk-DECur_0Z.js";import{B as t,Ct as n,E as r,K as i,Q as a,R as o,S as s,Y as c,g as ee,j as l,k as u,l as d,m as f,nt as p,o as m,r as h,s as g,u as _,w as te,xt as v}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{o as y}from"./api-3gMnsCKh.js";import{t as b}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as ne}from"./useTheme-B2sN4eXt.js";import{t as re}from"./index-DTUpsCzx.js";import{t as x}from"./formatters-CHyWlnnq.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,i as ue,l as de,m as fe,n as S,o as pe,r as me,s as C,t as w,u as he,v as ge,y as _e}from"./ChartCard-Dv7_dbhW.js";import{t as T}from"./chartjs-adapter-date-fns.esm-CUNlL-Mn.js";var ve={class:`p-6 space-y-6`},ye={class:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`},be={class:`grid grid-cols-1 lg:grid-cols-2 gap-6`},xe={class:`glass-card rounded-[15px] p-6`},Se={key:0,class:`grid grid-cols-2 gap-4 text-sm`},Ce={class:`text-content-primary dark:text-content-primary font-semibold`},we={class:`text-content-primary dark:text-content-primary font-semibold`},Te={class:`text-content-primary dark:text-content-primary font-semibold`},E={class:`text-content-primary dark:text-content-primary font-semibold`},D={class:`glass-card rounded-[15px] p-6`},O={key:0,class:`grid grid-cols-2 gap-4 text-sm`},Ee={class:`text-content-primary dark:text-content-primary font-semibold`},De={class:`text-content-primary dark:text-content-primary font-semibold`},Oe={class:`text-content-primary dark:text-content-primary font-semibold`},ke={class:`text-content-primary dark:text-content-primary font-semibold`},Ae={class:`grid grid-cols-1 lg:grid-cols-2 gap-6`},je={class:`glass-card rounded-[15px] p-6`},Me={class:`relative h-48`},Ne={key:0,class:`grid grid-cols-3 gap-4 text-sm mt-4`},Pe={class:`text-center`},Fe={class:`text-content-primary dark:text-content-primary font-semibold`},Ie={class:`text-center`},Le={class:`font-semibold text-accent-red`},Re={class:`text-center`},ze={class:`font-semibold text-accent-green`},Be={class:`glass-card rounded-[15px] p-6`},Ve={key:0,class:`space-y-4`},He={class:`grid grid-cols-2 gap-4 text-sm`},Ue={class:`text-content-primary dark:text-content-primary font-semibold`},We={class:`text-content-primary dark:text-content-primary font-semibold`},Ge={class:`text-content-primary dark:text-content-primary font-semibold`},Ke={class:`text-content-primary dark:text-content-primary font-semibold`},qe={key:0,class:`pt-4 border-t border-stroke-subtle dark:border-stroke/10`},Je={class:`grid grid-cols-2 gap-2 text-sm`},k={class:`text-content-secondary dark:text-content-muted`},Ye={class:`text-content-primary dark:text-content-primary font-semibold ml-1`},Xe={class:`glass-card rounded-[15px] p-6`},Ze={key:0,class:`overflow-x-auto`},Qe={class:`w-full text-sm`},$e={class:`text-content-secondary dark:text-content-primary/80 py-2 transition-all duration-300`},et={class:`text-content-primary dark:text-content-primary font-semibold py-2 transition-all duration-300`},tt={class:`text-center text-secondary py-2 transition-all duration-300`},nt={class:`text-center text-accent-green py-2 transition-all duration-300`},rt={class:`text-right text-content-secondary dark:text-content-primary/80 py-2 transition-all duration-300`},it={key:0,class:`mt-4 text-center text-content-secondary dark:text-content-muted text-sm transition-all duration-300`},at={key:1,class:`text-center text-content-secondary dark:text-content-muted py-8`},A=b(ee({name:`SystemStatsView`,__name:`SystemStats`,setup(ee){C.register(pe,se,ce,he,de,ue,oe,ge,_e,ie,me,ae,le,fe);let{theme:b}=ne(),A=()=>{let e=document.documentElement.classList.contains(`dark`);return{labelColor:e?`rgba(255, 255, 255, 0.5)`:`rgba(0, 0, 0, 0.5)`,textColor:e?`rgba(255, 255, 255, 0.8)`:`rgba(0, 0, 0, 0.8)`}},j={cpu:`#FFC246`,memory:`#A5E5B6`,disk:`#FB787B`,free:`#A5E5B6`,uptime:`#EBA0FC`},M=c(null),N=c(null),P=c([]),F=c(null),I=c({cpuChart:!0,memoryChart:!0,diskChart:!1,processChart:!0}),L=c(null),R=c(null),z=c(`Connecting...`),B=c(`Connecting...`),V=c(null),H=c(null),U=c(null),W=c(null),G=c(null),K=m(()=>M.value?{cpuUsage:M.value.cpu.usage_percent,memoryUsage:M.value.memory.usage_percent,diskUsage:M.value.disk.usage_percent,uptime:M.value.system.uptime}:{cpuUsage:0,memoryUsage:0,diskUsage:0,uptime:0}),q=m(()=>P.value.length===0?{cpu:[],memory:[],disk:[],network:[]}:{cpu:P.value.map(e=>e.cpu.usage_percent),memory:P.value.map(e=>e.memory.usage_percent),disk:P.value.map(e=>e.disk.usage_percent),network:P.value.map(e=>e.network.bytes_recv/1024/1024)}),J=m(()=>{let e=P.value.length;if(e<2)return``;let t=e*5;return t<120?`last ${t}s`:`last ${Math.round(t/60)}m`}),ot=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`},Y=async()=>{z.value=`Connecting...`,B.value=`Connecting...`;try{let e=await S(`/hardware_stats`,void 0,{onPhaseChange:e=>{let t=e===`receiving`?`Receiving data...`:`Connecting...`;z.value=t,B.value=t}});if(e?.success&&e.data){let t=e.data;M.value=t,P.value.push(t),P.value.length>20&&P.value.shift(),L.value=null,R.value=null,await s(),Z()}else L.value=`No data in server response`,R.value=`No data in server response`}catch(e){let t=e instanceof Error?e.message:`Failed to load data`;L.value=t,R.value=t}finally{I.value.cpuChart=!1,I.value.memoryChart=!1}},st=async()=>{try{let e=await S(`/hardware_processes`);e?.success&&e.data&&(F.value=N.value,N.value=e.data)}catch(e){console.error(`Failed to fetch process stats:`,e)}finally{I.value.processChart=!1}},X=(e,t)=>{if(!F.value)return!1;let n=F.value.processes.find(t=>t.pid===e.pid);return n?n[t]!==e[t]:!0},ct=()=>{Y(),st()},Z=()=>{M.value&&(lt(),ut(),dt())},lt=()=>{if(!U.value||!M.value){I.value.cpuChart=!1;return}let e=U.value.getContext(`2d`);if(!e){I.value.cpuChart=!1;return}let t=M.value.cpu.usage_percent,n=100-t;if(V.value)try{V.value.data.datasets[0].data=[t,n],V.value.update(`none`);return}catch(e){console.warn(`Failed to update CPU chart, recreating...`,e),V.value.destroy(),V.value=null}let r=j.cpu,a=A(),o=document.documentElement.classList.contains(`dark`),s=o?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,c=o?`rgba(255, 255, 255, 0.2)`:`rgba(0, 0, 0, 0.2)`;try{V.value=i(new C(e,{type:`doughnut`,data:{labels:[`Used`,`Available`],datasets:[{data:[t,n],backgroundColor:[r,s],borderColor:[r,c],borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`70%`,animation:{animateRotate:!1,animateScale:!1,duration:0},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){return`${e.label}: ${e.parsed.toFixed(1)}%`}}}}},plugins:[{id:`centerText`,beforeDraw:function(e){let t=e.ctx;t.save();let n=e.data.datasets[0].data[0],i=(e.chartArea.left+e.chartArea.right)/2,o=(e.chartArea.top+e.chartArea.bottom)/2;t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=r,t.font=`bold 18px sans-serif`,t.fillText(`${n.toFixed(1)}%`,i,o-5),t.fillStyle=a.labelColor,t.font=`10px sans-serif`,t.fillText(`CPU`,i,o+12),t.restore()}}]})),L.value=null,I.value.cpuChart=!1}catch(e){console.error(`Error creating CPU chart:`,e),L.value=`Failed to create CPU chart`,I.value.cpuChart=!1}},ut=()=>{if(!W.value||!M.value){I.value.memoryChart=!1;return}let e=W.value.getContext(`2d`);if(!e){I.value.memoryChart=!1;return}let t=M.value.memory.usage_percent,n=100-t;if(H.value)try{H.value.data.datasets[0].data=[t,n],H.value.update(`none`);return}catch(e){console.warn(`Failed to update Memory chart, recreating...`,e),H.value.destroy(),H.value=null}let r=j.memory,a=A(),o=document.documentElement.classList.contains(`dark`),s=o?`rgba(255, 255, 255, 0.1)`:`rgba(0, 0, 0, 0.1)`,c=o?`rgba(255, 255, 255, 0.2)`:`rgba(0, 0, 0, 0.2)`;try{H.value=i(new C(e,{type:`doughnut`,data:{labels:[`Used`,`Available`],datasets:[{data:[t,n],backgroundColor:[r,s],borderColor:[r,c],borderWidth:2}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`70%`,animation:{animateRotate:!1,animateScale:!1,duration:0},plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){return`${e.label}: ${e.parsed.toFixed(1)}%`}}}}},plugins:[{id:`centerText`,beforeDraw:function(e){let t=e.ctx;t.save();let n=e.data.datasets[0].data[0],i=(e.chartArea.left+e.chartArea.right)/2,o=(e.chartArea.top+e.chartArea.bottom)/2;t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=r,t.font=`bold 18px sans-serif`,t.fillText(`${n.toFixed(1)}%`,i,o-5),t.fillStyle=a.labelColor,t.font=`10px sans-serif`,t.fillText(`Memory`,i,o+12),t.restore()}}]})),R.value=null,I.value.memoryChart=!1}catch(e){console.error(`Error creating Memory chart:`,e),R.value=`Failed to create Memory chart`,I.value.memoryChart=!1}},dt=()=>{if(!G.value||!M.value)return;let t=A().textColor;try{y(()=>import(`./plotly.min-BmxIBpZZ.js`).then(t=>e(t.t(),1)).then(e=>{let n=e.default||e,r=M.value.disk,i=[{type:`pie`,labels:[`Used`,`Free`],values:[r.used,r.free],marker:{colors:[j.disk,j.free]},hovertemplate:`%{label}
Size: %{value}
Percentage: %{percent}`,textinfo:`label+percent`,textposition:`auto`,hole:.4}],a={title:{text:``,font:{color:t}},paper_bgcolor:`rgba(0,0,0,0)`,plot_bgcolor:`rgba(0,0,0,0)`,font:{color:t,size:11},margin:{t:20,b:20,l:20,r:20},showlegend:!0,legend:{orientation:`h`,x:0,y:-.2,font:{color:t,size:10}}};n.newPlot(G.value,i,a,{responsive:!0,displayModeBar:!1,staticPlot:!1})}),__vite__mapDeps([0,1]))}catch(e){console.error(`Error creating disk chart:`,e)}},Q=()=>{try{if(V.value&&=(V.value.destroy(),null),H.value&&=(H.value.destroy(),null),G.value)try{y(()=>import(`./plotly.min-BmxIBpZZ.js`).then(t=>e(t.t(),1)).then(e=>{let t=e?.default||e;t?.purge&&t.purge(G.value)}),__vite__mapDeps([0,1])).catch(()=>{})}catch{}}catch(e){console.error(`Error destroying charts:`,e)}};o(b,()=>{Q(),s(()=>Z())});let $=()=>{setTimeout(()=>{a(V.value)?.resize(),a(H.value)?.resize();try{y(()=>import(`./plotly.min-BmxIBpZZ.js`).then(t=>e(t.t(),1)).then(e=>{let t=e?.default||e;t?.Plots&&t.Plots.resize(G.value)}),__vite__mapDeps([0,1])).catch(()=>{})}catch{}},100)};return re(ct,{intervalMs:5e3,immediate:!0}),r(async()=>{await s(),window.addEventListener(`resize`,$)}),te(()=>{window.removeEventListener(`resize`,$),Q()}),(e,r)=>(u(),_(`div`,ve,[r[22]||=g(`div`,{class:`flex justify-between items-center`},[g(`h2`,{class:`text-2xl font-bold text-content-primary dark:text-content-primary`},` System Statistics `),g(`div`,{class:`text-content-secondary dark:text-content-muted text-sm`},` Updates every 5 seconds `)],-1),g(`div`,ye,[f(T,{title:`CPU Usage`,value:`${K.value.cpuUsage.toFixed(1)}%`,color:j.cpu,data:q.value.cpu,"min-y":0,"max-y":100,subtitle:J.value},null,8,[`value`,`color`,`data`,`subtitle`]),f(T,{title:`Memory Usage`,value:`${K.value.memoryUsage.toFixed(1)}%`,color:j.memory,data:q.value.memory,"min-y":0,"max-y":100,subtitle:J.value},null,8,[`value`,`color`,`data`,`subtitle`]),f(T,{title:`Disk Usage`,value:`${K.value.diskUsage.toFixed(1)}%`,color:j.disk,data:q.value.disk,"min-y":0,"max-y":100,subtitle:J.value},null,8,[`value`,`color`,`data`,`subtitle`]),f(T,{title:`Uptime`,value:ot(K.value.uptime),color:j.uptime,data:[],"show-chart":!1},null,8,[`value`,`color`])]),g(`div`,be,[g(`div`,xe,[r[4]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` CPU Performance `,-1),f(w,{class:`h-32 mb-4`,"is-loading":I.value.cpuChart,error:L.value,status:z.value,onRetry:Y},{default:t(()=>[g(`canvas`,{ref_key:`cpuCanvasRef`,ref:U,class:`w-full h-full`},null,512)]),_:1},8,[`is-loading`,`error`,`status`]),M.value?(u(),_(`div`,Se,[g(`div`,null,[r[0]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`CPU Count`,-1),g(`div`,Ce,n(M.value.cpu.count)+` cores `,1)]),g(`div`,null,[r[1]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Frequency`,-1),g(`div`,we,n(M.value.cpu.frequency.toFixed(0))+` MHz `,1)]),g(`div`,null,[r[2]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Load (1m)`,-1),g(`div`,Te,n(M.value.cpu.load_avg[`1min`].toFixed(2)),1)]),g(`div`,null,[r[3]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Load (5m)`,-1),g(`div`,E,n(M.value.cpu.load_avg[`5min`].toFixed(2)),1)])])):d(``,!0)]),g(`div`,D,[r[9]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Memory Usage `,-1),f(w,{class:`h-32 mb-4`,"is-loading":I.value.memoryChart,error:R.value,status:B.value,onRetry:Y},{default:t(()=>[g(`canvas`,{ref_key:`memoryCanvasRef`,ref:W,class:`w-full h-full`},null,512)]),_:1},8,[`is-loading`,`error`,`status`]),M.value?(u(),_(`div`,O,[g(`div`,null,[r[5]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Total`,-1),g(`div`,Ee,n(p(x)(M.value.memory.total)),1)]),g(`div`,null,[r[6]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Used`,-1),g(`div`,De,n(p(x)(M.value.memory.used)),1)]),g(`div`,null,[r[7]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Available`,-1),g(`div`,Oe,n(p(x)(M.value.memory.available)),1)]),g(`div`,null,[r[8]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Usage`,-1),g(`div`,ke,n(M.value.memory.usage_percent.toFixed(1))+`% `,1)])])):d(``,!0)])]),g(`div`,Ae,[g(`div`,je,[r[13]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Storage Usage `,-1),g(`div`,Me,[g(`div`,{ref_key:`diskCanvasRef`,ref:G,class:`w-full h-full`},null,512)]),M.value?(u(),_(`div`,Ne,[g(`div`,Pe,[r[10]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Total`,-1),g(`div`,Fe,n(p(x)(M.value.disk.total)),1)]),g(`div`,Ie,[r[11]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Used`,-1),g(`div`,Le,n(p(x)(M.value.disk.used)),1)]),g(`div`,Re,[r[12]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Free`,-1),g(`div`,ze,n(p(x)(M.value.disk.free)),1)])])):d(``,!0)]),g(`div`,Be,[r[19]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Network Statistics `,-1),M.value?(u(),_(`div`,Ve,[g(`div`,He,[g(`div`,null,[r[14]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Bytes Sent`,-1),g(`div`,Ue,n(p(x)(M.value.network.bytes_sent)),1)]),g(`div`,null,[r[15]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Bytes Received`,-1),g(`div`,We,n(p(x)(M.value.network.bytes_recv)),1)]),g(`div`,null,[r[16]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Packets Sent`,-1),g(`div`,Ge,n(M.value.network.packets_sent.toLocaleString()),1)]),g(`div`,null,[r[17]||=g(`div`,{class:`text-content-secondary dark:text-content-muted`},`Packets Received`,-1),g(`div`,Ke,n(M.value.network.packets_recv.toLocaleString()),1)])]),M.value.temperatures&&Object.keys(M.value.temperatures).length>0?(u(),_(`div`,qe,[r[18]||=g(`div`,{class:`text-content-secondary dark:text-content-muted mb-2`},` System Temperatures `,-1),g(`div`,Je,[(u(!0),_(h,null,l(M.value.temperatures,(e,t)=>(u(),_(`div`,{key:t},[g(`span`,k,n(t)+`:`,1),g(`span`,Ye,n(e.toFixed(1))+`°C`,1)]))),128))])])):d(``,!0)])):d(``,!0)])]),g(`div`,Xe,[r[21]||=g(`h3`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-4`},` Top Processes `,-1),N.value?.processes&&N.value.processes.length>0?(u(),_(`div`,Ze,[g(`table`,Qe,[r[20]||=g(`thead`,null,[g(`tr`,{class:`border-b border-stroke-subtle dark:border-stroke/10`},[g(`th`,{class:`text-left text-content-secondary dark:text-content-muted py-2`},`PID`),g(`th`,{class:`text-left text-content-secondary dark:text-content-muted py-2`},`Name`),g(`th`,{class:`text-center text-content-secondary dark:text-content-muted py-2`},`CPU %`),g(`th`,{class:`text-center text-content-secondary dark:text-content-muted py-2`},` Memory % `),g(`th`,{class:`text-right text-content-secondary dark:text-content-muted py-2`},`Memory`)])],-1),g(`tbody`,null,[(u(!0),_(h,null,l(N.value.processes.slice(0,10),e=>(u(),_(`tr`,{key:e.pid,class:`border-b border-stroke-subtle dark:border-white/5 process-row`},[g(`td`,$e,n(e.pid),1),g(`td`,et,n(e.name),1),g(`td`,tt,[g(`span`,{class:v([`cpu-value`,{"value-updated":X(e,`cpu_percent`)}])},n(e.cpu_percent.toFixed(1))+`% `,3)]),g(`td`,nt,[g(`span`,{class:v([`memory-value`,{"value-updated":X(e,`memory_percent`)}])},n(e.memory_percent.toFixed(1))+`% `,3)]),g(`td`,rt,[g(`span`,{class:v({"value-updated":X(e,`memory_mb`)})},n(e.memory_mb.toFixed(1))+` MB `,3)])]))),128))])]),N.value.total_processes?(u(),_(`div`,it,` Showing top 10 of `+n(N.value.total_processes)+` total processes `,1)):d(``,!0)])):I.value.processChart?d(``,!0):(u(),_(`div`,at,` No process data available `))])]))}}),[[`__scopeId`,`data-v-d0fbc86b`]]);export{A as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Terminal-tmed9q5z.css b/repeater/web/html/assets/Terminal-8k-H0_ky.css similarity index 76% rename from repeater/web/html/assets/Terminal-tmed9q5z.css rename to repeater/web/html/assets/Terminal-8k-H0_ky.css index abb5b36b..620c8b6c 100644 --- a/repeater/web/html/assets/Terminal-tmed9q5z.css +++ b/repeater/web/html/assets/Terminal-8k-H0_ky.css @@ -1 +1 @@ -.xterm{cursor:text;-webkit-user-select:none;user-select:none;position:relative}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{z-index:5;position:absolute;top:0}.xterm .xterm-helper-textarea{opacity:0;z-index:-5;white-space:nowrap;resize:none;border:0;width:0;height:0;margin:0;padding:0;position:absolute;top:0;left:-9999em;overflow:hidden}.xterm .composition-view{color:#fff;white-space:nowrap;z-index:1;background:#000;display:none;position:absolute}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{cursor:default;background-color:#000;position:absolute;inset:0;overflow-y:scroll}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;top:0;left:0}.xterm-char-measure-element{visibility:hidden;line-height:normal;display:inline-block;position:absolute;top:0;left:-9999em}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{z-index:10;color:#0000;pointer-events:none;position:absolute;inset:0}.xterm .xterm-accessibility-tree:not(.debug) ::selection{color:#0000}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre;font-family:monospace}.xterm .xterm-accessibility-tree>div{transform-origin:0;width:fit-content}.xterm .live-region{width:1px;height:1px;position:absolute;left:-9999px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:underline double;text-decoration:underline double}.xterm-underline-3{-webkit-text-decoration:underline wavy;text-decoration:underline wavy}.xterm-underline-4{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.xterm-underline-5{-webkit-text-decoration:underline dashed;text-decoration:underline dashed}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:underline overline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;pointer-events:none;position:absolute;top:0;right:0}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;z-index:11;background:0 0;transition:opacity .1s linear}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{display:none;position:absolute}.xterm .xterm-scrollable-element>.shadow.top{width:100%;height:3px;box-shadow:var(--vscode-scrollbar-shadow,#000) 0 6px 6px -6px inset;display:block;top:0;left:3px}.xterm .xterm-scrollable-element>.shadow.left{width:3px;height:100%;box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset;display:block;top:3px;left:0}.xterm .xterm-scrollable-element>.shadow.top-left-corner{width:3px;height:3px;display:block;top:0;left:0}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset}.terminal-container[data-v-e270e599]{background-color:var(--color-surface);height:calc(100vh - 220px);min-height:calc(100dvh - 220px)}@media (width<=768px){.terminal-container[data-v-e270e599]{height:calc(100vh - 140px);min-height:calc(100dvh - 140px)}}@media (width<=640px){.terminal-container[data-v-e270e599]{height:calc(100vh - 120px);min-height:calc(100dvh - 120px)}}[data-v-e270e599] .xterm{padding:1.5rem;height:100%!important}@media (width<=768px){[data-v-e270e599] .xterm{padding:1rem}}@media (width<=640px){[data-v-e270e599] .xterm{padding:.75rem}}[data-v-e270e599] .xterm-viewport,[data-v-e270e599] .xterm-screen{background-color:#0000!important}[data-v-e270e599] .xterm-selection{background-color:#00d9ff4d!important}kbd[data-v-e270e599]{font-family:Menlo,Monaco,Courier New,monospace;box-shadow:0 2px 4px #0003}.mobile-keyboard-input[data-v-e270e599]{opacity:.01;pointer-events:none;z-index:9999;border:none;width:1px;height:1px;margin:0;padding:0;position:absolute;bottom:0;left:0}.fullscreen-terminal[data-v-e270e599]{z-index:9999!important;background-color:var(--color-surface)!important;border-radius:0!important;width:100vw!important;height:100dvh!important;margin:0!important;position:fixed!important;inset:0!important}.fullscreen-content[data-v-e270e599]{height:100%!important;min-height:100%!important}.fullscreen-terminal[data-v-e270e599] .xterm{padding:2rem}@media (width<=768px){.fullscreen-terminal[data-v-e270e599] .xterm{padding:1rem}}.full-window-terminal[data-v-e270e599]{z-index:9998;inset:0;overflow:hidden;background-color:var(--color-surface)!important;border-radius:0!important;width:100vw!important;max-width:100vw!important;height:100dvh!important;max-height:100dvh!important;margin:0!important;position:fixed!important}.full-window-terminal .terminal-container[data-v-e270e599]{overflow:auto;width:100vw!important;height:100dvh!important}.full-window-terminal[data-v-e270e599] .xterm{padding:1rem;height:100%!important}@media (width<=768px){.full-window-terminal[data-v-e270e599]{touch-action:none}.full-window-terminal .terminal-container[data-v-e270e599]{overscroll-behavior:none}.full-window-terminal[data-v-e270e599] .xterm{padding:.75rem}} +.xterm{cursor:text;-webkit-user-select:none;user-select:none;position:relative}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{z-index:5;position:absolute;top:0}.xterm .xterm-helper-textarea{opacity:0;z-index:-5;white-space:nowrap;resize:none;border:0;width:0;height:0;margin:0;padding:0;position:absolute;top:0;left:-9999em;overflow:hidden}.xterm .composition-view{color:#fff;white-space:nowrap;z-index:1;background:#000;display:none;position:absolute}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{cursor:default;background-color:#000;position:absolute;inset:0;overflow-y:scroll}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;top:0;left:0}.xterm-char-measure-element{visibility:hidden;line-height:normal;display:inline-block;position:absolute;top:0;left:-9999em}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{z-index:10;color:#0000;pointer-events:none;position:absolute;inset:0}.xterm .xterm-accessibility-tree:not(.debug) ::selection{color:#0000}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre;font-family:monospace}.xterm .xterm-accessibility-tree>div{transform-origin:0;width:fit-content}.xterm .live-region{width:1px;height:1px;position:absolute;left:-9999px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:underline double;text-decoration:underline double}.xterm-underline-3{-webkit-text-decoration:underline wavy;text-decoration:underline wavy}.xterm-underline-4{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.xterm-underline-5{-webkit-text-decoration:underline dashed;text-decoration:underline dashed}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:underline overline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;pointer-events:none;position:absolute;top:0;right:0}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;z-index:11;background:0 0;transition:opacity .1s linear}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{display:none;position:absolute}.xterm .xterm-scrollable-element>.shadow.top{width:100%;height:3px;box-shadow:var(--vscode-scrollbar-shadow,#000) 0 6px 6px -6px inset;display:block;top:0;left:3px}.xterm .xterm-scrollable-element>.shadow.left{width:3px;height:100%;box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset;display:block;top:3px;left:0}.xterm .xterm-scrollable-element>.shadow.top-left-corner{width:3px;height:3px;display:block;top:0;left:0}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset}.terminal-container[data-v-7db8a6e5]{background-color:var(--color-surface);height:calc(100vh - 220px);min-height:calc(100dvh - 220px)}@media (width<=768px){.terminal-container[data-v-7db8a6e5]{height:calc(100vh - 140px);min-height:calc(100dvh - 140px)}}@media (width<=640px){.terminal-container[data-v-7db8a6e5]{height:calc(100vh - 120px);min-height:calc(100dvh - 120px)}}[data-v-7db8a6e5] .xterm{padding:1.5rem;height:100%!important}@media (width<=768px){[data-v-7db8a6e5] .xterm{padding:1rem}}@media (width<=640px){[data-v-7db8a6e5] .xterm{padding:.75rem}}[data-v-7db8a6e5] .xterm-viewport,[data-v-7db8a6e5] .xterm-screen{background-color:#0000!important}[data-v-7db8a6e5] .xterm-selection{background-color:#00d9ff4d!important}kbd[data-v-7db8a6e5]{font-family:Menlo,Monaco,Courier New,monospace;box-shadow:0 2px 4px #0003}.mobile-keyboard-input[data-v-7db8a6e5]{opacity:.01;pointer-events:none;z-index:9999;border:none;width:1px;height:1px;margin:0;padding:0;position:absolute;bottom:0;left:0}.fullscreen-terminal[data-v-7db8a6e5]{z-index:9999!important;background-color:var(--color-surface)!important;border-radius:0!important;width:100vw!important;height:100dvh!important;margin:0!important;position:fixed!important;inset:0!important}.fullscreen-content[data-v-7db8a6e5]{height:100%!important;min-height:100%!important}.fullscreen-terminal[data-v-7db8a6e5] .xterm{padding:2rem}@media (width<=768px){.fullscreen-terminal[data-v-7db8a6e5] .xterm{padding:1rem}}.full-window-terminal[data-v-7db8a6e5]{z-index:9998;inset:0;overflow:hidden;background-color:var(--color-surface)!important;border-radius:0!important;width:100vw!important;max-width:100vw!important;height:100dvh!important;max-height:100dvh!important;margin:0!important;position:fixed!important}.full-window-terminal .terminal-container[data-v-7db8a6e5]{overflow:auto;width:100vw!important;height:100dvh!important}.full-window-terminal[data-v-7db8a6e5] .xterm{padding:1rem;height:100%!important}@media (width<=768px){.full-window-terminal[data-v-7db8a6e5]{touch-action:none}.full-window-terminal .terminal-container[data-v-7db8a6e5]{overscroll-behavior:none}.full-window-terminal[data-v-7db8a6e5] .xterm{padding:.75rem}} diff --git a/repeater/web/html/assets/Terminal-Dpu_GlNL.js b/repeater/web/html/assets/Terminal-Dpu_GlNL.js deleted file mode 100644 index 28d7aacd..00000000 --- a/repeater/web/html/assets/Terminal-Dpu_GlNL.js +++ /dev/null @@ -1,198 +0,0 @@ -import{C as e,S as t,dt as n,g as r,j as i,k as a,l as o,pt as s,s as c,u as l,w as u,z as d}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as f}from"./api-CbM6k1ZB.js";import{t as p}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as m}from"./useTheme-DMOVV09x.js";import{f as h,h as g,m as _}from"./index-BFltqMtv.js";var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,b=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,r)=>{for(var i=r>1?void 0:r?y(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&v(t,n,i),i},S=(e,t)=>(n,r)=>t(n,r,e),ee=`Terminal input`,te={get:()=>ee,set:e=>ee=e},C=`Too much output to announce, navigate to rows manually to read`,w={get:()=>C,set:e=>C=e};function T(e){return e.replace(/\r?\n/g,`\r`)}function E(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function D(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ne(e,t,n,r){e.stopPropagation(),e.clipboardData&&O(e.clipboardData.getData(`text/plain`),t,n,r)}function O(e,t,n,r){e=T(e),e=E(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function k(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function A(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function j(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ie=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ae=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},oe=``,se=` `,ce=class e{constructor(){this.fg=0,this.bg=0,this.extended=new le}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},le=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},M=class e extends ce{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new le,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?A(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ue=`di$target`,de=`di$dependencies`,fe=new Map;function pe(e){return e[de]||[]}function N(e){if(fe.has(e))return fe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,fe.set(e,t),t}function me(e,t,n){t[ue]===t?t[de].push({id:e,index:n}):(t[de]=[{id:e,index:n}],t[ue]=t)}var P=N(`BufferService`),he=N(`CoreMouseService`),ge=N(`CoreService`),_e=N(`CharsetService`),ve=N(`InstantiationService`),ye=N(`LogService`),be=N(`OptionsService`),xe=N(`OscLinkService`),Se=N(`UnicodeService`),Ce=N(`DecorationService`),we=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new M,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):Te(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};we=x([S(0,P),S(1,be),S(2,xe)],we);function Te(e,t){if(confirm(`Do you want to navigate to ${t}? - -WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ee=N(`CharSizeService`),De=N(`CoreBrowserService`),Oe=N(`MouseService`),ke=N(`RenderService`),Ae=N(`SelectionService`),je=N(`CharacterJoinerService`),Me=N(`ThemeService`),Ne=N(`LinkProviderService`),Pe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Be.isErrorNoTelemetry(e)?new Be(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Fe(e){Le(e)||Pe.onUnexpectedError(e)}var Ie=`Canceled`;function Le(e){return e instanceof Re?!0:e instanceof Error&&e.name===Ie&&e.message===Ie}var Re=class extends Error{constructor(){super(Ie),this.name=this.message}};function ze(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var Be=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Ve=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function He(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Ge||={});function Ke(e,t){return(n,r)=>t(e(n),e(r))}var qe=(e,t)=>e-t,Je=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Ge.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Je.empty=new Je(e=>{});function Ye(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var Xe=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function Ze(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Qe;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` -`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new Xe;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` -`),e)}n.sort(Ke(e=>e.idx,qe));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` - - -==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== -${s.join(` -`)} -============================================================ - -`}return n.length>e&&(a+=` - - -... and ${n.length-e} more leaking disposables - -`),{leaks:n,details:a}}};tt.idx=0;function nt(e){et=e}if($e){let e=`__is_disposable_tracked__`;nt(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==I.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==I.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function rt(e){return et?.trackDisposable(e),e}function it(e){et?.markAsDisposed(e)}function at(e,t){et?.setParent(e,t)}function ot(e,t){if(et)for(let n of e)et.setParent(n,t)}function st(e){return et?.markAsSingleton(e),e}function ct(e){if(Qe.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function lt(...e){let t=F(()=>ct(e));return ot(e,t),t}function F(e){let t=rt({dispose:Ze(()=>{it(t),e()})});return t}var ut=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,rt(this)}dispose(){this._isDisposed||(it(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ct(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return at(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),at(e,null))}};ut.DISABLE_DISPOSED_WARNING=!1;var dt=ut,I=class{constructor(){this._store=new dt,rt(this),at(this._store,this)}dispose(){it(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};I.None=Object.freeze({dispose(){}});var ft=class{constructor(){this._isDisposed=!1,rt(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&at(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,it(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&at(e,null),e}},pt=typeof window==`object`?window:globalThis,mt=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};mt.Undefined=new mt(void 0);var L=mt,ht=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new L(e);if(this._first===L.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},gt=globalThis.performance&&typeof globalThis.performance.now==`function`,_t=class e{static create(t){return new e(t)}constructor(e){this._now=gt&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},vt=!1,yt=!1,bt=!1,xt;(e=>{e.None=()=>I.None;function t(e){if(bt){let{onDidAddListener:t}=e,n=Dt.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(lt(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new R(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new R(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new R({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new R({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new R({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function ee(e){let t=new R;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new R(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof dt?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(xt||={});var St=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new _t,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};St.all=new Set,St._idPool=0;var Ct=St,wt=-1,Tt=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof jt)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` -`)),e.length=0)},3e3),Pt=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var R=class{constructor(e){this._size=0,this._options=e,this._leakageMon=wt>0||this._options?.leakWarningThreshold?new Et(e?.onListenerError??Fe,this._options?.leakWarningThreshold??wt):void 0,this._perfMon=this._options?._profName?new Ct(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(yt){let e=this._listeners;queueMicrotask(()=>{Nt(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new kt(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Fe)(n),I.None}if(this._disposed)return I.None;t&&(e=e.bind(t));let r=new jt(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Dt.create(),i=this._leakageMon.check(r.stack,this._size+1)),yt&&(r.stack=Dt.create()),this._listeners?this._listeners instanceof jt?(this._deliveryQueue??=new Ft,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=F(()=>{Pt?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof dt?n.add(a):Array.isArray(n)&&n.push(a),Pt){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Pt.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Mt<=t.length){let e=0;for(let n=0;n0}},Ft=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},It=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new R,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new R,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};It.INSTANCE=new It;var Lt=It;function Rt(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Lt.INSTANCE.onDidChangeZoomLevel;function zt(e){return Lt.INSTANCE.getZoomFactor(e)}Lt.INSTANCE.onDidChangeFullscreen;var Bt=typeof navigator==`object`?navigator.userAgent:``,Vt=Bt.indexOf(`Firefox`)>=0,Ht=Bt.indexOf(`AppleWebKit`)>=0,Ut=Bt.indexOf(`Chrome`)>=0,Wt=!Ut&&Bt.indexOf(`Safari`)>=0;Bt.indexOf(`Electron/`),Bt.indexOf(`Android`);var Gt=!1;if(typeof pt.matchMedia==`function`){let e=pt.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=pt.matchMedia(`(display-mode: fullscreen)`);Gt=e.matches,Rt(pt,e,({matches:e})=>{Gt&&t.matches||(Gt=e)})}function Kt(){return Gt}var qt=`en`,Jt=!1,Yt=!1,Xt=!1,Zt=!1,Qt=!1,$t=qt,en,tn=globalThis,nn;typeof tn.vscode<`u`&&typeof tn.vscode.process<`u`?nn=tn.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(nn=process);var rn=typeof nn?.versions?.electron==`string`&&nn?.type===`renderer`;if(typeof nn==`object`){Jt=nn.platform===`win32`,Yt=nn.platform===`darwin`,Xt=nn.platform===`linux`,Xt&&nn.env.SNAP&&nn.env.SNAP_REVISION,nn.env.CI||nn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$t=qt;let e=nn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,$t=t.resolvedLanguage||qt,t.languagePack?.translationsConfigFile}catch{}Zt=!0}else typeof navigator==`object`&&!rn?(en=navigator.userAgent,Jt=en.indexOf(`Windows`)>=0,Yt=en.indexOf(`Macintosh`)>=0,(en.indexOf(`Macintosh`)>=0||en.indexOf(`iPad`)>=0||en.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Xt=en.indexOf(`Linux`)>=0,en?.indexOf(`Mobi`),Qt=!0,$t=globalThis._VSCODE_NLS_LANGUAGE||qt,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var an=Jt,on=Yt,sn=Xt,cn=Zt;Qt&&typeof tn.importScripts==`function`&&tn.origin;var ln=en,un=$t,dn;(e=>{function t(){return un}e.value=t;function n(){return un.length===2?un===`en`:un.length>=3?un[0]===`e`&&un[1]===`n`&&un[2]===`-`:!1}e.isDefaultVariant=n;function r(){return un===`en`}e.isDefault=r})(dn||={});var fn=typeof tn.postMessage==`function`&&!tn.importScripts;(()=>{if(fn){let e=[];tn.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),tn.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var pn=!!(ln&&ln.indexOf(`Chrome`)>=0);ln&&ln.indexOf(`Firefox`),!pn&&ln&&ln.indexOf(`Safari`),ln&&ln.indexOf(`Edg/`),ln&&ln.indexOf(`Android`);var mn=typeof navigator==`object`?navigator:{};cn||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||mn&&mn.clipboard&&mn.clipboard.writeText,cn||mn&&mn.clipboard&&mn.clipboard.readText,cn||Kt()||mn.keyboard,`ontouchstart`in pt||mn.maxTouchPoints,pt.PointerEvent&&(`ontouchstart`in pt||navigator.maxTouchPoints);var hn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},gn=new hn,_n=new hn,vn=new hn,yn=Array(230),bn;(e=>{function t(e){return gn.keyCodeToStr(e)}e.toString=t;function n(e){return gn.strToKeyCode(e)}e.fromString=n;function r(e){return _n.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return vn.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return _n.strToKeyCode(e)||vn.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return gn.keyCodeToStr(e)}e.toElectronAccelerator=o})(bn||={});var xn=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Sn([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Sn=class{constructor(e){if(e.length===0)throw ze(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t{function t(t){return t===e.None||t===e.Cancelled||t instanceof In?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pn})})(Fn||={});var In=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Pn:(this._emitter||=new R,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Ln=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Ve(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ve(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Rn=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Ve(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=F(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var zn;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(zn||={});var Bn=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new R,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Bn.EMPTY=Bn.fromArray([]);function Vn(e){return 55296<=e&&e<=56319}function Hn(e){return 56320<=e&&e<=57343}function Un(e,t){return(e-55296<<10)+(t-56320)+65536}function Wn(e){return Gn(e,0)}function Gn(e,t){switch(typeof e){case`object`:return e===null?Kn(349,t):Array.isArray(e)?Yn(e,t):Xn(e,t);case`string`:return Jn(e,t);case`boolean`:return qn(e,t);case`number`:return Kn(e,t);case`undefined`:return Kn(937,t);default:return Kn(617,t)}}function Kn(e,t){return(t<<5)-t+e|0}function qn(e,t){return Kn(e?433:863,t)}function Jn(e,t){t=Kn(149417,t);for(let n=0,r=e.length;nGn(t,e),t)}function Xn(e,t){return t=Kn(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Jn(n,t),Gn(e[n],t)),t)}function Zn(e,t,n=32){let r=n-t,i=~((1<>>r)>>>0}function Qn(e,t=0,n=e.byteLength,r=0){for(let i=0;ie.toString(16).padStart(2,`0`)).join(``):$n((e>>>0).toString(16),t/4)}var tr=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Vn(a))if(o+1>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),er(this._h0)+er(this._h1)+er(this._h2)+er(this._h3)+er(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Qn(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Qn(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,Zn(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=Zn(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=Zn(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};tr._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:nr,getWindow:rr,getDocument:ir,getWindows:ar,getWindowsCount:or,getWindowId:sr,getWindowById:cr,hasWindow:lr,onDidRegisterWindow:ur,onWillUnregisterWindow:dr,onDidUnregisterWindow:fr}=function(){let e=new Map,t={window:pt,disposables:new dt};e.set(pt.vscodeWindowId,t);let n=new R,r=new R,i=new R;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return I.None;let a=new dt,o={window:t,disposables:a.add(new dt)};return e.set(t.vscodeWindowId,o),a.add(F(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(z(t,Sr.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:pt},getDocument(e){return rr(e).document}}}(),pr=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function z(e,t,n,r){return new pr(e,t,n,r)}function mr(e,t){return function(n){return t(new Mn(e,n))}}function hr(e){return function(t){return e(new On(t))}}var gr=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=mr(rr(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=hr(n)),z(e,t,i,r)},_r,vr=class extends Rn{constructor(e){super(),this.defaultTarget=e&&rr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},yr=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Fe(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(yr.sort),a.shift().execute();r.set(i,!1)};_r=(t,r,a=0)=>{let o=sr(t),s=new yr(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var br=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};br.None=new br(0,0);function xr(e){let t=e.getBoundingClientRect(),n=rr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Wn(n),a=r.get(i);if(a)a.users+=1;else{let o=new R,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(F(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Sr={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Ht?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Ht?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Ht?`webkitAnimationIteration`:`animationiteration`},Cr=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function wr(e,t,n,...r){let i=Cr.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function Tr(e,t,...n){return wr(`http://www.w3.org/1999/xhtml`,e,t,...n)}Tr.SVG=function(e,t,...n){return wr(`http://www.w3.org/2000/svg`,e,t,...n)};var Er=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=Dr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Dr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Dr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Dr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Dr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Dr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Dr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Dr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Dr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Dr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Dr(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Dr(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Dr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Dr(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Dr(e){return typeof e==`number`?`${e}px`:e}function Or(e){return new Er(e)}var kr=class{constructor(){this._hooks=new dt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(F(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=rr(e)}this._hooks.add(z(a,Sr.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(z(a,Sr.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Ar(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var jr;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(jr||={});var Mr=class e extends I{constructor(){super(),this.dispatched=!1,this.targets=new ht,this.ignoreTargets=new ht,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(xt.runAndSubscribe(ur,({window:e,disposables:t})=>{t.add(z(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(z(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(z(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:pt,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=st(new e),F(e.INSTANCE.targets.push(t))):I.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=st(new e),F(e.INSTANCE.ignoreTargets.push(t))):I.None}static isTouchDevice(){return`ontouchstart`in pt||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n=e.HOLD_DELAY&&Math.abs(s.initialPageX-We(s.rollingPageX))<30&&Math.abs(s.initialPageY-We(s.rollingPageY))<30){let e=this.newGestureEvent(jr.Contextmenu,s.initialTarget);e.pageX=We(s.rollingPageX),e.pageY=We(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=We(s.rollingPageX),n=We(s.rollingPageY),i=We(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(jr.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===jr.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else (t.type===jr.Change||t.type===jr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=_r(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(jr.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Mr.SCROLL_FRICTION=-.005,Mr.HOLD_DELAY=700,Mr.CLEAR_TAP_COUNT_TIME=400,x([Ar],Mr,`isTouchDevice`,1);var Nr=Mr,Pr=class extends I{onclick(e,t){this._register(z(e,Sr.CLICK,n=>t(new Mn(rr(e),n))))}onmousedown(e,t){this._register(z(e,Sr.MOUSE_DOWN,n=>t(new Mn(rr(e),n))))}onmouseover(e,t){this._register(z(e,Sr.MOUSE_OVER,n=>t(new Mn(rr(e),n))))}onmouseleave(e,t){this._register(z(e,Sr.MOUSE_LEAVE,n=>t(new Mn(rr(e),n))))}onkeydown(e,t){this._register(z(e,Sr.KEY_DOWN,e=>t(new On(e))))}onkeyup(e,t){this._register(z(e,Sr.KEY_UP,e=>t(new On(e))))}oninput(e,t){this._register(z(e,Sr.INPUT,t))}onblur(e,t){this._register(z(e,Sr.BLUR,t))}onfocus(e,t){this._register(z(e,Sr.FOCUS,t))}onchange(e,t){this._register(z(e,Sr.CHANGE,t))}ignoreGesture(e){return Nr.ignoreTarget(e)}},Fr=11,Ir=class extends Pr{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=Fr+`px`,this.domNode.style.height=Fr+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new kr),this._register(gr(this.bgDomNode,Sr.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(gr(this.domNode,Sr.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new vr),this._pointerdownScheduleRepeatTimer=this._register(new Ln)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rr(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Lr=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Rr=class extends I{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Lr(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new Hr(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Hr.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},zr=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Br(e,t){let n=t-e;return function(t){return e+n*Wr(t)}}function Vr(e,t,n){return function(r){return r2.5*n){let r,i;return e{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},Kr=140,qr=class extends Pr{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Gr(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new kr),this._shouldRender=!0,this.domNode=Or(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(z(this.domNode.domNode,Sr.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Ir(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Or(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(z(this.slider.domNode,Sr.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=xr(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(an&&a>Kr){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Jr=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};ti.INSTANCE=new ti;var ni=ti,ri=class extends Pr{constructor(e,t,n){super(),this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new R),this.onWillScroll=this._onWillScroll.event,this._options=ai(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Xr(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Yr(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Or(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Or(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Or(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Ln),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ct(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,on&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Nn(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ct(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(z(this._listenOnDomNode,Sr.MOUSE_WHEEL,e=>{this._onMouseWheel(new Nn(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=ni.INSTANCE;$r&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!on&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=Qr*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Qr*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&($r&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Zr)}},ii=class extends ri{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ai(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`?e.horizontalHasArrows:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,on&&(t.className+=` mac`),t}var oi=class extends I{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new R),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Rr({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>_r(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ii(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(xt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(F(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(F(()=>this._styleElement.remove())),this._register(xt.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};oi=x([S(2,P),S(3,De),S(4,he),S(5,Me),S(6,be),S(7,ke)],oi);var si=class extends I{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(F(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};si=x([S(1,P),S(2,De),S(3,Ce),S(4,ke)],si);var ci=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},li={full:0,left:0,center:0,right:0},ui={full:0,left:0,center:0,right:0},di={full:0,left:0,center:0,right:0},fi=class extends I{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new ci,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(F(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ui.full=this._canvas.width,ui.left=e,ui.center=t,ui.right=e,this._refreshDrawHeightConstants(),di.full=1,di.left=1,di.center=1+ui.left,di.right=1+ui.left+ui.center}_refreshDrawHeightConstants(){li.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);li.left=t,li.center=t,li.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*li.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*li.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*li.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*li.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(di[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-li[e.position||`full`]/2),ui[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+li[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};fi=x([S(2,P),S(3,Ce),S(4,ke),S(5,be),S(6,Me),S(7,De)],fi);var B;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=` -`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(B||={});var pi;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(pi||={});var mi;(e=>e.ST=`${B.ESC}\\`)(mi||={});var hi=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};hi=x([S(2,P),S(3,be),S(4,ge),S(5,ke)],hi);var gi=0,_i=0,vi=0,V=0,yi={css:`#00000000`,rgba:0},H;(e=>{function t(e,t,n,r){return r===void 0?`#${Si(e)}${Si(t)}${Si(n)}`:`#${Si(e)}${Si(t)}${Si(n)}${Si(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(H||={});var U;(e=>{function t(e,t){if(V=(t.rgba&255)/255,V===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return gi=a+Math.round((n-a)*V),_i=o+Math.round((r-o)*V),vi=s+Math.round((i-s)*V),{css:H.toCss(gi,_i,vi),rgba:H.toRgba(gi,_i,vi)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=xi.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return H.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[gi,_i,vi]=xi.toChannels(t),{css:H.toCss(gi,_i,vi),rgba:t}}e.opaque=i;function a(e,t){return V=Math.round(t*255),[gi,_i,vi]=xi.toChannels(e.rgba),{css:H.toCss(gi,_i,vi,V),rgba:H.toRgba(gi,_i,vi,V)}}e.opacity=a;function o(e,t){return V=e.rgba&255,a(e,V*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(U||={});var W;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return gi=parseInt(e.slice(1,2).repeat(2),16),_i=parseInt(e.slice(2,3).repeat(2),16),vi=parseInt(e.slice(3,4).repeat(2),16),H.toColor(gi,_i,vi);case 5:return gi=parseInt(e.slice(1,2).repeat(2),16),_i=parseInt(e.slice(2,3).repeat(2),16),vi=parseInt(e.slice(3,4).repeat(2),16),V=parseInt(e.slice(4,5).repeat(2),16),H.toColor(gi,_i,vi,V);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return gi=parseInt(r[1]),_i=parseInt(r[2]),vi=parseInt(r[3]),V=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),H.toColor(gi,_i,vi,V);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[gi,_i,vi,V]=t.getImageData(0,0,1,1).data,V!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:H.toRgba(gi,_i,vi,V),css:e}}e.toColor=r})(W||={});var bi;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(bi||={});var xi;(e=>{function t(e,t){if(V=(t&255)/255,V===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return gi=a+Math.round((n-a)*V),_i=o+Math.round((r-o)*V),vi=s+Math.round((i-s)*V),H.toRgba(gi,_i,vi)}e.blend=t;function n(e,t,n){let a=bi.relativeLuminance(e>>8),o=bi.relativeLuminance(t>>8);if(Ci(a,o)>8));if(sCi(a,bi.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Ci(a,bi.relativeLuminance(s>>8));if(cCi(a,bi.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ci(bi.relativeLuminance2(o,s,c),bi.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Ci(bi.relativeLuminance2(o,s,c),bi.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ci(bi.relativeLuminance2(o,s,c),bi.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(xi||={});function Si(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Ci(e,t){return e1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t=w,re=D,k=this._workCell;if(f.length>0&&D===f[0][0]&&O){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v=r[1],O?(ne=!0,k=new wi(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),re=r[1]-1,m=k.getWidth()):w=r[1]}let A=this._isCellInSelection(D,t),j=n&&D===a,ie=E&&D>=l&&D<=u,ae=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{ae=!0});let oe=k.getChars()||se;if(oe===` `&&(k.isUnderline()||k.isOverline())&&(oe=`\xA0`),C=m*s-c.get(oe,k.isBold(),k.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(A&&te||!A&&!te&&k.bg===y)&&(A&&te&&p.selectionForeground||k.fg===b)&&k.extended.ext===x&&ie===S&&C===ee&&!j&&!ne&&!ae&&O){k.isInvisible()?_+=se:_+=oe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=k.bg,b=k.fg,x=k.extended.ext,S=ie,ee=C,te=A,ne&&a>=D&&a<=re&&(a=D),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(T.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&T.push(`xterm-cursor-blink`),T.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:T.push(`xterm-cursor-outline`);break;case`block`:T.push(`xterm-cursor-block`);break;case`bar`:T.push(`xterm-cursor-bar`);break;case`underline`:T.push(`xterm-cursor-underline`);break;default:break}}if(k.isBold()&&T.push(`xterm-bold`),k.isItalic()&&T.push(`xterm-italic`),k.isDim()&&T.push(`xterm-dim`),_=k.isInvisible()?se:k.getChars()||se,k.isUnderline()&&(T.push(`xterm-underline-${k.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!k.isUnderlineColorDefault()))if(k.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${ce.toColorRGB(k.getUnderlineColor()).join(`,`)})`;else{let e=k.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&k.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}k.isOverline()&&(T.push(`xterm-overline`),_===` `&&(_=`\xA0`)),k.isStrikethrough()&&T.push(`xterm-strikethrough`),ie&&(h.style.textDecoration=`underline`);let le=k.getFgColor(),M=k.getFgColorMode(),ue=k.getBgColor(),de=k.getBgColorMode(),fe=!!k.isInverse();if(fe){let e=le;le=ue,ue=e;let t=M;M=de,de=t}let pe,N,me=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{e.options.layer!==`top`&&me||(e.backgroundColorRGB&&(de=50331648,ue=e.backgroundColorRGB.rgba>>8&16777215,pe=e.backgroundColorRGB),e.foregroundColorRGB&&(M=50331648,le=e.foregroundColorRGB.rgba>>8&16777215,N=e.foregroundColorRGB),me=e.options.layer===`top`)}),!me&&A&&(pe=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ue=pe.rgba>>8&16777215,de=50331648,me=!0,p.selectionForeground&&(M=50331648,le=p.selectionForeground.rgba>>8&16777215,N=p.selectionForeground)),me&&T.push(`xterm-decoration-top`);let P;switch(de){case 16777216:case 33554432:P=p.ansi[ue],T.push(`xterm-bg-${ue}`);break;case 50331648:P=H.toColor(ue>>16,ue>>8&255,ue&255),this._addStyle(h,`background-color:#${Mi((ue>>>0).toString(16),`0`,6)}`);break;default:fe?(P=p.foreground,T.push(`xterm-bg-257`)):P=p.background}switch(pe||k.isDim()&&(pe=U.multiplyOpacity(P,.5)),M){case 16777216:case 33554432:k.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(h,P,p.ansi[le],k,pe,void 0)||T.push(`xterm-fg-${le}`);break;case 50331648:let e=H.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(h,P,e,k,pe,N)||this._addStyle(h,`color:#${Mi(le.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,P,p.foreground,k,pe,N)||fe&&T.push(`xterm-fg-257`)}T.length&&=(h.className=T.join(` `),0),!j&&!ne&&!ae&&O?g++:h.textContent=_,C!==this.defaultSpacing&&(h.style.letterSpacing=`${C}px`),d.push(h),D=re}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Oi(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=U.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t=n[0]&&e=n[0]}};ji=x([S(1,je),S(2,be),S(3,De),S(4,ge),S(5,Ce),S(6,Me)],ji);function Mi(e,t,n){for(;e.length0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Pi=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function Fi(){return new Pi}var Ii=`xterm-dom-renderer-owner-`,Li=`xterm-rows`,Ri=`xterm-fg-`,zi=`xterm-bg-`,Bi=`xterm-focus`,Vi=`xterm-selection`,Hi=1,Ui=class extends I{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Hi++,this._rowElements=[],this._selectionRenderModel=Fi(),this.onRequestRedraw=this._register(new R).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Li),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(Vi),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=ki(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(ji,document),this._element.classList.add(Ii+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(F(()=>{this._element.classList.remove(Ii+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ni(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Li} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Li} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Li} .xterm-dim { color: ${U.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Li}.${Bi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Li}.${Bi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Li}.${Bi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Li} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Li} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Li} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Li} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Li} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Vi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Vi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Vi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Ri}${n} { color: ${r.css}; }${this._terminalSelector} .${Ri}${n}.xterm-dim { color: ${U.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${zi}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Ri}257 { color: ${U.opaque(e.background).css}; }${this._terminalSelector} .${Ri}257.xterm-dim { color: ${U.multiplyOpacity(U.opaque(e.background),.5).css}; }${this._terminalSelector} .${zi}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Bi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Bi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ii}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};Ui=x([S(7,ve),S(8,Ee),S(9,be),S(10,P),S(11,ge),S(12,De),S(13,Me)],Ui);var Wi=class extends I{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new R),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new qi(this._optionsService))}catch{this._measureStrategy=this._register(new Ki(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Wi=x([S(2,be)],Wi);var Gi=class extends I{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Ki=class extends Gi{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},qi=class extends Gi{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Ji=class extends I{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Yi(this._window)),this._onDprChange=this._register(new R),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new R),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(xt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(z(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(z(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Yi=class extends I{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ft),this._onDprChange=this._register(new R),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(F(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=z(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Xi=class extends I{constructor(){super(),this.linkProviders=[],this._register(F(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Zi(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function Qi(e,t,n,r,i,a,o,s,c){if(!a)return;let l=Zi(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),i),l}var $i=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Qi(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=Zi(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};$i=x([S(0,ke),S(1,Ee)],$i);var ea=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ta={};b(ta,{getSafariVersion:()=>ca,isChromeOS:()=>ma,isFirefox:()=>aa,isIpad:()=>ua,isIphone:()=>da,isLegacyEdge:()=>oa,isLinux:()=>pa,isMac:()=>la,isNode:()=>na,isSafari:()=>sa,isWindows:()=>fa});var na=typeof process<`u`&&`title`in process,ra=na?`node`:navigator.userAgent,ia=na?`node`:navigator.platform,aa=ra.includes(`Firefox`),oa=ra.includes(`Edge`),sa=/^((?!chrome|android).)*safari/i.test(ra);function ca(){if(!sa)return 0;let e=ra.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var la=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(ia),ua=ia===`iPad`,da=ia===`iPhone`,fa=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(ia),pa=ia.indexOf(`Linux`)>=0,ma=/\bCrOS\b/.test(ra),ha=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},ga=class extends ha{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},_a=class extends ha{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},va=!na&&`requestIdleCallback`in window?_a:ga,ya=class{constructor(){this._queue=new va}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},ba=class extends I{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new ft),this._pausedResizeTask=new ya,this._observerDisposable=this._register(new ft),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new R),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new R),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new R),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new R),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ea((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new xa(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(F(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=F(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};ba=x([S(2,be),S(3,Ee),S(4,ge),S(5,Ce),S(6,P),S(7,De),S(8,Me)],ba);var xa=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Sa(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return Ta(i,a,e,t,n,r)+Ea(a,t,n,r)+Da(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Pa(Math.abs(i-e),Na(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Pa(wa(a>t?e:i,n)+(s-1)*n.cols+1+Ca(a>t?i:e,n),Na(o,r))}function Ca(e,t){return e-1}function wa(e,t){return t.cols-e}function Ta(e,t,n,r,i,a){return Ea(t,r,i,a).length===0?``:Pa(Ma(e,t,e,t-ka(t,i),!1,i).length,Na(`D`,a))}function Ea(e,t,n,r){let i=e-ka(e,n),a=t-ka(t,n);return Pa(Math.abs(i-a)-Oa(e,t,n),Na(ja(e,t),r))}function Da(e,t,n,r,i,a){let o;o=Ea(t,r,i,a).length>0?r-ka(r,i):t;let s=r,c=Aa(e,t,n,r,i,a);return Pa(Ma(e,o,n,s,c===`C`,i).length,Na(c,a))}function Oa(e,t,n){let r=0,i=e-ka(e,n),a=t-ka(t,n);for(let o=0;o=0&&e0?r-ka(r,i):t,e=n&&ot?`A`:`B`}function Ma(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&sa.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function Na(e,t){let n=t?`O`:`[`;return B.ESC+n+e}function Pa(e,t){e=Math.floor(e);let n=``;for(let r=0;rthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ia(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var La=50,Ra=15,za=50,Ba=500,Va=RegExp(`\xA0`,`g`),Ha=class extends I{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new M,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new R),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new R),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new R),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new R),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new Fa(this._bufferService),this._activeSelectionMode=0,this._register(F(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]e.replace(Va,` `)).join(fa?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),pa&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Ia(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Zi(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-La),La),t/=La,t/Math.abs(t)+Math.round(t*(Ra-1)))}shouldForceSelection(e){return la?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),za)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(la&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ia(n,this._bufferService.cols)}};Ha=x([S(3,P),S(4,ge),S(5,Oe),S(6,be),S(7,ke),S(8,De)],Ha);var Ua=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Wa=class{constructor(){this._color=new Ua,this._css=new Ua}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ga=Object.freeze((()=>{let e=[W.toColor(`#2e3436`),W.toColor(`#cc0000`),W.toColor(`#4e9a06`),W.toColor(`#c4a000`),W.toColor(`#3465a4`),W.toColor(`#75507b`),W.toColor(`#06989a`),W.toColor(`#d3d7cf`),W.toColor(`#555753`),W.toColor(`#ef2929`),W.toColor(`#8ae234`),W.toColor(`#fce94f`),W.toColor(`#729fcf`),W.toColor(`#ad7fa8`),W.toColor(`#34e2e2`),W.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:H.toCss(r,i,a),rgba:H.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:H.toCss(n,n,n),rgba:H.toRgba(n,n,n)})}return e})()),Ka=W.toColor(`#ffffff`),qa=W.toColor(`#000000`),Ja=W.toColor(`#ffffff`),Ya=qa,Xa={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},Za=Ka,Qa=class extends I{constructor(e){super(),this._optionsService=e,this._contrastCache=new Wa,this._halfContrastCache=new Wa,this._onChangeColors=this._register(new R),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ka,background:qa,cursor:Ja,cursorAccent:Ya,selectionForeground:void 0,selectionBackgroundTransparent:Xa,selectionBackgroundOpaque:U.blend(qa,Xa),selectionInactiveBackgroundTransparent:Xa,selectionInactiveBackgroundOpaque:U.blend(qa,Xa),scrollbarSliderBackground:U.opacity(Ka,.2),scrollbarSliderHoverBackground:U.opacity(Ka,.4),scrollbarSliderActiveBackground:U.opacity(Ka,.5),overviewRulerBorder:Ka,ansi:Ga.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=G(e.foreground,Ka),t.background=G(e.background,qa),t.cursor=U.blend(t.background,G(e.cursor,Ja)),t.cursorAccent=U.blend(t.background,G(e.cursorAccent,Ya)),t.selectionBackgroundTransparent=G(e.selectionBackground,Xa),t.selectionBackgroundOpaque=U.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=G(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=U.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?G(e.selectionForeground,yi):void 0,t.selectionForeground===yi&&(t.selectionForeground=void 0),U.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=U.opacity(t.selectionBackgroundTransparent,.3)),U.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=U.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=G(e.scrollbarSliderBackground,U.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=G(e.scrollbarSliderHoverBackground,U.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=G(e.scrollbarSliderActiveBackground,U.opacity(t.foreground,.5)),t.overviewRulerBorder=G(e.overviewRulerBorder,Za),t.ansi=Ga.slice(),t.ansi[0]=G(e.black,Ga[0]),t.ansi[1]=G(e.red,Ga[1]),t.ansi[2]=G(e.green,Ga[2]),t.ansi[3]=G(e.yellow,Ga[3]),t.ansi[4]=G(e.blue,Ga[4]),t.ansi[5]=G(e.magenta,Ga[5]),t.ansi[6]=G(e.cyan,Ga[6]),t.ansi[7]=G(e.white,Ga[7]),t.ansi[8]=G(e.brightBlack,Ga[8]),t.ansi[9]=G(e.brightRed,Ga[9]),t.ansi[10]=G(e.brightGreen,Ga[10]),t.ansi[11]=G(e.brightYellow,Ga[11]),t.ansi[12]=G(e.brightBlue,Ga[12]),t.ansi[13]=G(e.brightMagenta,Ga[13]),t.ansi[14]=G(e.brightCyan,Ga[14]),t.ansi[15]=G(e.brightWhite,Ga[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;re.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},to={trace:0,debug:1,info:2,warn:3,error:4,off:5},no=`xterm.js: `,ro=class extends I{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),io=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=to[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;tthis._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*K+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*K+0]=e|2097152|t[2]<<22):this._data[e*K+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*K+0]>>22}hasWidth(e){return this._data[e*K+0]&12582912}getFg(e){return this._data[e*K+1]}getBg(e){return this._data[e*K+2]}hasContent(e){return this._data[e*K+0]&4194303}getCodePoint(e){let t=this._data[e*K+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*K+0]&2097152}getString(e){let t=this._data[e*K+0];return t&2097152?this._combined[e]:t&2097151?A(t&2097151):``}isProtected(e){return this._data[e*K+2]&536870912}loadCell(e,t){return oo=e*K,t.content=this._data[oo+0],t.fg=this._data[oo+1],t.bg=this._data[oo+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*K+0]=t.content,this._data[e*K+1]=t.fg,this._data[e*K+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*K+0]=t|n<<22,this._data[e*K+1]=r.fg,this._data[e*K+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*K+0];r&2097152?this._combined[e]+=A(t):r&2097151?(this._combined[e]=A(r&2097151)+A(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*K+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;rthis.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*so=0;--e)if(this._data[e*K+0]&4194303)return e+(this._data[e*K+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*K+0]&4194303||this._data[e*K+2]&50331648)return e+(this._data[e*K+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t>22||1}return r&&r.push(t),i}};function lo(e,t,n,r,i,a){let o=[];for(let s=0;s=s&&r0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function uo(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;omo(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;sc&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function mo(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var ho=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new R),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ct(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ho._nextId=1;var go=ho,_o={},vo=_o.B;_o[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},_o.A={"#":`£`},_o.B=void 0,_o[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},_o.C=_o[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},_o.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},_o.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},_o.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},_o.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},_o.E=_o[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},_o.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},_o.H=_o[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},_o[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var yo=4294967295,bo=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=q.clone(),this.savedCharset=vo,this.markers=[],this._nullCell=M.fromCharData([0,oe,1,0]),this._whitespaceCell=M.fromCharData([0,se,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new va,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ao(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new le),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new le),this._whitespaceCell}getBlankLine(e,t){return new co(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&eyo?yo:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=q);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ao(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(q),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new co(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=lo(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(q),n);if(r.length>0){let n=uo(this.lines,r);fo(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(q),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=mo(c,Math.max(g,0),this._cols))}for(let t=0;t0;)this.ybase===0?this.y0){let e=[],t=[];for(let e=0;e=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.linee.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},xo=class extends I{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new R),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new bo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new bo(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},So=2,Co=1,wo=class extends I{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new R),this.onResize=this._onResize.event,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,So),this.rows=Math.max(e.rawOptions.rows||0,Co),this.buffers=this._register(new xo(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};wo=x([S(0,be)],wo);var To={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:la,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Eo=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Do=class extends I{constructor(e){super(),this._onOptionChange=this._register(new R),this.onOptionChange=this._onOptionChange.event;let t={...To};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(F(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in To))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in To))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=To[e],!Oo(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=To[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Eo.includes(t)?t:To[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function Oo(e){return e===`block`||e===`underline`||e===`bar`}function ko(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&ko(e[r],t-1);return n}var Ao=Object.freeze({insertMode:!1}),jo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Mo=class extends I{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new R),this.onData=this._onData.event,this._onUserInput=this._register(new R),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new R),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new R),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ko(Ao),this.decPrivateModes=ko(jo)}reset(){this.modes=ko(Ao),this.decPrivateModes=ko(jo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Mo=x([S(0,P),S(1,ye),S(2,be)],Mo);var No={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Po(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Fo=String.fromCharCode,Io={DEFAULT:e=>{let t=[Po(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Fo(t[0])}${Fo(t[1])}${Fo(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Po(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Po(e,!0)};${e.x};${e.y}${t}`}},Lo=class extends I{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new R),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(No))this.addProtocol(e,No[e]);for(let e of Object.keys(Io))this.addEncoding(e,Io[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Lo=x([S(0,P),S(1,ge),S(2,be)],Lo);var Ro=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],zo=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Bo;function Vo(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Uo.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Uo.createPropertyValue(0,n,r)}},Uo=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new R,this.onChange=this._onChange.event;let e=new Ho;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Wo=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Go(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Ko=2147483647,qo=256,Jo=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>qo)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=Array.isArray(t[0])?1:0;e>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Ko?Ko:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>Ko?Ko:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,Ko):e}},Yo=[],Xo=class{constructor(){this._state=0,this._active=Yo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Yo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Yo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Yo,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,j(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Yo,this._id=-1,this._state=0}}},Zo=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=j(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},Qo=[],$o=class{constructor(){this._handlers=Object.create(null),this._active=Qo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Qo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Qo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Qo,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,j(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Qo,this._ident=0}},es=new Jo;es.addParam(0);var ts=class{constructor(e){this._handler=e,this._data=``,this._params=es,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():es,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=j(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=es,this._data=``,this._hitLimit=!1,e));return this._params=es,this._data=``,this._hitLimit=!1,t}},ns=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;it),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(rs,0,2,0),e.add(rs,8,5,8),e.add(rs,6,0,6),e.add(rs,11,0,11),e.add(rs,13,13,13),e}(),as=class extends I{constructor(e=is){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Jo,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(F(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Xo),this._dcsParser=this._register(new $o),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;tr||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r=t||(r=e[i])<32||r>127&&r>4:i>>8}return n}}function ls(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function us(e,t=16){let[n,r,i]=e;return`rgb:${ls(n,t)}/${ls(r,t)}/${ls(i,t)}`}var ds={"(":0,")":1,"*":2,"+":3,"-":1,".":2},fs=131072,ps=10;function ms(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var hs=5e3,gs=0,_s=class extends I{constructor(e,t,n,r,i,a,o,s,c=new as){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ie,this._utf8Decoder=new ae,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=q.clone(),this._eraseAttrDataInternal=q.clone(),this._onRequestBell=this._register(new R),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new R),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new R),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new R),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new R),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new R),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new R),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new R),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new R),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new R),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new R),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new R),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new vs(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(B.BEL,()=>this.bell()),this._parser.setExecuteHandler(B.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(B.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(B.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(B.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(B.BS,()=>this.backspace()),this._parser.setExecuteHandler(B.HT,()=>this.tab()),this._parser.setExecuteHandler(B.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(B.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(pi.IND,()=>this.index()),this._parser.setExecuteHandler(pi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(pi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Zo(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Zo(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Zo(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Zo(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Zo(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Zo(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Zo(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Zo(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Zo(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Zo(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Zo(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Zo(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in _o)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new ts((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),hs))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${hs} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>fs&&(a=this._parseStack.position+fs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.lengthfs)for(let t=a;t0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;ps){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof co&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>ms(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new ts(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Zo(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let c=s;for(let e=1;e0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(B.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(B.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(B.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(B.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(B.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${B.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=ce.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=q.fg,e.bg=q.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=q.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=q.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=q.fg&16777215,r.bg&=-67108864,r.bg|=q.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${B.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${B.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${B.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=q.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ms(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${B.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ps&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ps&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(ys(n))if(r===`?`)t.push({type:0,index:n});else{let e=cs(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=cs(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=q.clone(),this._eraseAttrDataInternal=q.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new M;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${B.ESC}${e}${B.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},vs=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(gs=e,e=t,t=gs),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vs=x([S(0,P)],vs);function ys(e){return 0<=e&&e<256}var bs=5e7,xs=12,Ss=50,Cs=class extends I{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new R),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bs)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=xs?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=xs)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ss&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},ws=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};ws=x([S(0,P)],ws);var Ts=!1,Es=class extends I{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ft),this._onBinary=this._register(new R),this.onBinary=this._onBinary.event,this._onData=this._register(new R),this.onData=this._onData.event,this._onLineFeed=this._register(new R),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new R),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new R),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new R),this._instantiationService=new eo,this.optionsService=this._register(new Do(e)),this._instantiationService.setService(be,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(wo)),this._instantiationService.setService(P,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ro)),this._instantiationService.setService(ye,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Mo)),this._instantiationService.setService(ge,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Lo)),this._instantiationService.setService(he,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Uo)),this._instantiationService.setService(Se,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Wo),this._instantiationService.setService(_e,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ws),this._instantiationService.setService(xe,this._oscLinkService),this._inputHandler=this._register(new _s(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(xt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(xt.forward(this._bufferService.onResize,this._onResize)),this._register(xt.forward(this.coreService.onData,this._onData)),this._register(xt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Cs((e,t)=>this._inputHandler.parse(e,t))),this._register(xt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new R),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ts&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Ts=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,So),t=Math.max(t,Co),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Go.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Go(this._bufferService),!1))),this._windowsWrappingHeuristics.value=F(()=>{for(let t of e)t.dispose()})}}},Ds={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function Os(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=B.ESC+`OA`:i.key=B.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=B.ESC+`OD`:i.key=B.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=B.ESC+`OC`:i.key=B.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=B.ESC+`OB`:i.key=B.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:B.DEL,e.altKey&&(i.key=B.ESC+i.key);break;case 9:if(e.shiftKey){i.key=B.ESC+`[Z`;break}i.key=B.HT,i.cancel=!0;break;case 13:i.key=e.altKey?B.ESC+B.CR:B.CR,i.cancel=!0;break;case 27:i.key=B.ESC,e.altKey&&(i.key=B.ESC+B.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=B.ESC+`[1;`+(a+1)+`D`:t?i.key=B.ESC+`OD`:i.key=B.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=B.ESC+`[1;`+(a+1)+`C`:t?i.key=B.ESC+`OC`:i.key=B.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=B.ESC+`[1;`+(a+1)+`A`:t?i.key=B.ESC+`OA`:i.key=B.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=B.ESC+`[1;`+(a+1)+`B`:t?i.key=B.ESC+`OB`:i.key=B.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=B.ESC+`[2~`);break;case 46:a?i.key=B.ESC+`[3;`+(a+1)+`~`:i.key=B.ESC+`[3~`;break;case 36:a?i.key=B.ESC+`[1;`+(a+1)+`H`:t?i.key=B.ESC+`OH`:i.key=B.ESC+`[H`;break;case 35:a?i.key=B.ESC+`[1;`+(a+1)+`F`:t?i.key=B.ESC+`OF`:i.key=B.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=B.ESC+`[5;`+(a+1)+`~`:i.key=B.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=B.ESC+`[6;`+(a+1)+`~`:i.key=B.ESC+`[6~`;break;case 112:a?i.key=B.ESC+`[1;`+(a+1)+`P`:i.key=B.ESC+`OP`;break;case 113:a?i.key=B.ESC+`[1;`+(a+1)+`Q`:i.key=B.ESC+`OQ`;break;case 114:a?i.key=B.ESC+`[1;`+(a+1)+`R`:i.key=B.ESC+`OR`;break;case 115:a?i.key=B.ESC+`[1;`+(a+1)+`S`:i.key=B.ESC+`OS`;break;case 116:a?i.key=B.ESC+`[15;`+(a+1)+`~`:i.key=B.ESC+`[15~`;break;case 117:a?i.key=B.ESC+`[17;`+(a+1)+`~`:i.key=B.ESC+`[17~`;break;case 118:a?i.key=B.ESC+`[18;`+(a+1)+`~`:i.key=B.ESC+`[18~`;break;case 119:a?i.key=B.ESC+`[19;`+(a+1)+`~`:i.key=B.ESC+`[19~`;break;case 120:a?i.key=B.ESC+`[20;`+(a+1)+`~`:i.key=B.ESC+`[20~`;break;case 121:a?i.key=B.ESC+`[21;`+(a+1)+`~`:i.key=B.ESC+`[21~`;break;case 122:a?i.key=B.ESC+`[23;`+(a+1)+`~`:i.key=B.ESC+`[23~`;break;case 123:a?i.key=B.ESC+`[24;`+(a+1)+`~`:i.key=B.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=B.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=B.DEL:e.keyCode===219?i.key=B.ESC:e.keyCode===220?i.key=B.FS:e.keyCode===221&&(i.key=B.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Ds[e.keyCode]?.[e.shiftKey?1:0];if(t)i.key=B.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=B.ESC+n}else if(e.keyCode===32)i.key=B.ESC+(e.ctrlKey?B.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=B.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=B.US),e.key===`@`&&(i.key=B.NUL));break}return i}var J=0,ks=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new va,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new va,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(J=this._search(t),J===-1)||this._getKey(this._array[J])!==t)return!1;do if(this._array[J]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(J),!0;while(++Je-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(J=this._search(e),!(J<0||J>=this._array.length)&&this._getKey(this._array[J])===e))do yield this._array[J];while(++J=this._array.length)&&this._getKey(this._array[J])===e))do t(this._array[J]);while(++J=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},As=0,js=0,Ms=class extends I{constructor(){super(),this._decorations=new ks(e=>e?.marker.line),this._onDecorationRegistered=this._register(new R),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new R),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(F(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Ns(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e{As=t.options.x??0,js=As+(t.options.width??1),e>=As&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Is=20,Ls=!1,Rs=class extends I{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;ethis._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Fs(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);Ls?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(z(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(F(()=>{Ls?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Is+1&&(this._liveRegion.textContent+=w.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{ct(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(z(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(z(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(z(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(z(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;re?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;tthis._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;ethis._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Bs(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ct(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};zs=x([S(1,Oe),S(2,ke),S(3,P),S(4,Ne)],zs);function Bs(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Vs=class extends Es{constructor(e={}){super(e),this._linkifier=this._register(new ft),this.browser=ta,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ft),this._onCursorMove=this._register(new R),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new R),this.onKey=this._onKey.event,this._onRender=this._register(new R),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new R),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new R),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new R),this.onBell=this._onBell.event,this._onFocus=this._register(new R),this._onBlur=this._register(new R),this._onA11yCharEmitter=this._register(new R),this._onA11yTabEmitter=this._register(new R),this._onWillOpen=this._register(new R),this._setup(),this._decorationService=this._instantiationService.createInstance(Ms),this._instantiationService.setService(Ce,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Xi),this._instantiationService.setService(Ne,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(we)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(xt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(xt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(xt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(xt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(F(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=U.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${B.ESC}]${n};${us(r)}${mi.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=H.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=H.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Rs,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(B.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(B.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(z(this.element,`copy`,e=>{this.hasSelection()&&D(e,this._selectionService)}));let e=e=>ne(e,this.textarea,this.coreService,this.optionsService);this._register(z(this.textarea,`paste`,e)),this._register(z(this.element,`paste`,e)),aa?this._register(z(this.element,`mousedown`,e=>{e.button===2&&k(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(z(this.element,`contextmenu`,e=>{k(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),pa&&this._register(z(this.element,`auxclick`,e=>{e.button===1&&re(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(z(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(z(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(z(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(z(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(z(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(z(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(z(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(z(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,te.get()),ma||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Ji,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(De,this._coreBrowserService),this._register(z(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(z(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wi,this._document,this._helperContainer),this._instantiationService.setService(Ee,this._charSizeService),this._themeService=this._instantiationService.createInstance(Qa),this._instantiationService.setService(Me,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ti),this._instantiationService.setService(je,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ba,this.rows,this.screenElement)),this._instantiationService.setService(ke,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(hi,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance($i),this._instantiationService.setService(Oe,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(zs,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(oi,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ha,this.element,this.screenElement,r)),this._instantiationService.setService(Ae,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(xt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(si,this.screenElement)),this._register(z(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Rs,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ui,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(z(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(z(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=B.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){O(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=Os(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===B.ETX||n.key===B.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Hs(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new M)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Gs=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Ws(t)}getNullCell(){return new M}},Ks=class extends I{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new R),this.onBufferChange=this._onBufferChange.event,this._normal=new Gs(this._core.buffers.normal,`normal`),this._alternate=new Gs(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},qs=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Js=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Ys=[`cols`,`rows`],Xs=0,Zs=class extends I{constructor(e){super(),this._core=this._register(new Vs(e)),this._addonManager=this._register(new Us),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(Ys.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new qs(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Js(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new Ks(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return te.get()},set promptLabel(e){te.set(e)},get tooMuchOutput(){return w.get()},set tooMuchOutput(e){w.set(e)}}}_verifyIntegers(...e){for(Xs of e)if(Xs===1/0||isNaN(Xs)||Xs%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Xs of e)if(Xs&&(Xs===1/0||isNaN(Xs)||Xs%1!=0||Xs<0))throw Error(`This API only accepts positive integers`)}},Qs=2,$s=1,ec=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Qs,Math.floor(u/e.css.cell.width)),rows:Math.max($s,Math.floor(l/e.css.cell.height))}}},tc=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=rc.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function nc(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var rc=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!nc(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function ac(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var oc=class{constructor(e=ac,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ic;this._linkProvider=this._terminal.registerLinkProvider(new tc(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},sc=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?fc.isErrorNoTelemetry(e)?new fc(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function cc(e){uc(e)||sc.onUnexpectedError(e)}var lc=`Canceled`;function uc(e){return e instanceof dc?!0:e instanceof Error&&e.name===lc&&e.message===lc}var dc=class extends Error{constructor(){super(lc),this.name=this.message}},fc=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function pc(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(hc||={});function gc(e,t){return(n,r)=>t(e(n),e(r))}var _c=(e,t)=>e-t,vc=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||hc.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};vc.empty=new vc(e=>{});function yc(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var bc=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function xc(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Sc;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` -`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new bc;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` -`),e)}n.sort(gc(e=>e.idx,_c));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` - - -==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== -${s.join(` -`)} -============================================================ - -`}return n.length>e&&(a+=` - - -... and ${n.length-e} more leaking disposables - -`),{leaks:n,details:a}}};Tc.idx=0;function Ec(e){wc=e}if(Cc){let e=`__is_disposable_tracked__`;Ec(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==Ic.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==Ic.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function Dc(e){return wc?.trackDisposable(e),e}function Oc(e){wc?.markAsDisposed(e)}function kc(e,t){wc?.setParent(e,t)}function Ac(e,t){if(wc)for(let n of e)wc.setParent(n,t)}function jc(e){if(Sc.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Mc(...e){let t=Nc(()=>jc(e));return Ac(e,t),t}function Nc(e){let t=Dc({dispose:xc(()=>{Oc(t),e()})});return t}var Pc=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Dc(this)}dispose(){this._isDisposed||(Oc(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{jc(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return kc(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),kc(e,null))}};Pc.DISABLE_DISPOSED_WARNING=!1;var Fc=Pc,Ic=class{constructor(){this._store=new Fc,Dc(this),kc(this._store,this)}dispose(){Oc(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Ic.None=Object.freeze({dispose(){}});var Lc=class{constructor(){this._isDisposed=!1,Dc(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&kc(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Oc(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&kc(e,null),e}},Rc=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Rc.Undefined=new Rc(void 0);var zc=globalThis.performance&&typeof globalThis.performance.now==`function`,Bc=class e{static create(t){return new e(t)}constructor(e){this._now=zc&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Vc=!1,Hc=!1,Uc=!1,Wc;(e=>{e.None=()=>Ic.None;function t(e){if(Uc){let{onDidAddListener:t}=e,n=Xc.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(Mc(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new il(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new il(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new il({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new il({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new il({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function ee(e){let t=new il;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new il(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Fc?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Wc||={});var Gc=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Bc,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Gc.all=new Set,Gc._idPool=0;var Kc=Gc,qc=-1,Jc=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof el)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` -`)),e.length=0)},3e3),rl=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var il=class{constructor(e){this._size=0,this._options=e,this._leakageMon=qc>0||this._options?.leakWarningThreshold?new Yc(e?.onListenerError??cc,this._options?.leakWarningThreshold??qc):void 0,this._perfMon=this._options?._profName?new Kc(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Hc){let e=this._listeners;queueMicrotask(()=>{nl(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Qc(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||cc)(n),Ic.None}if(this._disposed)return Ic.None;t&&(e=e.bind(t));let r=new el(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Xc.create(),i=this._leakageMon.check(r.stack,this._size+1)),Hc&&(r.stack=Xc.create()),this._listeners?this._listeners instanceof el?(this._deliveryQueue??=new al,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Nc(()=>{rl?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof Fc?n.add(a):Array.isArray(n)&&n.push(a),rl){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);rl.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*tl<=t.length){let e=0;for(let n=0;n0}},al=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ol=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),sl;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof cl?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Wc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ol})})(sl||={});var cl=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ol:(this._emitter||=new il,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ll=`en`,ul=!1,dl=!1,fl=ll,pl,ml=globalThis,hl;typeof ml.vscode<`u`&&typeof ml.vscode.process<`u`?hl=ml.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(hl=process);var gl=typeof hl?.versions?.electron==`string`&&hl?.type===`renderer`;if(typeof hl==`object`){hl.platform,hl.platform,ul=hl.platform===`linux`,ul&&hl.env.SNAP&&hl.env.SNAP_REVISION,hl.env.CI||hl.env.BUILD_ARTIFACTSTAGINGDIRECTORY,fl=ll;let e=hl.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,fl=t.resolvedLanguage||ll,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!gl?(pl=navigator.userAgent,pl.indexOf(`Windows`),pl.indexOf(`Macintosh`),(pl.indexOf(`Macintosh`)>=0||pl.indexOf(`iPad`)>=0||pl.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ul=pl.indexOf(`Linux`)>=0,pl?.indexOf(`Mobi`),dl=!0,fl=globalThis._VSCODE_NLS_LANGUAGE||ll,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);dl&&typeof ml.importScripts==`function`&&ml.origin;var _l=pl,vl=fl,yl;(e=>{function t(){return vl}e.value=t;function n(){return vl.length===2?vl===`en`:vl.length>=3?vl[0]===`e`&&vl[1]===`n`&&vl[2]===`-`:!1}e.isDefaultVariant=n;function r(){return vl===`en`}e.isDefault=r})(yl||={});var bl=typeof ml.postMessage==`function`&&!ml.importScripts;(()=>{if(bl){let e=[];ml.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),ml.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var xl=!!(_l&&_l.indexOf(`Chrome`)>=0);_l&&_l.indexOf(`Firefox`),!xl&&_l&&_l.indexOf(`Safari`),_l&&_l.indexOf(`Edg/`),_l&&_l.indexOf(`Android`);function Sl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Nc(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Cl;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(Cl||={});var wl=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new il,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};wl.EMPTY=wl.fromArray([]);var Tl=class extends Ic{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Lc),this._linesCacheDisposables=this._register(new Lc),this._register(Nc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Mc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Sl(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},El=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Dl=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t=c[t+1];)t++;let r=t;for(;r=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;ethis.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){jc(n)}}}clearHighlightDecorations(){jc(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>jc(e))),s.push(i)}}return s.length===0?void 0:s}},kl=class extends Ic{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new il)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;tthis._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Nc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Sl(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.rowt[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Pu.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Pu.createPropertyValue(0,n,r)}},Il=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Vl.isErrorNoTelemetry(e)?new Vl(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Ll(e){zl(e)||Il.onUnexpectedError(e)}var Rl=`Canceled`;function zl(e){return e instanceof Bl?!0:e instanceof Error&&e.name===Rl&&e.message===Rl}var Bl=class extends Error{constructor(){super(Rl),this.name=this.message}},Vl=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function Hl(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}function Ul(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Gl||={});function Kl(e,t){return(n,r)=>t(e(n),e(r))}var ql=(e,t)=>e-t,Jl=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Gl.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Jl.empty=new Jl(e=>{});function Yl(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var Xl=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}},Zl;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` -`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new Xl;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` -`),e)}n.sort(Kl(e=>e.idx,ql));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` - - -==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== -${s.join(` -`)} -============================================================ - -`}return n.length>e&&(a+=` - - -... and ${n.length-e} more leaking disposables - -`),{leaks:n,details:a}}};eu.idx=0;function tu(e){$l=e}if(Ql){let e=`__is_disposable_tracked__`;tu(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==du.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==du.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function nu(e){return $l?.trackDisposable(e),e}function ru(e){$l?.markAsDisposed(e)}function iu(e,t){$l?.setParent(e,t)}function au(e,t){if($l)for(let n of e)$l.setParent(n,t)}function ou(e){if(Zl.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function su(...e){let t=cu(()=>ou(e));return au(e,t),t}function cu(e){let t=nu({dispose:Hl(()=>{ru(t),e()})});return t}var lu=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,nu(this)}dispose(){this._isDisposed||(ru(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ou(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return iu(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),iu(e,null))}};lu.DISABLE_DISPOSED_WARNING=!1;var uu=lu,du=class{constructor(){this._store=new uu,nu(this),iu(this._store,this)}dispose(){ru(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};du.None=Object.freeze({dispose(){}});var fu=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};fu.Undefined=new fu(void 0);var pu=globalThis.performance&&typeof globalThis.performance.now==`function`,mu=class e{static create(t){return new e(t)}constructor(e){this._now=pu&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},hu=!1,gu=!1,_u=!1,vu;(e=>{e.None=()=>du.None;function t(e){if(_u){let{onDidAddListener:t}=e,n=wu.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(su(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new Mu(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new Mu(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Mu({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Mu({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Mu({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function ee(e){let t=new Mu;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new Mu(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof uu?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(vu||={});var yu=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new mu,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};yu.all=new Set,yu._idPool=0;var bu=yu,xu=-1,Su=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof Ou)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` -`)),e.length=0)},3e3),ju=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var Mu=class{constructor(e){this._size=0,this._options=e,this._leakageMon=xu>0||this._options?.leakWarningThreshold?new Cu(e?.onListenerError??Ll,this._options?.leakWarningThreshold??xu):void 0,this._perfMon=this._options?._profName?new bu(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(gu){let e=this._listeners;queueMicrotask(()=>{Au(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Eu(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Ll)(n),du.None}if(this._disposed)return du.None;t&&(e=e.bind(t));let r=new Ou(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=wu.create(),i=this._leakageMon.check(r.stack,this._size+1)),gu&&(r.stack=wu.create()),this._listeners?this._listeners instanceof Ou?(this._deliveryQueue??=new Nu,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=cu(()=>{ju?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof uu?n.add(a):Array.isArray(n)&&n.push(a),ju){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);ju.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ku<=t.length){let e=0;for(let n=0;n0}},Nu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Pu=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Mu,this.onChange=this._onChange.event;let e=new Fl;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Fu=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],Iu=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],Lu=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],Ru=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],zu;function Bu(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(en&&(n=e)}return Pu.createPropertyValue(0,n,r)}},Hu=class{activate(e){e.unicode.register(new Vu)}dispose(){}},Uu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Gu=(e,t,n,r)=>{for(var i=r>1?void 0:r?Wu(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Uu(t,n,i),i},Ku=(e,t)=>(n,r)=>t(n,r,e),qu=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Qu.isErrorNoTelemetry(e)?new Qu(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Ju(e){Xu(e)||qu.onUnexpectedError(e)}var Yu=`Canceled`;function Xu(e){return e instanceof Zu?!0:e instanceof Error&&e.name===Yu&&e.message===Yu}var Zu=class extends Error{constructor(){super(Yu),this.name=this.message}},Qu=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function $u(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(td||={});function nd(e,t){return(n,r)=>t(e(n),e(r))}var rd=(e,t)=>e-t,id=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||td.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};id.empty=new id(e=>{});function ad(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var od=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function sd(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var cd;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` -`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new od;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` -`),e)}n.sort(nd(e=>e.idx,rd));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` - - -==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== -${s.join(` -`)} -============================================================ - -`}return n.length>e&&(a+=` - - -... and ${n.length-e} more leaking disposables - -`),{leaks:n,details:a}}};dd.idx=0;function fd(e){ud=e}if(ld){let e=`__is_disposable_tracked__`;fd(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==Sd.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==Sd.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function pd(e){return ud?.trackDisposable(e),e}function md(e){ud?.markAsDisposed(e)}function hd(e,t){ud?.setParent(e,t)}function gd(e,t){if(ud)for(let n of e)ud.setParent(n,t)}function _d(e){if(cd.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function vd(...e){let t=yd(()=>_d(e));return gd(e,t),t}function yd(e){let t=pd({dispose:sd(()=>{md(t),e()})});return t}var bd=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,pd(this)}dispose(){this._isDisposed||(md(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{_d(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return hd(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),hd(e,null))}};bd.DISABLE_DISPOSED_WARNING=!1;var xd=bd,Sd=class{constructor(){this._store=new xd,pd(this),hd(this._store,this)}dispose(){md(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Sd.None=Object.freeze({dispose(){}});var Cd=class{constructor(){this._isDisposed=!1,pd(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&hd(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,md(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&hd(e,null),e}},wd=typeof process<`u`&&`title`in process,Td=wd?`node`:navigator.userAgent,Ed=wd?`node`:navigator.platform,Dd=Td.includes(`Firefox`),Od=Td.includes(`Edge`),kd=/^((?!chrome|android).)*safari/i.test(Td);function Ad(){if(!kd)return 0;let e=Td.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Ed),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Ed),Ed.indexOf(`Linux`),/\bCrOS\b/.test(Td);var jd=``,Md=0,Nd=0,Pd=0,Y=0,Fd={css:`#00000000`,rgba:0},Id;(e=>{function t(e,t,n,r){return r===void 0?`#${Vd(e)}${Vd(t)}${Vd(n)}`:`#${Vd(e)}${Vd(t)}${Vd(n)}${Vd(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(Id||={});var Ld;(e=>{function t(e,t){if(Y=(t.rgba&255)/255,Y===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Md=a+Math.round((n-a)*Y),Nd=o+Math.round((r-o)*Y),Pd=s+Math.round((i-s)*Y),{css:Id.toCss(Md,Nd,Pd),rgba:Id.toRgba(Md,Nd,Pd)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Bd.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Id.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Md,Nd,Pd]=Bd.toChannels(t),{css:Id.toCss(Md,Nd,Pd),rgba:t}}e.opaque=i;function a(e,t){return Y=Math.round(t*255),[Md,Nd,Pd]=Bd.toChannels(e.rgba),{css:Id.toCss(Md,Nd,Pd,Y),rgba:Id.toRgba(Md,Nd,Pd,Y)}}e.opacity=a;function o(e,t){return Y=e.rgba&255,a(e,Y*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Ld||={});var Rd;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Md=parseInt(e.slice(1,2).repeat(2),16),Nd=parseInt(e.slice(2,3).repeat(2),16),Pd=parseInt(e.slice(3,4).repeat(2),16),Id.toColor(Md,Nd,Pd);case 5:return Md=parseInt(e.slice(1,2).repeat(2),16),Nd=parseInt(e.slice(2,3).repeat(2),16),Pd=parseInt(e.slice(3,4).repeat(2),16),Y=parseInt(e.slice(4,5).repeat(2),16),Id.toColor(Md,Nd,Pd,Y);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Md=parseInt(r[1]),Nd=parseInt(r[2]),Pd=parseInt(r[3]),Y=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Id.toColor(Md,Nd,Pd,Y);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Md,Nd,Pd,Y]=t.getImageData(0,0,1,1).data,Y!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Id.toRgba(Md,Nd,Pd,Y),css:e}}e.toColor=r})(Rd||={});var zd;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(zd||={});var Bd;(e=>{function t(e,t){if(Y=(t&255)/255,Y===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Md=a+Math.round((n-a)*Y),Nd=o+Math.round((r-o)*Y),Pd=s+Math.round((i-s)*Y),Id.toRgba(Md,Nd,Pd)}e.blend=t;function n(e,t,n){let a=zd.relativeLuminance(e>>8),o=zd.relativeLuminance(t>>8);if(Hd(a,o)>8));if(sHd(a,zd.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Hd(a,zd.relativeLuminance(s>>8));if(cHd(a,zd.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Hd(zd.relativeLuminance2(o,s,c),zd.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Hd(zd.relativeLuminance2(o,s,c),zd.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Hd(zd.relativeLuminance2(o,s,c),zd.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Bd||={});function Vd(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Hd(e,t){return e=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function Jd(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!qd(e)&&!Ud(e)&&!Gd(e)}function Yd(e){return Ud(e)||Kd(e)}function Xd(){return{css:{canvas:Zd(),cell:Zd()},device:{canvas:Zd(),cell:Zd(),char:{width:0,height:0,left:0,top:0}}}}function Zd(){return{width:0,height:0}}function Qd(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var $d=0,ef=0,tf=!1,nf=!1,rf=!1,af,of=0,sf=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,ef=0,$d=0,nf=!1,tf=!1,rf=!1,af=this._themeService.colors,of=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));of=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(ef=e.backgroundColorRGB.rgba>>8&16777215,nf=!0),e.foregroundColorRGB&&($d=e.foregroundColorRGB.rgba>>8&16777215,tf=!0)}),rf=this._selectionRenderModel.isCellSelected(this._terminal,t,n),rf){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ef=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ef=(this.result.fg&16777215)<<8|255;break;case 0:default:ef=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ef=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ef=(this.result.bg&16777215)<<8|255;break}ef=Bd.blend(ef,(this._coreBrowserService.isFocused?af.selectionBackgroundOpaque:af.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ef=(this._coreBrowserService.isFocused?af.selectionBackgroundOpaque:af.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(nf=!0,af.selectionForeground&&($d=af.selectionForeground.rgba>>8&16777215,tf=!0),Yd(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))$d=(this._coreBrowserService.isFocused?af.selectionBackgroundOpaque:af.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:$d=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:$d=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:$d=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:$d=(this.result.fg&16777215)<<8|255;break;case 0:default:$d=this._themeService.colors.foreground.rgba}$d=Bd.blend($d,(this._coreBrowserService.isFocused?af.selectionBackgroundOpaque:af.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}tf=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(ef=e.backgroundColorRGB.rgba>>8&16777215,nf=!0),e.foregroundColorRGB&&($d=e.foregroundColorRGB.rgba>>8&16777215,tf=!0)}),nf&&(ef=rf?e.bg&-150994944|ef|50331648:e.bg&-16777216|ef|50331648),tf&&($d=e.fg&-83886080|$d|50331648),this.result.fg&67108864&&(nf&&!tf&&($d=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|af.background.rgba>>8&16777215|50331648,tf=!0),!nf&&tf&&(ef=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|af.foreground.rgba>>8&16777215|50331648,nf=!0)),af=void 0,this.result.bg=nf?ef:this.result.bg,this.result.fg=tf?$d:this.result.fg,this.result.ext&=536870911,this.result.ext|=of<<29&3758096384}},cf=.5,lf=Dd||Od?`bottom`:`ideographic`,uf={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},df={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},ff={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},pf={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};pf[``]=pf[``],pf[``]=pf[``];function mf(e,t,n,r,i,a,o,s){let c=uf[t];if(c)return hf(e,c,n,r,i,a),!0;let l=df[t];if(l)return _f(e,l,n,r,i,a),!0;let u=ff[t];if(u)return vf(e,u,n,r,i,a,s),!0;let d=pf[t];return d?(yf(e,d,n,r,i,a,o,s),!0):!1}function hf(e,t,n,r,i,a){for(let o=0;o7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;ee.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function Sf(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;ei){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},Ef=class extends Tf{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Df=class extends Tf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Of=!wd&&`requestIdleCallback`in window?Df:Ef,kf=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Af}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Af=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},jf=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};jf.Undefined=new jf(void 0);var Mf=globalThis.performance&&typeof globalThis.performance.now==`function`,Nf=class e{static create(t){return new e(t)}constructor(e){this._now=Mf&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Pf=!1,Ff=!1,If=!1,Lf;(e=>{e.None=()=>Sd.None;function t(e){if(If){let{onDidAddListener:t}=e,n=Uf.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(vd(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new Z(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new Z(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Z({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function ee(e){let t=new Z;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new Z(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof xd?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Lf||={});var Rf=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Nf,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Rf.all=new Set,Rf._idPool=0;var zf=Rf,Bf=-1,Vf=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof qf)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` -`)),e.length=0)},3e3),Xf=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Bf>0||this._options?.leakWarningThreshold?new Hf(e?.onListenerError??Ju,this._options?.leakWarningThreshold??Bf):void 0,this._perfMon=this._options?._profName?new zf(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Ff){let e=this._listeners;queueMicrotask(()=>{Yf(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Gf(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Ju)(n),Sd.None}if(this._disposed)return Sd.None;t&&(e=e.bind(t));let r=new qf(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Uf.create(),i=this._leakageMon.check(r.stack,this._size+1)),Ff&&(r.stack=Uf.create()),this._listeners?this._listeners instanceof qf?(this._deliveryQueue??=new Zf,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=yd(()=>{Xf?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof xd?n.add(a):Array.isArray(n)&&n.push(a),Xf){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Xf.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Jf<=t.length){let e=0;for(let n=0;n0}},Zf=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Qf={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},$f=2,ep,tp=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new wf,this._cacheMapCombined=new wf,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new kf,this._textureSize=512,this._onAddTextureAtlasCanvas=new Z,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Z,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=ap(e,this._config.deviceCellWidth*4+$f*2,this._config.deviceCellHeight+$f*2),this._tmpCtx=X(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new Of;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;ee.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new np(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new np(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return Fd;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=kf.toColorRGB(t);i=Id.toColor(e[0],e[1],e[2]);break;default:i=n?Ld.opaque(this._config.colors.foreground):this._config.colors.background;break}return this._config.allowTransparency||(i=Ld.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=kf.toColorRGB(a);d=Id.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=Ld.opaque(d)),s&&(d=Ld.multiplyOpacity(d,cf)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=Bd.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=Id.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+$f*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=Qd(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!E&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*ne,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,T,T+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*ne,T+t),this._tmpCtx.stroke()}if(E||this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=rp(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,D);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight-t),e=rp(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,D),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*ne,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let O=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),re;if(re=this._config.allowTransparency?ip(O):rp(O,x,w,D),re)return Qf;let k=this._findGlyphBoundingBox(O,this._workBoundingBox,c,C,E,T),A,j;for(;;){if(this._activePages.length===0){let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y;break}A=this._activePages[this._activePages.length-1],j=A.currentRow;for(let e of this._activePages)k.size.y<=e.currentRow.height&&(A=e,j=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=j.height&&k.size.y<=t.height&&(A=this._activePages[e],j=t);if(k.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new np(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),A=this._overflowSizePage,j=this._overflowSizePage.currentRow,j.x+k.size.x>=A.canvas.width&&(j.x=0,j.y+=j.height,j.height=0);break}if(j.y+k.size.y>=A.canvas.height||j.height>k.size.y+2){let t=!1;if(A.currentRow.y+A.currentRow.height+k.size.y>=A.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+k.size.y=e.maxAtlasPages&&j.y+k.size.y<=A.canvas.height&&j.height>=k.size.y&&j.x+k.size.x<=A.canvas.width)t=!0;else{let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y,t=!0}}t||(A.currentRow.height>0&&A.fixedRows.push(A.currentRow),j={x:0,y:A.currentRow.y+A.currentRow.height,height:k.size.y},A.fixedRows.push(j),A.currentRow={x:0,y:j.y+j.height,height:0})}if(j.x+k.size.x<=A.canvas.width)break;j===A.currentRow?(j.x=0,j.y+=j.height,j.height=0):A.fixedRows.splice(A.fixedRows.indexOf(j),1)}return k.texturePage=this._pages.indexOf(A),k.texturePosition.x=j.x,k.texturePosition.y=j.y,k.texturePositionClipSpace.x=j.x/A.canvas.width,k.texturePositionClipSpace.y=j.y/A.canvas.height,k.sizeClipSpace.x/=A.canvas.width,k.sizeClipSpace.y/=A.canvas.height,j.height=Math.max(j.height,k.size.y),j.x+=k.size.x,A.ctx.putImageData(O,k.texturePosition.x-this._workBoundingBox.left,k.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,k.size.x,k.size.y),A.addGlyph(k),A.version++,k}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n=a;n--){for(let r=0;r=0;n--){for(let r=0;r>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t0)return!1;return!0}function ap(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function op(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:Fd,cursorAccent:Fd,selectionForeground:Fd,selectionBackgroundTransparent:Fd,selectionBackgroundOpaque:Fd,selectionInactiveBackgroundTransparent:Fd,selectionInactiveBackgroundOpaque:Fd,overviewRulerBorder:Fd,scrollbarSliderBackground:Fd,scrollbarSliderHoverBackground:Fd,scrollbarSliderActiveBackground:Fd,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function sp(e,t){for(let n=0;n=0){if(sp(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),lp.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=fp){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=fp-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=fp-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},fp)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function mp(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return yd(()=>r?.disconnect())}function hp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var gp=class e extends kf{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Af,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?hp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},_p=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function vp(e,t,n){let r=X(e.createProgram());if(e.attachShader(r,X(yp(e,e.VERTEX_SHADER,t))),e.attachShader(r,X(yp(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function yp(e,t,n){let r=X(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function bp(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=X(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=X(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(yd(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(yd(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(yd(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Tp,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Tp,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Tp,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Tp,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Tp,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Tp,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(tp.maxAtlasPages);for(let e=0;ei.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){if(Q=(n*this._terminal.cols+t)*wp,r===0||r===void 0){e.fill(0,Q,Q+wp-1-Ep);return}this._atlas&&($=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),Dp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&$.offset.x>Dp?(Op=$.offset.x-Dp,e[Q]=-($.offset.x-Op)+this._dimensions.device.char.left,e[Q+1]=-$.offset.y+this._dimensions.device.char.top,e[Q+2]=($.size.x-Op)/this._dimensions.device.canvas.width,e[Q+3]=$.size.y/this._dimensions.device.canvas.height,e[Q+4]=$.texturePage,e[Q+5]=$.texturePositionClipSpace.x+Op/this._atlas.pages[$.texturePage].canvas.width,e[Q+6]=$.texturePositionClipSpace.y,e[Q+7]=$.sizeClipSpace.x-Op/this._atlas.pages[$.texturePage].canvas.width,e[Q+8]=$.sizeClipSpace.y):(e[Q]=-$.offset.x+this._dimensions.device.char.left,e[Q+1]=-$.offset.y+this._dimensions.device.char.top,e[Q+2]=$.size.x/this._dimensions.device.canvas.width,e[Q+3]=$.size.y/this._dimensions.device.canvas.height,e[Q+4]=$.texturePage,e[Q+5]=$.texturePositionClipSpace.x,e[Q+6]=$.texturePositionClipSpace.y,e[Q+7]=$.sizeClipSpace.x,e[Q+8]=$.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Jd(r,c,$.size.x,this._dimensions.device.cell.width)&&(e[Q+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*wp;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function jp(){return new Ap}var Mp=4,Np=1,Pp=2,Fp=3,Ip=2147483648,Lp=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=jp()}resize(e,t){let n=e*t*Mp;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Rp=`#version 300 es -layout (location = 0) in vec2 a_position; -layout (location = 1) in vec2 a_size; -layout (location = 2) in vec4 a_color; -layout (location = 3) in vec2 a_unitquad; - -uniform mat4 u_projection; - -out vec4 v_color; - -void main() { - vec2 zeroToOne = a_position + (a_unitquad * a_size); - gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0); - v_color = a_color; -}`,zp=`#version 300 es -precision lowp float; - -in vec4 v_color; - -out vec4 outColor; - -void main() { - outColor = v_color; -}`,Bp=8,Vp=Bp*Float32Array.BYTES_PER_ELEMENT,Hp=20*Bp,Up=class{constructor(){this.attributes=new Float32Array(Hp),this.count=0}},Wp=0,Gp=0,Kp=0,qp=0,Jp=0,Yp=0,Xp=0,Zp=class extends Sd{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Up,this._verticesCursor=new Up;let i=this._gl;this._program=X(vp(i,Rp,zp)),this._register(yd(()=>i.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(yd(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(yd(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(yd(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Vp,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Vp,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Vp,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,_p),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i>24&255)/255,Jp=(Wp>>16&255)/255,Yp=(Wp>>8&255)/255,Xp=1,this._addRectangle(e.attributes,t,Gp,Kp,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,qp,Jp,Yp,Xp)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},Qp=class extends Sd{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(yd(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=X(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=up(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=lf,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},$p=class extends Qp{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&cp(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t=0;!(im.indexOf(`Chrome`)>=0)&&im.indexOf(`Safari`),im.indexOf(`Electron/`),im.indexOf(`Android`);var om=!1;if(typeof em.matchMedia==`function`){let e=em.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=em.matchMedia(`(display-mode: fullscreen)`);om=e.matches,rm(em,e,({matches:e})=>{om&&t.matches||(om=e)})}function sm(){return om}var cm=`en`,lm=!1,um=!1,dm=!1,fm=cm,pm,mm=globalThis,hm;typeof mm.vscode<`u`&&typeof mm.vscode.process<`u`?hm=mm.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(hm=process);var gm=typeof hm?.versions?.electron==`string`&&hm?.type===`renderer`;if(typeof hm==`object`){hm.platform,hm.platform,lm=hm.platform===`linux`,lm&&hm.env.SNAP&&hm.env.SNAP_REVISION,hm.env.CI||hm.env.BUILD_ARTIFACTSTAGINGDIRECTORY,fm=cm;let e=hm.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,fm=t.resolvedLanguage||cm,t.languagePack?.translationsConfigFile}catch{}um=!0}else typeof navigator==`object`&&!gm?(pm=navigator.userAgent,pm.indexOf(`Windows`),pm.indexOf(`Macintosh`),(pm.indexOf(`Macintosh`)>=0||pm.indexOf(`iPad`)>=0||pm.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,lm=pm.indexOf(`Linux`)>=0,pm?.indexOf(`Mobi`),dm=!0,fm=globalThis._VSCODE_NLS_LANGUAGE||cm,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var _m=um;dm&&typeof mm.importScripts==`function`&&mm.origin;var vm=pm,ym=fm,bm;(e=>{function t(){return ym}e.value=t;function n(){return ym.length===2?ym===`en`:ym.length>=3?ym[0]===`e`&&ym[1]===`n`&&ym[2]===`-`:!1}e.isDefaultVariant=n;function r(){return ym===`en`}e.isDefault=r})(bm||={});var xm=typeof mm.postMessage==`function`&&!mm.importScripts;(()=>{if(xm){let e=[];mm.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),mm.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Sm=!!(vm&&vm.indexOf(`Chrome`)>=0);vm&&vm.indexOf(`Firefox`),!Sm&&vm&&vm.indexOf(`Safari`),vm&&vm.indexOf(`Edg/`),vm&&vm.indexOf(`Android`);var Cm=typeof navigator==`object`?navigator:{};_m||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Cm&&Cm.clipboard&&Cm.clipboard.writeText,_m||Cm&&Cm.clipboard&&Cm.clipboard.readText,_m||sm()||Cm.keyboard,`ontouchstart`in em||Cm.maxTouchPoints,em.PointerEvent&&(`ontouchstart`in em||navigator.maxTouchPoints);var wm=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Tm=new wm,Em=new wm,Dm=new wm;Array(230);var Om;(e=>{function t(e){return Tm.keyCodeToStr(e)}e.toString=t;function n(e){return Tm.strToKeyCode(e)}e.fromString=n;function r(e){return Em.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Dm.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Em.strToKeyCode(e)||Dm.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Tm.keyCodeToStr(e)}e.toElectronAccelerator=o})(Om||={});var km=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Am;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof jm?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Lf.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:km})})(Am||={});var jm=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?km:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Mm;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(Mm||={});var Nm=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Nm.EMPTY=Nm.fromArray([]);function Pm(e){return 55296<=e&&e<=56319}function Fm(e){return 56320<=e&&e<=57343}function Im(e,t){return(e-55296<<10)+(t-56320)+65536}function Lm(e){return Rm(e,0)}function Rm(e,t){switch(typeof e){case`object`:return e===null?zm(349,t):Array.isArray(e)?Hm(e,t):Um(e,t);case`string`:return Vm(e,t);case`boolean`:return Bm(e,t);case`number`:return zm(e,t);case`undefined`:return zm(937,t);default:return zm(617,t)}}function zm(e,t){return(t<<5)-t+e|0}function Bm(e,t){return zm(e?433:863,t)}function Vm(e,t){t=zm(149417,t);for(let n=0,r=e.length;nRm(t,e),t)}function Um(e,t){return t=zm(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Vm(n,t),Rm(e[n],t)),t)}function Wm(e,t,n=32){let r=n-t,i=~((1<>>r)>>>0}function Gm(e,t=0,n=e.byteLength,r=0){for(let i=0;ie.toString(16).padStart(2,`0`)).join(``):Km((e>>>0).toString(16),t/4)}var Jm=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Pm(a))if(o+1>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),qm(this._h0)+qm(this._h1)+qm(this._h2)+qm(this._h3)+qm(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Gm(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Gm(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,Wm(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=Wm(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=Wm(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};Jm._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:Ym,getWindow:Xm,getDocument:Zm,getWindows:Qm,getWindowsCount:$m,getWindowId:eh,getWindowById:th,hasWindow:nh,onDidRegisterWindow:rh,onWillUnregisterWindow:ih,onDidUnregisterWindow:ah}=function(){let e=new Map,t={window:em,disposables:new xd};e.set(em.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Sd.None;let a=new xd,o={window:t,disposables:a.add(new xd)};return e.set(t.vscodeWindowId,o),a.add(yd(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(sh(t,lh.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:em},getDocument(e){return Xm(e).document}}}(),oh=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function sh(e,t,n,r){return new oh(e,t,n,r)}var ch=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};ch.None=new ch(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Lm(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(yd(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var lh={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:am?`webkitAnimationStart`:`animationstart`,ANIMATION_END:am?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:am?`webkitAnimationIteration`:`animationiteration`},uh=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function dh(e,t,n,...r){let i=uh.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function fh(e,t,...n){return dh(`http://www.w3.org/1999/xhtml`,e,t,...n)}fh.SVG=function(e,t,...n){return dh(`http://www.w3.org/2000/svg`,e,t,...n)};var ph=class extends Sd{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new Cd,this._charAtlasDisposable=this._register(new Cd),this._observerDisposable=this._register(new Cd),this._model=new Lp,this._workCell=new gp,this._workCell2=new gp,this._rectangleRenderer=this._register(new Cd),this._glyphRenderer=this._register(new Cd),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new sf(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new $p(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Xd(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(sh(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(sh(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,dp(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=mp(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=mp(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(yd(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),dp(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Zp(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new kp(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=up(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=vd(Lf.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Lf.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new pp(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=hh(e,n.rows-1,0),t=hh(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,ee=S-n.buffer.ydisp,te=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),C=-1,w=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let T=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=S===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v=p[1],d?(l=!0,r=new mh(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*Mp,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),w&&o===S&&(y===te&&(this._model.cursor={x:te,y:ee,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},C=te+r.getWidth()-1),y>=te&&y<=C&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),!(this._model.cells[v]===g&&this._model.cells[v+Np]===this._cellColorResolver.result.bg&&this._model.cells[v+Pp]===this._cellColorResolver.result.fg&&this._model.cells[v+Fp]===this._cellColorResolver.result.ext)&&(T=!0,h.length>1&&(g|=Ip),this._model.cells[v]=g,this._model.cells[v+Np]=this._cellColorResolver.result.bg,this._model.cells[v+Pp]=this._cellColorResolver.result.fg,this._model.cells[v+Fp]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*Mp,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,jd,0,0),this._model.cells[b]=0,this._model.cells[b+Np]=this._cellColorResolver.result.bg,this._model.cells[b+Pp]=this._cellColorResolver.result.fg,this._model.cells[b+Fp]=this._cellColorResolver.result.ext;y--}}T&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},mh=class extends kf{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function hh(e,t,n=0){return Math.max(Math.min(e,t),n)}var gh=`di$target`,_h=`di$dependencies`,vh=new Map;function yh(e){if(vh.has(e))return vh.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);bh(t,e,r)};return t._id=e,vh.set(e,t),t}function bh(e,t,n){t[gh]===t?t[_h].push({id:e,index:n}):(t[_h]=[{id:e,index:n}],t[gh]=t)}yh(`BufferService`),yh(`CoreMouseService`),yh(`CoreService`),yh(`CharsetService`),yh(`InstantiationService`),yh(`LogService`);var xh=yh(`OptionsService`);yh(`OscLinkService`),yh(`UnicodeService`),yh(`DecorationService`);var Sh={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ch=`xterm.js: `,wh=class extends Sd{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Th=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Sh[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new ph(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(Lf.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Lf.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Lf.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Lf.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(yd(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},Dh=class{aliases;usage;matches(e){let t=e.toLowerCase();return t===this.name.toLowerCase()||(this.aliases?.some(e=>t===e.toLowerCase())??!1)}writeLine(e,t,n){n?e.writeln(`${n}${t}\x1b[0m`):e.writeln(t)}writeSuccess(e,t){e.writeln(`\x1b[1;32m✓\x1b[0m ${t}`)}writeError(e,t){e.writeln(`\x1b[1;31m✗ Error:\x1b[0m ${t}`)}writeInfo(e,t){e.writeln(`\x1b[90m${t}\x1b[0m`)}startLoading(e,t){let n=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],r=0,i=!0,a=setInterval(()=>{if(!i){clearInterval(a);return}e.write(`\r\x1b[36m${n[r]}\x1b[0m ${t}`),r=(r+1)%n.length},80);return()=>{i=!1,clearInterval(a),e.write(`\r\x1B[K`)}}},Oh=class extends Dh{name=`help`;description=`Show available commands`;aliases=[`?`,`h`];constructor(e){super(),this.commands=e}execute({term:e,writePrompt:t}){e.writeln(``),e.writeln(`\x1B[1;33mAvailable Commands:\x1B[0m`),e.writeln(``),this.commands.forEach(t=>{let n=t.aliases?.length?` (${t.aliases.join(`, `)})`:``;e.writeln(` \x1b[1;36m${t.name.padEnd(15)}\x1b[0m ${t.description}${n}`)}),e.writeln(``),e.writeln(`\x1B[90mTip: Use Tab for autocomplete, ↑↓ for history, Ctrl+F to search\x1B[0m`),t()}},kh=class extends Dh{name=`clear`;description=`Clear terminal screen`;aliases=[`cls`];execute({term:e,writePrompt:t}){e.clear(),t()}},Ah=class extends Dh{name=`status`;description=`Show repeater status`;aliases=[`st`];async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching status...`);try{let t=await f.get(`/stats`);n();let r=t.success&&t.data?t.data:t;if(r&&typeof r==`object`){this.writeSuccess(e,`Repeater Status:`),e.writeln(``);for(let[t,n]of Object.entries(r))e.writeln(` \x1b[36m${t.padEnd(20)}\x1b[0m ${n}`)}else this.writeError(e,`No status data available`)}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch status`)}t()}},jh=class extends Dh{name=`uptime`;description=`Show system uptime`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching uptime...`);try{let t=await f.get(`/stats`);n();let r=(t.data||t).uptime_seconds||0,i=this.formatUptime(r);this.writeSuccess(e,i)}catch(t){n(),this.writeError(e,`Failed to get uptime: ${t}`)}t()}formatUptime(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}},Mh=class extends Dh{name=`packets`;description=`Show packet statistics`;isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching packet stats...`);try{let t=await f.get(`/stats`);n();let r=t.data||t;this.writeLine(e,``),this.isMobile()?(this.writeLine(e,` \x1B[1;36mPacket Statistics\x1B[0m`),this.writeLine(e,` \x1B[90mRX:\x1B[0m `+(r.rx_count||0)),this.writeLine(e,` \x1B[90mTX:\x1B[0m `+(r.tx_count||0)),this.writeLine(e,` \x1B[90mForward:\x1B[0m `+(r.forwarded_count||0)),this.writeLine(e,` \x1B[90mDropped:\x1B[0m `+(r.dropped_count||0))):(this.writeLine(e,` \x1B[36m┌──────────┬──────────┐\x1B[0m`),this.writeLine(e,` \x1B[36m│\x1B[0m \x1B[1mMetric\x1B[0m \x1B[36m│\x1B[0m \x1B[1mCount\x1B[0m \x1B[36m│\x1B[0m`),this.writeLine(e,` \x1B[36m├──────────┼──────────┤\x1B[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m RX \x1b[36m│\x1b[0m ${String(r.rx_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m TX \x1b[36m│\x1b[0m ${String(r.tx_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m Forward \x1b[36m│\x1b[0m ${String(r.forwarded_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m Dropped \x1b[36m│\x1b[0m ${String(r.dropped_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1B[36m└──────────┴──────────┘\x1B[0m`)),this.writeLine(e,``)}catch(t){n(),this.writeError(e,`Failed to get packet stats: ${t}`)}t()}},Nh=class extends Dh{name=`board`;description=`Show board information`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching board info...`);try{let t=await f.get(`/stats`);n();let r=(t.data||t).board_info||`pyMC_Repeater (Linux/RPi)`;this.writeSuccess(e,r)}catch{n(),this.writeSuccess(e,`pyMC_Repeater (Linux/RPi)`)}t()}},Ph=class extends Dh{name=`advert`;description=`Send neighbor advert immediately`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Sending advert...`);try{let t=await f.post(`/send_advert`,{},{timeout:1e4});n(),t.success?this.writeSuccess(e,t.data||`Advert sent successfully`):this.writeError(e,t.error||`Failed to send advert`)}catch(t){n(),this.writeError(e,`Failed to send advert: ${t}`)}t()}},Fh=class extends Dh{name=`get`;description=`Get configuration values (name, freq, tx, mode, duty, etc.)`;matches(e){let t=e.toLowerCase();return t===`get`||t.startsWith(`get `)}async execute({term:e,args:t,writePrompt:n}){let r=t[0]?.toLowerCase();if(!r){this.writeError(e,`Usage: get `),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeLine(e,``),this.writeLine(e,` \x1B[36mname\x1B[0m Node name`),this.writeLine(e,` \x1B[36mrole\x1B[0m Node role`),this.writeLine(e,` \x1B[36mlat\x1B[0m Latitude`),this.writeLine(e,` \x1B[36mlon\x1B[0m Longitude`),this.writeLine(e,` \x1B[36mfreq\x1B[0m Frequency (MHz)`),this.writeLine(e,` \x1B[36mtx\x1B[0m TX power (dBm)`),this.writeLine(e,` \x1B[36mbw\x1B[0m Bandwidth (kHz)`),this.writeLine(e,` \x1B[36msf\x1B[0m Spreading factor`),this.writeLine(e,` \x1B[36mcr\x1B[0m Coding rate`),this.writeLine(e,` \x1B[36mradio\x1B[0m All radio settings`),this.writeLine(e,` \x1B[36mtxdelay\x1B[0m TX delay factor`),this.writeLine(e,` \x1B[36mdirect.txdelay\x1B[0m Direct TX delay`),this.writeLine(e,` \x1B[36mrxdelay\x1B[0m RX delay base`),this.writeLine(e,` \x1B[36maf\x1B[0m Airtime factor`),this.writeLine(e,` \x1B[36mmode\x1B[0m Repeater mode`),this.writeLine(e,` \x1B[36mrepeat\x1B[0m Repeat on/off`),this.writeLine(e,` \x1B[36mflood.max\x1B[0m Max flood hops`),this.writeLine(e,` \x1B[36madvert.interval\x1B[0m Advert interval`),this.writeLine(e,` \x1B[36mduty\x1B[0m Duty cycle enabled`),this.writeLine(e,` \x1B[36mduty.max\x1B[0m Max airtime %`),this.writeLine(e,` \x1B[36mpublic.key\x1B[0m Public key`),this.writeLine(e,``),n();return}let i=this.startLoading(e,`Fetching configuration...`);try{let t=await f.get(`/stats`);i();let a=t.data||t,o=a.config||{},s=o.radio||{},c=o.repeater||{},l=o.delays||{},u=o.duty_cycle||{},d=``;switch(r){case`name`:d=o.node_name||`Unknown`;break;case`role`:d=`repeater`;break;case`lat`:d=c.latitude==null?`not set`:String(c.latitude);break;case`lon`:d=c.longitude==null?`not set`:String(c.longitude);break;case`freq`:d=s.frequency?`${(s.frequency/1e6).toFixed(3)} MHz`:`?`;break;case`tx`:d=s.tx_power==null?`?`:`${s.tx_power}dBm`;break;case`bw`:d=s.bandwidth?`${s.bandwidth/1e3} kHz`:`?`;break;case`sf`:d=s.spreading_factor==null?`?`:String(s.spreading_factor);break;case`cr`:d=s.coding_rate==null?`?`:`4/${s.coding_rate}`;break;case`radio`:if(s.frequency){this.writeSuccess(e,`Radio Configuration:`),this.writeLine(e,``),this.writeLine(e,` \x1b[36mFrequency:\x1b[0m ${(s.frequency/1e6).toFixed(3)} MHz`),this.writeLine(e,` \x1b[36mBandwidth:\x1b[0m ${s.bandwidth/1e3} kHz`),this.writeLine(e,` \x1b[36mSpreading Factor:\x1b[0m ${s.spreading_factor}`),this.writeLine(e,` \x1b[36mCoding Rate:\x1b[0m 4/${s.coding_rate}`),this.writeLine(e,` \x1b[36mTX Power:\x1b[0m ${s.tx_power}dBm`),this.writeLine(e,``),n();return}else d=`Radio configuration not available`;break;case`af`:case`txdelay`:d=l.tx_delay_factor==null?`\x1B[90mnot set (default: 1.0)\x1B[0m`:String(l.tx_delay_factor);break;case`direct.txdelay`:d=l.direct_tx_delay_factor==null?`\x1B[90mnot set (default: 0.5)\x1B[0m`:String(l.direct_tx_delay_factor);break;case`rxdelay`:d=l.rx_delay_base==null?`\x1B[90mnot set (default: 0.0s)\x1B[0m`:`${l.rx_delay_base}s`;break;case`mode`:d=c.mode==null?`\x1B[90mnot set (default: forward)\x1B[0m`:c.mode;break;case`repeat`:d=c.mode==null?`\x1B[90mnot set (default: on)\x1B[0m`:c.mode===`forward`?`on`:`off`;break;case`flood.max`:d=c.max_flood_hops==null?`\x1B[90mnot set (default: 3)\x1B[0m`:String(c.max_flood_hops);break;case`flood.advert.interval`:d=c.send_advert_interval_hours==null?`\x1B[90mnot set\x1B[0m`:`${c.send_advert_interval_hours}h`;break;case`advert.interval`:d=c.advert_interval_minutes==null?`\x1B[90mnot set (default: 120m)\x1B[0m`:`${c.advert_interval_minutes}m`;break;case`duty`:case`duty.enabled`:d=u.enforcement_enabled==null?`\x1B[90mnot set (default: off)\x1B[0m`:u.enforcement_enabled?`on`:`off`;break;case`duty.max`:d=u.max_airtime_percent==null?`\x1B[90mnot set\x1B[0m`:`${u.max_airtime_percent}%`;break;case`public.key`:d=a.public_key||`\x1B[90mnot available\x1B[0m`;break;case`prv.key`:this.writeWarning(e,`Private key not exposed via API for security`),this.writeInfo(e,`Check /etc/pymc_repeater/config.yaml`),n();return;case`guest.password`:case`allow.read.only`:this.writeWarning(e,`Security settings not exposed via API`),this.writeInfo(e,`Check /etc/pymc_repeater/config.yaml`),n();return;default:this.writeError(e,`Unknown parameter: ${r}`),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeInfo(e,` Identity: name, role, lat, lon`),this.writeInfo(e,` Radio: freq, tx, bw, sf, cr, radio`),this.writeInfo(e,` Timing: txdelay, direct.txdelay, rxdelay, af`),this.writeInfo(e,` Repeater: mode, repeat, flood.max, advert.interval`),this.writeInfo(e,` Duty: duty, duty.max`),this.writeInfo(e,` Security: public.key`),n();return}this.writeSuccess(e,d)}catch(t){i(),this.writeError(e,`Failed to get ${r}: ${t}`)}n()}writeWarning(e,t){e.writeln(`\x1b[1;33m⚠ Warning:\x1b[0m ${t}`)}},Ih=class extends Dh{name=`set`;description=`Set configuration values (tx, txdelay, mode, duty, etc.)`;matches(e){let t=e.toLowerCase();return t===`set`||t.startsWith(`set `)}async execute({term:e,args:t,writePrompt:n}){let r=t[0]?.toLowerCase(),i=t.slice(1).join(` `).trim();if(!r){this.writeError(e,`Usage: set `),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mRadio:\x1B[0m`),this.writeLine(e,` \x1B[36mtx <2-30>\x1B[0m TX power in dBm`),this.writeLine(e,` \x1B[36mfreq \x1B[0m Frequency (100-1000 MHz) *restart required*`),this.writeLine(e,` \x1B[36mbw \x1B[0m Bandwidth (7.8-500 kHz) *restart required*`),this.writeLine(e,` \x1B[36msf <5-12>\x1B[0m Spreading factor *restart required*`),this.writeLine(e,` \x1B[36mcr <5-8>\x1B[0m Coding rate (for 4/5 to 4/8) *restart required*`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mTiming:\x1B[0m`),this.writeLine(e,` \x1B[36mtxdelay <0.0-5.0>\x1B[0m TX delay factor`),this.writeLine(e,` \x1B[36mdirect.txdelay <0.0-5.0>\x1B[0m Direct TX delay factor`),this.writeLine(e,` \x1B[36mrxdelay \x1B[0m RX delay base (>= 0)`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mIdentity:\x1B[0m`),this.writeLine(e,` \x1B[36mname \x1B[0m Node name`),this.writeLine(e,` \x1B[36mlat <-90 to 90>\x1B[0m Latitude`),this.writeLine(e,` \x1B[36mlon <-180 to 180>\x1B[0m Longitude`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mRepeater:\x1B[0m`),this.writeLine(e,` \x1B[36mmode \x1B[0m Repeater mode`),this.writeLine(e,` \x1B[36mduty \x1B[0m Duty cycle enforcement`),this.writeLine(e,` \x1B[36mflood.max <0-64>\x1B[0m Max flood hops`),this.writeLine(e,` \x1B[36madvert.interval \x1B[0m Local advert interval`),this.writeLine(e,``),n();return}let a=this.startLoading(e,`Updating configuration...`);try{let t;switch(r){case`tx`:{let r=parseInt(i);if(isNaN(r)||r<2||r>30){a(),this.writeError(e,`TX power must be 2-30 dBm`),n();return}t=await f.post(`/update_radio_config`,{tx_power:r},{timeout:3e4});break}case`freq`:{let r=parseFloat(i);if(isNaN(r)||r<100||r>1e3){a(),this.writeError(e,`Frequency must be 100-1000 MHz`),n();return}t=await f.post(`/update_radio_config`,{frequency:r*1e6},{timeout:3e4});break}case`bw`:{let r=parseFloat(i),o=[7.8,10.4,15.6,20.8,31.25,41.7,62.5,125,250,500];if(isNaN(r)||!o.includes(r)){a(),this.writeError(e,`Bandwidth must be one of: ${o.join(`, `)} kHz`),n();return}t=await f.post(`/update_radio_config`,{bandwidth:r*1e3},{timeout:3e4});break}case`sf`:{let r=parseInt(i);if(isNaN(r)||r<5||r>12){a(),this.writeError(e,`Spreading factor must be 5-12`),n();return}t=await f.post(`/update_radio_config`,{spreading_factor:r},{timeout:3e4});break}case`cr`:{let r=parseInt(i);if(isNaN(r)||r<5||r>8){a(),this.writeError(e,`Coding rate must be 5-8 (for 4/5 to 4/8)`),n();return}t=await f.post(`/update_radio_config`,{coding_rate:r},{timeout:3e4});break}case`af`:case`txdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0||r>5){a(),this.writeError(e,`TX delay factor must be 0.0-5.0`),n();return}t=await f.post(`/update_radio_config`,{tx_delay_factor:r},{timeout:3e4});break}case`direct.txdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0||r>5){a(),this.writeError(e,`Direct TX delay factor must be 0.0-5.0`),n();return}t=await f.post(`/update_radio_config`,{direct_tx_delay_factor:r},{timeout:3e4});break}case`rxdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0){a(),this.writeError(e,`RX delay must be >= 0`),n();return}t=await f.post(`/update_radio_config`,{rx_delay_base:r},{timeout:3e4});break}case`name`:if(!i.trim()){a(),this.writeError(e,`Node name cannot be empty`),n();return}t=await f.post(`/update_radio_config`,{node_name:i.trim()},{timeout:3e4});break;case`lat`:{let r=parseFloat(i);if(isNaN(r)||r<-90||r>90){a(),this.writeError(e,`Latitude must be -90 to 90`),n();return}t=await f.post(`/update_radio_config`,{latitude:r},{timeout:3e4});break}case`lon`:{let r=parseFloat(i);if(isNaN(r)||r<-180||r>180){a(),this.writeError(e,`Longitude must be -180 to 180`),n();return}t=await f.post(`/update_radio_config`,{longitude:r},{timeout:3e4});break}case`mode`:{let r=i.toLowerCase();if(r!==`forward`&&r!==`monitor`&&r!==`no_tx`){a(),this.writeError(e,`Mode must be "forward", "monitor", or "no_tx"`),this.writeLine(e,``),this.writeInfo(e,`Valid values:`),this.writeLine(e,` \x1B[36mforward\x1B[0m - Forward packets`),this.writeLine(e,` \x1B[36mmonitor\x1B[0m - Monitor only (no forwarding)`),this.writeLine(e,` \x1B[36mno_tx\x1B[0m - No repeat, no local TX; adverts skipped`),n();return}t=await f.post(`/set_mode`,{mode:r},{timeout:3e4}),t.data&&(t.data.applied=[`mode=${r}`],t.data.persisted=!0,t.data.live_update=!0);break}case`duty`:{let r=i.toLowerCase();if(r!==`on`&&r!==`off`){a(),this.writeError(e,`Duty cycle must be "on" or "off"`),this.writeLine(e,``),this.writeInfo(e,`Valid values:`),this.writeLine(e,` \x1B[36mon\x1B[0m - Enable duty cycle enforcement`),this.writeLine(e,` \x1B[36moff\x1B[0m - Disable duty cycle enforcement`),n();return}let o=r===`on`;t=await f.post(`/set_duty_cycle`,{enabled:o},{timeout:3e4}),t.data&&(t.data.applied=[`duty=${r}`],t.data.persisted=!0,t.data.live_update=!0);break}case`flood.max`:{let r=parseInt(i);if(isNaN(r)||r<0||r>64){a(),this.writeError(e,`Max flood hops must be 0-64`),n();return}t=await f.post(`/update_radio_config`,{max_flood_hops:r},{timeout:3e4});break}case`flood.advert.interval`:{let r=parseInt(i);if(isNaN(r)||r!==0&&(r<3||r>48)){a(),this.writeError(e,`Flood advert interval must be 0 (off) or 3-48 hours`),n();return}t=await f.post(`/update_radio_config`,{flood_advert_interval_hours:r},{timeout:3e4});break}case`advert.interval`:{let r=parseInt(i);if(isNaN(r)||r!==0&&(r<1||r>10080)){a(),this.writeError(e,`Advert interval must be 0 (off) or 1-10080 minutes`),n();return}t=await f.post(`/update_radio_config`,{advert_interval_minutes:r},{timeout:3e4});break}case`log`:a(),this.writeWarning(e,`Log level configuration not yet implemented`),this.writeInfo(e,`Backend endpoint /set_log_level does not exist`),n();return;default:a(),this.writeError(e,`Unknown parameter: ${r}`),this.writeLine(e,``),this.writeInfo(e,`Type "set" without arguments to see available parameters`),n();return}a();let o=t.data||t;t.success?(o.applied&&o.applied.length>0?this.writeSuccess(e,`Configuration updated: ${o.applied.join(`, `)}`):this.writeSuccess(e,`Configuration updated`),o.restart_required?(this.writeLine(e,``),this.writeWarning(e,`⚠ Service restart required for changes to take effect`),this.writeInfo(e,`Run: sudo systemctl restart pymc_repeater`)):o.message&&!o.live_update&&(this.writeLine(e,``),this.writeInfo(e,o.message))):this.writeError(e,t.error||`Failed to update configuration`)}catch(t){a(),this.writeError(e,`Failed to update ${r}: ${t}`)}this.writeLine(e,``),n()}writeWarning(e,t){e.writeln(`\x1b[1;33m⚠ Warning:\x1b[0m ${t}`)}},Lh=class extends Dh{name=`identities`;description=`List all identities`;aliases=[`id`,`ids`];isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching identities...`);try{let t=await f.getIdentities();n();let r=[];if(t.success&&t.data){let e=t.data,n=e.registered||[],i=e.configured||[];r=i.length>0?i:n}else Array.isArray(t)&&(r=t);r.length===0?this.writeInfo(e,`No identities found`):(this.writeSuccess(e,`Found \x1b[1m${r.length}\x1b[0m identit${r.length===1?`y`:`ies`}`),e.writeln(``),this.isMobile()?r.forEach((t,n)=>{e.writeln(`\x1b[1;36m[${n+1}] ${t.name||`Unnamed`}\x1b[0m`),e.writeln(` \x1b[90mType:\x1b[0m ${t.type||`-`}`),e.writeln(` \x1b[90mHash:\x1b[0m ${t.hash||`-`}`),e.writeln(` \x1b[90mAddress:\x1b[0m ${t.address||`-`}`),e.writeln(` \x1b[90mRegistered:\x1b[0m ${t.registered?`\x1B[32myes\x1B[0m`:`\x1B[31mno\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.name||`Unnamed`).padEnd(27),a=(t.type||`-`).padEnd(13),o=(t.hash||`-`).padEnd(4),s=(t.address||`-`).padEnd(7),c=(t.registered?`yes`:`no`).padEnd(10);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴─────────────────────────────┴───────────────┴──────┴─────────┴────────────┘\x1B[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch identities`)}t()}},Rh=class extends Dh{name=`keys`;description=`List transport keys`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching transport keys...`);try{let t=await f.getTransportKeys();n();let r=t.success&&t.data?t.data:t,i=Array.isArray(r)?r:[];i.length===0?this.writeInfo(e,`No transport keys found`):(this.writeSuccess(e,`Found \x1b[1m${i.length}\x1b[0m transport key${i.length===1?``:`s`}`),e.writeln(``),i.forEach((t,n)=>{e.writeln(`\x1b[36m${(n+1).toString().padStart(2)}.\x1b[0m \x1b[1m${t.name||`Unnamed`}\x1b[0m`),t.flood_policy&&e.writeln(` Policy: \x1b[90m${t.flood_policy}\x1b[0m`),t.parent_id&&e.writeln(` Parent: \x1b[90m${t.parent_id}\x1b[0m`),n{if(e.writeln(`\x1b[1;36m[${n+1}] ${t.node_name||`Unknown`}\x1b[0m`),e.writeln(` \x1b[90mPubKey:\x1b[0m ${t.pubkey?.substring(0,8)||`----`}`),e.writeln(` \x1b[90mType:\x1b[0m ${t.contact_type||`-`}`),t.last_seen){let n=new Date(t.last_seen*1e3).toLocaleString(`en-US`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1});e.writeln(` \x1b[90mLast Seen:\x1b[0m ${n}`)}t.rssi&&e.writeln(` \x1b[90mRSSI:\x1b[0m ${t.rssi}`),t.snr&&e.writeln(` \x1b[90mSNR:\x1b[0m ${t.snr}`),e.writeln(` \x1b[90mAdverts:\x1b[0m ${t.advert_count||0}`),e.writeln(` \x1b[90mDirect:\x1b[0m ${t.zero_hop?`\x1B[32myes\x1B[0m`:`\x1B[31mno\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.node_name||`Unknown`).padEnd(20),a=(t.pubkey?.substring(0,4)||`----`).padEnd(6),o=(t.contact_type||`-`).padEnd(12),s=t.last_seen?new Date(t.last_seen*1e3).toLocaleString(`en-US`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).padEnd(20):`-`.padEnd(20),c=(t.rssi?`${t.rssi}`:`-`).padEnd(8),l=(t.snr?`${t.snr}`:`-`).padEnd(4),u=(t.advert_count?.toString()||`0`).padEnd(6),d=(t.zero_hop?`yes`:`no`).padEnd(6);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m ${l} \x1b[36m│\x1b[0m ${u} \x1b[36m│\x1b[0m ${d} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴──────────────────────┴────────┴──────────────┴──────────────────────┴──────────┴──────┴────────┴────────┘\x1B[0m`)),r.length>10&&(e.writeln(``),e.writeln(`\x1b[90m... and ${r.length-10} more neighbors\x1b[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch neighbors`)}t()}},Bh=class extends Dh{name=`acl`;description=`Show ACL statistics`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching ACL stats...`);try{let t=await f.getACLStats();n();let r=t.success&&t.data?t.data:t;if(r&&typeof r==`object`){this.writeSuccess(e,`ACL Statistics:`),e.writeln(``);let t=(n,r=` `)=>{if(typeof n==`object`&&n&&!Array.isArray(n))for(let[i,a]of Object.entries(n))typeof a==`object`&&a?(e.writeln(`${r}\x1b[90m${i}:\x1b[0m`),t(a,r+` `)):e.writeln(`${r}\x1b[90m${i.padEnd(18)}\x1b[0m ${a}`);else e.writeln(`${r}${n}`)};for(let[n,i]of Object.entries(r))typeof i==`object`&&i?(e.writeln(` \x1b[36m${n}\x1b[0m`),t(i,` `)):e.writeln(` \x1b[36m${n.padEnd(20)}\x1b[0m ${i}`)}else this.writeError(e,`No ACL data available`)}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch ACL stats`)}t()}},Vh=class extends Dh{name=`rooms`;description=`List room servers`;isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching room stats...`);try{let t=await f.getRoomStats();n();let r=[];t.success&&t.data?r=t.data.rooms||(Array.isArray(t.data)?t.data:[]):Array.isArray(t)&&(r=t),r.length===0?this.writeInfo(e,`No room servers found`):(this.writeSuccess(e,`Found \x1b[1m${r.length}\x1b[0m room server${r.length===1?``:`s`}`),e.writeln(``),this.isMobile()?r.forEach((t,n)=>{e.writeln(`\x1b[1;36m[${n+1}] ${t.room_name||`Unnamed`}\x1b[0m`),e.writeln(` \x1b[90mMessages:\x1b[0m ${t.total_messages||0}`),e.writeln(` \x1b[90mTotal Clients:\x1b[0m ${t.total_clients||0}`),e.writeln(` \x1b[90mActive Clients:\x1b[0m ${t.active_clients||0}`),e.writeln(` \x1b[90mSync:\x1b[0m ${t.sync_running?`\x1B[32mrunning\x1B[0m`:`\x1B[31mstopped\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.room_name||`Unnamed`).padEnd(27),a=(t.total_messages?.toString()||`0`).padEnd(8),o=(t.total_clients?.toString()||`0`).padEnd(12),s=(t.active_clients?.toString()||`0`).padEnd(14),c=(t.sync_running?`running`:`stopped`).padEnd(8);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴─────────────────────────────┴──────────┴──────────────┴────────────────┴──────────┘\x1B[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch room stats`)}t()}},Hh=class extends Dh{name=`restart`;description=`Restart the pymc-repeater service`;aliases=[`reboot`];matches(e){let t=e.toLowerCase();return t===`restart`||t===`reboot`}async execute({term:e,writePrompt:t}){this.writeLine(e,``),this.writeLine(e,`\x1B[33m⚠️ This will restart the repeater service!\x1B[0m`),this.writeLine(e,``),this.writeInfo(e,`Attempting to restart service...`);let n=this.startLoading(e,`Restarting...`);try{let t=await f.post(`/restart_service`,{},{timeout:1e4});n(),t.success?(this.writeLine(e,``),this.writeSuccess(e,t.message||`Service restart initiated`),this.writeLine(e,``),this.writeInfo(e,`The service will restart momentarily. You may need to refresh this page.`)):(this.writeLine(e,``),this.writeError(e,`Restart failed: `+(t.error||t.message||`Unknown error`)),this.writeLine(e,``),this.writeInfo(e,`You may need to manually restart: sudo systemctl restart pymc-repeater`))}catch(r){n(),this.writeLine(e,``);let i=r;if(i.code===`ERR_NETWORK`||i.message?.includes(`Network error`)||i.message?.includes(`ECONNRESET`)||i.code===`ECONNRESET`){this.writeSuccess(e,`Service restart initiated successfully`),this.writeLine(e,``),await this.waitForServiceRestart(e,t);return}else i.code===`ECONNABORTED`||i.message?.includes(`timeout`)?(this.writeLine(e,`\x1B[33m⚠️ Request timed out - service may be restarting\x1B[0m`),this.writeLine(e,``),this.writeInfo(e,`Refresh the page in a few seconds to reconnect.`)):i.response?.status===403||i.response?.status===401?(this.writeError(e,`Permission denied. Polkit rules may need configuration.`),this.writeLine(e,``),this.writeInfo(e,`Run: sudo bash -c 'mkdir -p /etc/polkit-1/rules.d && cat > /etc/polkit-1/rules.d/10-pymc-repeater.rules <0;t--)e.write(`\r\x1b[36m⏳\x1b[0m Restarting service... ${t}s`),await new Promise(e=>setTimeout(e,1e3));e.write(`\r\x1B[K`);let n=4,r=0;for(;n<20;){r++,e.write(` ⏳ Verifying restart (attempt ${r})... `);try{if((await fetch(`${window.location.protocol}//${window.location.host}/api/stats`,{signal:AbortSignal.timeout(3e3)})).ok){e.write(`\r\x1B[K`),this.writeLine(e,``),this.writeSuccess(e,`Service is back online! (took ~${n}s)`),this.writeLine(e,``),t();return}}catch(t){let n=t;n.code&&![`ERR_NETWORK`,`ECONNREFUSED`,`ECONNRESET`].includes(n.code)&&e.write(`[${n.code}] `)}await new Promise(e=>setTimeout(e,1*1e3)),n+=1}e.write(`\r\x1B[K`),this.writeLine(e,``),this.writeLine(e,`\x1B[33m⚠️ Service did not respond within 20 seconds\x1B[0m`),this.writeLine(e,``),this.writeInfo(e,`The service may still be starting. Try: status`),this.writeLine(e,``),t()}},Uh=class extends Dh{name=`ping`;description=`Ping a neighbor node to measure latency and signal quality`;usage=`ping [timeout_seconds]`;async execute({term:e,args:t,writePrompt:n}){if(t.length===0){this.writeError(e,`Missing target node`),e.writeln(``),this.writeInfo(e,`Usage: ${this.usage}`),e.writeln(``),this.writeInfo(e,`Examples:`),this.writeInfo(e,` ping MyNeighbor - Ping node by name`),this.writeInfo(e,` ping 0xb5 - Ping node by pubkey hash`),this.writeInfo(e,` ping MyNeighbor 20 - Ping with 20s timeout`),n();return}let r=t[0],i=t.length>1?parseInt(t[1]):10;if(isNaN(i)||i<1||i>60){this.writeError(e,`Invalid timeout. Must be between 1-60 seconds`),n();return}let a=null,o=r.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(o)a=`0x${o[2].padStart(2,`0`)}`;else{let t=this.startLoading(e,`Resolving target...`);try{let i=[`Chat Node`,`Repeater`,`Room Server`,`Hybrid Node`,`Unknown`],o=!1;for(let e of i)try{let t=await f.get(`/adverts_by_contact_type`,{contact_type:e,hours:168}),n=t.success&&t.data?t.data:t,i=(Array.isArray(n)?n:[]).find(e=>e.node_name&&e.node_name.toLowerCase()===r.toLowerCase());if(i&&i.pubkey){a=`0x${i.pubkey.substring(0,2)}`,o=!0;break}}catch{continue}if(t(),!o){this.writeError(e,`Node '${r}' not found in neighbors`),e.writeln(``),this.writeInfo(e,`Try: neighbors - to list available nodes`),n();return}}catch(r){t(),this.writeError(e,`Failed to resolve target: ${r}`),n();return}}this.writeLine(e,`\x1b[36mPinging ${r} (${a}) with ${i}s timeout...\x1b[0m`),e.writeln(``);let s=this.startLoading(e,`Waiting for response...`);try{let t=await f.pingNeighbor(a,i);if(s(),t.success&&t.data){let n=t.data;this.writeSuccess(e,`Reply from ${r} (${n.target_id})`),e.writeln(``);let i=`\x1B[32m`;if(n.rtt_ms>500?i=`\x1B[31m`:n.rtt_ms>250&&(i=`\x1B[33m`),e.writeln(` \x1b[1mRound-Trip Time:\x1b[0m ${i}${n.rtt_ms.toFixed(2)} ms\x1b[0m`),e.writeln(` \x1b[1mRSSI:\x1b[0m ${n.rssi} dBm`),e.writeln(` \x1b[1mSNR:\x1b[0m ${n.snr_db} dB`),n.path&&n.path.length>0){let t=n.path.join(` → `),r=n.path.length;e.writeln(` \x1b[1mPath:\x1b[0m ${t}`),e.writeln(` \x1b[1mHops:\x1b[0m ${r}`)}e.writeln(``);let a=`Excellent`,o=`\x1B[32m`;n.rtt_ms>500||n.rssi<-120?(a=`Poor`,o=`\x1B[31m`):n.rtt_ms>250||n.rssi<-100?(a=`Fair`,o=`\x1B[33m`):(n.rtt_ms>100||n.rssi<-80)&&(a=`Good`,o=`\x1B[36m`),e.writeln(` \x1b[1mLink Quality:\x1b[0m ${o}${a}\x1b[0m`)}else this.writeError(e,t.error||`Ping failed`)}catch(t){s(),this.writeError(e,`Ping failed: ${t.message||t}`)}e.writeln(``),n()}};async function Wh(){try{let e=[`Chat Node`,`Repeater`,`Room Server`,`Hybrid Node`,`Unknown`],t=[];for(let n of e)try{let e=await f.get(`/adverts_by_contact_type`,{contact_type:n,hours:168}),r=e.success&&e.data?e.data:e;(Array.isArray(r)?r:[]).forEach(e=>{e.node_name&&!t.includes(e.node_name)&&t.push(e.node_name)})}catch{continue}return t.sort()}catch{return[]}}var Gh=class{commands=[];constructor(){let e=new kh,t=new Ah,n=new jh,r=new Mh,i=new Nh,a=new Ph,o=new Fh,s=new Ih,c=new Lh,l=new Rh,u=new zh,d=new Bh,f=new Vh,p=new Hh,m=new Uh;this.commands=[new Oh([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m]),e,t,n,r,i,a,o,s,c,l,u,d,f,p,m]}findCommand(e){return this.commands.find(t=>t.matches(e))}getAllCommands(){return this.commands}getCommandNames(){return this.commands.map(e=>e.name)}},Kh={class:`space-y-4 md:space-y-6`},qh={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-3 md:p-4`},Jh={class:`flex items-center justify-between`},Yh={class:`flex items-center gap-2 md:gap-3`},Xh=[`title`],Zh={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},Qh={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},$h={class:`hidden sm:inline`},eg=[`title`],tg={class:`hidden sm:inline`},ng=[`title`],rg={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ig={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ag={class:`hidden sm:inline`},og={key:0,class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-4`},sg={class:`flex items-center gap-3`},cg=[`onKeydown`],lg={key:1,class:`absolute top-4 right-4 bg-black/80 backdrop-blur-sm px-3 py-2 rounded-lg border border-primary/30 flex items-center gap-2`},ug=p(r({name:`TerminalView`,__name:`Terminal`,setup(r){let{theme:f}=m(),p={background:`#1A1E1F`,foreground:`#e0e0e0`,cursor:`#00d9ff`,cursorAccent:`#000000`,selectionBackground:`#00d9ff40`,selectionForeground:`#ffffff`,black:`#000000`,red:`#ff6b6b`,green:`#51cf66`,yellow:`#ffd93d`,blue:`#00d9ff`,magenta:`#e599f7`,cyan:`#00d9ff`,white:`#e0e0e0`,brightBlack:`#6c757d`,brightRed:`#ff8787`,brightGreen:`#69db7c`,brightYellow:`#ffe066`,brightBlue:`#74c0fc`,brightMagenta:`#f3a6ff`,brightCyan:`#3bc9db`,brightWhite:`#ffffff`},v={background:`#F3F4F6`,foreground:`#1f2937`,cursor:`#0D7377`,cursorAccent:`#ffffff`,selectionBackground:`#0D737740`,selectionForeground:`#000000`,black:`#1f2937`,red:`#dc2626`,green:`#15803d`,yellow:`#a16207`,blue:`#0D7377`,magenta:`#7c3aed`,cyan:`#0e7490`,white:`#f3f4f6`,brightBlack:`#6b7280`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#0891b2`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`},y=d(null),b=d(null),x=d(null),S=d(``),ee=d(!1),te=d(!1),C=d(!1),w=d(!1),T=d(!1);d(0);let E=null,D=null,ne=null,O=``,re=[],k=-1,A=``,j=new Gh,ie=j.getCommandNames(),ae=[],oe=0,se={get:[`name`,`role`,`lat`,`lon`,`freq`,`tx`,`bw`,`sf`,`cr`,`radio`,`txdelay`,`direct.txdelay`,`rxdelay`,`af`,`mode`,`repeat`,`flood.max`,`advert.interval`,`duty`,`duty.max`,`public.key`],set:[`tx`,`freq`,`bw`,`sf`,`cr`,`txdelay`,`direct.txdelay`,`rxdelay`,`name`,`lat`,`lon`,`mode`,`duty`,`flood.max`,`advert.interval`,`flood.advert.interval`],ping:[]},ce={set:{mode:[`forward`,`monitor`],duty:[`on`,`off`]}},le={get:{name:`Node name`,role:`Node role`,lat:`Latitude`,lon:`Longitude`,freq:`Frequency (MHz)`,tx:`TX power (dBm)`,bw:`Bandwidth (kHz)`,sf:`Spreading factor`,cr:`Coding rate`,radio:`All radio settings`,txdelay:`TX delay factor`,"direct.txdelay":`Direct TX delay`,rxdelay:`RX delay base`,af:`Airtime factor`,mode:`Repeater mode`,repeat:`Repeat on/off`,"flood.max":`Max flood hops`,"advert.interval":`Advert interval`,duty:`Duty cycle enabled`,"duty.max":`Max airtime %`,"public.key":`Public key`},set:{tx:`TX power (2-30 dBm)`,freq:`Frequency (100-1000 MHz) *restart required*`,bw:`Bandwidth (7.8-500 kHz) *restart required*`,sf:`Spreading factor (5-12) *restart required*`,cr:`Coding rate (5-8) *restart required*`,txdelay:`TX delay factor (0.0-5.0)`,"direct.txdelay":`Direct TX delay (0.0-5.0)`,rxdelay:`RX delay base (>= 0)`,name:`Node name`,lat:`Latitude (-90 to 90)`,lon:`Longitude (-180 to 180)`,mode:`Repeater mode (forward/monitor/no_tx)`,duty:`Duty cycle (on/off)`,"flood.max":`Max flood hops (0-64)`,"advert.interval":`Advert interval (0 or 1-10080 mins)`,"flood.advert.interval":`Flood advert (0 or 3-48 hrs)`},ping:{}};t(()=>{if(!y.value)return;C.value=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),E=new Zs({cursorBlink:!1,cursorStyle:`underline`,cursorWidth:3,fontFamily:`"JetBrains Mono", "Fira Code", Menlo, Monaco, "Courier New", monospace`,fontSize:window.innerWidth<768?11:13,fontWeight:`400`,fontWeightBold:`700`,lineHeight:1.3,letterSpacing:.5,smoothScrollDuration:50,scrollSensitivity:3,fastScrollSensitivity:5,allowProposedApi:!0,screenReaderMode:C.value,theme:f.value===`dark`?p:v,scrollback:1e4,tabStopWidth:4,macOptionIsMeta:!0}),D=new ec,E.loadAddon(D);try{let e=new Eh;E.loadAddon(e)}catch{console.warn(`WebGL addon failed to load, falling back to canvas renderer`)}let t=new oc((e,t)=>{window.open(t,`_blank`)});E.loadAddon(t);let n=new Hu;if(E.loadAddon(n),E.unicode.activeVersion=`11`,ne=new Al,E.loadAddon(ne),E.open(y.value),D.fit(),E.focus(),C.value&&b.value){let t=b.value,n=()=>{t.focus({preventScroll:!1})};y.value?.addEventListener(`click`,n),y.value?.addEventListener(`touchstart`,n),t.addEventListener(`input`,()=>{setTimeout(()=>{E?.scrollToBottom()},10)}),e(()=>{y.value?.removeEventListener(`click`,n),y.value?.removeEventListener(`touchstart`,n)})}let r=f.value===`dark`?`\x1B[1;37m`:`\x1B[1;90m`;f.value;let i=(f.value,`\x1B[90m`),a=`\x1B[0m`;E.writeln(``),E.writeln(`${r} ██████ ██ ██ ███ ███ ██████${a}`),E.writeln(`${r} ██ ██ ██ ██ ████ ████ ██ ${a}`),E.writeln(`${r} ██████ ████ ██ ████ ██ ██ ${a}`),E.writeln(`${r} ██ ██ ██ ██ ██ ██ ${a}`),E.writeln(`${r} ██ ██ ██ ██ ██████${a}`),E.writeln(``),E.writeln(` Repeater Terminal${a}`),E.writeln(``),E.writeln(`${i} Type help${i} for available commands${a}`),E.writeln(``),M(),E.onData(e=>{fe(e)});let o=new ResizeObserver(()=>{D?.fit()});o.observe(y.value),e(()=>{o.disconnect(),E?.dispose()})});let M=()=>{E?.write(`\r -\x1B[1;36m❯\x1B[0m `)},ue=e=>{if(!(!E||!e)){E.write(`\x1b[90m${e}\x1b[0m`);for(let t=0;t{if(!(!E||!A)){for(let e=0;e{if(!E)return;let t=e.charCodeAt(0);if(t===13){de(),E.write(`\r -`),O.trim()?(N(O.trim()),re.push(O.trim()),k=re.length):M(),O=``;return}if(t===127){O.length>0&&(de(),O=O.slice(0,-1),E.write(`\b \b`),pe());return}if(t===3){de(),E.write(`^C\r -`),O=``,M();return}if(t===12){E.clear(),O=``,M();return}if(t===6){ee.value=!ee.value;return}if(e===`\x1B[A`){re.length>0&&k>0&&(de(),k--,E.write(`\r\x1B[K`),M(),O=re[k],E.write(O));return}if(e===`\x1B[B`){de(),k2&&ce[n]){let e=t[1]?.toLowerCase(),r=t.slice(2).join(` `).toLowerCase(),i=ce[n][e];if(i){let e=i.filter(e=>e.toLowerCase().startsWith(r));if(e.length===1){let n=t.slice(2).join(` `),r=e[0].slice(n.length);O+=r,E.write(r)}else e.length>1&&(E.write(`\r -\r -\x1B[33mAvailable values:\x1B[0m\r -\r -`),e.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O));return}}if(t.length>1&&se[n]){if(n===`ping`){let e=t.slice(1).join(` `).toLowerCase(),n=Date.now();n-oe>3e4&&Wh().then(e=>{ae=e,oe=n,se.ping=e});let r=ae.filter(t=>t.toLowerCase().startsWith(e));if(r.length===1){let e=t.slice(1).join(` `),n=r[0].slice(e.length)+` `;O+=n,E.write(n)}else r.length>1?(E.write(`\r -\r -\x1B[33mAvailable neighbors:\x1B[0m\r -\r -`),r.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O)):ae.length===0&&e===``&&(E.write(`\r -\r -\x1B[33mFetching neighbors...\x1B[0m\r -`),Wh().then(e=>{ae=e,oe=n,se.ping=e,E.write(`\r -\x1B[33mAvailable neighbors:\x1B[0m\r -\r -`),e.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O)}).catch(()=>{E.write(`\r -\x1B[31mFailed to fetch neighbors\x1B[0m\r -`),M(),E.write(O)}));return}let e=t.slice(1).join(` `).toLowerCase(),r=se[n].filter(t=>t.toLowerCase().startsWith(e));if(r.length===1){let e=t.slice(1).join(` `),n=r[0].slice(e.length)+` `;O+=n,E.write(n)}else if(r.length>1){E.write(`\r -\r -\x1B[33mAvailable parameters:\x1B[0m\r -\r -`);let e=le[n]||{};r.forEach(t=>{let n=e[t]||``,r=t.padEnd(20);E.writeln(` \x1b[36m${r}\x1b[0m\x1b[90m${n}\x1b[0m`)}),M(),E.write(O)}return}let r=j.getAllCommands().filter(t=>!!(t.name.toLowerCase().startsWith(e)||t.aliases?.some(t=>t.toLowerCase().startsWith(e))));if(r.length===1){let e=r[0].name.slice(O.length)+` `;O+=e,E.write(e)}else r.length>1&&(E.write(`\r -\r -\x1B[33mAvailable commands:\x1B[0m\r -\r -`),r.forEach(e=>{let t=e.aliases&&e.aliases.length>0?` (${e.aliases.join(`, `)})`:``;E.writeln(` \x1b[36m${e.name.padEnd(15)}\x1b[0m ${e.description}${t}`)}),M(),E.write(O));return}t>=32&&t<127&&(de(),O+=e,E.write(e),C.value||pe())},pe=()=>{if(O.length===0){A=``;return}let e=ie.filter(e=>e.startsWith(O.toLowerCase()));e.length===1&&e[0]!==O?(A=e[0].slice(O.length),ue(A)):A=``},N=async e=>{if(!E)return;let[t,...n]=e.trim().split(/\s+/),r=j.findCommand(t);if(r)try{await r.execute({term:E,args:n,writePrompt:M})}catch(e){console.error(`Command execution error:`,e),E.writeln(`\x1b[1;31m✗ Error:\x1b[0m ${e instanceof Error?e.message:`Command failed`}`),M()}else E.writeln(`\x1b[1;31m✗ Unknown command:\x1b[0m ${t}`),E.writeln(`\x1B[90mType \x1B[36mhelp\x1B[90m for available commands\x1B[0m`),M()},me=()=>{!ne||!S.value||ne.findNext(S.value,{caseSensitive:!1})},P=()=>{!ne||!S.value||ne.findPrevious(S.value,{caseSensitive:!1})},he=()=>{ee.value=!1,S.value=``,E?.focus()},ge=async()=>{if(x.value){if(w.value)try{document.exitFullscreen&&await document.exitFullscreen(),w.value=!1}catch(e){console.error(`Failed to exit fullscreen:`,e)}else try{x.value.requestFullscreen&&await x.value.requestFullscreen(),w.value=!0,setTimeout(()=>{C.value&&b.value?b.value.focus():E&&E.focus()},100)}catch(e){console.error(`Failed to enter fullscreen:`,e)}setTimeout(()=>{D?.fit()},100)}},_e=()=>{T.value=!T.value,T.value&&C.value&&setTimeout(()=>{window.scrollTo(0,1)},100),setTimeout(()=>{C.value&&b.value?b.value.focus():E?.focus(),D?.fit()},150)},ve=()=>{T.value=!1,setTimeout(()=>{D?.fit()},100)};a(f,e=>{E&&(E.options.theme=e===`dark`?p:v)}),typeof document<`u`&&(document.addEventListener(`fullscreenchange`,()=>{w.value=!!document.fullscreenElement,setTimeout(()=>D?.fit(),100)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&!w.value&&ve()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&!w.value&&ve()}));let ye=()=>{C.value&&b.value&&b.value.focus()},be=e=>{let t=e.target,n=t.value;n&&E&&fe(n.slice(-1)),t.value=``},xe=()=>{E&&fe(`\r`),b.value&&(b.value.value=``)},Se=()=>{E&&fe(``),b.value&&(b.value.value=``)};return(e,t)=>(u(),l(`div`,Kh,[c(`div`,qh,[c(`div`,Jh,[t[8]||=c(`div`,null,[c(`h1`,{class:`text-content-primary dark:text-content-primary text-lg md:text-xl font-semibold`},` Terminal `),c(`p`,{class:`text-content-secondary dark:text-content-muted text-sm hidden md:block`},` Interactive command-line interface `)],-1),c(`div`,Yh,[C.value?(u(),l(`button`,{key:0,onClick:_e,class:`flex items-center gap-2 px-3 py-2 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:T.value?`Exit fullscreen`:`Enter fullscreen`},[T.value?(u(),l(`svg`,Qh,[...t[3]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(u(),l(`svg`,Zh,[...t[2]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4`},null,-1)]])),c(`span`,$h,s(T.value?`Exit`:`Fullscreen`),1)],8,Xh)):o(``,!0),C.value?o(``,!0):(u(),l(`button`,{key:1,onClick:_e,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:T.value?`Exit full window`:`Full window`},[t[4]||=c(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z`})],-1),c(`span`,tg,s(T.value?`Exit Window`:`Full Window`),1)],8,eg)),C.value?o(``,!0):(u(),l(`button`,{key:2,onClick:ge,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:w.value?`Exit fullscreen`:`Fullscreen`},[w.value?(u(),l(`svg`,ig,[...t[6]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(u(),l(`svg`,rg,[...t[5]||=[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4`},null,-1)]])),c(`span`,ag,s(w.value?`Exit Full`:`Fullscreen`),1)],8,ng)),c(`button`,{onClick:t[0]||=e=>ee.value=!ee.value,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-primary/20 hover:bg-primary/30 text-primary border border-primary/50 rounded-lg transition-colors`},[...t[7]||=[c(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1),c(`span`,{class:`hidden sm:inline`},`Search`,-1)]])])])]),ee.value?(u(),l(`div`,og,[c(`div`,sg,[i(c(`input`,{"onUpdate:modelValue":t[1]||=e=>S.value=e,onKeydown:[_(me,[`enter`]),_(he,[`esc`])],type:`text`,placeholder:`Search terminal output...`,class:`flex-1 px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 outline-none focus:border-primary/50 transition-colors`},null,544),[[h,S.value]]),c(`button`,{onClick:P,class:`px-3 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary transition-colors`,title:`Previous (Shift+Enter)`},` ↑ `),c(`button`,{onClick:me,class:`px-3 py-2 bg-primary/20 hover:bg-primary/30 border border-primary/50 rounded-lg text-primary transition-colors`,title:`Next (Enter)`},` ↓ `),c(`button`,{onClick:he,class:`px-3 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary transition-colors`},` ✕ `)])])):o(``,!0),c(`div`,{ref_key:`terminalContainerRef`,ref:x,class:n([`bg-surface dark:bg-surface-elevated/80 backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] overflow-hidden relative`,{"fullscreen-terminal":w.value,"full-window-terminal":T.value}])},[T.value&&!w.value?(u(),l(`button`,{key:0,onClick:ve,class:`absolute top-4 right-4 z-50 p-2 bg-black/80 backdrop-blur-sm hover:bg-black/90 text-white border border-white/20 rounded-lg transition-colors`,title:`Exit full window (ESC)`},[...t[9]||=[c(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[c(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])):o(``,!0),c(`div`,{ref_key:`terminalRef`,ref:y,class:n([`terminal-container`,{"fullscreen-content":w.value}]),onClick:ye,onTouchstart:ye},[C.value?(u(),l(`input`,{key:0,ref_key:`mobileInputRef`,ref:b,type:`text`,class:`mobile-keyboard-input`,onInput:be,onKeydown:[_(g(xe,[`prevent`]),[`enter`]),_(Se,[`delete`])],inputmode:`text`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`},null,40,cg)):o(``,!0)],34),te.value?(u(),l(`div`,lg,[...t[10]||=[c(`div`,{class:`w-2 h-2 bg-primary rounded-full animate-pulse`},null,-1),c(`span`,{class:`text-primary text-sm font-medium`},`Processing...`,-1)]])):o(``,!0)],2)]))}}),[[`__scopeId`,`data-v-e270e599`]]);export{ug as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/Terminal-IUdfvY-m.js b/repeater/web/html/assets/Terminal-IUdfvY-m.js new file mode 100644 index 00000000..faa75545 --- /dev/null +++ b/repeater/web/html/assets/Terminal-IUdfvY-m.js @@ -0,0 +1,198 @@ +import{Ct as e,D as t,E as n,R as r,V as i,Y as a,g as o,k as s,l as c,s as l,u,xt as d}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{l as f,s as p,u as m}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{t as h}from"./api-3gMnsCKh.js";import{t as g}from"./system-DbBvxitf.js";import{t as _}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as v}from"./useTheme-B2sN4eXt.js";import{r as y,t as b}from"./constants-C3rXUIAq.js";var x=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,r)=>{for(var i=r>1?void 0:r?ee(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&x(t,n,i),i},C=(e,t)=>(n,r)=>t(n,r,e),w=`Terminal input`,T={get:()=>w,set:e=>w=e},E=`Too much output to announce, navigate to rows manually to read`,D={get:()=>E,set:e=>E=e};function ne(e){return e.replace(/\r?\n/g,`\r`)}function re(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function O(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function k(e,t,n,r){e.stopPropagation(),e.clipboardData&&A(e.clipboardData.getData(`text/plain`),t,n,r)}function A(e,t,n,r){e=ne(e),e=re(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function j(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){j(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ae(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},le=``,ue=` `,M=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},N=class e extends M{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ae(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function he(e){return e[pe]||[]}function ge(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);_e(t,e,r)};return t._id=e,me.set(e,t),t}function _e(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var ve=ge(`BufferService`),ye=ge(`CoreMouseService`),be=ge(`CoreService`),xe=ge(`CharsetService`),Se=ge(`InstantiationService`),Ce=ge(`LogService`),we=ge(`OptionsService`),Te=ge(`OscLinkService`),Ee=ge(`UnicodeService`),De=ge(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new N,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=S([C(0,ve),C(1,we),C(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}? + +WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ae=ge(`CharSizeService`),je=ge(`CoreBrowserService`),Me=ge(`MouseService`),Ne=ge(`RenderService`),Pe=ge(`SelectionService`),Fe=ge(`CharacterJoinerService`),Ie=ge(`ThemeService`),Le=ge(`LinkProviderService`),Re=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?We.isErrorNoTelemetry(e)?new We(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function ze(e){Ve(e)||Re.onUnexpectedError(e)}var Be=`Canceled`;function Ve(e){return e instanceof He?!0:e instanceof Error&&e.name===Be&&e.message===Be}var He=class extends Error{constructor(){super(Be),this.name=this.message}};function Ue(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var We=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Ge=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Ke(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Ye||={});function Xe(e,t){return(n,r)=>t(e(n),e(r))}var Ze=(e,t)=>e-t,Qe=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Ye.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Qe.empty=new Qe(e=>{});function $e(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var et=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function tt(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var nt;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` +`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new et;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` +`),e)}n.sort(Xe(e=>e.idx,Ze));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` + + +==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== +${s.join(` +`)} +============================================================ + +`}return n.length>e&&(a+=` + + +... and ${n.length-e} more leaking disposables + +`),{leaks:n,details:a}}};at.idx=0;function ot(e){it=e}if(rt){let e=`__is_disposable_tracked__`;ot(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==F.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==F.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function st(e){return it?.trackDisposable(e),e}function ct(e){it?.markAsDisposed(e)}function lt(e,t){it?.setParent(e,t)}function ut(e,t){if(it)for(let n of e)it.setParent(n,t)}function dt(e){return it?.markAsSingleton(e),e}function ft(e){if(nt.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function pt(...e){let t=P(()=>ft(e));return ut(e,t),t}function P(e){let t=st({dispose:tt(()=>{ct(t),e()})});return t}var mt=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,st(this)}dispose(){this._isDisposed||(ct(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ft(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return lt(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),lt(e,null))}};mt.DISABLE_DISPOSED_WARNING=!1;var ht=mt,F=class{constructor(){this._store=new ht,st(this),lt(this._store,this)}dispose(){ct(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};F.None=Object.freeze({dispose(){}});var gt=class{constructor(){this._isDisposed=!1,st(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&<(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,ct(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&<(e,null),e}},_t=typeof window==`object`?window:globalThis,vt=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};vt.Undefined=new vt(void 0);var I=vt,yt=class{constructor(){this._first=I.Undefined,this._last=I.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===I.Undefined}clear(){let e=this._first;for(;e!==I.Undefined;){let t=e.next;e.prev=I.Undefined,e.next=I.Undefined,e=t}this._first=I.Undefined,this._last=I.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new I(e);if(this._first===I.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==I.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==I.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==I.Undefined&&e.next!==I.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===I.Undefined&&e.next===I.Undefined?(this._first=I.Undefined,this._last=I.Undefined):e.next===I.Undefined?(this._last=this._last.prev,this._last.next=I.Undefined):e.prev===I.Undefined&&(this._first=this._first.next,this._first.prev=I.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==I.Undefined;)yield e.element,e=e.next}},bt=globalThis.performance&&typeof globalThis.performance.now==`function`,xt=class e{static create(t){return new e(t)}constructor(e){this._now=bt&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},St=!1,Ct=!1,wt=!1,Tt;(e=>{e.None=()=>F.None;function t(e){if(wt){let{onDidAddListener:t}=e,n=jt.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(pt(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new L(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new L(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new L({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new L({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new L({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function ee(e){return new Promise(t=>r(e)(t))}e.toPromise=ee;function te(e){let t=new L;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=te;function S(e,t){return e(e=>t.fire(e))}e.forward=S;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new L(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof ht?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Tt||={});var Et=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new xt,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Et.all=new Set,Et._idPool=0;var Dt=Et,Ot=-1,kt=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof Ft)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` +`)),e.length=0)},3e3),Rt=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var L=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Ot>0||this._options?.leakWarningThreshold?new At(e?.onListenerError??ze,this._options?.leakWarningThreshold??Ot):void 0,this._perfMon=this._options?._profName?new Dt(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Ct){let e=this._listeners;queueMicrotask(()=>{Lt(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Nt(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||ze)(n),F.None}if(this._disposed)return F.None;t&&(e=e.bind(t));let r=new Ft(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=jt.create(),i=this._leakageMon.check(r.stack,this._size+1)),Ct&&(r.stack=jt.create()),this._listeners?this._listeners instanceof Ft?(this._deliveryQueue??=new zt,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=P(()=>{Rt?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof ht?n.add(a):Array.isArray(n)&&n.push(a),Rt){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Rt.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*It<=t.length){let e=0;for(let n=0;n0}},zt=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Bt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new L,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new L,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Bt.INSTANCE=new Bt;var Vt=Bt;function Ht(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Vt.INSTANCE.onDidChangeZoomLevel;function Ut(e){return Vt.INSTANCE.getZoomFactor(e)}Vt.INSTANCE.onDidChangeFullscreen;var Wt=typeof navigator==`object`?navigator.userAgent:``,Gt=Wt.indexOf(`Firefox`)>=0,Kt=Wt.indexOf(`AppleWebKit`)>=0,qt=Wt.indexOf(`Chrome`)>=0,Jt=!qt&&Wt.indexOf(`Safari`)>=0;Wt.indexOf(`Electron/`),Wt.indexOf(`Android`);var Yt=!1;if(typeof _t.matchMedia==`function`){let e=_t.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=_t.matchMedia(`(display-mode: fullscreen)`);Yt=e.matches,Ht(_t,e,({matches:e})=>{Yt&&t.matches||(Yt=e)})}function Xt(){return Yt}var Zt=`en`,Qt=!1,$t=!1,en=!1,tn=!1,nn=!1,rn=Zt,an,on=globalThis,sn;typeof on.vscode<`u`&&typeof on.vscode.process<`u`?sn=on.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(sn=process);var cn=typeof sn?.versions?.electron==`string`&&sn?.type===`renderer`;if(typeof sn==`object`){Qt=sn.platform===`win32`,$t=sn.platform===`darwin`,en=sn.platform===`linux`,en&&sn.env.SNAP&&sn.env.SNAP_REVISION,sn.env.CI||sn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,rn=Zt;let e=sn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,rn=t.resolvedLanguage||Zt,t.languagePack?.translationsConfigFile}catch{}tn=!0}else typeof navigator==`object`&&!cn?(an=navigator.userAgent,Qt=an.indexOf(`Windows`)>=0,$t=an.indexOf(`Macintosh`)>=0,(an.indexOf(`Macintosh`)>=0||an.indexOf(`iPad`)>=0||an.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,en=an.indexOf(`Linux`)>=0,an?.indexOf(`Mobi`),nn=!0,rn=globalThis._VSCODE_NLS_LANGUAGE||Zt,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var ln=Qt,un=$t,dn=en,fn=tn;nn&&typeof on.importScripts==`function`&&on.origin;var pn=an,mn=rn,hn;(e=>{function t(){return mn}e.value=t;function n(){return mn.length===2?mn===`en`:mn.length>=3?mn[0]===`e`&&mn[1]===`n`&&mn[2]===`-`:!1}e.isDefaultVariant=n;function r(){return mn===`en`}e.isDefault=r})(hn||={});var gn=typeof on.postMessage==`function`&&!on.importScripts;(()=>{if(gn){let e=[];on.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),on.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var _n=!!(pn&&pn.indexOf(`Chrome`)>=0);pn&&pn.indexOf(`Firefox`),!_n&&pn&&pn.indexOf(`Safari`),pn&&pn.indexOf(`Edg/`),pn&&pn.indexOf(`Android`);var vn=typeof navigator==`object`?navigator:{};fn||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||vn&&vn.clipboard&&vn.clipboard.writeText,fn||vn&&vn.clipboard&&vn.clipboard.readText,fn||Xt()||vn.keyboard,`ontouchstart`in _t||vn.maxTouchPoints,_t.PointerEvent&&(`ontouchstart`in _t||navigator.maxTouchPoints);var yn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},bn=new yn,xn=new yn,Sn=new yn,Cn=Array(230),wn;(e=>{function t(e){return bn.keyCodeToStr(e)}e.toString=t;function n(e){return bn.strToKeyCode(e)}e.fromString=n;function r(e){return xn.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Sn.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return xn.strToKeyCode(e)||Sn.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return bn.keyCodeToStr(e)}e.toElectronAccelerator=o})(wn||={});var Tn=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new En([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},En=class{constructor(e){if(e.length===0)throw Ue(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t{function t(t){return t===e.None||t===e.Cancelled||t instanceof Bn?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Tt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Rn})})(zn||={});var Bn=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Rn:(this._emitter||=new L,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Vn=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Ge(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ge(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Hn=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Ge(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=P(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Un;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(Un||={});var Wn=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new L,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Wn.EMPTY=Wn.fromArray([]);function Gn(e){return 55296<=e&&e<=56319}function Kn(e){return 56320<=e&&e<=57343}function qn(e,t){return(e-55296<<10)+(t-56320)+65536}function Jn(e){return Yn(e,0)}function Yn(e,t){switch(typeof e){case`object`:return e===null?Xn(349,t):Array.isArray(e)?$n(e,t):er(e,t);case`string`:return Qn(e,t);case`boolean`:return Zn(e,t);case`number`:return Xn(e,t);case`undefined`:return Xn(937,t);default:return Xn(617,t)}}function Xn(e,t){return(t<<5)-t+e|0}function Zn(e,t){return Xn(e?433:863,t)}function Qn(e,t){t=Xn(149417,t);for(let n=0,r=e.length;nYn(t,e),t)}function er(e,t){return t=Xn(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Qn(n,t),Yn(e[n],t)),t)}function tr(e,t,n=32){let r=n-t,i=~((1<>>r)>>>0}function nr(e,t=0,n=e.byteLength,r=0){for(let i=0;ie.toString(16).padStart(2,`0`)).join(``):rr((e>>>0).toString(16),t/4)}var ar=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Gn(a))if(o+1>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),ir(this._h0)+ir(this._h1)+ir(this._h2)+ir(this._h3)+ir(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,nr(this._buff,this._buffLen),this._buffLen>56&&(this._step(),nr(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,tr(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=tr(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=tr(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};ar._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:or,getWindow:sr,getDocument:cr,getWindows:lr,getWindowsCount:ur,getWindowId:dr,getWindowById:fr,hasWindow:pr,onDidRegisterWindow:mr,onWillUnregisterWindow:hr,onDidUnregisterWindow:gr}=function(){let e=new Map,t={window:_t,disposables:new ht};e.set(_t.vscodeWindowId,t);let n=new L,r=new L,i=new L;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return F.None;let a=new ht,o={window:t,disposables:a.add(new ht)};return e.set(t.vscodeWindowId,o),a.add(P(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(R(t,Er.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:_t},getDocument(e){return sr(e).document}}}(),_r=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function R(e,t,n,r){return new _r(e,t,n,r)}function vr(e,t){return function(n){return t(new In(e,n))}}function yr(e){return function(t){return e(new Mn(t))}}var br=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=vr(sr(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=yr(n)),R(e,t,i,r)},xr,Sr=class extends Hn{constructor(e){super(),this.defaultTarget=e&&sr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Cr=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ze(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(Cr.sort),a.shift().execute();r.set(i,!1)};xr=(t,r,a=0)=>{let o=dr(t),s=new Cr(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var wr=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};wr.None=new wr(0,0);function Tr(e){let t=e.getBoundingClientRect(),n=sr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Jn(n),a=r.get(i);if(a)a.users+=1;else{let o=new L,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(P(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Er={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Kt?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Kt?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Kt?`webkitAnimationIteration`:`animationiteration`},Dr=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function Or(e,t,n,...r){let i=Dr.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function kr(e,t,...n){return Or(`http://www.w3.org/1999/xhtml`,e,t,...n)}kr.SVG=function(e,t,...n){return Or(`http://www.w3.org/2000/svg`,e,t,...n)};var Ar=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=jr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=jr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=jr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=jr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=jr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=jr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=jr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=jr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=jr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=jr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=jr(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=jr(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=jr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=jr(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function jr(e){return typeof e==`number`?`${e}px`:e}function Mr(e){return new Ar(e)}var Nr=class{constructor(){this._hooks=new ht,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(P(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=sr(e)}this._hooks.add(R(a,Er.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(R(a,Er.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Pr(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Fr;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Fr||={});var Ir=class e extends F{constructor(){super(),this.dispatched=!1,this.targets=new yt,this.ignoreTargets=new yt,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Tt.runAndSubscribe(mr,({window:e,disposables:t})=>{t.add(R(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(R(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(R(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:_t,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=dt(new e),P(e.INSTANCE.targets.push(t))):F.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=dt(new e),P(e.INSTANCE.ignoreTargets.push(t))):F.None}static isTouchDevice(){return`ontouchstart`in _t||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n=e.HOLD_DELAY&&Math.abs(s.initialPageX-Je(s.rollingPageX))<30&&Math.abs(s.initialPageY-Je(s.rollingPageY))<30){let e=this.newGestureEvent(Fr.Contextmenu,s.initialTarget);e.pageX=Je(s.rollingPageX),e.pageY=Je(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Je(s.rollingPageX),n=Je(s.rollingPageY),i=Je(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Fr.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Fr.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else (t.type===Fr.Change||t.type===Fr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=xr(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Fr.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Ir.SCROLL_FRICTION=-.005,Ir.HOLD_DELAY=700,Ir.CLEAR_TAP_COUNT_TIME=400,S([Pr],Ir,`isTouchDevice`,1);var Lr=Ir,Rr=class extends F{onclick(e,t){this._register(R(e,Er.CLICK,n=>t(new In(sr(e),n))))}onmousedown(e,t){this._register(R(e,Er.MOUSE_DOWN,n=>t(new In(sr(e),n))))}onmouseover(e,t){this._register(R(e,Er.MOUSE_OVER,n=>t(new In(sr(e),n))))}onmouseleave(e,t){this._register(R(e,Er.MOUSE_LEAVE,n=>t(new In(sr(e),n))))}onkeydown(e,t){this._register(R(e,Er.KEY_DOWN,e=>t(new Mn(e))))}onkeyup(e,t){this._register(R(e,Er.KEY_UP,e=>t(new Mn(e))))}oninput(e,t){this._register(R(e,Er.INPUT,t))}onblur(e,t){this._register(R(e,Er.BLUR,t))}onfocus(e,t){this._register(R(e,Er.FOCUS,t))}onchange(e,t){this._register(R(e,Er.CHANGE,t))}ignoreGesture(e){return Lr.ignoreTarget(e)}},zr=11,Br=class extends Rr{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=zr+`px`,this.domNode.style.height=zr+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new Nr),this._register(br(this.bgDomNode,Er.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(br(this.domNode,Er.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Sr),this._pointerdownScheduleRepeatTimer=this._register(new Vn)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,sr(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Vr=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Hr=class extends F{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Vr(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new Kr(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Kr.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Ur=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Wr(e,t){let n=t-e;return function(t){return e+n*Jr(t)}}function Gr(e,t,n){return function(r){return r2.5*n){let r,i;return e{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},Xr=140,Zr=class extends Rr{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Yr(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Nr),this._shouldRender=!0,this.domNode=Mr(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(R(this.domNode.domNode,Er.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Br(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Mr(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(R(this.slider.domNode,Er.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=Tr(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(ln&&a>Xr){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Qr=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};ai.INSTANCE=new ai;var oi=ai,si=class extends Rr{constructor(e,t,n){super(),this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new L),this.onWillScroll=this._onWillScroll.event,this._options=li(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ei(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $r(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Mr(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Mr(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Mr(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Vn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ft(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,un&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ln(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ft(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(R(this._listenOnDomNode,Er.MOUSE_WHEEL,e=>{this._onMouseWheel(new Ln(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=oi.INSTANCE;ri&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!un&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=ni*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=ni*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(ri&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),ti)}},ci=class extends si{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function li(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`?e.horizontalHasArrows:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,un&&(t.className+=` mac`),t}var ui=class extends F{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Hr({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>xr(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ci(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Tt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(P(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(P(()=>this._styleElement.remove())),this._register(Tt.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};ui=S([C(2,ve),C(3,je),C(4,ye),C(5,Ie),C(6,we),C(7,Ne)],ui);var di=class extends F{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(P(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};di=S([C(1,ve),C(2,je),C(3,De),C(4,Ne)],di);var fi=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},pi={full:0,left:0,center:0,right:0},mi={full:0,left:0,center:0,right:0},hi={full:0,left:0,center:0,right:0},gi=class extends F{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new fi,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(P(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);mi.full=this._canvas.width,mi.left=e,mi.center=t,mi.right=e,this._refreshDrawHeightConstants(),hi.full=1,hi.left=1,hi.center=1+mi.left,hi.right=1+mi.left+mi.center}_refreshDrawHeightConstants(){pi.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);pi.left=t,pi.center=t,pi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pi.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(hi[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-pi[e.position||`full`]/2),mi[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+pi[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};gi=S([C(2,ve),C(3,De),C(4,Ne),C(5,we),C(6,Ie),C(7,je)],gi);var z;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=` +`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(z||={});var _i;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(_i||={});var vi;(e=>e.ST=`${z.ESC}\\`)(vi||={});var yi=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};yi=S([C(2,ve),C(3,we),C(4,be),C(5,Ne)],yi);var bi=0,xi=0,Si=0,B=0,Ci={css:`#00000000`,rgba:0},V;(e=>{function t(e,t,n,r){return r===void 0?`#${Ei(e)}${Ei(t)}${Ei(n)}`:`#${Ei(e)}${Ei(t)}${Ei(n)}${Ei(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(V||={});var H;(e=>{function t(e,t){if(B=(t.rgba&255)/255,B===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return bi=a+Math.round((n-a)*B),xi=o+Math.round((r-o)*B),Si=s+Math.round((i-s)*B),{css:V.toCss(bi,xi,Si),rgba:V.toRgba(bi,xi,Si)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Ti.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return V.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[bi,xi,Si]=Ti.toChannels(t),{css:V.toCss(bi,xi,Si),rgba:t}}e.opaque=i;function a(e,t){return B=Math.round(t*255),[bi,xi,Si]=Ti.toChannels(e.rgba),{css:V.toCss(bi,xi,Si,B),rgba:V.toRgba(bi,xi,Si,B)}}e.opacity=a;function o(e,t){return B=e.rgba&255,a(e,B*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(H||={});var U;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return bi=parseInt(e.slice(1,2).repeat(2),16),xi=parseInt(e.slice(2,3).repeat(2),16),Si=parseInt(e.slice(3,4).repeat(2),16),V.toColor(bi,xi,Si);case 5:return bi=parseInt(e.slice(1,2).repeat(2),16),xi=parseInt(e.slice(2,3).repeat(2),16),Si=parseInt(e.slice(3,4).repeat(2),16),B=parseInt(e.slice(4,5).repeat(2),16),V.toColor(bi,xi,Si,B);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return bi=parseInt(r[1]),xi=parseInt(r[2]),Si=parseInt(r[3]),B=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),V.toColor(bi,xi,Si,B);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[bi,xi,Si,B]=t.getImageData(0,0,1,1).data,B!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:V.toRgba(bi,xi,Si,B),css:e}}e.toColor=r})(U||={});var wi;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(wi||={});var Ti;(e=>{function t(e,t){if(B=(t&255)/255,B===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return bi=a+Math.round((n-a)*B),xi=o+Math.round((r-o)*B),Si=s+Math.round((i-s)*B),V.toRgba(bi,xi,Si)}e.blend=t;function n(e,t,n){let a=wi.relativeLuminance(e>>8),o=wi.relativeLuminance(t>>8);if(Di(a,o)>8));if(sDi(a,wi.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Di(a,wi.relativeLuminance(s>>8));if(cDi(a,wi.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Di(wi.relativeLuminance2(o,s,c),wi.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Di(wi.relativeLuminance2(o,s,c),wi.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Di(wi.relativeLuminance2(o,s,c),wi.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Ti||={});function Ei(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Di(e,t){return e1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t=w,O=D,k=this._workCell;if(f.length>0&&D===f[0][0]&&re){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v=r[1],re?(ne=!0,k=new Oi(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),O=r[1]-1,m=k.getWidth()):w=r[1]}let A=this._isCellInSelection(D,t),j=n&&D===a,ie=E&&D>=l&&D<=u,ae=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{ae=!0});let oe=k.getChars()||ue;if(oe===` `&&(k.isUnderline()||k.isOverline())&&(oe=`\xA0`),C=m*s-c.get(oe,k.isBold(),k.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(A&&S||!A&&!S&&k.bg===y)&&(A&&S&&p.selectionForeground||k.fg===b)&&k.extended.ext===x&&ie===ee&&C===te&&!j&&!ne&&!ae&&re){k.isInvisible()?_+=ue:_+=oe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=k.bg,b=k.fg,x=k.extended.ext,ee=ie,te=C,S=A,ne&&a>=D&&a<=O&&(a=D),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(T.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&T.push(`xterm-cursor-blink`),T.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:T.push(`xterm-cursor-outline`);break;case`block`:T.push(`xterm-cursor-block`);break;case`bar`:T.push(`xterm-cursor-bar`);break;case`underline`:T.push(`xterm-cursor-underline`);break;default:break}}if(k.isBold()&&T.push(`xterm-bold`),k.isItalic()&&T.push(`xterm-italic`),k.isDim()&&T.push(`xterm-dim`),_=k.isInvisible()?ue:k.getChars()||ue,k.isUnderline()&&(T.push(`xterm-underline-${k.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!k.isUnderlineColorDefault()))if(k.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${M.toColorRGB(k.getUnderlineColor()).join(`,`)})`;else{let e=k.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&k.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}k.isOverline()&&(T.push(`xterm-overline`),_===` `&&(_=`\xA0`)),k.isStrikethrough()&&T.push(`xterm-strikethrough`),ie&&(h.style.textDecoration=`underline`);let se=k.getFgColor(),ce=k.getFgColorMode(),le=k.getBgColor(),de=k.getBgColorMode(),N=!!k.isInverse();if(N){let e=se;se=le,le=e;let t=ce;ce=de,de=t}let fe,pe,me=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{e.options.layer!==`top`&&me||(e.backgroundColorRGB&&(de=50331648,le=e.backgroundColorRGB.rgba>>8&16777215,fe=e.backgroundColorRGB),e.foregroundColorRGB&&(ce=50331648,se=e.foregroundColorRGB.rgba>>8&16777215,pe=e.foregroundColorRGB),me=e.options.layer===`top`)}),!me&&A&&(fe=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,le=fe.rgba>>8&16777215,de=50331648,me=!0,p.selectionForeground&&(ce=50331648,se=p.selectionForeground.rgba>>8&16777215,pe=p.selectionForeground)),me&&T.push(`xterm-decoration-top`);let he;switch(de){case 16777216:case 33554432:he=p.ansi[le],T.push(`xterm-bg-${le}`);break;case 50331648:he=V.toColor(le>>16,le>>8&255,le&255),this._addStyle(h,`background-color:#${Ii((le>>>0).toString(16),`0`,6)}`);break;default:N?(he=p.foreground,T.push(`xterm-bg-257`)):he=p.background}switch(fe||k.isDim()&&(fe=H.multiplyOpacity(he,.5)),ce){case 16777216:case 33554432:k.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(h,he,p.ansi[se],k,fe,void 0)||T.push(`xterm-fg-${se}`);break;case 50331648:let e=V.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(h,he,e,k,fe,pe)||this._addStyle(h,`color:#${Ii(se.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,he,p.foreground,k,fe,pe)||N&&T.push(`xterm-fg-257`)}T.length&&=(h.className=T.join(` `),0),!j&&!ne&&!ae&&re?g++:h.textContent=_,C!==this.defaultSpacing&&(h.style.letterSpacing=`${C}px`),d.push(h),D=O}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Mi(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=H.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t=n[0]&&e=n[0]}};Fi=S([C(1,Fe),C(2,we),C(3,je),C(4,be),C(5,De),C(6,Ie)],Fi);function Ii(e,t,n){for(;e.length0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Ri=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function zi(){return new Ri}var Bi=`xterm-dom-renderer-owner-`,Vi=`xterm-rows`,Hi=`xterm-fg-`,Ui=`xterm-bg-`,Wi=`xterm-focus`,Gi=`xterm-selection`,Ki=1,qi=class extends F{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Ki++,this._rowElements=[],this._selectionRenderModel=zi(),this.onRequestRedraw=this._register(new L).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Vi),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(Gi),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Ni(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Fi,document),this._element.classList.add(Bi+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(P(()=>{this._element.classList.remove(Bi+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Li(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Vi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Vi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Vi} .xterm-dim { color: ${H.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Vi}.${Wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Vi}.${Wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Vi}.${Wi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Vi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Vi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Vi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Vi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Vi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Gi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Gi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Gi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Hi}${n} { color: ${r.css}; }${this._terminalSelector} .${Hi}${n}.xterm-dim { color: ${H.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ui}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Hi}257 { color: ${H.opaque(e.background).css}; }${this._terminalSelector} .${Hi}257.xterm-dim { color: ${H.multiplyOpacity(H.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ui}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Wi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Wi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Bi}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};qi=S([C(7,Se),C(8,Ae),C(9,we),C(10,ve),C(11,be),C(12,je),C(13,Ie)],qi);var Ji=class extends F{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new L),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Zi(this._optionsService))}catch{this._measureStrategy=this._register(new Xi(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Ji=S([C(2,we)],Ji);var Yi=class extends F{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Xi=class extends Yi{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Zi=class extends Yi{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Qi=class extends F{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new $i(this._window)),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new L),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Tt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(R(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(R(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},$i=class extends F{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new gt),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(P(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=R(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},ea=class extends F{constructor(){super(),this.linkProviders=[],this._register(P(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ta(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function na(e,t,n,r,i,a,o,s,c){if(!a)return;let l=ta(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),i),l}var ra=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return na(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=ta(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ra=S([C(0,Ne),C(1,Ae)],ra);var ia=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},aa={};te(aa,{getSafariVersion:()=>fa,isChromeOS:()=>va,isFirefox:()=>la,isIpad:()=>ma,isIphone:()=>ha,isLegacyEdge:()=>ua,isLinux:()=>_a,isMac:()=>pa,isNode:()=>oa,isSafari:()=>da,isWindows:()=>ga});var oa=typeof process<`u`&&`title`in process,sa=oa?`node`:navigator.userAgent,ca=oa?`node`:navigator.platform,la=sa.includes(`Firefox`),ua=sa.includes(`Edge`),da=/^((?!chrome|android).)*safari/i.test(sa);function fa(){if(!da)return 0;let e=sa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var pa=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(ca),ma=ca===`iPad`,ha=ca===`iPhone`,ga=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(ca),_a=ca.indexOf(`Linux`)>=0,va=/\bCrOS\b/.test(sa),ya=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},ba=class extends ya{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},xa=class extends ya{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sa=!oa&&`requestIdleCallback`in window?xa:ba,Ca=class{constructor(){this._queue=new Sa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},wa=class extends F{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new gt),this._pausedResizeTask=new Ca,this._observerDisposable=this._register(new gt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new L),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new L),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new L),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ia((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Ta(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(P(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=P(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};wa=S([C(2,we),C(3,Ae),C(4,be),C(5,De),C(6,ve),C(7,je),C(8,Ie)],wa);var Ta=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Ea(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return ka(i,a,e,t,n,r)+Aa(a,t,n,r)+ja(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Ra(Math.abs(i-e),La(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Ra(Oa(a>t?e:i,n)+(s-1)*n.cols+1+Da(a>t?i:e,n),La(o,r))}function Da(e,t){return e-1}function Oa(e,t){return t.cols-e}function ka(e,t,n,r,i,a){return Aa(t,r,i,a).length===0?``:Ra(Ia(e,t,e,t-Na(t,i),!1,i).length,La(`D`,a))}function Aa(e,t,n,r){let i=e-Na(e,n),a=t-Na(t,n);return Ra(Math.abs(i-a)-Ma(e,t,n),La(Fa(e,t),r))}function ja(e,t,n,r,i,a){let o;o=Aa(t,r,i,a).length>0?r-Na(r,i):t;let s=r,c=Pa(e,t,n,r,i,a);return Ra(Ia(e,o,n,s,c===`C`,i).length,La(c,a))}function Ma(e,t,n){let r=0,i=e-Na(e,n),a=t-Na(t,n);for(let o=0;o=0&&e0?r-Na(r,i):t,e=n&&ot?`A`:`B`}function Ia(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&sa.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function La(e,t){let n=t?`O`:`[`;return z.ESC+n+e}function Ra(e,t){e=Math.floor(e);let n=``;for(let r=0;rthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ba(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Va=50,Ha=15,Ua=50,Wa=500,Ga=RegExp(`\xA0`,`g`),Ka=class extends F{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new N,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new L),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new L),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new za(this._bufferService),this._activeSelectionMode=0,this._register(P(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]e.replace(Ga,` `)).join(ga?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),_a&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Ba(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ta(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Va),Va),t/=Va,t/Math.abs(t)+Math.round(t*(Ha-1)))}shouldForceSelection(e){return pa?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Ua)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(pa&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ba(n,this._bufferService.cols)}};Ka=S([C(3,ve),C(4,be),C(5,Me),C(6,we),C(7,Ne),C(8,je)],Ka);var qa=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ja=class{constructor(){this._color=new qa,this._css=new qa}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},W=Object.freeze((()=>{let e=[U.toColor(`#2e3436`),U.toColor(`#cc0000`),U.toColor(`#4e9a06`),U.toColor(`#c4a000`),U.toColor(`#3465a4`),U.toColor(`#75507b`),U.toColor(`#06989a`),U.toColor(`#d3d7cf`),U.toColor(`#555753`),U.toColor(`#ef2929`),U.toColor(`#8ae234`),U.toColor(`#fce94f`),U.toColor(`#729fcf`),U.toColor(`#ad7fa8`),U.toColor(`#34e2e2`),U.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:V.toCss(r,i,a),rgba:V.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:V.toCss(n,n,n),rgba:V.toRgba(n,n,n)})}return e})()),Ya=U.toColor(`#ffffff`),Xa=U.toColor(`#000000`),Za=U.toColor(`#ffffff`),Qa=Xa,$a={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},eo=Ya,to=class extends F{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ja,this._halfContrastCache=new Ja,this._onChangeColors=this._register(new L),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ya,background:Xa,cursor:Za,cursorAccent:Qa,selectionForeground:void 0,selectionBackgroundTransparent:$a,selectionBackgroundOpaque:H.blend(Xa,$a),selectionInactiveBackgroundTransparent:$a,selectionInactiveBackgroundOpaque:H.blend(Xa,$a),scrollbarSliderBackground:H.opacity(Ya,.2),scrollbarSliderHoverBackground:H.opacity(Ya,.4),scrollbarSliderActiveBackground:H.opacity(Ya,.5),overviewRulerBorder:Ya,ansi:W.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=G(e.foreground,Ya),t.background=G(e.background,Xa),t.cursor=H.blend(t.background,G(e.cursor,Za)),t.cursorAccent=H.blend(t.background,G(e.cursorAccent,Qa)),t.selectionBackgroundTransparent=G(e.selectionBackground,$a),t.selectionBackgroundOpaque=H.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=G(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=H.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?G(e.selectionForeground,Ci):void 0,t.selectionForeground===Ci&&(t.selectionForeground=void 0),H.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=H.opacity(t.selectionBackgroundTransparent,.3)),H.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=H.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=G(e.scrollbarSliderBackground,H.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=G(e.scrollbarSliderHoverBackground,H.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=G(e.scrollbarSliderActiveBackground,H.opacity(t.foreground,.5)),t.overviewRulerBorder=G(e.overviewRulerBorder,eo),t.ansi=W.slice(),t.ansi[0]=G(e.black,W[0]),t.ansi[1]=G(e.red,W[1]),t.ansi[2]=G(e.green,W[2]),t.ansi[3]=G(e.yellow,W[3]),t.ansi[4]=G(e.blue,W[4]),t.ansi[5]=G(e.magenta,W[5]),t.ansi[6]=G(e.cyan,W[6]),t.ansi[7]=G(e.white,W[7]),t.ansi[8]=G(e.brightBlack,W[8]),t.ansi[9]=G(e.brightRed,W[9]),t.ansi[10]=G(e.brightGreen,W[10]),t.ansi[11]=G(e.brightYellow,W[11]),t.ansi[12]=G(e.brightBlue,W[12]),t.ansi[13]=G(e.brightMagenta,W[13]),t.ansi[14]=G(e.brightCyan,W[14]),t.ansi[15]=G(e.brightWhite,W[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;re.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},io={trace:0,debug:1,info:2,warn:3,error:4,off:5},ao=`xterm.js: `,oo=class extends F{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),so=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=io[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;tthis._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*K+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*K+0]=e|2097152|t[2]<<22):this._data[e*K+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*K+0]>>22}hasWidth(e){return this._data[e*K+0]&12582912}getFg(e){return this._data[e*K+1]}getBg(e){return this._data[e*K+2]}hasContent(e){return this._data[e*K+0]&4194303}getCodePoint(e){let t=this._data[e*K+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*K+0]&2097152}getString(e){let t=this._data[e*K+0];return t&2097152?this._combined[e]:t&2097151?ae(t&2097151):``}isProtected(e){return this._data[e*K+2]&536870912}loadCell(e,t){return lo=e*K,t.content=this._data[lo+0],t.fg=this._data[lo+1],t.bg=this._data[lo+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*K+0]=t.content,this._data[e*K+1]=t.fg,this._data[e*K+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*K+0]=t|n<<22,this._data[e*K+1]=r.fg,this._data[e*K+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*K+0];r&2097152?this._combined[e]+=ae(t):r&2097151?(this._combined[e]=ae(r&2097151)+ae(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*K+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;rthis.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*uo=0;--e)if(this._data[e*K+0]&4194303)return e+(this._data[e*K+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*K+0]&4194303||this._data[e*K+2]&50331648)return e+(this._data[e*K+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t>22||1}return r&&r.push(t),i}};function po(e,t,n,r,i,a){let o=[];for(let s=0;s=s&&r0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function mo(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o_o(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;sc&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function _o(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var vo=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new L),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ft(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};vo._nextId=1;var yo=vo,bo={},xo=bo.B;bo[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},bo.A={"#":`£`},bo.B=void 0,bo[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},bo.C=bo[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},bo.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},bo.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},bo.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},bo.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},bo.E=bo[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},bo.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},bo.H=bo[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},bo[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var So=4294967295,Co=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=q.clone(),this.savedCharset=xo,this.markers=[],this._nullCell=N.fromCharData([0,le,1,0]),this._whitespaceCell=N.fromCharData([0,ue,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Sa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new co(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new de),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new de),this._whitespaceCell}getBlankLine(e,t){return new fo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&eSo?So:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=q);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new co(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(q),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new fo(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=po(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(q),n);if(r.length>0){let n=mo(this.lines,r);ho(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(q),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=_o(c,Math.max(g,0),this._cols))}for(let t=0;t0;)this.ybase===0?this.y0){let e=[],t=[];for(let e=0;e=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.linee.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},wo=class extends F{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new L),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new Co(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Co(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},To=2,Eo=1,Do=class extends F{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,To),this.rows=Math.max(e.rawOptions.rows||0,Eo),this.buffers=this._register(new wo(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Do=S([C(0,we)],Do);var Oo={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:pa,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},ko=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Ao=class extends F{constructor(e){super(),this._onOptionChange=this._register(new L),this.onOptionChange=this._onOptionChange.event;let t={...Oo};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(P(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in Oo))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Oo))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=Oo[e],!jo(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Oo[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=ko.includes(t)?t:Oo[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function jo(e){return e===`block`||e===`underline`||e===`bar`}function Mo(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Mo(e[r],t-1);return n}var No=Object.freeze({insertMode:!1}),Po=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fo=class extends F{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new L),this.onData=this._onData.event,this._onUserInput=this._register(new L),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new L),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Mo(No),this.decPrivateModes=Mo(Po)}reset(){this.modes=Mo(No),this.decPrivateModes=Mo(Po)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Fo=S([C(0,ve),C(1,Ce),C(2,we)],Fo);var Io={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Lo(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Ro=String.fromCharCode,zo={DEFAULT:e=>{let t=[Lo(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Ro(t[0])}${Ro(t[1])}${Ro(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Lo(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Lo(e,!0)};${e.x};${e.y}${t}`}},Bo=class extends F{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new L),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Io))this.addProtocol(e,Io[e]);for(let e of Object.keys(zo))this.addEncoding(e,zo[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Bo=S([C(0,ve),C(1,be),C(2,we)],Bo);var Vo=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Ho=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Uo;function Wo(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Ko.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Ko.createPropertyValue(0,n,r)}},Ko=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new L,this.onChange=this._onChange.event;let e=new Go;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},qo=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Jo(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Yo=2147483647,Xo=256,Zo=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>Xo)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=Array.isArray(t[0])?1:0;e>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Yo?Yo:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>Yo?Yo:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,Yo):e}},Qo=[],$o=class{constructor(){this._state=0,this._active=Qo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Qo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Qo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Qo,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,oe(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Qo,this._id=-1,this._state=0}}},es=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=oe(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},ts=[],ns=class{constructor(){this._handlers=Object.create(null),this._active=ts,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ts}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ts,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ts,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,oe(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=ts,this._ident=0}},rs=new Zo;rs.addParam(0);var is=class{constructor(e){this._handler=e,this._data=``,this._params=rs,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():rs,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=oe(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=rs,this._data=``,this._hitLimit=!1,e));return this._params=rs,this._data=``,this._hitLimit=!1,t}},as=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;it),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(os,0,2,0),e.add(os,8,5,8),e.add(os,6,0,6),e.add(os,11,0,11),e.add(os,13,13,13),e}(),cs=class extends F{constructor(e=ss){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Zo,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(P(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new $o),this._dcsParser=this._register(new ns),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;tr||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r=t||(r=e[i])<32||r>127&&r>4:i>>8}return n}}function fs(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function ps(e,t=16){let[n,r,i]=e;return`rgb:${fs(n,t)}/${fs(r,t)}/${fs(i,t)}`}var ms={"(":0,")":1,"*":2,"+":3,"-":1,".":2},hs=131072,gs=10;function _s(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var vs=5e3,ys=0,bs=class extends F{constructor(e,t,n,r,i,a,o,s,c=new cs){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new se,this._utf8Decoder=new ce,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=q.clone(),this._eraseAttrDataInternal=q.clone(),this._onRequestBell=this._register(new L),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new L),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new L),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new L),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new L),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new L),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new L),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new L),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new L),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new xs(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(z.BEL,()=>this.bell()),this._parser.setExecuteHandler(z.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(z.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(z.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(z.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(z.BS,()=>this.backspace()),this._parser.setExecuteHandler(z.HT,()=>this.tab()),this._parser.setExecuteHandler(z.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(z.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(_i.IND,()=>this.index()),this._parser.setExecuteHandler(_i.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(_i.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new es(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new es(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new es(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new es(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new es(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new es(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new es(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new es(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new es(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new es(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new es(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new es(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in bo)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new is((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),vs))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${vs} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>hs&&(a=this._parseStack.position+hs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.lengthhs)for(let t=a;t0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;ps){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof fo&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>_s(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new is(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new es(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let c=s;for(let e=1;e0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(z.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(z.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(z.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(z.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(z.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${z.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=M.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=q.fg,e.bg=q.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=q.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=q.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=q.fg&16777215,r.bg&=-67108864,r.bg|=q.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${z.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${z.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${z.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=q.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!_s(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${z.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>gs&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>gs&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(Ss(n))if(r===`?`)t.push({type:0,index:n});else{let e=ds(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=ds(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=q.clone(),this._eraseAttrDataInternal=q.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new N;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${z.ESC}${e}${z.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},xs=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(ys=e,e=t,t=ys),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};xs=S([C(0,ve)],xs);function Ss(e){return 0<=e&&e<256}var Cs=5e7,ws=12,Ts=50,Es=class extends F{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Cs)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=ws?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=ws)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ts&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Ds=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Ds=S([C(0,ve)],Ds);var Os=!1,ks=class extends F{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new gt),this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onData=this._register(new L),this.onData=this._onData.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new L),this._instantiationService=new ro,this.optionsService=this._register(new Ao(e)),this._instantiationService.setService(we,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Do)),this._instantiationService.setService(ve,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(oo)),this._instantiationService.setService(Ce,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fo)),this._instantiationService.setService(be,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Bo)),this._instantiationService.setService(ye,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ko)),this._instantiationService.setService(Ee,this.unicodeService),this._charsetService=this._instantiationService.createInstance(qo),this._instantiationService.setService(xe,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ds),this._instantiationService.setService(Te,this._oscLinkService),this._inputHandler=this._register(new bs(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Tt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Tt.forward(this._bufferService.onResize,this._onResize)),this._register(Tt.forward(this.coreService.onData,this._onData)),this._register(Tt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Es((e,t)=>this._inputHandler.parse(e,t))),this._register(Tt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new L),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Os&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Os=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,To),t=Math.max(t,Eo),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Jo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Jo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=P(()=>{for(let t of e)t.dispose()})}}},As={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function js(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=z.ESC+`OA`:i.key=z.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=z.ESC+`OD`:i.key=z.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=z.ESC+`OC`:i.key=z.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=z.ESC+`OB`:i.key=z.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:z.DEL,e.altKey&&(i.key=z.ESC+i.key);break;case 9:if(e.shiftKey){i.key=z.ESC+`[Z`;break}i.key=z.HT,i.cancel=!0;break;case 13:i.key=e.altKey?z.ESC+z.CR:z.CR,i.cancel=!0;break;case 27:i.key=z.ESC,e.altKey&&(i.key=z.ESC+z.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=z.ESC+`[1;`+(a+1)+`D`:t?i.key=z.ESC+`OD`:i.key=z.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=z.ESC+`[1;`+(a+1)+`C`:t?i.key=z.ESC+`OC`:i.key=z.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=z.ESC+`[1;`+(a+1)+`A`:t?i.key=z.ESC+`OA`:i.key=z.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=z.ESC+`[1;`+(a+1)+`B`:t?i.key=z.ESC+`OB`:i.key=z.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=z.ESC+`[2~`);break;case 46:a?i.key=z.ESC+`[3;`+(a+1)+`~`:i.key=z.ESC+`[3~`;break;case 36:a?i.key=z.ESC+`[1;`+(a+1)+`H`:t?i.key=z.ESC+`OH`:i.key=z.ESC+`[H`;break;case 35:a?i.key=z.ESC+`[1;`+(a+1)+`F`:t?i.key=z.ESC+`OF`:i.key=z.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=z.ESC+`[5;`+(a+1)+`~`:i.key=z.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=z.ESC+`[6;`+(a+1)+`~`:i.key=z.ESC+`[6~`;break;case 112:a?i.key=z.ESC+`[1;`+(a+1)+`P`:i.key=z.ESC+`OP`;break;case 113:a?i.key=z.ESC+`[1;`+(a+1)+`Q`:i.key=z.ESC+`OQ`;break;case 114:a?i.key=z.ESC+`[1;`+(a+1)+`R`:i.key=z.ESC+`OR`;break;case 115:a?i.key=z.ESC+`[1;`+(a+1)+`S`:i.key=z.ESC+`OS`;break;case 116:a?i.key=z.ESC+`[15;`+(a+1)+`~`:i.key=z.ESC+`[15~`;break;case 117:a?i.key=z.ESC+`[17;`+(a+1)+`~`:i.key=z.ESC+`[17~`;break;case 118:a?i.key=z.ESC+`[18;`+(a+1)+`~`:i.key=z.ESC+`[18~`;break;case 119:a?i.key=z.ESC+`[19;`+(a+1)+`~`:i.key=z.ESC+`[19~`;break;case 120:a?i.key=z.ESC+`[20;`+(a+1)+`~`:i.key=z.ESC+`[20~`;break;case 121:a?i.key=z.ESC+`[21;`+(a+1)+`~`:i.key=z.ESC+`[21~`;break;case 122:a?i.key=z.ESC+`[23;`+(a+1)+`~`:i.key=z.ESC+`[23~`;break;case 123:a?i.key=z.ESC+`[24;`+(a+1)+`~`:i.key=z.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=z.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=z.DEL:e.keyCode===219?i.key=z.ESC:e.keyCode===220?i.key=z.FS:e.keyCode===221&&(i.key=z.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=As[e.keyCode]?.[e.shiftKey?1:0];if(t)i.key=z.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=z.ESC+n}else if(e.keyCode===32)i.key=z.ESC+(e.ctrlKey?z.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=z.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=z.US),e.key===`@`&&(i.key=z.NUL));break}return i}var J=0,Ms=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Sa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Sa,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(J=this._search(t),J===-1)||this._getKey(this._array[J])!==t)return!1;do if(this._array[J]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(J),!0;while(++Je-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(J=this._search(e),!(J<0||J>=this._array.length)&&this._getKey(this._array[J])===e))do yield this._array[J];while(++J=this._array.length)&&this._getKey(this._array[J])===e))do t(this._array[J]);while(++J=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Ns=0,Ps=0,Fs=class extends F{constructor(){super(),this._decorations=new Ms(e=>e?.marker.line),this._onDecorationRegistered=this._register(new L),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new L),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(P(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Is(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e{Ns=t.options.x??0,Ps=Ns+(t.options.width??1),e>=Ns&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},zs=20,Bs=!1,Vs=class extends F{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;ethis._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Rs(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);Bs?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(R(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(P(()=>{Bs?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===zs+1&&(this._liveRegion.textContent+=D.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{ft(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(R(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(R(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(R(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(R(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;re?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;tthis._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;ethis._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Us(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ft(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Hs=S([C(1,Me),C(2,Ne),C(3,ve),C(4,Le)],Hs);function Us(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Ws=class extends ks{constructor(e={}){super(e),this._linkifier=this._register(new gt),this.browser=aa,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new gt),this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new L),this.onKey=this._onKey.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new L),this.onBell=this._onBell.event,this._onFocus=this._register(new L),this._onBlur=this._register(new L),this._onA11yCharEmitter=this._register(new L),this._onA11yTabEmitter=this._register(new L),this._onWillOpen=this._register(new L),this._setup(),this._decorationService=this._instantiationService.createInstance(Fs),this._instantiationService.setService(De,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ea),this._instantiationService.setService(Le,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Oe)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Tt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Tt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Tt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Tt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(P(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=H.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${z.ESC}]${n};${ps(r)}${vi.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=V.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=V.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Vs,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(R(this.element,`copy`,e=>{this.hasSelection()&&O(e,this._selectionService)}));let e=e=>k(e,this.textarea,this.coreService,this.optionsService);this._register(R(this.textarea,`paste`,e)),this._register(R(this.element,`paste`,e)),la?this._register(R(this.element,`mousedown`,e=>{e.button===2&&ie(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(R(this.element,`contextmenu`,e=>{ie(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),_a&&this._register(R(this.element,`auxclick`,e=>{e.button===1&&j(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(R(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(R(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(R(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(R(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(R(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(R(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(R(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(R(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,T.get()),va||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Qi,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(je,this._coreBrowserService),this._register(R(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(R(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ji,this._document,this._helperContainer),this._instantiationService.setService(Ae,this._charSizeService),this._themeService=this._instantiationService.createInstance(to),this._instantiationService.setService(Ie,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ki),this._instantiationService.setService(Fe,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(wa,this.rows,this.screenElement)),this._instantiationService.setService(Ne,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(yi,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ra),this._instantiationService.setService(Me,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Hs,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ui,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ka,this.element,this.screenElement,r)),this._instantiationService.setService(Pe,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Tt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(di,this.screenElement)),this._register(R(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Vs,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qi,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(R(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(R(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=z.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){A(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=js(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===z.ETX||n.key===z.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Gs(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new N)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Js=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new qs(t)}getNullCell(){return new N}},Ys=class extends F{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new L),this.onBufferChange=this._onBufferChange.event,this._normal=new Js(this._core.buffers.normal,`normal`),this._alternate=new Js(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Xs=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Zs=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Qs=[`cols`,`rows`],$s=0,ec=class extends F{constructor(e){super(),this._core=this._register(new Ws(e)),this._addonManager=this._register(new Ks),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(Qs.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new Xs(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Zs(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new Ys(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return T.get()},set promptLabel(e){T.set(e)},get tooMuchOutput(){return D.get()},set tooMuchOutput(e){D.set(e)}}}_verifyIntegers(...e){for($s of e)if($s===1/0||isNaN($s)||$s%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for($s of e)if($s&&($s===1/0||isNaN($s)||$s%1!=0||$s<0))throw Error(`This API only accepts positive integers`)}},tc=2,nc=1,rc=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(tc,Math.floor(u/e.css.cell.width)),rows:Math.max(nc,Math.floor(l/e.css.cell.height))}}},ic=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=oc.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ac(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var oc=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ac(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function cc(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var lc=class{constructor(e=cc,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||sc;this._linkProvider=this._terminal.registerLinkProvider(new ic(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},uc=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?hc.isErrorNoTelemetry(e)?new hc(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function dc(e){pc(e)||uc.onUnexpectedError(e)}var fc=`Canceled`;function pc(e){return e instanceof mc?!0:e instanceof Error&&e.name===fc&&e.message===fc}var mc=class extends Error{constructor(){super(fc),this.name=this.message}},hc=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function gc(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(vc||={});function yc(e,t){return(n,r)=>t(e(n),e(r))}var bc=(e,t)=>e-t,xc=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||vc.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};xc.empty=new xc(e=>{});function Sc(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var Cc=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function wc(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Tc;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` +`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new Cc;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` +`),e)}n.sort(yc(e=>e.idx,bc));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` + + +==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== +${s.join(` +`)} +============================================================ + +`}return n.length>e&&(a+=` + + +... and ${n.length-e} more leaking disposables + +`),{leaks:n,details:a}}};Oc.idx=0;function kc(e){Dc=e}if(Ec){let e=`__is_disposable_tracked__`;kc(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==zc.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==zc.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function Ac(e){return Dc?.trackDisposable(e),e}function jc(e){Dc?.markAsDisposed(e)}function Mc(e,t){Dc?.setParent(e,t)}function Nc(e,t){if(Dc)for(let n of e)Dc.setParent(n,t)}function Pc(e){if(Tc.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Fc(...e){let t=Ic(()=>Pc(e));return Nc(e,t),t}function Ic(e){let t=Ac({dispose:wc(()=>{jc(t),e()})});return t}var Lc=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ac(this)}dispose(){this._isDisposed||(jc(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Pc(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Mc(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Mc(e,null))}};Lc.DISABLE_DISPOSED_WARNING=!1;var Rc=Lc,zc=class{constructor(){this._store=new Rc,Ac(this),Mc(this._store,this)}dispose(){jc(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};zc.None=Object.freeze({dispose(){}});var Bc=class{constructor(){this._isDisposed=!1,Ac(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Mc(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,jc(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Mc(e,null),e}},Vc=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Vc.Undefined=new Vc(void 0);var Hc=globalThis.performance&&typeof globalThis.performance.now==`function`,Uc=class e{static create(t){return new e(t)}constructor(e){this._now=Hc&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Wc=!1,Gc=!1,Kc=!1,qc;(e=>{e.None=()=>zc.None;function t(e){if(Kc){let{onDidAddListener:t}=e,n=$c.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(Fc(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new sl(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new sl(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new sl({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new sl({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new sl({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function ee(e){return new Promise(t=>r(e)(t))}e.toPromise=ee;function te(e){let t=new sl;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=te;function S(e,t){return e(e=>t.fire(e))}e.forward=S;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new sl(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Rc?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(qc||={});var Jc=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Uc,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Jc.all=new Set,Jc._idPool=0;var Yc=Jc,Xc=-1,Zc=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof rl)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` +`)),e.length=0)},3e3),ol=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var sl=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Xc>0||this._options?.leakWarningThreshold?new Qc(e?.onListenerError??dc,this._options?.leakWarningThreshold??Xc):void 0,this._perfMon=this._options?._profName?new Yc(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Gc){let e=this._listeners;queueMicrotask(()=>{al(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new tl(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||dc)(n),zc.None}if(this._disposed)return zc.None;t&&(e=e.bind(t));let r=new rl(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=$c.create(),i=this._leakageMon.check(r.stack,this._size+1)),Gc&&(r.stack=$c.create()),this._listeners?this._listeners instanceof rl?(this._deliveryQueue??=new cl,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Ic(()=>{ol?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof Rc?n.add(a):Array.isArray(n)&&n.push(a),ol){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);ol.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*il<=t.length){let e=0;for(let n=0;n0}},cl=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ll=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ul;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof dl?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ll})})(ul||={});var dl=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ll:(this._emitter||=new sl,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},fl=`en`,pl=!1,ml=!1,hl=fl,gl,_l=globalThis,vl;typeof _l.vscode<`u`&&typeof _l.vscode.process<`u`?vl=_l.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(vl=process);var yl=typeof vl?.versions?.electron==`string`&&vl?.type===`renderer`;if(typeof vl==`object`){vl.platform,vl.platform,pl=vl.platform===`linux`,pl&&vl.env.SNAP&&vl.env.SNAP_REVISION,vl.env.CI||vl.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hl=fl;let e=vl.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,hl=t.resolvedLanguage||fl,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!yl?(gl=navigator.userAgent,gl.indexOf(`Windows`),gl.indexOf(`Macintosh`),(gl.indexOf(`Macintosh`)>=0||gl.indexOf(`iPad`)>=0||gl.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,pl=gl.indexOf(`Linux`)>=0,gl?.indexOf(`Mobi`),ml=!0,hl=globalThis._VSCODE_NLS_LANGUAGE||fl,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);ml&&typeof _l.importScripts==`function`&&_l.origin;var bl=gl,xl=hl,Sl;(e=>{function t(){return xl}e.value=t;function n(){return xl.length===2?xl===`en`:xl.length>=3?xl[0]===`e`&&xl[1]===`n`&&xl[2]===`-`:!1}e.isDefaultVariant=n;function r(){return xl===`en`}e.isDefault=r})(Sl||={});var Cl=typeof _l.postMessage==`function`&&!_l.importScripts;(()=>{if(Cl){let e=[];_l.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),_l.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var wl=!!(bl&&bl.indexOf(`Chrome`)>=0);bl&&bl.indexOf(`Firefox`),!wl&&bl&&bl.indexOf(`Safari`),bl&&bl.indexOf(`Edg/`),bl&&bl.indexOf(`Android`);function Tl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Ic(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var El;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(El||={});var Dl=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new sl,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Dl.EMPTY=Dl.fromArray([]);var Ol=class extends zc{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Bc),this._linesCacheDisposables=this._register(new Bc),this._register(Ic(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Fc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Tl(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},kl=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Al=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t=c[t+1];)t++;let r=t;for(;r=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;ethis.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){Pc(n)}}}clearHighlightDecorations(){Pc(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>Pc(e))),s.push(i)}}return s.length===0?void 0:s}},Ml=class extends zc{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new sl)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;tthis._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ic(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Tl(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.rowt[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Lu.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Lu.createPropertyValue(0,n,r)}},zl=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Wl.isErrorNoTelemetry(e)?new Wl(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Bl(e){Hl(e)||zl.onUnexpectedError(e)}var Vl=`Canceled`;function Hl(e){return e instanceof Ul?!0:e instanceof Error&&e.name===Vl&&e.message===Vl}var Ul=class extends Error{constructor(){super(Vl),this.name=this.message}},Wl=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function Gl(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}function Kl(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Jl||={});function Yl(e,t){return(n,r)=>t(e(n),e(r))}var Xl=(e,t)=>e-t,Zl=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Jl.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Zl.empty=new Zl(e=>{});function Ql(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var $l=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}},eu;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` +`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new $l;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` +`),e)}n.sort(Yl(e=>e.idx,Xl));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` + + +==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== +${s.join(` +`)} +============================================================ + +`}return n.length>e&&(a+=` + + +... and ${n.length-e} more leaking disposables + +`),{leaks:n,details:a}}};ru.idx=0;function iu(e){nu=e}if(tu){let e=`__is_disposable_tracked__`;iu(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==mu.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==mu.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function au(e){return nu?.trackDisposable(e),e}function ou(e){nu?.markAsDisposed(e)}function su(e,t){nu?.setParent(e,t)}function cu(e,t){if(nu)for(let n of e)nu.setParent(n,t)}function lu(e){if(eu.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function uu(...e){let t=du(()=>lu(e));return cu(e,t),t}function du(e){let t=au({dispose:Gl(()=>{ou(t),e()})});return t}var fu=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,au(this)}dispose(){this._isDisposed||(ou(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{lu(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return su(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),su(e,null))}};fu.DISABLE_DISPOSED_WARNING=!1;var pu=fu,mu=class{constructor(){this._store=new pu,au(this),su(this._store,this)}dispose(){ou(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};mu.None=Object.freeze({dispose(){}});var hu=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};hu.Undefined=new hu(void 0);var gu=globalThis.performance&&typeof globalThis.performance.now==`function`,_u=class e{static create(t){return new e(t)}constructor(e){this._now=gu&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},vu=!1,yu=!1,bu=!1,xu;(e=>{e.None=()=>mu.None;function t(e){if(bu){let{onDidAddListener:t}=e,n=Du.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(uu(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new Fu(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new Fu(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Fu({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Fu({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Fu({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function ee(e){return new Promise(t=>r(e)(t))}e.toPromise=ee;function te(e){let t=new Fu;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=te;function S(e,t){return e(e=>t.fire(e))}e.forward=S;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new Fu(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof pu?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(xu||={});var Su=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new _u,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Su.all=new Set,Su._idPool=0;var Cu=Su,wu=-1,Tu=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof ju)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` +`)),e.length=0)},3e3),Pu=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var Fu=class{constructor(e){this._size=0,this._options=e,this._leakageMon=wu>0||this._options?.leakWarningThreshold?new Eu(e?.onListenerError??Bl,this._options?.leakWarningThreshold??wu):void 0,this._perfMon=this._options?._profName?new Cu(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(yu){let e=this._listeners;queueMicrotask(()=>{Nu(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new ku(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Bl)(n),mu.None}if(this._disposed)return mu.None;t&&(e=e.bind(t));let r=new ju(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Du.create(),i=this._leakageMon.check(r.stack,this._size+1)),yu&&(r.stack=Du.create()),this._listeners?this._listeners instanceof ju?(this._deliveryQueue??=new Iu,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=du(()=>{Pu?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof pu?n.add(a):Array.isArray(n)&&n.push(a),Pu){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Pu.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Mu<=t.length){let e=0;for(let n=0;n0}},Iu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Lu=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Fu,this.onChange=this._onChange.event;let e=new Rl;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Ru=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],zu=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],Bu=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],Vu=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],Hu;function Uu(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(en&&(n=e)}return Lu.createPropertyValue(0,n,r)}},Gu=class{activate(e){e.unicode.register(new Wu)}dispose(){}},Ku=Object.defineProperty,qu=Object.getOwnPropertyDescriptor,Ju=(e,t,n,r)=>{for(var i=r>1?void 0:r?qu(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ku(t,n,i),i},Yu=(e,t)=>(n,r)=>t(n,r,e),Xu=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?td.isErrorNoTelemetry(e)?new td(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Zu(e){$u(e)||Xu.onUnexpectedError(e)}var Qu=`Canceled`;function $u(e){return e instanceof ed?!0:e instanceof Error&&e.name===Qu&&e.message===Qu}var ed=class extends Error{constructor(){super(Qu),this.name=this.message}},td=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}};function nd(e,t,n=0,r=e.length){let i=n,a=r;for(;i{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(id||={});function ad(e,t){return(n,r)=>t(e(n),e(r))}var od=(e,t)=>e-t,sd=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||id.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};sd.empty=new sd(e=>{});function cd(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var ld=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function ud(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var dd;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);tt.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(` +`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new ld;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(` +`),e)}n.sort(ad(e=>e.idx,od));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;tr(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=` + + +==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ==================== +${s.join(` +`)} +============================================================ + +`}return n.length>e&&(a+=` + + +... and ${n.length-e} more leaking disposables + +`),{leaks:n,details:a}}};md.idx=0;function hd(e){pd=e}if(fd){let e=`__is_disposable_tracked__`;hd(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==Td.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==Td.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function gd(e){return pd?.trackDisposable(e),e}function _d(e){pd?.markAsDisposed(e)}function vd(e,t){pd?.setParent(e,t)}function yd(e,t){if(pd)for(let n of e)pd.setParent(n,t)}function bd(e){if(dd.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function xd(...e){let t=Sd(()=>bd(e));return yd(e,t),t}function Sd(e){let t=gd({dispose:ud(()=>{_d(t),e()})});return t}var Cd=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,gd(this)}dispose(){this._isDisposed||(_d(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{bd(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return vd(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),vd(e,null))}};Cd.DISABLE_DISPOSED_WARNING=!1;var wd=Cd,Td=class{constructor(){this._store=new wd,gd(this),vd(this._store,this)}dispose(){_d(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Td.None=Object.freeze({dispose(){}});var Ed=class{constructor(){this._isDisposed=!1,gd(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&vd(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,_d(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&vd(e,null),e}},Dd=typeof process<`u`&&`title`in process,Od=Dd?`node`:navigator.userAgent,kd=Dd?`node`:navigator.platform,Ad=Od.includes(`Firefox`),jd=Od.includes(`Edge`),Md=/^((?!chrome|android).)*safari/i.test(Od);function Nd(){if(!Md)return 0;let e=Od.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(kd),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(kd),kd.indexOf(`Linux`),/\bCrOS\b/.test(Od);var Pd=``,Fd=0,Id=0,Ld=0,Y=0,Rd={css:`#00000000`,rgba:0},zd;(e=>{function t(e,t,n,r){return r===void 0?`#${Wd(e)}${Wd(t)}${Wd(n)}`:`#${Wd(e)}${Wd(t)}${Wd(n)}${Wd(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(zd||={});var Bd;(e=>{function t(e,t){if(Y=(t.rgba&255)/255,Y===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Fd=a+Math.round((n-a)*Y),Id=o+Math.round((r-o)*Y),Ld=s+Math.round((i-s)*Y),{css:zd.toCss(Fd,Id,Ld),rgba:zd.toRgba(Fd,Id,Ld)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Ud.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return zd.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Fd,Id,Ld]=Ud.toChannels(t),{css:zd.toCss(Fd,Id,Ld),rgba:t}}e.opaque=i;function a(e,t){return Y=Math.round(t*255),[Fd,Id,Ld]=Ud.toChannels(e.rgba),{css:zd.toCss(Fd,Id,Ld,Y),rgba:zd.toRgba(Fd,Id,Ld,Y)}}e.opacity=a;function o(e,t){return Y=e.rgba&255,a(e,Y*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Bd||={});var Vd;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Fd=parseInt(e.slice(1,2).repeat(2),16),Id=parseInt(e.slice(2,3).repeat(2),16),Ld=parseInt(e.slice(3,4).repeat(2),16),zd.toColor(Fd,Id,Ld);case 5:return Fd=parseInt(e.slice(1,2).repeat(2),16),Id=parseInt(e.slice(2,3).repeat(2),16),Ld=parseInt(e.slice(3,4).repeat(2),16),Y=parseInt(e.slice(4,5).repeat(2),16),zd.toColor(Fd,Id,Ld,Y);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Fd=parseInt(r[1]),Id=parseInt(r[2]),Ld=parseInt(r[3]),Y=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),zd.toColor(Fd,Id,Ld,Y);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Fd,Id,Ld,Y]=t.getImageData(0,0,1,1).data,Y!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:zd.toRgba(Fd,Id,Ld,Y),css:e}}e.toColor=r})(Vd||={});var Hd;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Hd||={});var Ud;(e=>{function t(e,t){if(Y=(t&255)/255,Y===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Fd=a+Math.round((n-a)*Y),Id=o+Math.round((r-o)*Y),Ld=s+Math.round((i-s)*Y),zd.toRgba(Fd,Id,Ld)}e.blend=t;function n(e,t,n){let a=Hd.relativeLuminance(e>>8),o=Hd.relativeLuminance(t>>8);if(Gd(a,o)>8));if(sGd(a,Hd.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Gd(a,Hd.relativeLuminance(s>>8));if(cGd(a,Hd.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Gd(Hd.relativeLuminance2(o,s,c),Hd.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Gd(Hd.relativeLuminance2(o,s,c),Hd.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Gd(Hd.relativeLuminance2(o,s,c),Hd.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Ud||={});function Wd(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Gd(e,t){return e=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function Zd(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Xd(e)&&!Kd(e)&&!Jd(e)}function Qd(e){return Kd(e)||Yd(e)}function $d(){return{css:{canvas:ef(),cell:ef()},device:{canvas:ef(),cell:ef(),char:{width:0,height:0,left:0,top:0}}}}function ef(){return{width:0,height:0}}function tf(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var nf=0,rf=0,af=!1,of=!1,sf=!1,cf,lf=0,uf=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,rf=0,nf=0,of=!1,af=!1,sf=!1,cf=this._themeService.colors,lf=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));lf=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(rf=e.backgroundColorRGB.rgba>>8&16777215,of=!0),e.foregroundColorRGB&&(nf=e.foregroundColorRGB.rgba>>8&16777215,af=!0)}),sf=this._selectionRenderModel.isCellSelected(this._terminal,t,n),sf){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:rf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:rf=(this.result.fg&16777215)<<8|255;break;case 0:default:rf=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:rf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:rf=(this.result.bg&16777215)<<8|255;break}rf=Ud.blend(rf,(this._coreBrowserService.isFocused?cf.selectionBackgroundOpaque:cf.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else rf=(this._coreBrowserService.isFocused?cf.selectionBackgroundOpaque:cf.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(of=!0,cf.selectionForeground&&(nf=cf.selectionForeground.rgba>>8&16777215,af=!0),Qd(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))nf=(this._coreBrowserService.isFocused?cf.selectionBackgroundOpaque:cf.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:nf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:nf=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:nf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:nf=(this.result.fg&16777215)<<8|255;break;case 0:default:nf=this._themeService.colors.foreground.rgba}nf=Ud.blend(nf,(this._coreBrowserService.isFocused?cf.selectionBackgroundOpaque:cf.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}af=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(rf=e.backgroundColorRGB.rgba>>8&16777215,of=!0),e.foregroundColorRGB&&(nf=e.foregroundColorRGB.rgba>>8&16777215,af=!0)}),of&&(rf=sf?e.bg&-150994944|rf|50331648:e.bg&-16777216|rf|50331648),af&&(nf=e.fg&-83886080|nf|50331648),this.result.fg&67108864&&(of&&!af&&(nf=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|cf.background.rgba>>8&16777215|50331648,af=!0),!of&&af&&(rf=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|cf.foreground.rgba>>8&16777215|50331648,of=!0)),cf=void 0,this.result.bg=of?rf:this.result.bg,this.result.fg=af?nf:this.result.fg,this.result.ext&=536870911,this.result.ext|=lf<<29&3758096384}},df=.5,ff=Ad||jd?`bottom`:`ideographic`,pf={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},mf={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},hf={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},gf={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};gf[``]=gf[``],gf[``]=gf[``];function _f(e,t,n,r,i,a,o,s){let c=pf[t];if(c)return vf(e,c,n,r,i,a),!0;let l=mf[t];if(l)return bf(e,l,n,r,i,a),!0;let u=hf[t];if(u)return xf(e,u,n,r,i,a,s),!0;let d=gf[t];return d?(Sf(e,d,n,r,i,a,o,s),!0):!1}function vf(e,t,n,r,i,a){for(let o=0;o7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;ee.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function Tf(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;ei){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},kf=class extends Of{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Af=class extends Of{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},jf=!Dd&&`requestIdleCallback`in window?Af:kf,Mf=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Nf}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Nf=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pf=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Pf.Undefined=new Pf(void 0);var Ff=globalThis.performance&&typeof globalThis.performance.now==`function`,If=class e{static create(t){return new e(t)}constructor(e){this._now=Ff&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Lf=!1,Rf=!1,zf=!1,Bf;(e=>{e.None=()=>Td.None;function t(e){if(zf){let{onDidAddListener:t}=e,n=Kf.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(xd(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new Z(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new Z(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Z({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function ee(e){return new Promise(t=>r(e)(t))}e.toPromise=ee;function te(e){let t=new Z;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=te;function S(e,t){return e(e=>t.fire(e))}e.forward=S;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new Z(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof wd?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Bf||={});var Vf=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new If,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Vf.all=new Set,Vf._idPool=0;var Hf=Vf,Uf=-1,Wf=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t{if(e instanceof Xf)t(e);else for(let n=0;n{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(` +`)),e.length=0)},3e3),$f=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Uf>0||this._options?.leakWarningThreshold?new Gf(e?.onListenerError??Zu,this._options?.leakWarningThreshold??Uf):void 0,this._perfMon=this._options?._profName?new Hf(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Rf){let e=this._listeners;queueMicrotask(()=>{Qf(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Jf(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Zu)(n),Td.None}if(this._disposed)return Td.None;t&&(e=e.bind(t));let r=new Xf(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Kf.create(),i=this._leakageMon.check(r.stack,this._size+1)),Rf&&(r.stack=Kf.create()),this._listeners?this._listeners instanceof Xf?(this._deliveryQueue??=new ep,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Sd(()=>{$f?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof wd?n.add(a):Array.isArray(n)&&n.push(a),$f){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);$f.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Zf<=t.length){let e=0;for(let n=0;n0}},ep=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},tp={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},np=2,rp,ip=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new Df,this._cacheMapCombined=new Df,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Mf,this._textureSize=512,this._onAddTextureAtlasCanvas=new Z,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Z,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=cp(e,this._config.deviceCellWidth*4+np*2,this._config.deviceCellHeight+np*2),this._tmpCtx=X(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new jf;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;ee.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new ap(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new ap(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return Rd;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=Mf.toColorRGB(t);i=zd.toColor(e[0],e[1],e[2]);break;default:i=n?Bd.opaque(this._config.colors.foreground):this._config.colors.background;break}return this._config.allowTransparency||(i=Bd.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=Mf.toColorRGB(a);d=zd.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=Bd.opaque(d)),s&&(d=Bd.multiplyOpacity(d,df)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=Ud.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=zd.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+np*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=tf(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!E&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*ne,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,T,T+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*ne,T+t),this._tmpCtx.stroke()}if(E||this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=op(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,D);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight-t),e=op(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,D),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*ne,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let re=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),O;if(O=this._config.allowTransparency?sp(re):op(re,x,w,D),O)return tp;let k=this._findGlyphBoundingBox(re,this._workBoundingBox,c,C,E,T),A,j;for(;;){if(this._activePages.length===0){let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y;break}A=this._activePages[this._activePages.length-1],j=A.currentRow;for(let e of this._activePages)k.size.y<=e.currentRow.height&&(A=e,j=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=j.height&&k.size.y<=t.height&&(A=this._activePages[e],j=t);if(k.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new ap(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),A=this._overflowSizePage,j=this._overflowSizePage.currentRow,j.x+k.size.x>=A.canvas.width&&(j.x=0,j.y+=j.height,j.height=0);break}if(j.y+k.size.y>=A.canvas.height||j.height>k.size.y+2){let t=!1;if(A.currentRow.y+A.currentRow.height+k.size.y>=A.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+k.size.y=e.maxAtlasPages&&j.y+k.size.y<=A.canvas.height&&j.height>=k.size.y&&j.x+k.size.x<=A.canvas.width)t=!0;else{let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y,t=!0}}t||(A.currentRow.height>0&&A.fixedRows.push(A.currentRow),j={x:0,y:A.currentRow.y+A.currentRow.height,height:k.size.y},A.fixedRows.push(j),A.currentRow={x:0,y:j.y+j.height,height:0})}if(j.x+k.size.x<=A.canvas.width)break;j===A.currentRow?(j.x=0,j.y+=j.height,j.height=0):A.fixedRows.splice(A.fixedRows.indexOf(j),1)}return k.texturePage=this._pages.indexOf(A),k.texturePosition.x=j.x,k.texturePosition.y=j.y,k.texturePositionClipSpace.x=j.x/A.canvas.width,k.texturePositionClipSpace.y=j.y/A.canvas.height,k.sizeClipSpace.x/=A.canvas.width,k.sizeClipSpace.y/=A.canvas.height,j.height=Math.max(j.height,k.size.y),j.x+=k.size.x,A.ctx.putImageData(re,k.texturePosition.x-this._workBoundingBox.left,k.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,k.size.x,k.size.y),A.addGlyph(k),A.version++,k}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n=a;n--){for(let r=0;r=0;n--){for(let r=0;r>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t0)return!1;return!0}function cp(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function lp(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:Rd,cursorAccent:Rd,selectionForeground:Rd,selectionBackgroundTransparent:Rd,selectionBackgroundOpaque:Rd,selectionInactiveBackgroundTransparent:Rd,selectionInactiveBackgroundOpaque:Rd,overviewRulerBorder:Rd,scrollbarSliderBackground:Rd,scrollbarSliderHoverBackground:Rd,scrollbarSliderActiveBackground:Rd,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function up(e,t){for(let n=0;n=0){if(up(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),fp.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=hp){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=hp-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=hp-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},hp)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function _p(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return Sd(()=>r?.disconnect())}function vp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var yp=class e extends Mf{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nf,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?vp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},bp=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function xp(e,t,n){let r=X(e.createProgram());if(e.attachShader(r,X(Sp(e,e.VERTEX_SHADER,t))),e.attachShader(r,X(Sp(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function Sp(e,t,n){let r=X(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function Cp(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=X(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=X(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(Sd(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(Sd(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(Sd(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Op,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Op,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Op,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Op,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Op,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Op,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(ip.maxAtlasPages);for(let e=0;ei.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){if(Q=(n*this._terminal.cols+t)*Dp,r===0||r===void 0){e.fill(0,Q,Q+Dp-1-kp);return}this._atlas&&($=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),Ap=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&$.offset.x>Ap?(jp=$.offset.x-Ap,e[Q]=-($.offset.x-jp)+this._dimensions.device.char.left,e[Q+1]=-$.offset.y+this._dimensions.device.char.top,e[Q+2]=($.size.x-jp)/this._dimensions.device.canvas.width,e[Q+3]=$.size.y/this._dimensions.device.canvas.height,e[Q+4]=$.texturePage,e[Q+5]=$.texturePositionClipSpace.x+jp/this._atlas.pages[$.texturePage].canvas.width,e[Q+6]=$.texturePositionClipSpace.y,e[Q+7]=$.sizeClipSpace.x-jp/this._atlas.pages[$.texturePage].canvas.width,e[Q+8]=$.sizeClipSpace.y):(e[Q]=-$.offset.x+this._dimensions.device.char.left,e[Q+1]=-$.offset.y+this._dimensions.device.char.top,e[Q+2]=$.size.x/this._dimensions.device.canvas.width,e[Q+3]=$.size.y/this._dimensions.device.canvas.height,e[Q+4]=$.texturePage,e[Q+5]=$.texturePositionClipSpace.x,e[Q+6]=$.texturePositionClipSpace.y,e[Q+7]=$.sizeClipSpace.x,e[Q+8]=$.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Zd(r,c,$.size.x,this._dimensions.device.cell.width)&&(e[Q+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*Dp;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function Pp(){return new Np}var Fp=4,Ip=1,Lp=2,Rp=3,zp=2147483648,Bp=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=Pp()}resize(e,t){let n=e*t*Fp;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Vp=`#version 300 es +layout (location = 0) in vec2 a_position; +layout (location = 1) in vec2 a_size; +layout (location = 2) in vec4 a_color; +layout (location = 3) in vec2 a_unitquad; + +uniform mat4 u_projection; + +out vec4 v_color; + +void main() { + vec2 zeroToOne = a_position + (a_unitquad * a_size); + gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0); + v_color = a_color; +}`,Hp=`#version 300 es +precision lowp float; + +in vec4 v_color; + +out vec4 outColor; + +void main() { + outColor = v_color; +}`,Up=8,Wp=Up*Float32Array.BYTES_PER_ELEMENT,Gp=20*Up,Kp=class{constructor(){this.attributes=new Float32Array(Gp),this.count=0}},qp=0,Jp=0,Yp=0,Xp=0,Zp=0,Qp=0,$p=0,em=class extends Td{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Kp,this._verticesCursor=new Kp;let i=this._gl;this._program=X(xp(i,Vp,Hp)),this._register(Sd(()=>i.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(Sd(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(Sd(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(Sd(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Wp,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Wp,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Wp,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,bp),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i>24&255)/255,Zp=(qp>>16&255)/255,Qp=(qp>>8&255)/255,$p=1,this._addRectangle(e.attributes,t,Jp,Yp,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Xp,Zp,Qp,$p)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},tm=class extends Td{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(Sd(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=X(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=pp(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=ff,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},nm=class extends tm{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&dp(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t=0;!(sm.indexOf(`Chrome`)>=0)&&sm.indexOf(`Safari`),sm.indexOf(`Electron/`),sm.indexOf(`Android`);var lm=!1;if(typeof rm.matchMedia==`function`){let e=rm.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=rm.matchMedia(`(display-mode: fullscreen)`);lm=e.matches,om(rm,e,({matches:e})=>{lm&&t.matches||(lm=e)})}function um(){return lm}var dm=`en`,fm=!1,pm=!1,mm=!1,hm=dm,gm,_m=globalThis,vm;typeof _m.vscode<`u`&&typeof _m.vscode.process<`u`?vm=_m.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(vm=process);var ym=typeof vm?.versions?.electron==`string`&&vm?.type===`renderer`;if(typeof vm==`object`){vm.platform,vm.platform,fm=vm.platform===`linux`,fm&&vm.env.SNAP&&vm.env.SNAP_REVISION,vm.env.CI||vm.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hm=dm;let e=vm.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,hm=t.resolvedLanguage||dm,t.languagePack?.translationsConfigFile}catch{}pm=!0}else typeof navigator==`object`&&!ym?(gm=navigator.userAgent,gm.indexOf(`Windows`),gm.indexOf(`Macintosh`),(gm.indexOf(`Macintosh`)>=0||gm.indexOf(`iPad`)>=0||gm.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,fm=gm.indexOf(`Linux`)>=0,gm?.indexOf(`Mobi`),mm=!0,hm=globalThis._VSCODE_NLS_LANGUAGE||dm,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var bm=pm;mm&&typeof _m.importScripts==`function`&&_m.origin;var xm=gm,Sm=hm,Cm;(e=>{function t(){return Sm}e.value=t;function n(){return Sm.length===2?Sm===`en`:Sm.length>=3?Sm[0]===`e`&&Sm[1]===`n`&&Sm[2]===`-`:!1}e.isDefaultVariant=n;function r(){return Sm===`en`}e.isDefault=r})(Cm||={});var wm=typeof _m.postMessage==`function`&&!_m.importScripts;(()=>{if(wm){let e=[];_m.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),_m.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Tm=!!(xm&&xm.indexOf(`Chrome`)>=0);xm&&xm.indexOf(`Firefox`),!Tm&&xm&&xm.indexOf(`Safari`),xm&&xm.indexOf(`Edg/`),xm&&xm.indexOf(`Android`);var Em=typeof navigator==`object`?navigator:{};bm||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Em&&Em.clipboard&&Em.clipboard.writeText,bm||Em&&Em.clipboard&&Em.clipboard.readText,bm||um()||Em.keyboard,`ontouchstart`in rm||Em.maxTouchPoints,rm.PointerEvent&&(`ontouchstart`in rm||navigator.maxTouchPoints);var Dm=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Om=new Dm,km=new Dm,Am=new Dm;Array(230);var jm;(e=>{function t(e){return Om.keyCodeToStr(e)}e.toString=t;function n(e){return Om.strToKeyCode(e)}e.fromString=n;function r(e){return km.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Am.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return km.strToKeyCode(e)||Am.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Om.keyCodeToStr(e)}e.toElectronAccelerator=o})(jm||={});var Mm=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Nm;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Pm?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Bf.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Mm})})(Nm||={});var Pm=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Mm:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Fm;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(Fm||={});var Im=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Im.EMPTY=Im.fromArray([]);function Lm(e){return 55296<=e&&e<=56319}function Rm(e){return 56320<=e&&e<=57343}function zm(e,t){return(e-55296<<10)+(t-56320)+65536}function Bm(e){return Vm(e,0)}function Vm(e,t){switch(typeof e){case`object`:return e===null?Hm(349,t):Array.isArray(e)?Gm(e,t):Km(e,t);case`string`:return Wm(e,t);case`boolean`:return Um(e,t);case`number`:return Hm(e,t);case`undefined`:return Hm(937,t);default:return Hm(617,t)}}function Hm(e,t){return(t<<5)-t+e|0}function Um(e,t){return Hm(e?433:863,t)}function Wm(e,t){t=Hm(149417,t);for(let n=0,r=e.length;nVm(t,e),t)}function Km(e,t){return t=Hm(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Wm(n,t),Vm(e[n],t)),t)}function qm(e,t,n=32){let r=n-t,i=~((1<>>r)>>>0}function Jm(e,t=0,n=e.byteLength,r=0){for(let i=0;ie.toString(16).padStart(2,`0`)).join(``):Ym((e>>>0).toString(16),t/4)}var Zm=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Lm(a))if(o+1>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),Xm(this._h0)+Xm(this._h1)+Xm(this._h2)+Xm(this._h3)+Xm(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Jm(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Jm(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,qm(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=qm(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=qm(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};Zm._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:Qm,getWindow:$m,getDocument:eh,getWindows:th,getWindowsCount:nh,getWindowId:rh,getWindowById:ih,hasWindow:ah,onDidRegisterWindow:oh,onWillUnregisterWindow:sh,onDidUnregisterWindow:ch}=function(){let e=new Map,t={window:rm,disposables:new wd};e.set(rm.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Td.None;let a=new wd,o={window:t,disposables:a.add(new wd)};return e.set(t.vscodeWindowId,o),a.add(Sd(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(uh(t,fh.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:rm},getDocument(e){return $m(e).document}}}(),lh=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function uh(e,t,n,r){return new lh(e,t,n,r)}var dh=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};dh.None=new dh(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Bm(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(Sd(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var fh={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:cm?`webkitAnimationStart`:`animationstart`,ANIMATION_END:cm?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:cm?`webkitAnimationIteration`:`animationiteration`},ph=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function mh(e,t,n,...r){let i=ph.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function hh(e,t,...n){return mh(`http://www.w3.org/1999/xhtml`,e,t,...n)}hh.SVG=function(e,t,...n){return mh(`http://www.w3.org/2000/svg`,e,t,...n)};var gh=class extends Td{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new Ed,this._charAtlasDisposable=this._register(new Ed),this._observerDisposable=this._register(new Ed),this._model=new Bp,this._workCell=new yp,this._workCell2=new yp,this._rectangleRenderer=this._register(new Ed),this._glyphRenderer=this._register(new Ed),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new uf(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new nm(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=$d(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(uh(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(uh(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,mp(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=_p(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=_p(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Sd(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),mp(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new em(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Mp(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=pp(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=xd(Bf.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Bf.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new gp(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=vh(e,n.rows-1,0),t=vh(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,ee=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,te=ee-n.buffer.ydisp,S=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),C=-1,w=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let T=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=ee===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v=p[1],d?(l=!0,r=new _h(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*Fp,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),w&&o===ee&&(y===S&&(this._model.cursor={x:S,y:te,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},C=S+r.getWidth()-1),y>=S&&y<=C&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),!(this._model.cells[v]===g&&this._model.cells[v+Ip]===this._cellColorResolver.result.bg&&this._model.cells[v+Lp]===this._cellColorResolver.result.fg&&this._model.cells[v+Rp]===this._cellColorResolver.result.ext)&&(T=!0,h.length>1&&(g|=zp),this._model.cells[v]=g,this._model.cells[v+Ip]=this._cellColorResolver.result.bg,this._model.cells[v+Lp]=this._cellColorResolver.result.fg,this._model.cells[v+Rp]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*Fp,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,Pd,0,0),this._model.cells[b]=0,this._model.cells[b+Ip]=this._cellColorResolver.result.bg,this._model.cells[b+Lp]=this._cellColorResolver.result.fg,this._model.cells[b+Rp]=this._cellColorResolver.result.ext;y--}}T&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},_h=class extends Mf{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function vh(e,t,n=0){return Math.max(Math.min(e,t),n)}var yh=`di$target`,bh=`di$dependencies`,xh=new Map;function Sh(e){if(xh.has(e))return xh.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ch(t,e,r)};return t._id=e,xh.set(e,t),t}function Ch(e,t,n){t[yh]===t?t[bh].push({id:e,index:n}):(t[bh]=[{id:e,index:n}],t[yh]=t)}Sh(`BufferService`),Sh(`CoreMouseService`),Sh(`CoreService`),Sh(`CharsetService`),Sh(`InstantiationService`),Sh(`LogService`);var wh=Sh(`OptionsService`);Sh(`OscLinkService`),Sh(`UnicodeService`),Sh(`DecorationService`);var Th={trace:0,debug:1,info:2,warn:3,error:4,off:5},Eh=`xterm.js: `,Dh=class extends Td{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Oh=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Th[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new gh(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(Bf.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Bf.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Bf.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Bf.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(Sd(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},Ah=class{aliases;usage;matches(e){let t=e.toLowerCase();return t===this.name.toLowerCase()||(this.aliases?.some(e=>t===e.toLowerCase())??!1)}writeLine(e,t,n){n?e.writeln(`${n}${t}\x1b[0m`):e.writeln(t)}writeSuccess(e,t){e.writeln(`\x1b[1;32m✓\x1b[0m ${t}`)}writeError(e,t){e.writeln(`\x1b[1;31m✗ Error:\x1b[0m ${t}`)}writeInfo(e,t){e.writeln(`\x1b[90m${t}\x1b[0m`)}startLoading(e,t){let n=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],r=0,i=!0,a=setInterval(()=>{if(!i){clearInterval(a);return}e.write(`\r\x1b[36m${n[r]}\x1b[0m ${t}`),r=(r+1)%n.length},80);return()=>{i=!1,clearInterval(a),e.write(`\r\x1B[K`)}}},jh=class extends Ah{name=`help`;description=`Show available commands`;aliases=[`?`,`h`];constructor(e){super(),this.commands=e}execute({term:e,writePrompt:t}){e.writeln(``),e.writeln(`\x1B[1;33mAvailable Commands:\x1B[0m`),e.writeln(``),this.commands.forEach(t=>{let n=t.aliases?.length?` (${t.aliases.join(`, `)})`:``;e.writeln(` \x1b[1;36m${t.name.padEnd(15)}\x1b[0m ${t.description}${n}`)}),e.writeln(``),e.writeln(`\x1B[90mTip: Use Tab for autocomplete, ↑↓ for history, Ctrl+F to search\x1B[0m`),t()}},Mh=class extends Ah{name=`clear`;description=`Clear terminal screen`;aliases=[`cls`];execute({term:e,writePrompt:t}){e.clear(),t()}},Nh=class extends Ah{name=`status`;description=`Show repeater status`;aliases=[`st`];execute({term:e,writePrompt:t}){let n=g().stats;if(n&&typeof n==`object`){this.writeSuccess(e,`Repeater Status:`),e.writeln(``);for(let[t,r]of Object.entries(n))e.writeln(` \x1b[36m${t.padEnd(20)}\x1b[0m ${r}`)}else this.writeError(e,`No status data available`);t()}},Ph=class extends Ah{name=`uptime`;description=`Show system uptime`;execute({term:e,writePrompt:t}){let n=g().stats?.uptime_seconds||0;this.writeSuccess(e,this.formatUptime(n)),t()}formatUptime(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}},Fh=class extends Ah{name=`packets`;description=`Show packet statistics`;isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}execute({term:e,writePrompt:t}){let n=g().stats;this.writeLine(e,``),this.isMobile()?(this.writeLine(e,` \x1B[1;36mPacket Statistics\x1B[0m`),this.writeLine(e,` \x1B[90mRX:\x1B[0m `+(n?.rx_count||0)),this.writeLine(e,` \x1B[90mTX:\x1B[0m `+(n?.tx_count||0)),this.writeLine(e,` \x1B[90mForward:\x1B[0m `+(n?.forwarded_count||0)),this.writeLine(e,` \x1B[90mDropped:\x1B[0m `+(n?.dropped_count||0))):(this.writeLine(e,` \x1B[36m┌──────────┬──────────┐\x1B[0m`),this.writeLine(e,` \x1B[36m│\x1B[0m \x1B[1mMetric\x1B[0m \x1B[36m│\x1B[0m \x1B[1mCount\x1B[0m \x1B[36m│\x1B[0m`),this.writeLine(e,` \x1B[36m├──────────┼──────────┤\x1B[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m RX \x1b[36m│\x1b[0m ${String(n?.rx_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m TX \x1b[36m│\x1b[0m ${String(n?.tx_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m Forward \x1b[36m│\x1b[0m ${String(n?.forwarded_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1b[36m│\x1b[0m Dropped \x1b[36m│\x1b[0m ${String(n?.dropped_count||0).padStart(8)} \x1b[36m│\x1b[0m`),this.writeLine(e,` \x1B[36m└──────────┴──────────┘\x1B[0m`)),this.writeLine(e,``),t()}},Ih=class extends Ah{name=`board`;description=`Show board information`;execute({term:e,writePrompt:t}){let n=g().stats?.board_info||`pyMC_Repeater (Linux/RPi)`;this.writeSuccess(e,n),t()}},Lh=class extends Ah{name=`advert`;description=`Send neighbor advert immediately`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Sending advert...`);try{let t=await h.post(`/send_advert`,{},{timeout:1e4});n(),t.success?this.writeSuccess(e,t.data||`Advert sent successfully`):this.writeError(e,t.error||`Failed to send advert`)}catch(t){n(),this.writeError(e,`Failed to send advert: ${t}`)}t()}},Rh=class extends Ah{name=`get`;description=`Get configuration values (name, freq, tx, mode, duty, etc.)`;matches(e){let t=e.toLowerCase();return t===`get`||t.startsWith(`get `)}execute({term:e,args:t,writePrompt:n}){let r=t[0]?.toLowerCase();if(!r){this.writeError(e,`Usage: get `),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeLine(e,``),this.writeLine(e,` \x1B[36mname\x1B[0m Node name`),this.writeLine(e,` \x1B[36mrole\x1B[0m Node role`),this.writeLine(e,` \x1B[36mlat\x1B[0m Latitude`),this.writeLine(e,` \x1B[36mlon\x1B[0m Longitude`),this.writeLine(e,` \x1B[36mfreq\x1B[0m Frequency (MHz)`),this.writeLine(e,` \x1B[36mtx\x1B[0m TX power (dBm)`),this.writeLine(e,` \x1B[36mbw\x1B[0m Bandwidth (kHz)`),this.writeLine(e,` \x1B[36msf\x1B[0m Spreading factor`),this.writeLine(e,` \x1B[36mcr\x1B[0m Coding rate`),this.writeLine(e,` \x1B[36mradio\x1B[0m All radio settings`),this.writeLine(e,` \x1B[36mtxdelay\x1B[0m TX delay factor`),this.writeLine(e,` \x1B[36mdirect.txdelay\x1B[0m Direct TX delay`),this.writeLine(e,` \x1B[36mrxdelay\x1B[0m RX delay base`),this.writeLine(e,` \x1B[36maf\x1B[0m Airtime factor`),this.writeLine(e,` \x1B[36mmode\x1B[0m Repeater mode`),this.writeLine(e,` \x1B[36mrepeat\x1B[0m Repeat on/off`),this.writeLine(e,` \x1B[36mflood.max\x1B[0m Max flood hops`),this.writeLine(e,` \x1B[36madvert.interval\x1B[0m Advert interval`),this.writeLine(e,` \x1B[36mduty\x1B[0m Duty cycle enabled`),this.writeLine(e,` \x1B[36mduty.max\x1B[0m Max airtime %`),this.writeLine(e,` \x1B[36mpublic.key\x1B[0m Public key`),this.writeLine(e,``),n();return}let i=g().stats;if(!i){this.writeError(e,`System stats not available`),n();return}{let t=i,a=t.config||{},o=a.radio||{},s=a.repeater||{},c=a.delays||{},l=a.duty_cycle||{},u=``;switch(r){case`name`:u=a.node_name||`Unknown`;break;case`role`:u=`repeater`;break;case`lat`:u=s.latitude==null?`not set`:String(s.latitude);break;case`lon`:u=s.longitude==null?`not set`:String(s.longitude);break;case`freq`:u=o.frequency?`${(o.frequency/1e6).toFixed(3)} MHz`:`?`;break;case`tx`:u=o.tx_power==null?`?`:`${o.tx_power}dBm`;break;case`bw`:u=o.bandwidth?`${o.bandwidth/1e3} kHz`:`?`;break;case`sf`:u=o.spreading_factor==null?`?`:String(o.spreading_factor);break;case`cr`:u=o.coding_rate==null?`?`:`4/${o.coding_rate}`;break;case`radio`:if(o.frequency){this.writeSuccess(e,`Radio Configuration:`),this.writeLine(e,``),this.writeLine(e,` \x1b[36mFrequency:\x1b[0m ${(o.frequency/1e6).toFixed(3)} MHz`),this.writeLine(e,` \x1b[36mBandwidth:\x1b[0m ${o.bandwidth/1e3} kHz`),this.writeLine(e,` \x1b[36mSpreading Factor:\x1b[0m ${o.spreading_factor}`),this.writeLine(e,` \x1b[36mCoding Rate:\x1b[0m 4/${o.coding_rate}`),this.writeLine(e,` \x1b[36mTX Power:\x1b[0m ${o.tx_power}dBm`),this.writeLine(e,``),n();return}else u=`Radio configuration not available`;break;case`af`:case`txdelay`:u=c.tx_delay_factor==null?`\x1B[90mnot set (default: 1.0)\x1B[0m`:String(c.tx_delay_factor);break;case`direct.txdelay`:u=c.direct_tx_delay_factor==null?`\x1B[90mnot set (default: 0.5)\x1B[0m`:String(c.direct_tx_delay_factor);break;case`rxdelay`:u=c.rx_delay_base==null?`\x1B[90mnot set (default: 0.0s)\x1B[0m`:`${c.rx_delay_base}s`;break;case`mode`:u=s.mode==null?`\x1B[90mnot set (default: forward)\x1B[0m`:s.mode;break;case`repeat`:u=s.mode==null?`\x1B[90mnot set (default: on)\x1B[0m`:s.mode===`forward`?`on`:`off`;break;case`flood.max`:u=s.max_flood_hops==null?`\x1B[90mnot set (default: 3)\x1B[0m`:String(s.max_flood_hops);break;case`flood.advert.interval`:u=s.send_advert_interval_hours==null?`\x1B[90mnot set\x1B[0m`:`${s.send_advert_interval_hours}h`;break;case`advert.interval`:u=s.advert_interval_minutes==null?`\x1B[90mnot set (default: 120m)\x1B[0m`:`${s.advert_interval_minutes}m`;break;case`duty`:case`duty.enabled`:u=l.enforcement_enabled==null?`\x1B[90mnot set (default: off)\x1B[0m`:l.enforcement_enabled?`on`:`off`;break;case`duty.max`:u=l.max_airtime_percent==null?`\x1B[90mnot set\x1B[0m`:`${l.max_airtime_percent}%`;break;case`public.key`:u=t.public_key||`\x1B[90mnot available\x1B[0m`;break;case`prv.key`:this.writeWarning(e,`Private key not exposed via API for security`),this.writeInfo(e,`Check /etc/pymc_repeater/config.yaml`),n();return;case`guest.password`:case`allow.read.only`:this.writeWarning(e,`Security settings not exposed via API`),this.writeInfo(e,`Check /etc/pymc_repeater/config.yaml`),n();return;default:this.writeError(e,`Unknown parameter: ${r}`),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeInfo(e,` Identity: name, role, lat, lon`),this.writeInfo(e,` Radio: freq, tx, bw, sf, cr, radio`),this.writeInfo(e,` Timing: txdelay, direct.txdelay, rxdelay, af`),this.writeInfo(e,` Repeater: mode, repeat, flood.max, advert.interval`),this.writeInfo(e,` Duty: duty, duty.max`),this.writeInfo(e,` Security: public.key`),n();return}this.writeSuccess(e,u)}n()}writeWarning(e,t){e.writeln(`\x1b[1;33m⚠ Warning:\x1b[0m ${t}`)}},zh=class extends Ah{name=`set`;description=`Set configuration values (tx, txdelay, mode, duty, etc.)`;matches(e){let t=e.toLowerCase();return t===`set`||t.startsWith(`set `)}async execute({term:e,args:t,writePrompt:n}){let r=t[0]?.toLowerCase(),i=t.slice(1).join(` `).trim();if(!r){this.writeError(e,`Usage: set `),this.writeLine(e,``),this.writeInfo(e,`Available parameters:`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mRadio:\x1B[0m`),this.writeLine(e,` \x1B[36mtx <2-30>\x1B[0m TX power in dBm`),this.writeLine(e,` \x1B[36mfreq \x1B[0m Frequency (100-1000 MHz) *restart required*`),this.writeLine(e,` \x1B[36mbw \x1B[0m Bandwidth (7.8-500 kHz) *restart required*`),this.writeLine(e,` \x1B[36msf <5-12>\x1B[0m Spreading factor *restart required*`),this.writeLine(e,` \x1B[36mcr <5-8>\x1B[0m Coding rate (for 4/5 to 4/8) *restart required*`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mTiming:\x1B[0m`),this.writeLine(e,` \x1B[36mtxdelay <0.0-5.0>\x1B[0m TX delay factor`),this.writeLine(e,` \x1B[36mdirect.txdelay <0.0-5.0>\x1B[0m Direct TX delay factor`),this.writeLine(e,` \x1B[36mrxdelay \x1B[0m RX delay base (>= 0)`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mIdentity:\x1B[0m`),this.writeLine(e,` \x1B[36mname \x1B[0m Node name`),this.writeLine(e,` \x1B[36mlat <-90 to 90>\x1B[0m Latitude`),this.writeLine(e,` \x1B[36mlon <-180 to 180>\x1B[0m Longitude`),this.writeLine(e,``),this.writeLine(e,` \x1B[33mRepeater:\x1B[0m`),this.writeLine(e,` \x1B[36mmode \x1B[0m Repeater mode`),this.writeLine(e,` \x1B[36mduty \x1B[0m Duty cycle enforcement`),this.writeLine(e,` \x1B[36mflood.max <0-64>\x1B[0m Max flood hops`),this.writeLine(e,` \x1B[36madvert.interval \x1B[0m Local advert interval`),this.writeLine(e,``),n();return}let a=this.startLoading(e,`Updating configuration...`);try{let t;switch(r){case`tx`:{let r=parseInt(i);if(isNaN(r)||r<2||r>30){a(),this.writeError(e,`TX power must be 2-30 dBm`),n();return}t=await h.post(`/update_radio_config`,{tx_power:r},{timeout:3e4});break}case`freq`:{let r=parseFloat(i);if(isNaN(r)||r<100||r>1e3){a(),this.writeError(e,`Frequency must be 100-1000 MHz`),n();return}t=await h.post(`/update_radio_config`,{frequency:r*1e6},{timeout:3e4});break}case`bw`:{let r=parseFloat(i),o=[7.8,10.4,15.6,20.8,31.25,41.7,62.5,125,250,500];if(isNaN(r)||!o.includes(r)){a(),this.writeError(e,`Bandwidth must be one of: ${o.join(`, `)} kHz`),n();return}t=await h.post(`/update_radio_config`,{bandwidth:r*1e3},{timeout:3e4});break}case`sf`:{let r=parseInt(i);if(isNaN(r)||r<5||r>12){a(),this.writeError(e,`Spreading factor must be 5-12`),n();return}t=await h.post(`/update_radio_config`,{spreading_factor:r},{timeout:3e4});break}case`cr`:{let r=parseInt(i);if(isNaN(r)||r<5||r>8){a(),this.writeError(e,`Coding rate must be 5-8 (for 4/5 to 4/8)`),n();return}t=await h.post(`/update_radio_config`,{coding_rate:r},{timeout:3e4});break}case`af`:case`txdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0||r>5){a(),this.writeError(e,`TX delay factor must be 0.0-5.0`),n();return}t=await h.post(`/update_radio_config`,{tx_delay_factor:r},{timeout:3e4});break}case`direct.txdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0||r>5){a(),this.writeError(e,`Direct TX delay factor must be 0.0-5.0`),n();return}t=await h.post(`/update_radio_config`,{direct_tx_delay_factor:r},{timeout:3e4});break}case`rxdelay`:{let r=parseFloat(i);if(isNaN(r)||r<0){a(),this.writeError(e,`RX delay must be >= 0`),n();return}t=await h.post(`/update_radio_config`,{rx_delay_base:r},{timeout:3e4});break}case`name`:if(!i.trim()){a(),this.writeError(e,`Node name cannot be empty`),n();return}t=await h.post(`/update_radio_config`,{node_name:i.trim()},{timeout:3e4});break;case`lat`:{let r=parseFloat(i);if(isNaN(r)||r<-90||r>90){a(),this.writeError(e,`Latitude must be -90 to 90`),n();return}t=await h.post(`/update_radio_config`,{latitude:r},{timeout:3e4});break}case`lon`:{let r=parseFloat(i);if(isNaN(r)||r<-180||r>180){a(),this.writeError(e,`Longitude must be -180 to 180`),n();return}t=await h.post(`/update_radio_config`,{longitude:r},{timeout:3e4});break}case`mode`:{let r=i.toLowerCase();if(r!==`forward`&&r!==`monitor`&&r!==`no_tx`){a(),this.writeError(e,`Mode must be "forward", "monitor", or "no_tx"`),this.writeLine(e,``),this.writeInfo(e,`Valid values:`),this.writeLine(e,` \x1B[36mforward\x1B[0m - Forward packets`),this.writeLine(e,` \x1B[36mmonitor\x1B[0m - Monitor only (no forwarding)`),this.writeLine(e,` \x1B[36mno_tx\x1B[0m - No repeat, no local TX; adverts skipped`),n();return}t=await h.post(`/set_mode`,{mode:r},{timeout:3e4}),t.data&&(t.data.applied=[`mode=${r}`],t.data.persisted=!0,t.data.live_update=!0);break}case`duty`:{let r=i.toLowerCase();if(r!==`on`&&r!==`off`){a(),this.writeError(e,`Duty cycle must be "on" or "off"`),this.writeLine(e,``),this.writeInfo(e,`Valid values:`),this.writeLine(e,` \x1B[36mon\x1B[0m - Enable duty cycle enforcement`),this.writeLine(e,` \x1B[36moff\x1B[0m - Disable duty cycle enforcement`),n();return}let o=r===`on`;t=await h.post(`/set_duty_cycle`,{enabled:o},{timeout:3e4}),t.data&&(t.data.applied=[`duty=${r}`],t.data.persisted=!0,t.data.live_update=!0);break}case`flood.max`:{let r=parseInt(i);if(isNaN(r)||r<0||r>64){a(),this.writeError(e,`Max flood hops must be 0-64`),n();return}t=await h.post(`/update_radio_config`,{max_flood_hops:r},{timeout:3e4});break}case`flood.advert.interval`:{let r=parseInt(i);if(isNaN(r)||r!==0&&(r<3||r>48)){a(),this.writeError(e,`Flood advert interval must be 0 (off) or 3-48 hours`),n();return}t=await h.post(`/update_radio_config`,{flood_advert_interval_hours:r},{timeout:3e4});break}case`advert.interval`:{let r=parseInt(i);if(isNaN(r)||r!==0&&(r<1||r>10080)){a(),this.writeError(e,`Advert interval must be 0 (off) or 1-10080 minutes`),n();return}t=await h.post(`/update_radio_config`,{advert_interval_minutes:r},{timeout:3e4});break}case`log`:a(),this.writeWarning(e,`Log level configuration not yet implemented`),this.writeInfo(e,`Backend endpoint /set_log_level does not exist`),n();return;default:a(),this.writeError(e,`Unknown parameter: ${r}`),this.writeLine(e,``),this.writeInfo(e,`Type "set" without arguments to see available parameters`),n();return}a();let o=t.data||t;t.success?(o.applied&&o.applied.length>0?this.writeSuccess(e,`Configuration updated: ${o.applied.join(`, `)}`):this.writeSuccess(e,`Configuration updated`),g().fetchStats(),o.restart_required?(this.writeLine(e,``),this.writeWarning(e,`⚠ Service restart required for changes to take effect`),this.writeInfo(e,`Run: sudo systemctl restart pymc_repeater`)):o.message&&!o.live_update&&(this.writeLine(e,``),this.writeInfo(e,o.message))):this.writeError(e,t.error||`Failed to update configuration`)}catch(t){a(),this.writeError(e,`Failed to update ${r}: ${t}`)}this.writeLine(e,``),n()}writeWarning(e,t){e.writeln(`\x1b[1;33m⚠ Warning:\x1b[0m ${t}`)}},Bh=class extends Ah{name=`identities`;description=`List all identities`;aliases=[`id`,`ids`];isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching identities...`);try{let t=await h.getIdentities();n();let r=[];if(t.success&&t.data){let e=t.data,n=e.registered||[],i=e.configured||[];r=i.length>0?i:n}else Array.isArray(t)&&(r=t);r.length===0?this.writeInfo(e,`No identities found`):(this.writeSuccess(e,`Found \x1b[1m${r.length}\x1b[0m identit${r.length===1?`y`:`ies`}`),e.writeln(``),this.isMobile()?r.forEach((t,n)=>{e.writeln(`\x1b[1;36m[${n+1}] ${t.name||`Unnamed`}\x1b[0m`),e.writeln(` \x1b[90mType:\x1b[0m ${t.type||`-`}`),e.writeln(` \x1b[90mHash:\x1b[0m ${t.hash||`-`}`),e.writeln(` \x1b[90mAddress:\x1b[0m ${t.address||`-`}`),e.writeln(` \x1b[90mRegistered:\x1b[0m ${t.registered?`\x1B[32myes\x1B[0m`:`\x1B[31mno\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.name||`Unnamed`).padEnd(27),a=(t.type||`-`).padEnd(13),o=(t.hash||`-`).padEnd(4),s=(t.address||`-`).padEnd(7),c=(t.registered?`yes`:`no`).padEnd(10);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴─────────────────────────────┴───────────────┴──────┴─────────┴────────────┘\x1B[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch identities`)}t()}},Vh=class extends Ah{name=`keys`;description=`List transport keys`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching transport keys...`);try{let t=await h.getTransportKeys();n();let r=t.success&&t.data?t.data:t,i=Array.isArray(r)?r:[];i.length===0?this.writeInfo(e,`No transport keys found`):(this.writeSuccess(e,`Found \x1b[1m${i.length}\x1b[0m transport key${i.length===1?``:`s`}`),e.writeln(``),i.forEach((t,n)=>{e.writeln(`\x1b[36m${(n+1).toString().padStart(2)}.\x1b[0m \x1b[1m${t.name||`Unnamed`}\x1b[0m`),t.flood_policy&&e.writeln(` Policy: \x1b[90m${t.flood_policy}\x1b[0m`),t.parent_id&&e.writeln(` Parent: \x1b[90m${t.parent_id}\x1b[0m`),n{if(e.writeln(`\x1b[1;36m[${n+1}] ${t.node_name||`Unknown`}\x1b[0m`),e.writeln(` \x1b[90mPubKey:\x1b[0m ${t.pubkey?.substring(0,8)||`----`}`),e.writeln(` \x1b[90mType:\x1b[0m ${t.contact_type||`-`}`),t.last_seen){let n=new Date(t.last_seen*1e3).toLocaleString(`en-US`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1});e.writeln(` \x1b[90mLast Seen:\x1b[0m ${n}`)}t.rssi&&e.writeln(` \x1b[90mRSSI:\x1b[0m ${t.rssi}`),t.snr&&e.writeln(` \x1b[90mSNR:\x1b[0m ${t.snr}`),e.writeln(` \x1b[90mAdverts:\x1b[0m ${t.advert_count||0}`),e.writeln(` \x1b[90mDirect:\x1b[0m ${t.zero_hop?`\x1B[32myes\x1B[0m`:`\x1B[31mno\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.node_name||`Unknown`).padEnd(20),a=(t.pubkey?.substring(0,4)||`----`).padEnd(6),o=(t.contact_type||`-`).padEnd(12),s=t.last_seen?new Date(t.last_seen*1e3).toLocaleString(`en-US`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).padEnd(20):`-`.padEnd(20),c=(t.rssi?`${t.rssi}`:`-`).padEnd(8),l=(t.snr?`${t.snr}`:`-`).padEnd(4),u=(t.advert_count?.toString()||`0`).padEnd(6),d=(t.zero_hop?`yes`:`no`).padEnd(6);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m ${l} \x1b[36m│\x1b[0m ${u} \x1b[36m│\x1b[0m ${d} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴──────────────────────┴────────┴──────────────┴──────────────────────┴──────────┴──────┴────────┴────────┘\x1B[0m`)),r.length>10&&(e.writeln(``),e.writeln(`\x1b[90m... and ${r.length-10} more neighbors\x1b[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch neighbors`)}t()}},Uh=class extends Ah{name=`acl`;description=`Show ACL statistics`;async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching ACL stats...`);try{let t=await h.getACLStats();n();let r=t.success&&t.data?t.data:t;if(r&&typeof r==`object`){this.writeSuccess(e,`ACL Statistics:`),e.writeln(``);let t=(n,r=` `)=>{if(typeof n==`object`&&n&&!Array.isArray(n))for(let[i,a]of Object.entries(n))typeof a==`object`&&a?(e.writeln(`${r}\x1b[90m${i}:\x1b[0m`),t(a,r+` `)):e.writeln(`${r}\x1b[90m${i.padEnd(18)}\x1b[0m ${a}`);else e.writeln(`${r}${n}`)};for(let[n,i]of Object.entries(r))typeof i==`object`&&i?(e.writeln(` \x1b[36m${n}\x1b[0m`),t(i,` `)):e.writeln(` \x1b[36m${n.padEnd(20)}\x1b[0m ${i}`)}else this.writeError(e,`No ACL data available`)}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch ACL stats`)}t()}},Wh=class extends Ah{name=`rooms`;description=`List room servers`;isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<768}async execute({term:e,writePrompt:t}){let n=this.startLoading(e,`Fetching room stats...`);try{let t=await h.getRoomStats();n();let r=[];t.success&&t.data?r=t.data.rooms||(Array.isArray(t.data)?t.data:[]):Array.isArray(t)&&(r=t),r.length===0?this.writeInfo(e,`No room servers found`):(this.writeSuccess(e,`Found \x1b[1m${r.length}\x1b[0m room server${r.length===1?``:`s`}`),e.writeln(``),this.isMobile()?r.forEach((t,n)=>{e.writeln(`\x1b[1;36m[${n+1}] ${t.room_name||`Unnamed`}\x1b[0m`),e.writeln(` \x1b[90mMessages:\x1b[0m ${t.total_messages||0}`),e.writeln(` \x1b[90mTotal Clients:\x1b[0m ${t.total_clients||0}`),e.writeln(` \x1b[90mActive Clients:\x1b[0m ${t.active_clients||0}`),e.writeln(` \x1b[90mSync:\x1b[0m ${t.sync_running?`\x1B[32mrunning\x1B[0m`:`\x1B[31mstopped\x1B[0m`}`),n{let r=(n+1).toString().padEnd(2),i=(t.room_name||`Unnamed`).padEnd(27),a=(t.total_messages?.toString()||`0`).padEnd(8),o=(t.total_clients?.toString()||`0`).padEnd(12),s=(t.active_clients?.toString()||`0`).padEnd(14),c=(t.sync_running?`running`:`stopped`).padEnd(8);e.writeln(`\x1b[36m│\x1b[0m ${r} \x1b[36m│\x1b[0m \x1b[1m${i}\x1b[0m \x1b[36m│\x1b[0m ${a} \x1b[36m│\x1b[0m ${o} \x1b[36m│\x1b[0m ${s} \x1b[36m│\x1b[0m ${c} \x1b[36m│\x1b[0m`)}),e.writeln(`\x1B[36m└────┴─────────────────────────────┴──────────┴──────────────┴────────────────┴──────────┘\x1B[0m`)))}catch(t){n(),this.writeError(e,t instanceof Error?t.message:`Failed to fetch room stats`)}t()}},Gh=class extends Ah{name=`restart`;description=`Restart the pymc-repeater service`;aliases=[`reboot`];matches(e){let t=e.toLowerCase();return t===`restart`||t===`reboot`}async execute({term:e,writePrompt:t}){this.writeLine(e,``),this.writeLine(e,`\x1B[33m⚠️ This will restart the repeater service!\x1B[0m`),this.writeLine(e,``),this.writeInfo(e,`Attempting to restart service...`);let n=this.startLoading(e,`Restarting...`);try{let r=await h.post(`/restart_service`,{},{timeout:1e4});if(n(),r.success){this.writeLine(e,``),this.writeSuccess(e,`Service restart initiated`),this.writeLine(e,``),await this.waitForServiceRestart(e,t);return}else this.writeLine(e,``),this.writeError(e,`Restart failed: `+(r.error||r.message||`Unknown error`)),this.writeLine(e,``),this.writeInfo(e,`You may need to manually restart: sudo systemctl restart pymc-repeater`)}catch(r){n(),this.writeLine(e,``);let i=r;if(i.code===`ERR_NETWORK`||i.message?.includes(`Network error`)||i.message?.includes(`ECONNRESET`)||i.code===`ECONNRESET`){this.writeSuccess(e,`Service restart initiated successfully`),this.writeLine(e,``),await this.waitForServiceRestart(e,t);return}else if(i.code===`ECONNABORTED`||i.message?.includes(`timeout`)){this.writeSuccess(e,`Service restart initiated successfully`),this.writeLine(e,``),await this.waitForServiceRestart(e,t);return}else i.response?.status===403||i.response?.status===401?(this.writeError(e,`Permission denied. Polkit rules may need configuration.`),this.writeLine(e,``),this.writeInfo(e,`Run: sudo bash -c 'mkdir -p /etc/polkit-1/rules.d && cat > /etc/polkit-1/rules.d/10-pymc-repeater.rules <0;t--)e.write(`\r\x1b[36m⏳\x1b[0m Restarting service... ${t}s`),await new Promise(e=>setTimeout(e,1e3));e.write(`\r\x1B[K`);let a=n,o=0,s=0;for(;a=5){e.write(`\r\x1B[K`),this.writeLine(e,``),this.writeSuccess(e,`Service is back online! (took ~${a}s)`),this.writeLine(e,``),t();return}}else s=0}catch(t){s=0;let n=t;n.code&&![`ERR_NETWORK`,`ECONNREFUSED`,`ECONNRESET`].includes(n.code)&&e.write(`[${n.code}] `)}await new Promise(e=>setTimeout(e,i*1e3)),a+=i}e.write(`\r\x1B[K`),this.writeLine(e,``),this.writeLine(e,`\x1B[33m⚠️ Service did not respond within 60 seconds\x1B[0m`),this.writeLine(e,``),this.writeInfo(e,`The service may still be starting. Try: status`),this.writeLine(e,``),t()}},Kh=class extends Ah{name=`ping`;description=`Ping a neighbor node to measure latency and signal quality`;usage=`ping [timeout_seconds]`;async execute({term:e,args:t,writePrompt:n}){if(t.length===0){this.writeError(e,`Missing target node`),e.writeln(``),this.writeInfo(e,`Usage: ${this.usage}`),e.writeln(``),this.writeInfo(e,`Examples:`),this.writeInfo(e,` ping MyNeighbor - Ping node by name`),this.writeInfo(e,` ping 0xb5 - Ping node by pubkey hash`),this.writeInfo(e,` ping MyNeighbor 20 - Ping with 20s timeout`),n();return}let r=t[0],i=t.length>1?parseInt(t[1]):10;if(isNaN(i)||i<1||i>60){this.writeError(e,`Invalid timeout. Must be between 1-60 seconds`),n();return}let a=null,o=r.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(o)a=`0x${o[2].padStart(2,`0`)}`;else{let t=this.startLoading(e,`Resolving target...`);try{let i=[`Chat Node`,`Repeater`,`Room Server`,`Hybrid Node`,`Unknown`],o=!1;for(let e of i)try{let t=await h.get(`/adverts_by_contact_type`,{contact_type:e,hours:168}),n=t.success&&t.data?t.data:t,i=(Array.isArray(n)?n:[]).find(e=>e.node_name&&e.node_name.toLowerCase()===r.toLowerCase());if(i&&i.pubkey){a=`0x${i.pubkey.substring(0,2)}`,o=!0;break}}catch{continue}if(t(),!o){this.writeError(e,`Node '${r}' not found in neighbors`),e.writeln(``),this.writeInfo(e,`Try: neighbors - to list available nodes`),n();return}}catch(r){t(),this.writeError(e,`Failed to resolve target: ${r}`),n();return}}this.writeLine(e,`\x1b[36mPinging ${r} (${a}) with ${i}s timeout...\x1b[0m`),e.writeln(``);let s=this.startLoading(e,`Waiting for response...`);try{let t=await h.pingNeighbor(a,i);if(s(),t.success&&t.data){let n=t.data;this.writeSuccess(e,`Reply from ${r} (${n.target_id})`),e.writeln(``);let i=`\x1B[32m`;if(n.rtt_ms>500?i=`\x1B[31m`:n.rtt_ms>250&&(i=`\x1B[33m`),e.writeln(` \x1b[1mRound-Trip Time:\x1b[0m ${i}${n.rtt_ms.toFixed(2)} ms\x1b[0m`),e.writeln(` \x1b[1mRSSI:\x1b[0m ${n.rssi} dBm`),e.writeln(` \x1b[1mSNR:\x1b[0m ${n.snr_db} dB`),n.path&&n.path.length>0){let t=n.path.join(` → `),r=n.path.length;e.writeln(` \x1b[1mPath:\x1b[0m ${t}`),e.writeln(` \x1b[1mHops:\x1b[0m ${r}`)}e.writeln(``);let a=`Excellent`,o=`\x1B[32m`;n.rtt_ms>500||n.rssi<-120?(a=`Poor`,o=`\x1B[31m`):n.rtt_ms>250||n.rssi<-100?(a=`Fair`,o=`\x1B[33m`):(n.rtt_ms>100||n.rssi<-80)&&(a=`Good`,o=`\x1B[36m`),e.writeln(` \x1b[1mLink Quality:\x1b[0m ${o}${a}\x1b[0m`)}else this.writeError(e,t.error||`Ping failed`)}catch(t){s(),this.writeError(e,`Ping failed: ${t.message||t}`)}e.writeln(``),n()}};async function qh(){try{let e=[`Chat Node`,`Repeater`,`Room Server`,`Hybrid Node`,`Unknown`],t=[];for(let n of e)try{let e=await h.get(`/adverts_by_contact_type`,{contact_type:n,hours:168}),r=e.success&&e.data?e.data:e;(Array.isArray(r)?r:[]).forEach(e=>{e.node_name&&!t.includes(e.node_name)&&t.push(e.node_name)})}catch{continue}return t.sort()}catch{return[]}}var Jh=class{commands=[];constructor(){let e=new Mh,t=new Nh,n=new Ph,r=new Fh,i=new Ih,a=new Lh,o=new Rh,s=new zh,c=new Bh,l=new Vh,u=new Hh,d=new Uh,f=new Wh,p=new Gh,m=new Kh;this.commands=[new jh([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m]),e,t,n,r,i,a,o,s,c,l,u,d,f,p,m]}findCommand(e){return this.commands.find(t=>t.matches(e))}getAllCommands(){return this.commands}getCommandNames(){return this.commands.map(e=>e.name)}},Yh={class:`space-y-4 md:space-y-6`},Xh={class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-3 md:p-4`},Zh={class:`flex items-center justify-between`},Qh={class:`flex items-center gap-2 md:gap-3`},$h=[`title`],eg={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},tg={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},ng={class:`hidden sm:inline`},rg=[`title`],ig={class:`hidden sm:inline`},ag=[`title`],og={key:0,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},sg={key:1,class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},cg={class:`hidden sm:inline`},lg={key:0,class:`glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] p-4`},ug={class:`flex items-center gap-3`},dg=[`onKeydown`],fg={key:1,class:`absolute top-4 right-4 bg-black/80 backdrop-blur-sm px-3 py-2 rounded-lg border border-primary/30 flex items-center gap-2`},pg=_(o({name:`TerminalView`,__name:`Terminal`,setup(o){let{theme:h}=v(),g={background:`#1A1E1F`,foreground:`#e0e0e0`,cursor:`#00d9ff`,cursorAccent:`#000000`,selectionBackground:`#00d9ff40`,selectionForeground:`#ffffff`,black:`#000000`,red:`#ff6b6b`,green:`#51cf66`,yellow:`#ffd93d`,blue:`#00d9ff`,magenta:`#e599f7`,cyan:`#00d9ff`,white:`#e0e0e0`,brightBlack:`#6c757d`,brightRed:`#ff8787`,brightGreen:`#69db7c`,brightYellow:`#ffe066`,brightBlue:`#74c0fc`,brightMagenta:`#f3a6ff`,brightCyan:`#3bc9db`,brightWhite:`#ffffff`},_={background:`#F3F4F6`,foreground:`#1f2937`,cursor:`#0D7377`,cursorAccent:`#ffffff`,selectionBackground:`#0D737740`,selectionForeground:`#000000`,black:`#1f2937`,red:`#dc2626`,green:`#15803d`,yellow:`#a16207`,blue:`#0D7377`,magenta:`#7c3aed`,cyan:`#0e7490`,white:`#f3f4f6`,brightBlack:`#6b7280`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#0891b2`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`},y=a(null),b=a(null),x=a(null),ee=a(``),te=a(!1),S=a(!1),C=a(!1),w=a(!1),T=a(!1);a(0);let E=null,D=null,ne=null,re=null,O=``,k=[],A=-1,j=``,ie=new Jh,ae=ie.getCommandNames(),oe=[],se=0,ce={get:[`name`,`role`,`lat`,`lon`,`freq`,`tx`,`bw`,`sf`,`cr`,`radio`,`txdelay`,`direct.txdelay`,`rxdelay`,`af`,`mode`,`repeat`,`flood.max`,`advert.interval`,`duty`,`duty.max`,`public.key`],set:[`tx`,`freq`,`bw`,`sf`,`cr`,`txdelay`,`direct.txdelay`,`rxdelay`,`name`,`lat`,`lon`,`mode`,`duty`,`flood.max`,`advert.interval`,`flood.advert.interval`],ping:[]},le={set:{mode:[`forward`,`monitor`],duty:[`on`,`off`]}},ue={get:{name:`Node name`,role:`Node role`,lat:`Latitude`,lon:`Longitude`,freq:`Frequency (MHz)`,tx:`TX power (dBm)`,bw:`Bandwidth (kHz)`,sf:`Spreading factor`,cr:`Coding rate`,radio:`All radio settings`,txdelay:`TX delay factor`,"direct.txdelay":`Direct TX delay`,rxdelay:`RX delay base`,af:`Airtime factor`,mode:`Repeater mode`,repeat:`Repeat on/off`,"flood.max":`Max flood hops`,"advert.interval":`Advert interval`,duty:`Duty cycle enabled`,"duty.max":`Max airtime %`,"public.key":`Public key`},set:{tx:`TX power (2-30 dBm)`,freq:`Frequency (100-1000 MHz) *restart required*`,bw:`Bandwidth (7.8-500 kHz) *restart required*`,sf:`Spreading factor (5-12) *restart required*`,cr:`Coding rate (5-8) *restart required*`,txdelay:`TX delay factor (0.0-5.0)`,"direct.txdelay":`Direct TX delay (0.0-5.0)`,rxdelay:`RX delay base (>= 0)`,name:`Node name`,lat:`Latitude (-90 to 90)`,lon:`Longitude (-180 to 180)`,mode:`Repeater mode (forward/monitor/no_tx)`,duty:`Duty cycle (on/off)`,"flood.max":`Max flood hops (0-64)`,"advert.interval":`Advert interval (0 or 1-10080 mins)`,"flood.advert.interval":`Flood advert (0 or 3-48 hrs)`},ping:{}};n(()=>{if(!y.value)return;C.value=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),E=new ec({cursorBlink:!1,cursorStyle:`underline`,cursorWidth:3,fontFamily:`"JetBrains Mono", "Fira Code", Menlo, Monaco, "Courier New", monospace`,fontSize:window.innerWidth<768?11:13,fontWeight:`400`,fontWeightBold:`700`,lineHeight:1.3,letterSpacing:.5,smoothScrollDuration:50,scrollSensitivity:3,fastScrollSensitivity:5,allowProposedApi:!0,screenReaderMode:C.value,theme:h.value===`dark`?g:_,scrollback:C.value?500:1e4,tabStopWidth:4,macOptionIsMeta:!0}),D=new rc,E.loadAddon(D);try{re=new kh,E.loadAddon(re)}catch{console.warn(`WebGL addon failed to load, falling back to canvas renderer`),re=null}let e=new lc((e,t)=>{window.open(t,`_blank`)});E.loadAddon(e);let n=new Gu;if(E.loadAddon(n),E.unicode.activeVersion=`11`,ne=new Nl,E.loadAddon(ne),E.open(y.value),D.fit(),E.focus(),C.value&&b.value){let e=b.value,n=()=>{e.focus({preventScroll:!1})};y.value?.addEventListener(`click`,n),y.value?.addEventListener(`touchstart`,n),e.addEventListener(`input`,()=>{setTimeout(()=>{E?.scrollToBottom()},10)}),t(()=>{y.value?.removeEventListener(`click`,n),y.value?.removeEventListener(`touchstart`,n)})}let r=h.value===`dark`?`\x1B[1;37m`:`\x1B[1;90m`;h.value;let i=(h.value,`\x1B[90m`),a=`\x1B[0m`;E.writeln(``),E.writeln(`${r} ██████ ██ ██ ███ ███ ██████${a}`),E.writeln(`${r} ██ ██ ██ ██ ████ ████ ██ ${a}`),E.writeln(`${r} ██████ ████ ██ ████ ██ ██ ${a}`),E.writeln(`${r} ██ ██ ██ ██ ██ ██ ${a}`),E.writeln(`${r} ██ ██ ██ ██ ██████${a}`),E.writeln(``),E.writeln(` Repeater Terminal${a}`),E.writeln(``),E.writeln(`${i} Type help${i} for available commands${a}`),E.writeln(``),M(),E.onData(e=>{fe(e)});let o=new ResizeObserver(()=>{D?.fit()});o.observe(y.value),t(()=>{o.disconnect(),re?.dispose(),re=null,E?.dispose(),E=null})});let M=()=>{E?.write(`\r +\x1B[1;36m❯\x1B[0m `)},de=e=>{if(!(!E||!e)){E.write(`\x1b[90m${e}\x1b[0m`);for(let t=0;t{if(!(!E||!j)){for(let e=0;e{if(!E)return;let t=e.charCodeAt(0);if(t===13){N(),E.write(`\r +`),O.trim()?(me(O.trim()),k.push(O.trim()),A=k.length):M(),O=``;return}if(t===127){O.length>0&&(N(),O=O.slice(0,-1),E.write(`\b \b`),pe());return}if(t===3){N(),E.write(`^C\r +`),O=``,M();return}if(t===12){E.clear(),O=``,M();return}if(t===6){te.value=!te.value;return}if(e===`\x1B[A`){k.length>0&&A>0&&(N(),A--,E.write(`\r\x1B[K`),M(),O=k[A],E.write(O));return}if(e===`\x1B[B`){N(),A2&&le[n]){let e=t[1]?.toLowerCase(),r=t.slice(2).join(` `).toLowerCase(),i=le[n][e];if(i){let e=i.filter(e=>e.toLowerCase().startsWith(r));if(e.length===1){let n=t.slice(2).join(` `),r=e[0].slice(n.length);O+=r,E.write(r)}else e.length>1&&(E.write(`\r +\r +\x1B[33mAvailable values:\x1B[0m\r +\r +`),e.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O));return}}if(t.length>1&&ce[n]){if(n===`ping`){let e=t.slice(1).join(` `).toLowerCase(),n=Date.now();n-se>3e4&&qh().then(e=>{oe=e,se=n,ce.ping=e});let r=oe.filter(t=>t.toLowerCase().startsWith(e));if(r.length===1){let e=t.slice(1).join(` `),n=r[0].slice(e.length)+` `;O+=n,E.write(n)}else r.length>1?(E.write(`\r +\r +\x1B[33mAvailable neighbors:\x1B[0m\r +\r +`),r.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O)):oe.length===0&&e===``&&(E.write(`\r +\r +\x1B[33mFetching neighbors...\x1B[0m\r +`),qh().then(e=>{oe=e,se=n,ce.ping=e,E.write(`\r +\x1B[33mAvailable neighbors:\x1B[0m\r +\r +`),e.forEach(e=>{E.writeln(` \x1b[36m${e}\x1b[0m`)}),M(),E.write(O)}).catch(()=>{E.write(`\r +\x1B[31mFailed to fetch neighbors\x1B[0m\r +`),M(),E.write(O)}));return}let e=t.slice(1).join(` `).toLowerCase(),r=ce[n].filter(t=>t.toLowerCase().startsWith(e));if(r.length===1){let e=t.slice(1).join(` `),n=r[0].slice(e.length)+` `;O+=n,E.write(n)}else if(r.length>1){E.write(`\r +\r +\x1B[33mAvailable parameters:\x1B[0m\r +\r +`);let e=ue[n]||{};r.forEach(t=>{let n=e[t]||``,r=t.padEnd(20);E.writeln(` \x1b[36m${r}\x1b[0m\x1b[90m${n}\x1b[0m`)}),M(),E.write(O)}return}let r=ie.getAllCommands().filter(t=>!!(t.name.toLowerCase().startsWith(e)||t.aliases?.some(t=>t.toLowerCase().startsWith(e))));if(r.length===1){let e=r[0].name.slice(O.length)+` `;O+=e,E.write(e)}else r.length>1&&(E.write(`\r +\r +\x1B[33mAvailable commands:\x1B[0m\r +\r +`),r.forEach(e=>{let t=e.aliases&&e.aliases.length>0?` (${e.aliases.join(`, `)})`:``;E.writeln(` \x1b[36m${e.name.padEnd(15)}\x1b[0m ${e.description}${t}`)}),M(),E.write(O));return}t>=32&&t<127&&(N(),O+=e,E.write(e),C.value||pe())},pe=()=>{if(O.length===0){j=``;return}let e=ae.filter(e=>e.startsWith(O.toLowerCase()));e.length===1&&e[0]!==O?(j=e[0].slice(O.length),de(j)):j=``},me=async e=>{if(!E)return;let[t,...n]=e.trim().split(/\s+/),r=ie.findCommand(t);if(r)try{await r.execute({term:E,args:n,writePrompt:M})}catch(e){console.error(`Command execution error:`,e),E.writeln(`\x1b[1;31m✗ Error:\x1b[0m ${e instanceof Error?e.message:`Command failed`}`),M()}else E.writeln(`\x1b[1;31m✗ Unknown command:\x1b[0m ${t}`),E.writeln(`\x1B[90mType \x1B[36mhelp\x1B[90m for available commands\x1B[0m`),M()},he=()=>{!ne||!ee.value||ne.findNext(ee.value,{caseSensitive:!1})},ge=()=>{!ne||!ee.value||ne.findPrevious(ee.value,{caseSensitive:!1})},_e=()=>{te.value=!1,ee.value=``,E?.focus()},ve=async()=>{if(x.value){if(w.value)try{document.exitFullscreen&&await document.exitFullscreen(),w.value=!1}catch(e){console.error(`Failed to exit fullscreen:`,e)}else try{x.value.requestFullscreen&&await x.value.requestFullscreen(),w.value=!0,setTimeout(()=>{C.value&&b.value?b.value.focus():E&&E.focus()},100)}catch(e){console.error(`Failed to enter fullscreen:`,e)}setTimeout(()=>{D?.fit()},100)}},ye=()=>{T.value=!T.value,T.value&&C.value&&setTimeout(()=>{window.scrollTo(0,1)},100),setTimeout(()=>{C.value&&b.value?b.value.focus():E?.focus(),D?.fit()},150)},be=()=>{T.value=!1,setTimeout(()=>{D?.fit()},100)};r(h,e=>{E&&(E.options.theme=e===`dark`?g:_)}),typeof document<`u`&&(document.addEventListener(`fullscreenchange`,()=>{w.value=!!document.fullscreenElement,setTimeout(()=>D?.fit(),100)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&!w.value&&be()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&!w.value&&be()}));let xe=()=>{C.value&&b.value&&b.value.focus()},Se=e=>{let t=e.target,n=t.value;n&&E&&fe(n.slice(-1)),t.value=``},Ce=()=>{E&&fe(`\r`),b.value&&(b.value.value=``)},we=()=>{E&&fe(``),b.value&&(b.value.value=``)};return(t,n)=>(s(),u(`div`,Yh,[l(`div`,Xh,[l(`div`,Zh,[n[8]||=l(`div`,null,[l(`h1`,{class:`text-content-primary dark:text-content-primary text-lg md:text-xl font-semibold`},` Terminal `),l(`p`,{class:`text-content-secondary dark:text-content-muted text-sm hidden md:block`},` Interactive command-line interface `)],-1),l(`div`,Qh,[C.value?(s(),u(`button`,{key:0,onClick:ye,class:`flex items-center gap-2 px-3 py-2 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:T.value?`Exit fullscreen`:`Enter fullscreen`},[T.value?(s(),u(`svg`,tg,[...n[3]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(s(),u(`svg`,eg,[...n[2]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4`},null,-1)]])),l(`span`,ng,e(T.value?`Exit`:`Fullscreen`),1)],8,$h)):c(``,!0),C.value?c(``,!0):(s(),u(`button`,{key:1,onClick:ye,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:T.value?`Exit full window`:`Full window`},[n[4]||=l(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z`})],-1),l(`span`,ig,e(T.value?`Exit Window`:`Full Window`),1)],8,rg)),C.value?c(``,!0):(s(),u(`button`,{key:2,onClick:ve,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-accent-purple/20 hover:bg-accent-purple/30 text-accent-purple border border-accent-purple/50 rounded-lg transition-colors`,title:w.value?`Exit fullscreen`:`Fullscreen`},[w.value?(s(),u(`svg`,sg,[...n[6]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`},null,-1)]])):(s(),u(`svg`,og,[...n[5]||=[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4`},null,-1)]])),l(`span`,cg,e(w.value?`Exit Full`:`Fullscreen`),1)],8,ag)),l(`button`,{onClick:n[0]||=e=>te.value=!te.value,class:`flex items-center gap-2 px-3 py-2 md:px-4 bg-primary/20 hover:bg-primary/30 text-primary border border-primary/50 rounded-lg transition-colors`},[...n[7]||=[l(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1),l(`span`,{class:`hidden sm:inline`},`Search`,-1)]])])])]),te.value?(s(),u(`div`,lg,[l(`div`,ug,[i(l(`input`,{"onUpdate:modelValue":n[1]||=e=>ee.value=e,onKeydown:[f(he,[`enter`]),f(_e,[`esc`])],type:`text`,placeholder:`Search terminal output...`,class:`flex-1 px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/40 outline-none focus:border-primary/50 transition-colors`},null,544),[[p,ee.value]]),l(`button`,{onClick:ge,class:`px-3 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary transition-colors`,title:`Previous (Shift+Enter)`},` ↑ `),l(`button`,{onClick:he,class:`px-3 py-2 bg-primary/20 hover:bg-primary/30 border border-primary/50 rounded-lg text-primary transition-colors`,title:`Next (Enter)`},` ↓ `),l(`button`,{onClick:_e,class:`px-3 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary transition-colors`},` ✕ `)])])):c(``,!0),l(`div`,{ref_key:`terminalContainerRef`,ref:x,class:d([`bg-surface dark:bg-surface-elevated/80 backdrop-blur-xl border border-stroke-subtle dark:border-white/10 rounded-[15px] overflow-hidden relative`,{"fullscreen-terminal":w.value,"full-window-terminal":T.value}])},[T.value&&!w.value?(s(),u(`button`,{key:0,onClick:be,class:`absolute top-4 right-4 z-50 p-2 bg-black/80 backdrop-blur-sm hover:bg-black/90 text-white border border-white/20 rounded-lg transition-colors`,title:`Exit full window (ESC)`},[...n[9]||=[l(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[l(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])):c(``,!0),l(`div`,{ref_key:`terminalRef`,ref:y,class:d([`terminal-container`,{"fullscreen-content":w.value}]),onClick:xe,onTouchstart:xe},[C.value?(s(),u(`input`,{key:0,ref_key:`mobileInputRef`,ref:b,type:`text`,class:`mobile-keyboard-input`,onInput:Se,onKeydown:[f(m(Ce,[`prevent`]),[`enter`]),f(we,[`delete`])],inputmode:`text`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`},null,40,dg)):c(``,!0)],34),S.value?(s(),u(`div`,fg,[...n[10]||=[l(`div`,{class:`w-2 h-2 bg-primary rounded-full animate-pulse`},null,-1),l(`span`,{class:`text-primary text-sm font-medium`},`Processing...`,-1)]])):c(``,!0)],2)]))}}),[[`__scopeId`,`data-v-7db8a6e5`]]);export{pg as default}; \ No newline at end of file diff --git a/repeater/web/html/assets/TxPowerNoticeModal-DLQEpbGj.js b/repeater/web/html/assets/TxPowerNoticeModal-DLQEpbGj.js new file mode 100644 index 00000000..6ddd994b --- /dev/null +++ b/repeater/web/html/assets/TxPowerNoticeModal-DLQEpbGj.js @@ -0,0 +1 @@ +import{B as e,Ct as t,Y as n,c as r,g as i,k as a,l as o,m as s,nt as c,o as l,s as u,u as d,x as f,y as p}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{t as m,u as h}from"./runtime-dom.esm-bundler-fKU3dih-.js";import{_ as g}from"./api-3gMnsCKh.js";var _=g(`setup`,()=>{let e=n(1),t=n(6),r=n(`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`),i=n(null),a=n(null),o=n(null),s=n(``),c=n(``),u=n(`/dev/ttyACM0`),d=n(``),f=n(5055),p=n(``),m=n(!1),h=n({frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`,tx_power:`14`}),g=n([]),_=n([]),v=n(!1),y=n(!1),b=n(null),x=l(()=>{switch(e.value){case 1:return!0;case 2:return r.value.trim().length>0;case 3:return a.value!==null;case 4:{if(!i.value)return!1;let e=i.value.key.toLowerCase();return e===`kiss`||e===`pymc_usb`?u.value.trim().length>0:e===`pymc_tcp`?d.value.trim().length>0:!0}case 5:return m.value?h.value.frequency&&h.value.spreading_factor&&h.value.bandwidth&&h.value.coding_rate&&h.value.tx_power:o.value!==null;case 6:return s.value.length>=6&&s.value===c.value;default:return!1}}),S=l(()=>e.value>1),C=l(()=>e.value===t.value);async function w(){v.value=!0,b.value=null;try{let e=await(await fetch(`/api/hardware_options`)).json();if(e.error)throw Error(e.error);g.value=e.hardware||[]}catch(e){b.value=e instanceof Error?e.message:`Failed to load hardware options`,console.error(`Error fetching hardware options:`,e)}finally{v.value=!1}}let T=e=>({title:String(e.title??``),description:String(e.description??``),frequency:String(e.frequency??``),spreading_factor:String(e.spreading_factor??``),bandwidth:String(e.bandwidth??``),coding_rate:String(e.coding_rate??``),tx_power:String(e.tx_power??`14`)});async function E(){v.value=!0,b.value=null;try{try{let e=new AbortController,t=setTimeout(()=>e.abort(),4e3);try{let t=await fetch(`https://api.meshcore.nz/api/v1/config`,{signal:e.signal});if(t.ok){let e=(await t.json())?.config?.suggested_radio_settings?.entries??[];if(e.length>0){_.value=e.map(e=>T(e));return}}}finally{clearTimeout(t)}}catch{}let e=await(await fetch(`/api/radio_presets`)).json();if(e.error)throw Error(e.error);_.value=(e.presets??[]).map(e=>T(e))}catch(e){b.value=e instanceof Error?e.message:`Failed to load radio presets`,console.error(`Error fetching radio presets:`,e)}finally{v.value=!1}}async function D(){if(!x.value)return{success:!1,error:`Please complete all required fields`};y.value=!0,b.value=null;try{let e=m.value?{title:`Custom Configuration`,description:`Custom radio settings`,frequency:h.value.frequency,spreading_factor:h.value.spreading_factor,bandwidth:h.value.bandwidth,coding_rate:h.value.coding_rate,tx_power:h.value.tx_power}:o.value,t=Number(e?.tx_power??14);if(!Number.isFinite(t)||t<-9||t>22)throw Error(`TX power must be between -9 and +22 dBm`);let n=await(await fetch(`/api/setup_wizard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({node_name:r.value.trim(),hardware_key:i.value?.key,radio_preset:e,admin_password:s.value,...i.value&&(()=>{let e=i.value.key.toLowerCase();return e===`kiss`?{kiss_port:u.value.trim()||`/dev/ttyUSB0`,kiss_baud_rate:115200}:e===`pymc_usb`?{pymc_usb_port:u.value.trim()||`/dev/ttyACM0`,pymc_usb_baudrate:921600}:e===`pymc_tcp`?{pymc_tcp_host:d.value.trim(),pymc_tcp_port:f.value,pymc_tcp_token:p.value.trim()}:{}})()})})).json();if(!n.success)throw Error(n.error||`Setup failed`);return{success:!0,data:n}}catch(e){let t=e instanceof Error?e.message:`Failed to complete setup`;return b.value=t,{success:!1,error:t}}finally{y.value=!1}}function O(){x.value&&e.value=1&&n<=t.value&&(e.value=n)}function j(){e.value=1,r.value=`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`,i.value=null,a.value=null,o.value=null,m.value=!1,h.value={frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`,tx_power:`14`},s.value=``,c.value=``,u.value=`/dev/ttyACM0`,d.value=``,f.value=5055,p.value=``,b.value=null}return{currentStep:e,totalSteps:t,nodeName:r,selectedHardware:i,selectedHardwareConnection:a,selectedRadioPreset:o,useCustomRadio:m,usbPort:u,tcpHost:d,tcpPort:f,tcpToken:p,customRadio:h,adminPassword:s,confirmPassword:c,hardwareOptions:g,radioPresets:_,isLoading:v,isSubmitting:y,error:b,canGoNext:x,canGoBack:S,isLastStep:C,fetchHardwareOptions:w,fetchRadioPresets:E,completeSetup:D,nextStep:O,previousStep:k,goToStep:A,reset:j}}),v=e=>e===``,y=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),b=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),x=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),S=e=>{let t=x(e);return t.charAt(0).toUpperCase()+t.slice(1)},C={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},w=Symbol(`lucide-icons`);function T(){return f(w,{})}var E=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":r,strokeWidth:i,"stroke-width":a,size:o,color:s,...c},{slots:u})=>{let{size:d,color:f,strokeWidth:m=2,absoluteStrokeWidth:h=!1,class:g=``}=T(),_=l(()=>{let e=v(n)||v(r)||n===!0||r===!0||h===!0,t=i||a||m||C[`stroke-width`];return e?Number(t)*24/Number(o??d??C.width):t});return p(`svg`,{...C,...c,width:o??d??C.width,height:o??d??C.height,stroke:s??f??C.stroke,"stroke-width":_.value,class:y(`lucide`,g,...e?[`lucide-${b(S(e))}-icon`,`lucide-${b(e)}`]:[`lucide-icon`])},[...t.map(e=>p(...e)),...u.default?[u.default()]:[]])},D=(e,t)=>(n,{slots:r,attrs:i})=>p(E,{...i,...n,iconNode:t,name:e},r.default?{default:r.default}:void 0),O=D(`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`}]]),k={class:`w-full max-w-2xl rounded-3xl border border-amber-300/70 dark:border-amber-400/30 bg-white dark:bg-surface-elevated shadow-[0_20px_80px_rgba(0,0,0,0.35)] overflow-hidden`},A={class:`p-5 border-b border-amber-200/70 dark:border-amber-400/20 bg-amber-50/70 dark:bg-amber-500/10`},j={class:`flex items-start gap-3`},M={class:`rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 p-2`},N={key:0,class:`text-xs text-content-secondary dark:text-content-muted mt-1`},P={key:1,class:`text-xs text-content-secondary dark:text-content-muted mt-1`},F={class:`p-5 space-y-3 text-sm text-content-secondary dark:text-content-muted max-h-[60vh] overflow-y-auto`},I={class:`flex items-start gap-2 pt-1`},L=[`checked`],R={class:`p-5 border-t border-stroke-subtle dark:border-white/10 flex items-center justify-end gap-2`},z=[`disabled`],B=i({__name:`TxPowerNoticeModal`,props:{show:{type:Boolean},confirmed:{type:Boolean},selectedTxPower:{default:null},actionLabel:{default:`I Understand, Continue`},busy:{type:Boolean,default:!1}},emits:[`update:show`,`update:confirmed`,`confirm`],setup(n,{emit:i}){let l=n,f=i;function p(){f(`update:show`,!1)}function g(){!l.confirmed||l.busy||f(`confirm`)}return(i,l)=>(a(),r(m,{name:`fade`},{default:e(()=>[n.show?(a(),d(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm`,onClick:h(p,[`self`])},[u(`div`,k,[u(`div`,A,[u(`div`,j,[u(`div`,M,[s(c(O),{class:`w-5 h-5`})]),u(`div`,null,[l[1]||=u(`h4`,{class:`text-content-primary dark:text-content-primary text-base font-semibold`},` TX Power & PA Configuration Notice `,-1),n.selectedTxPower===null?(a(),d(`p`,P,` Review this safety notice before applying TX power changes. `)):(a(),d(`p`,N,` Selected TX power: `+t(n.selectedTxPower)+` dBm `,1))])])]),u(`div`,F,[l[3]||=u(`p`,{class:`leading-relaxed`},` Always ensure your configured TX power complies with local country and regional radio regulations before transmitting. `,-1),l[4]||=u(`p`,{class:`leading-relaxed`},` Before changing TX power settings, research your specific LoRa board/module design carefully. Many SX1262-based boards include an external Power Amplifier (PA) and RF switching circuitry, which may require different configuration values, TX paths, or firmware settings than a standard SX1262 reference design. `,-1),l[5]||=u(`p`,{class:`leading-relaxed`},` Do not assume all boards support the same maximum power levels or PA configuration methods. `,-1),l[6]||=u(`div`,{class:`rounded-xl border border-stroke-subtle dark:border-white/10 bg-background-mute/60 dark:bg-white/5 p-3`},[u(`p`,{class:`text-content-primary dark:text-content-primary font-medium mb-2`},`Recommended checks before applying changes:`),u(`ul`,{class:`list-disc pl-5 space-y-1`},[u(`li`,null,`Verify whether your board includes an external PA/LNA stage`),u(`li`,null,`Confirm the manufacturer’s recommended TX power limits`),u(`li`,null,`Check required RXen/TXen or RF switch pin configuration`),u(`li`,null,`Use board-specific library settings where available`),u(`li`,null,`Ensure thermal limits and duty cycle recommendations are respected`),u(`li`,null,`Never transmit without a correctly connected antenna or suitable load`)])],-1),l[7]||=u(`p`,{class:`leading-relaxed text-amber-700 dark:text-amber-300 font-medium`},` Incorrect PA configuration can damage hardware, lock the radio into a busy state, or cause illegal RF output levels. `,-1),u(`label`,I,[u(`input`,{checked:n.confirmed,type:`checkbox`,class:`mt-0.5`,onChange:l[0]||=e=>f(`update:confirmed`,e.target.checked)},null,40,L),l[2]||=u(`span`,{class:`text-content-primary dark:text-content-primary`},`I have read and understood this warning.`,-1)])]),u(`div`,R,[u(`button`,{type:`button`,class:`cfg-btn-secondary`,onClick:p},` Cancel `),u(`button`,{type:`button`,class:`cfg-btn-primary`,disabled:!n.confirmed||n.busy,onClick:g},t(n.actionLabel),9,z)])])])):o(``,!0)]),_:1}))}});export{D as n,_ as r,B as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/api-3gMnsCKh.js b/repeater/web/html/assets/api-3gMnsCKh.js new file mode 100644 index 00000000..125c57c4 --- /dev/null +++ b/repeater/web/html/assets/api-3gMnsCKh.js @@ -0,0 +1,7 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Setup-CaLinAtC.js","assets/_plugin-vue_export-helper-B7aGp3iI.js","assets/index-DTUpsCzx.js","assets/runtime-core.esm-bundler-C5QBTNWE.js","assets/runtime-dom.esm-bundler-fKU3dih-.js","assets/Spinner-CcYauG9D.js","assets/useTheme-B2sN4eXt.js","assets/dataService-DelZA92b.js","assets/packets-KU2POtN6.js","assets/system-DbBvxitf.js","assets/websocket-Bupmxvtc.js","assets/constants-C3rXUIAq.js","assets/index-G9r6MePO.css","assets/TxPowerNoticeModal-DLQEpbGj.js","assets/Setup-BFlxpW4p.css","assets/Login-DTJPC25k.js","assets/Login-9CbeeXng.css","assets/Dashboard-BQS_QL_q.js","assets/ChartCard-Dv7_dbhW.js","assets/useSignalQuality-BurD4HtO.js","assets/preferences-CkCjR0CQ.js","assets/Dashboard-BGrwr2sL.css","assets/Neighbors-DSCosrf5.js","assets/chunk-DECur_0Z.js","assets/leaflet-src-rW8DhqPH.js","assets/formatters-CHyWlnnq.js","assets/Neighbors-Bng0BMwC.css","assets/leaflet-vh-t_kPv.css","assets/Statistics-BeGVnnkk.js","assets/chartjs-adapter-date-fns.esm-CUNlL-Mn.js","assets/chartjs-adapter-date-fns-BKkkO1xH.css","assets/GPSDiagnostics-crPCBW12.js","assets/GPSDiagnostics-ozfiXH-7.css","assets/SystemStats-sG4byBWD.js","assets/SystemStats-DzIGYJV7.css","assets/Sensors-C31-xdDY.js","assets/Configuration-DqetrFgk.js","assets/ConfirmDialog-DBlDmP2I.js","assets/LocationPicker-KRjSN9TZ.js","assets/LocationPicker-KkKL2lD_.css","assets/Configuration-C7dIc7Ik.css","assets/CADCalibration-CMgcsyU9.js","assets/plotly.min-BmxIBpZZ.js","assets/CADCalibration-C4Y61LYy.css","assets/Sessions-XCAfIBGI.js","assets/RoomServers-DBObY362.js","assets/MessageDialog-bhwyqS5K.js","assets/Companions-CPdWnFPt.js","assets/Logs-Dw5-qzdU.js","assets/Terminal-IUdfvY-m.js","assets/Terminal-8k-H0_ky.css","assets/Help-CfDEEAoD.js","assets/websocket-CFOZ2WXa.js","assets/packets-i0z-xors.js","assets/system-BivdkLQN.js","assets/dataService-BP1CezIa.js"])))=>i.map(i=>d[i]); +import{n as e}from"./chunk-DECur_0Z.js";import{$ as t,A as n,C as r,D as i,G as a,H as o,J as s,K as c,Q as l,R as u,S as d,T as f,U as p,W as m,X as h,Y as g,Z as _,b as v,et as y,g as b,nt as x,o as S,q as C,x as w,y as ee}from"./runtime-core.esm-bundler-C5QBTNWE.js";var te=typeof window<`u`,T,ne=e=>T=e,E=Symbol();function re(e){return e&&typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`&&typeof e.toJSON!=`function`}var ie;(function(e){e.direct=`direct`,e.patchObject=`patch object`,e.patchFunction=`patch function`})(ie||={});var ae=typeof window==`object`&&window.window===window?window:typeof self==`object`&&self.self===self?self:typeof global==`object`&&global.global===global?global:typeof globalThis==`object`?globalThis:{HTMLElement:null};function oe(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([``,e],{type:e.type}):e}function se(e,t,n){let r=new XMLHttpRequest;r.open(`GET`,e),r.responseType=`blob`,r.onload=function(){de(r.response,t,n)},r.onerror=function(){console.error(`could not download file`)},r.send()}function ce(e){let t=new XMLHttpRequest;t.open(`HEAD`,e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function le(e){try{e.dispatchEvent(new MouseEvent(`click`))}catch{let t=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:80,screenY:20,clientX:80,clientY:20,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});e.dispatchEvent(t)}}var D=typeof navigator==`object`?navigator:{userAgent:``},ue=/Macintosh/.test(D.userAgent)&&/AppleWebKit/.test(D.userAgent)&&!/Safari/.test(D.userAgent),de=te?typeof HTMLAnchorElement<`u`&&`download`in HTMLAnchorElement.prototype&&!ue?fe:`msSaveOrOpenBlob`in D?pe:me:()=>{};function fe(e,t=`download`,n){let r=document.createElement(`a`);r.download=t,r.rel=`noopener`,typeof e==`string`?(r.href=e,r.origin===location.origin?le(r):ce(r.href)?se(e,t,n):(r.target=`_blank`,le(r))):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){le(r)},0))}function pe(e,t=`download`,n){if(typeof e==`string`)if(ce(e))se(e,t,n);else{let t=document.createElement(`a`);t.href=e,t.target=`_blank`,setTimeout(function(){le(t)})}else navigator.msSaveOrOpenBlob(oe(e,n),t)}function me(e,t,n,r){if(r||=open(``,`_blank`),r&&(r.document.title=r.document.body.innerText=`downloading...`),typeof e==`string`)return se(e,t,n);let i=e.type===`application/octet-stream`,a=/constructor/i.test(String(ae.HTMLElement))||`safari`in ae,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||i&&a||ue)&&typeof FileReader<`u`){let t=new FileReader;t.onloadend=function(){let e=t.result;if(typeof e!=`string`)throw r=null,Error(`Wrong reader.result type`);e=o?e:e.replace(/^data:[^;]*;/,`data:attachment/file;`),r?r.location.href=e:location.assign(e),r=null},t.readAsDataURL(e)}else{let t=URL.createObjectURL(e);r?r.location.assign(t):location.href=t,r=null,setTimeout(function(){URL.revokeObjectURL(t)},4e4)}}var{assign:he}=Object;function ge(){let e=o(!0),t=e.run(()=>g({})),n=[],r=[],i=c({install(e){ne(i),i._a=e,e.provide(E,i),e.config.globalProperties.$pinia=i,r.forEach(e=>n.push(e)),r=[]},use(e){return this._a?n.push(e):r.push(e),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return i}var O=()=>{};function k(e,t,n,r=O){e.add(t);let i=()=>{e.delete(t)&&r()};return!n&&p()&&C(i),i}function _e(e,...t){e.forEach(e=>{e(...t)})}var ve=e=>e(),ye=Symbol(),be=Symbol();function xe(e,t){e instanceof Map&&t instanceof Map?t.forEach((t,n)=>e.set(n,t)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(let n in t){if(!t.hasOwnProperty(n))continue;let r=t[n],i=e[n];re(i)&&re(r)&&e.hasOwnProperty(n)&&!a(r)&&!m(r)?e[n]=xe(i,r):e[n]=r}return e}var Se=Symbol();function Ce(e){return!re(e)||!Object.prototype.hasOwnProperty.call(e,Se)}var{assign:A}=Object;function we(e){return!!(a(e)&&e.effect)}function Te(e,t,n,r){let{state:i,actions:a,getters:o}=t,s=n.state.value[e],l;function u(){return s||(n.state.value[e]=i?i():{}),A(y(n.state.value[e]),a,Object.keys(o||{}).reduce((t,r)=>(t[r]=c(S(()=>{ne(n);let t=n._s.get(e);return o[r].call(t,t)})),t),{}))}return l=Ee(e,u,t,n,r,!0),l}function Ee(e,t,n={},r,i,c){let f,p=A({actions:{}},n),h={deep:!0},_,v,y=new Set,b=new Set,x=r.state.value[e];!c&&!x&&(r.state.value[e]={}),g({});let S;function C(t){let n;_=v=!1,typeof t==`function`?(t(r.state.value[e]),n={type:ie.patchFunction,storeId:e,events:void 0}):(xe(r.state.value[e],t),n={type:ie.patchObject,payload:t,storeId:e,events:void 0});let i=S=Symbol();d().then(()=>{S===i&&(_=!0)}),v=!0,_e(y,n,r.state.value[e])}let w=c?function(){let{state:e}=n,t=e?e():{};this.$patch(e=>{A(e,t)})}:O;function ee(){f.stop(),y.clear(),b.clear(),r._s.delete(e)}let te=(t,n=``)=>{if(ye in t)return t[be]=n,t;let i=function(){ne(r);let n=Array.from(arguments),a=new Set,o=new Set;function s(e){a.add(e)}function c(e){o.add(e)}_e(b,{args:n,name:i[be],store:T,after:s,onError:c});let l;try{l=t.apply(this&&this.$id===e?this:T,n)}catch(e){throw _e(o,e),e}return l instanceof Promise?l.then(e=>(_e(a,e),e)).catch(e=>(_e(o,e),Promise.reject(e))):(_e(a,l),l)};return i[ye]=!0,i[be]=n,i},T=s({_p:r,$id:e,$onAction:k.bind(null,b),$patch:C,$reset:w,$subscribe(t,n={}){let i=k(y,t,n.detached,()=>a()),a=f.run(()=>u(()=>r.state.value[e],r=>{(n.flush===`sync`?v:_)&&t({storeId:e,type:ie.direct,events:void 0},r)},A({},h,n)));return i},$dispose:ee});r._s.set(e,T);let E=(r._a&&r._a.runWithContext||ve)(()=>r._e.run(()=>(f=o()).run(()=>t({action:te}))));for(let t in E){let n=E[t];a(n)&&!we(n)||m(n)?c||(x&&Ce(n)&&(a(n)?n.value=x[t]:xe(n,x[t])),r.state.value[e][t]=n):typeof n==`function`&&(E[t]=te(n,t),p.actions[t]=n)}return A(T,E),A(l(T),E),Object.defineProperty(T,`$state`,{get:()=>r.state.value[e],set:e=>{C(t=>{A(t,e)})}}),r._p.forEach(e=>{A(T,f.run(()=>e({store:T,app:r._a,pinia:r,options:p})))}),x&&c&&n.hydrate&&n.hydrate(T.$state,x),_=!0,v=!0,T}function De(e,t,n){let r,i=typeof t==`function`;r=i?n:t;function a(n,a){let o=v();return n||=o?w(E,null):null,n&&ne(n),n=T,n._s.has(e)||(i?Ee(e,t,r,n):Te(e,r,n)),n._s.get(e)}return a.$id=e,a}function Oe(e){let n=l(e),r={};for(let i in n){let o=n[i];o.effect?r[i]=S({get:()=>e[i],set(t){e[i]=t}}):(a(o)||m(o))&&(r[i]=t(e,i))}return r}var ke=typeof document<`u`;function Ae(e){return typeof e==`object`||`displayName`in e||`props`in e||`__vccOpts`in e}function je(e){return e.__esModule||e[Symbol.toStringTag]===`Module`||e.default&&Ae(e.default)}var j=Object.assign;function Me(e,t){let n={};for(let r in t){let i=t[r];n[r]=M(i)?i.map(e):e(i)}return n}var Ne=()=>{},M=Array.isArray;function Pe(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}var N=function(e){return e[e.MATCHER_NOT_FOUND=1]=`MATCHER_NOT_FOUND`,e[e.NAVIGATION_GUARD_REDIRECT=2]=`NAVIGATION_GUARD_REDIRECT`,e[e.NAVIGATION_ABORTED=4]=`NAVIGATION_ABORTED`,e[e.NAVIGATION_CANCELLED=8]=`NAVIGATION_CANCELLED`,e[e.NAVIGATION_DUPLICATED=16]=`NAVIGATION_DUPLICATED`,e}({}),Fe=Symbol(``);N.MATCHER_NOT_FOUND,N.NAVIGATION_GUARD_REDIRECT,N.NAVIGATION_ABORTED,N.NAVIGATION_CANCELLED,N.NAVIGATION_DUPLICATED;function Ie(e,t){return j(Error(),{type:e,[Fe]:!0},t)}function P(e,t){return e instanceof Error&&Fe in e&&(t==null||!!(e.type&t))}var Le=Symbol(``),Re=Symbol(``),ze=Symbol(``),Be=Symbol(``),Ve=Symbol(``);function He(){return w(ze)}function Ue(e){return w(Be)}var We=/#/g,Ge=/&/g,Ke=/\//g,qe=/=/g,Je=/\?/g,Ye=/\+/g,Xe=/%5B/g,Ze=/%5D/g,Qe=/%5E/g,$e=/%60/g,et=/%7B/g,tt=/%7C/g,nt=/%7D/g,rt=/%20/g;function it(e){return e==null?``:encodeURI(``+e).replace(tt,`|`).replace(Xe,`[`).replace(Ze,`]`)}function at(e){return it(e).replace(et,`{`).replace(nt,`}`).replace(Qe,`^`)}function ot(e){return it(e).replace(Ye,`%2B`).replace(rt,`+`).replace(We,`%23`).replace(Ge,`%26`).replace($e,"`").replace(et,`{`).replace(nt,`}`).replace(Qe,`^`)}function st(e){return ot(e).replace(qe,`%3D`)}function ct(e){return it(e).replace(We,`%23`).replace(Je,`%3F`)}function lt(e){return ct(e).replace(Ke,`%2F`)}function ut(e){if(e==null)return null;try{return decodeURIComponent(``+e)}catch{}return``+e}var dt=/\/$/,ft=e=>e.replace(dt,``);function pt(e,t,n=`/`){let r,i={},a=``,o=``,s=t.indexOf(`#`),c=t.indexOf(`?`);return c=s>=0&&c>s?-1:c,c>=0&&(r=t.slice(0,c),a=t.slice(c,s>0?s:t.length),i=e(a.slice(1))),s>=0&&(r||=t.slice(0,s),o=t.slice(s,t.length)),r=xt(r??t,n),{fullPath:r+a+o,path:r,query:i,hash:ut(o)}}function mt(e,t){let n=t.query?e(t.query):``;return t.path+(n&&`?`)+n+(t.hash||``)}function ht(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||`/`}function gt(e,t,n){let r=t.matched.length-1,i=n.matched.length-1;return r>-1&&r===i&&_t(t.matched[r],n.matched[i])&&vt(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function _t(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function vt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!yt(e[n],t[n]))return!1;return!0}function yt(e,t){return M(e)?bt(e,t):M(t)?bt(t,e):(e&&e.valueOf())===(t&&t.valueOf())}function bt(e,t){return M(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e.length===1&&e[0]===t}function xt(e,t){if(e.startsWith(`/`))return e;if(!e)return t;let n=t.split(`/`),r=e.split(`/`),i=r[r.length-1];(i===`..`||i===`.`)&&r.push(``);let a=n.length-1,o,s;for(o=0;o1&&a--;else break;return n.slice(0,a).join(`/`)+`/`+r.slice(o).join(`/`)}var F={path:`/`,name:void 0,params:{},query:{},hash:``,fullPath:`/`,matched:[],meta:{},redirectedFrom:void 0},St=function(e){return e.pop=`pop`,e.push=`push`,e}({}),Ct=function(e){return e.back=`back`,e.forward=`forward`,e.unknown=``,e}({});function wt(e){if(!e)if(ke){let t=document.querySelector(`base`);e=t&&t.getAttribute(`href`)||`/`,e=e.replace(/^\w+:\/\/[^\/]+/,``)}else e=`/`;return e[0]!==`/`&&e[0]!==`#`&&(e=`/`+e),ft(e)}var Tt=/^[^#]+#/;function Et(e,t){return e.replace(Tt,`#`)+t}function Dt(e,t){let n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}var Ot=()=>({left:window.scrollX,top:window.scrollY});function kt(e){let t;if(`el`in e){let n=e.el,r=typeof n==`string`&&n.startsWith(`#`),i=typeof n==`string`?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!i)return;t=Dt(i,e)}else t=e;`scrollBehavior`in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left==null?window.scrollX:t.left,t.top==null?window.scrollY:t.top)}function At(e,t){return(history.state?history.state.position-t:-1)+e}var jt=new Map;function Mt(e,t){jt.set(e,t)}function Nt(e){let t=jt.get(e);return jt.delete(e),t}function Pt(e){return typeof e==`string`||e&&typeof e==`object`}function Ft(e){return typeof e==`string`||typeof e==`symbol`}function It(e){let t={};if(e===``||e===`?`)return t;let n=(e[0]===`?`?e.slice(1):e).split(`&`);for(let e=0;ee&&ot(e)):[r&&ot(r)]).forEach(e=>{e!==void 0&&(t+=(t.length?`&`:``)+n,e!=null&&(t+=`=`+e))})}return t}function Rt(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=M(r)?r.map(e=>e==null?null:``+e):r==null?r:``+r)}return t}function zt(){let e=[];function t(t){return e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function Bt(e,t,n){let a=e.value;if(!a)return;let o=a,s=()=>{o[t].delete(n)};i(s),f(s),r(()=>{let r=e.value;r&&(o=r),o[t].add(n)}),o[t].add(n)}function Vt(e){Bt(w(Le,{}),`leaveGuards`,e)}function I(e,t,n,r,i,a=e=>e()){let o=r&&(r.enterCallbacks[i]=r.enterCallbacks[i]||[]);return()=>new Promise((s,c)=>{let l=e=>{e===!1?c(Ie(N.NAVIGATION_ABORTED,{from:n,to:t})):e instanceof Error?c(e):Pt(e)?c(Ie(N.NAVIGATION_GUARD_REDIRECT,{from:t,to:e})):(o&&r.enterCallbacks[i]===o&&typeof e==`function`&&o.push(e),s())},u=a(()=>e.call(r&&r.instances[i],t,n,l)),d=Promise.resolve(u);e.length<3&&(d=d.then(l)),d.catch(e=>c(e))})}function Ht(e,t,n,r,i=e=>e()){let a=[];for(let o of e)for(let e in o.components){let s=o.components[e];if(!(t!==`beforeRouteEnter`&&!o.instances[e]))if(Ae(s)){let c=(s.__vccOpts||s)[t];c&&a.push(I(c,n,r,o,e,i))}else{let c=s();a.push(()=>c.then(a=>{if(!a)throw Error(`Couldn't resolve component "${e}" at "${o.path}"`);let s=je(a)?a.default:a;o.mods[e]=a,o.components[e]=s;let c=(s.__vccOpts||s)[t];return c&&I(c,n,r,o,e,i)()}))}}return a}function Ut(e,t){let n=[],r=[],i=[],a=Math.max(t.matched.length,e.matched.length);for(let o=0;o_t(e,a))?r.push(a):n.push(a));let s=e.matched[o];s&&(t.matched.find(e=>_t(e,s))||i.push(s))}return[n,r,i]}var Wt=()=>location.protocol+`//`+location.host;function Gt(e,t){let{pathname:n,search:r,hash:i}=t,a=e.indexOf(`#`);if(a>-1){let t=i.includes(e.slice(a))?e.slice(a).length:1,n=i.slice(t);return n[0]!==`/`&&(n=`/`+n),ht(n,``)}return ht(n,e)+r+i}function Kt(e,t,n,r){let i=[],a=[],o=null,s=({state:a})=>{let s=Gt(e,location),c=n.value,l=t.value,u=0;if(a){if(n.value=s,t.value=a,o&&o===c){o=null;return}u=l?a.position-l.position:0}else r(s);i.forEach(e=>{e(n.value,c,{delta:u,type:St.pop,direction:u?u>0?Ct.forward:Ct.back:Ct.unknown})})};function c(){o=n.value}function l(e){i.push(e);let t=()=>{let t=i.indexOf(e);t>-1&&i.splice(t,1)};return a.push(t),t}function u(){if(document.visibilityState===`hidden`){let{history:e}=window;if(!e.state)return;e.replaceState(j({},e.state,{scroll:Ot()}),``)}}function d(){for(let e of a)e();a=[],window.removeEventListener(`popstate`,s),window.removeEventListener(`pagehide`,u),document.removeEventListener(`visibilitychange`,u)}return window.addEventListener(`popstate`,s),window.addEventListener(`pagehide`,u),document.addEventListener(`visibilitychange`,u),{pauseListeners:c,listen:l,destroy:d}}function qt(e,t,n,r=!1,i=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:i?Ot():null}}function Jt(e){let{history:t,location:n}=window,r={value:Gt(e,n)},i={value:t.state};i.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function a(r,a,o){let s=e.indexOf(`#`),c=s>-1?(n.host&&document.querySelector(`base`)?e:e.slice(s))+r:Wt()+e+r;try{t[o?`replaceState`:`pushState`](a,``,c),i.value=a}catch(e){console.error(e),n[o?`replace`:`assign`](c)}}function o(e,n){a(e,j({},t.state,qt(i.value.back,e,i.value.forward,!0),n,{position:i.value.position}),!0),r.value=e}function s(e,n){let o=j({},i.value,t.state,{forward:e,scroll:Ot()});a(o.current,o,!0),a(e,j({},qt(r.value,e,null),{position:o.position+1},n),!1),r.value=e}return{location:r,state:i,push:s,replace:o}}function Yt(e){e=wt(e);let t=Jt(e),n=Kt(e,t.state,t.location,t.replace);function r(e,t=!0){t||n.pauseListeners(),history.go(e)}let i=j({location:``,base:e,go:r,createHref:Et.bind(null,e)},t,n);return Object.defineProperty(i,`location`,{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,`state`,{enumerable:!0,get:()=>t.state.value}),i}var L=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.Group=2]=`Group`,e}({}),R=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.ParamRegExp=2]=`ParamRegExp`,e[e.ParamRegExpEnd=3]=`ParamRegExpEnd`,e[e.EscapeNext=4]=`EscapeNext`,e}(R||{}),Xt={type:L.Static,value:``},Zt=/[a-zA-Z0-9_]/;function Qt(e){if(!e)return[[]];if(e===`/`)return[[Xt]];if(!e.startsWith(`/`))throw Error(`Invalid path "${e}"`);function t(e){throw Error(`ERR (${n})/"${l}": ${e}`)}let n=R.Static,r=n,i=[],a;function o(){a&&i.push(a),a=[]}let s=0,c,l=``,u=``;function d(){l&&=(n===R.Static?a.push({type:L.Static,value:l}):n===R.Param||n===R.ParamRegExp||n===R.ParamRegExpEnd?(a.length>1&&(c===`*`||c===`+`)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:L.Param,value:l,regexp:u,repeatable:c===`*`||c===`+`,optional:c===`*`||c===`?`})):t(`Invalid state to consume buffer`),``)}function f(){l+=c}for(;st.length?t.length===1&&t[0]===z.Static+z.Segment?1:-1:0}function an(e,t){let n=0,r=e.score,i=t.score;for(;n0&&t[t.length-1]<0}var sn={strict:!1,end:!0,sensitive:!1};function cn(e,t,n){let r=j(nn(Qt(e.path),n),{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function ln(e,t){let n=[],r=new Map;t=Pe(sn,t);function i(e){return r.get(e)}function a(e,n,r){let i=!r,s=dn(e);s.aliasOf=r&&r.record;let l=Pe(t,e),u=[s];if(`alias`in e){let t=typeof e.alias==`string`?[e.alias]:e.alias;for(let e of t)u.push(dn(j({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s})))}let d,f;for(let t of u){let{path:u}=t;if(n&&u[0]!==`/`){let e=n.record.path,r=e[e.length-1]===`/`?``:`/`;t.path=n.record.path+(u&&r+u)}if(d=cn(t,n,l),r?r.alias.push(d):(f||=d,f!==d&&f.alias.push(d),i&&e.name&&!pn(d)&&o(e.name)),_n(d)&&c(d),s.children){let e=s.children;for(let t=0;t{o(f)}:Ne}function o(e){if(Ft(e)){let t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(o),t.alias.forEach(o))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(o),e.alias.forEach(o))}}function s(){return n}function c(e){let t=hn(e,n);n.splice(t,0,e),e.record.name&&!pn(e)&&r.set(e.record.name,e)}function l(e,t){let i,a={},o,s;if(`name`in e&&e.name){if(i=r.get(e.name),!i)throw Ie(N.MATCHER_NOT_FOUND,{location:e});s=i.record.name,a=j(un(t.params,i.keys.filter(e=>!e.optional).concat(i.parent?i.parent.keys.filter(e=>e.optional):[]).map(e=>e.name)),e.params&&un(e.params,i.keys.map(e=>e.name))),o=i.stringify(a)}else if(e.path!=null)o=e.path,i=n.find(e=>e.re.test(o)),i&&(a=i.parse(o),s=i.record.name);else{if(i=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!i)throw Ie(N.MATCHER_NOT_FOUND,{location:e,currentLocation:t});s=i.record.name,a=j({},t.params,e.params),o=i.stringify(a)}let c=[],l=i;for(;l;)c.unshift(l.record),l=l.parent;return{name:s,path:o,params:a,matched:c,meta:mn(c)}}e.forEach(e=>a(e));function u(){n.length=0,r.clear()}return{addRoute:a,resolve:l,removeRoute:o,clearRoutes:u,getRoutes:s,getRecordMatcher:i}}function un(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function dn(e){let t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:fn(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:`components`in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,`mods`,{value:{}}),t}function fn(e){let t={},n=e.props||!1;if(`component`in e)t.default=n;else for(let r in e.components)t[r]=typeof n==`object`?n[r]:n;return t}function pn(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function mn(e){return e.reduce((e,t)=>j(e,t.meta),{})}function hn(e,t){let n=0,r=t.length;for(;n!==r;){let i=n+r>>1;an(e,t[i])<0?r=i:n=i+1}let i=gn(e);return i&&(r=t.lastIndexOf(i,r-1)),r}function gn(e){let t=e;for(;t=t.parent;)if(_n(t)&&an(e,t)===0)return t}function _n({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function vn(e){let t=w(ze),n=w(Be),r=S(()=>{let n=x(e.to);return t.resolve(n)}),i=S(()=>{let{matched:e}=r.value,{length:t}=e,i=e[t-1],a=n.matched;if(!i||!a.length)return-1;let o=a.findIndex(_t.bind(null,i));if(o>-1)return o;let s=Cn(e[t-2]);return t>1&&Cn(i)===s&&a[a.length-1].path!==s?a.findIndex(_t.bind(null,e[t-2])):o}),a=S(()=>i.value>-1&&Sn(n.params,r.value.params)),o=S(()=>i.value>-1&&i.value===n.matched.length-1&&vt(n.params,r.value.params));function s(n={}){if(xn(n)){let n=t[x(e.replace)?`replace`:`push`](x(e.to)).catch(Ne);return e.viewTransition&&typeof document<`u`&&`startViewTransition`in document&&document.startViewTransition(()=>n),n}return Promise.resolve()}return{route:r,href:S(()=>r.value.href),isActive:a,isExactActive:o,navigate:s}}function yn(e){return e.length===1?e[0]:e}var bn=b({name:`RouterLink`,compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:`page`},viewTransition:Boolean},useLink:vn,setup(e,{slots:t}){let n=s(vn(e)),{options:r}=w(ze),i=S(()=>({[wn(e.activeClass,r.linkActiveClass,`router-link-active`)]:n.isActive,[wn(e.exactActiveClass,r.linkExactActiveClass,`router-link-exact-active`)]:n.isExactActive}));return()=>{let r=t.default&&yn(t.default(n));return e.custom?r:ee(`a`,{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:i.value},r)}}});function xn(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){let t=e.currentTarget.getAttribute(`target`);if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Sn(e,t){for(let n in t){let r=t[n],i=e[n];if(typeof r==`string`){if(r!==i)return!1}else if(!M(i)||i.length!==r.length||r.some((e,t)=>e.valueOf()!==i[t].valueOf()))return!1}return!0}function Cn(e){return e?e.aliasOf?e.aliasOf.path:e.path:``}var wn=(e,t,n)=>e??t??n,Tn=b({name:`RouterView`,inheritAttrs:!1,props:{name:{type:String,default:`default`},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:r}){let i=w(Ve),a=S(()=>e.route||i.value),o=w(Re,0),s=S(()=>{let e=x(o),{matched:t}=a.value,n;for(;(n=t[e])&&!n.components;)e++;return e}),c=S(()=>a.value.matched[s.value]);n(Re,S(()=>s.value+1)),n(Le,c),n(Ve,a);let l=g();return u(()=>[l.value,c.value,e.name],([e,t,n],[r,i,a])=>{t&&(t.instances[n]=e,i&&i!==t&&e&&e===r&&(t.leaveGuards.size||(t.leaveGuards=i.leaveGuards),t.updateGuards.size||(t.updateGuards=i.updateGuards))),e&&t&&(!i||!_t(t,i)||!r)&&(t.enterCallbacks[n]||[]).forEach(t=>t(e))},{flush:`post`}),()=>{let n=a.value,i=e.name,o=c.value,s=o&&o.components[i];if(!s)return En(r.default,{Component:s,route:n});let u=o.props[i],d=ee(s,j({},u?u===!0?n.params:typeof u==`function`?u(n):u:null,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(o.instances[i]=null)},ref:l}));return En(r.default,{Component:d,route:n})||d}}});function En(e,t){if(!e)return null;let n=e(t);return n.length===1?n[0]:n}var Dn=Tn;function On(e){let t=ln(e.routes,e),n=e.parseQuery||It,r=e.stringifyQuery||Lt,i=e.history,a=zt(),o=zt(),s=zt(),c=_(F),l=F;ke&&e.scrollBehavior&&`scrollRestoration`in history&&(history.scrollRestoration=`manual`);let u=Me.bind(null,e=>``+e),f=Me.bind(null,lt),p=Me.bind(null,ut);function m(e,n){let r,i;return Ft(e)?(r=t.getRecordMatcher(e),i=n):i=e,t.addRoute(i,r)}function g(e){let n=t.getRecordMatcher(e);n&&t.removeRoute(n)}function v(){return t.getRoutes().map(e=>e.record)}function y(e){return!!t.getRecordMatcher(e)}function b(e,a){if(a=j({},a||c.value),typeof e==`string`){let r=pt(n,e,a.path),o=t.resolve({path:r.path},a),s=i.createHref(r.fullPath);return j(r,o,{params:p(o.params),hash:ut(r.hash),redirectedFrom:void 0,href:s})}let o;if(e.path!=null)o=j({},e,{path:pt(n,e.path,a.path).path});else{let t=j({},e.params);for(let e in t)t[e]??delete t[e];o=j({},e,{params:f(t)}),a.params=f(a.params)}let s=t.resolve(o,a),l=e.hash||``;s.params=u(p(s.params));let d=mt(r,j({},e,{hash:at(l),path:s.path})),m=i.createHref(d);return j({fullPath:d,hash:l,query:r===Lt?Rt(e.query):e.query||{}},s,{redirectedFrom:void 0,href:m})}function S(e){return typeof e==`string`?pt(n,e,c.value.path):j({},e)}function C(e,t){if(l!==e)return Ie(N.NAVIGATION_CANCELLED,{from:t,to:e})}function w(e){return T(e)}function ee(e){return w(j(S(e),{replace:!0}))}function te(e,t){let n=e.matched[e.matched.length-1];if(n&&n.redirect){let{redirect:r}=n,i=typeof r==`function`?r(e,t):r;return typeof i==`string`&&(i=i.includes(`?`)||i.includes(`#`)?i=S(i):{path:i},i.params={}),j({query:e.query,hash:e.hash,params:i.path==null?e.params:{}},i)}}function T(e,t){let n=l=b(e),i=c.value,a=e.state,o=e.force,s=e.replace===!0,u=te(n,i);if(u)return T(j(S(u),{state:typeof u==`object`?j({},a,u.state):a,force:o,replace:s}),t||n);let d=n;d.redirectedFrom=t;let f;return!o&>(r,i,n)&&(f=Ie(N.NAVIGATION_DUPLICATED,{to:d,from:i}),pe(i,i,!0,!1)),(f?Promise.resolve(f):re(d,i)).catch(e=>P(e)?P(e,N.NAVIGATION_GUARD_REDIRECT)?e:fe(e):ue(e,d,i)).then(e=>{if(e){if(P(e,N.NAVIGATION_GUARD_REDIRECT))return T(j({replace:s},S(e.to),{state:typeof e.to==`object`?j({},a,e.to.state):a,force:o}),t||d)}else e=ae(d,i,!0,s,a);return ie(d,i,e),e})}function ne(e,t){let n=C(e,t);return n?Promise.reject(n):Promise.resolve()}function E(e){let t=ge.values().next().value;return t&&typeof t.runWithContext==`function`?t.runWithContext(e):e()}function re(e,t){let n,[r,i,s]=Ut(e,t);n=Ht(r.reverse(),`beforeRouteLeave`,e,t);for(let i of r)i.leaveGuards.forEach(r=>{n.push(I(r,e,t))});let c=ne.bind(null,e,t);return n.push(c),k(n).then(()=>{n=[];for(let r of a.list())n.push(I(r,e,t));return n.push(c),k(n)}).then(()=>{n=Ht(i,`beforeRouteUpdate`,e,t);for(let r of i)r.updateGuards.forEach(r=>{n.push(I(r,e,t))});return n.push(c),k(n)}).then(()=>{n=[];for(let r of s)if(r.beforeEnter)if(M(r.beforeEnter))for(let i of r.beforeEnter)n.push(I(i,e,t));else n.push(I(r.beforeEnter,e,t));return n.push(c),k(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=Ht(s,`beforeRouteEnter`,e,t,E),n.push(c),k(n))).then(()=>{n=[];for(let r of o.list())n.push(I(r,e,t));return n.push(c),k(n)}).catch(e=>P(e,N.NAVIGATION_CANCELLED)?e:Promise.reject(e))}function ie(e,t,n){s.list().forEach(r=>E(()=>r(e,t,n)))}function ae(e,t,n,r,a){let o=C(e,t);if(o)return o;let s=t===F,l=ke?history.state:{};n&&(r||s?i.replace(e.fullPath,j({scroll:s&&l&&l.scroll},a)):i.push(e.fullPath,a)),c.value=e,pe(e,t,n,s),fe()}let oe;function se(){oe||=i.listen((e,t,n)=>{if(!O.listening)return;let r=b(e),a=te(r,O.currentRoute.value);if(a){T(j(a,{replace:!0,force:!0}),r).catch(Ne);return}l=r;let o=c.value;ke&&Mt(At(o.fullPath,n.delta),Ot()),re(r,o).catch(e=>P(e,N.NAVIGATION_ABORTED|N.NAVIGATION_CANCELLED)?e:P(e,N.NAVIGATION_GUARD_REDIRECT)?(T(j(S(e.to),{force:!0}),r).then(e=>{P(e,N.NAVIGATION_ABORTED|N.NAVIGATION_DUPLICATED)&&!n.delta&&n.type===St.pop&&i.go(-1,!1)}).catch(Ne),Promise.reject()):(n.delta&&i.go(-n.delta,!1),ue(e,r,o))).then(e=>{e||=ae(r,o,!1),e&&(n.delta&&!P(e,N.NAVIGATION_CANCELLED)?i.go(-n.delta,!1):n.type===St.pop&&P(e,N.NAVIGATION_ABORTED|N.NAVIGATION_DUPLICATED)&&i.go(-1,!1)),ie(r,o,e)}).catch(Ne)})}let ce=zt(),le=zt(),D;function ue(e,t,n){fe(e);let r=le.list();return r.length?r.forEach(r=>r(e,t,n)):console.error(e),Promise.reject(e)}function de(){return D&&c.value!==F?Promise.resolve():new Promise((e,t)=>{ce.add([e,t])})}function fe(e){return D||(D=!e,se(),ce.list().forEach(([t,n])=>e?n(e):t()),ce.reset()),e}function pe(t,n,r,i){let{scrollBehavior:a}=e;if(!ke||!a)return Promise.resolve();let o=!r&&Nt(At(t.fullPath,0))||(i||!r)&&history.state&&history.state.scroll||null;return d().then(()=>a(t,n,o)).then(e=>e&&kt(e)).catch(e=>ue(e,t,n))}let me=e=>i.go(e),he,ge=new Set,O={currentRoute:c,listening:!0,addRoute:m,removeRoute:g,clearRoutes:t.clearRoutes,hasRoute:y,getRoutes:v,resolve:b,options:e,push:w,replace:ee,go:me,back:()=>me(-1),forward:()=>me(1),beforeEach:a.add,beforeResolve:o.add,afterEach:s.add,onError:le.add,isReady:de,install(e){e.component(`RouterLink`,bn),e.component(`RouterView`,Dn),e.config.globalProperties.$router=O,Object.defineProperty(e.config.globalProperties,`$route`,{enumerable:!0,get:()=>x(c)}),ke&&!he&&c.value===F&&(he=!0,w(i.location).catch(e=>{}));let t={};for(let e in F)Object.defineProperty(t,e,{get:()=>c.value[e],enumerable:!0});e.provide(ze,O),e.provide(Be,h(t)),e.provide(Ve,c);let n=e.unmount;ge.add(e),e.unmount=function(){ge.delete(e),ge.size<1&&(l=F,oe&&oe(),oe=null,c.value=F,he=!1,D=!1),n()}}};function k(e){return e.reduce((e,t)=>e.then(()=>E(t)),Promise.resolve())}return O}function kn(e,t){return function(){return e.apply(t,arguments)}}var{toString:An}=Object.prototype,{getPrototypeOf:jn}=Object,{iterator:Mn,toStringTag:Nn}=Symbol,Pn=(e=>t=>{let n=An.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),B=e=>(e=e.toLowerCase(),t=>Pn(t)===e),Fn=e=>t=>typeof t===e,{isArray:In}=Array,Ln=Fn(`undefined`);function Rn(e){return e!==null&&!Ln(e)&&e.constructor!==null&&!Ln(e.constructor)&&V(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var zn=B(`ArrayBuffer`);function Bn(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&zn(e.buffer),t}var Vn=Fn(`string`),V=Fn(`function`),Hn=Fn(`number`),Un=e=>typeof e==`object`&&!!e,Wn=e=>e===!0||e===!1,Gn=e=>{if(Pn(e)!==`object`)return!1;let t=jn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Nn in e)&&!(Mn in e)},Kn=e=>{if(!Un(e)||Rn(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},qn=B(`Date`),Jn=B(`File`),Yn=e=>!!(e&&e.uri!==void 0),Xn=e=>e&&e.getParts!==void 0,Zn=B(`Blob`),Qn=B(`FileList`),$n=e=>Un(e)&&V(e.pipe);function er(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var tr=er(),nr=tr.FormData===void 0?void 0:tr.FormData,rr=e=>{let t;return e&&(nr&&e instanceof nr||V(e.append)&&((t=Pn(e))===`formdata`||t===`object`&&V(e.toString)&&e.toString()===`[object FormData]`))},ir=B(`URLSearchParams`),[ar,or,sr,cr]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(B),lr=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function ur(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),In(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}var H=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,fr=e=>!Ln(e)&&e!==H;function pr(){let{caseless:e,skipUndefined:t}=fr(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&dr(n,i)||i;Gn(n[a])&&Gn(r)?n[a]=pr(n[a],r):Gn(r)?n[a]=pr({},r):In(r)?n[a]=r.slice():(!t||!Ln(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e(ur(t,(t,r)=>{n&&V(t)?Object.defineProperty(e,r,{value:kn(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),hr=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gr=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},_r=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&jn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vr=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},yr=e=>{if(!e)return null;if(In(e))return e;let t=e.length;if(!Hn(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},br=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&jn(Uint8Array)),xr=(e,t)=>{let n=(e&&e[Mn]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Sr=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Cr=B(`HTMLFormElement`),wr=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),Tr=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Er=B(`RegExp`),Dr=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};ur(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Or=e=>{Dr(e,(t,n)=>{if(V(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(V(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},kr=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return In(e)?r(e):r(String(e).split(t)),n},Ar=()=>{},jr=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Mr(e){return!!(e&&V(e.append)&&e[Nn]===`FormData`&&e[Mn])}var Nr=e=>{let t=Array(10),n=(e,r)=>{if(Un(e)){if(t.indexOf(e)>=0)return;if(Rn(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=In(e)?[]:{};return ur(e,(e,t)=>{let a=n(e,r+1);!Ln(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Pr=B(`AsyncFunction`),Fr=e=>e&&(Un(e)||V(e))&&V(e.then)&&V(e.catch),Ir=((e,t)=>e?setImmediate:t?((e,t)=>(H.addEventListener(`message`,({source:n,data:r})=>{n===H&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),H.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,V(H.postMessage)),U={isArray:In,isArrayBuffer:zn,isBuffer:Rn,isFormData:rr,isArrayBufferView:Bn,isString:Vn,isNumber:Hn,isBoolean:Wn,isObject:Un,isPlainObject:Gn,isEmptyObject:Kn,isReadableStream:ar,isRequest:or,isResponse:sr,isHeaders:cr,isUndefined:Ln,isDate:qn,isFile:Jn,isReactNativeBlob:Yn,isReactNative:Xn,isBlob:Zn,isRegExp:Er,isFunction:V,isStream:$n,isURLSearchParams:ir,isTypedArray:br,isFileList:Qn,forEach:ur,merge:pr,extend:mr,trim:lr,stripBOM:hr,inherits:gr,toFlatObject:_r,kindOf:Pn,kindOfTest:B,endsWith:vr,toArray:yr,forEachEntry:xr,matchAll:Sr,isHTMLForm:Cr,hasOwnProperty:Tr,hasOwnProp:Tr,reduceDescriptors:Dr,freezeMethods:Or,toObjectSet:kr,toCamelCase:wr,noop:Ar,toFiniteNumber:jr,findKey:dr,global:H,isContextDefined:fr,isSpecCompliantForm:Mr,toJSONObject:Nr,isAsyncFn:Pr,isThenable:Fr,setImmediate:Ir,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(H):typeof process<`u`&&process.nextTick||Ir,isIterable:e=>e!=null&&V(e[Mn])},W=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:U.toJSONObject(this.config),code:this.code,status:this.status}}};W.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,W.ERR_BAD_OPTION=`ERR_BAD_OPTION`,W.ECONNABORTED=`ECONNABORTED`,W.ETIMEDOUT=`ETIMEDOUT`,W.ERR_NETWORK=`ERR_NETWORK`,W.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,W.ERR_DEPRECATED=`ERR_DEPRECATED`,W.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,W.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,W.ERR_CANCELED=`ERR_CANCELED`,W.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,W.ERR_INVALID_URL=`ERR_INVALID_URL`;function Lr(e){return U.isPlainObject(e)||U.isArray(e)}function Rr(e){return U.endsWith(e,`[]`)?e.slice(0,-2):e}function zr(e,t,n){return e?e.concat(t).map(function(e,t){return e=Rr(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function Br(e){return U.isArray(e)&&!e.some(Lr)}var Vr=U.toFlatObject(U,{},null,function(e){return/^is[A-Z]/.test(e)});function Hr(e,t,n){if(!U.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!U.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if(U.isDate(e))return e.toISOString();if(U.isBoolean(e))return e.toString();if(!s&&U.isBlob(e))throw new W(`Blob is not supported. Use a Buffer instead.`);return U.isArrayBuffer(e)||U.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(U.isReactNative(t)&&U.isReactNativeBlob(e))return t.append(zr(i,n,a),c(e)),!1;if(e&&!i&&typeof e==`object`){if(U.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(U.isArray(e)&&Br(e)||(U.isFileList(e)||U.endsWith(n,`[]`))&&(s=U.toArray(e)))return n=Rr(n),s.forEach(function(e,r){!(U.isUndefined(e)||e===null)&&t.append(o===!0?zr([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return Lr(e)?!0:(t.append(zr(i,n,a),c(e)),!1)}let u=[],d=Object.assign(Vr,{defaultVisitor:l,convertValue:c,isVisitable:Lr});function f(e,n){if(!U.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),U.forEach(e,function(e,r){(!(U.isUndefined(e)||e===null)&&i.call(t,e,U.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!U.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function Ur(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Wr(e,t){this._pairs=[],e&&Hr(e,this,t)}var Gr=Wr.prototype;Gr.append=function(e,t){this._pairs.push([e,t])},Gr.toString=function(e){let t=e?function(t){return e.call(this,t,Ur)}:Ur;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function Kr(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function qr(e,t,n){if(!t)return e;let r=n&&n.encode||Kr,i=U.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):U.isURLSearchParams(t)?t.toString():new Wr(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var Jr=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){U.forEach(this.handlers,function(t){t!==null&&e(t)})}},Yr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Xr={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:Wr,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},Zr=e({hasBrowserEnv:()=>Qr,hasStandardBrowserEnv:()=>ei,hasStandardBrowserWebWorkerEnv:()=>ti,navigator:()=>$r,origin:()=>ni}),Qr=typeof window<`u`&&typeof document<`u`,$r=typeof navigator==`object`&&navigator||void 0,ei=Qr&&(!$r||[`ReactNative`,`NativeScript`,`NS`].indexOf($r.product)<0),ti=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,ni=Qr&&window.location.href||`http://localhost`,G={...Zr,...Xr};function ri(e,t){return Hr(e,new G.classes.URLSearchParams,{visitor:function(e,t,n,r){return G.isNode&&U.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function ii(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function ai(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r=e.length;return a=!a&&U.isArray(r)?r.length:a,s?(U.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!U.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&U.isArray(r[a])&&(r[a]=ai(r[a])),!o)}if(U.isFormData(e)&&U.isFunction(e.entries)){let n={};return U.forEachEntry(e,(e,r)=>{t(ii(e),r,n,0)}),n}return null}function si(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var ci={transitional:Yr,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=U.isObject(e);if(i&&U.isHTMLForm(e)&&(e=new FormData(e)),U.isFormData(e))return r?JSON.stringify(oi(e)):e;if(U.isArrayBuffer(e)||U.isBuffer(e)||U.isStream(e)||U.isFile(e)||U.isBlob(e)||U.isReadableStream(e))return e;if(U.isArrayBufferView(e))return e.buffer;if(U.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return ri(e,this.formSerializer).toString();if((a=U.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return Hr(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),si(e)):e}],transformResponse:[function(e){let t=this.transitional||ci.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if(U.isResponse(e)||U.isReadableStream(e))return e;if(e&&U.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?W.from(e,W.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:G.classes.FormData,Blob:G.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};U.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{ci.headers[e]={}});var li=U.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),ui=e=>{let t={},n,r,i;return e&&e.split(` +`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&li[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},di=Symbol(`internals`);function fi(e){return e&&String(e).trim().toLowerCase()}function pi(e){return e===!1||e==null?e:U.isArray(e)?e.map(pi):String(e).replace(/[\r\n]+$/,``)}function mi(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var hi=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function gi(e,t,n,r,i){if(U.isFunction(r))return r.call(this,t,n);if(i&&(t=n),U.isString(t)){if(U.isString(r))return t.indexOf(r)!==-1;if(U.isRegExp(r))return r.test(t)}}function _i(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function vi(e,t){let n=U.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var K=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=fi(t);if(!i)throw Error(`header name must be a non-empty string`);let a=U.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=pi(e))}let a=(e,t)=>U.forEach(e,(e,n)=>i(e,n,t));if(U.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(U.isString(e)&&(e=e.trim())&&!hi(e))a(ui(e),t);else if(U.isObject(e)&&U.isIterable(e)){let n={},r,i;for(let t of e){if(!U.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?U.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=fi(e),e){let n=U.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return mi(e);if(U.isFunction(t))return t.call(this,e,n);if(U.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=fi(e),e){let n=U.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||gi(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=fi(e),e){let i=U.findKey(n,e);i&&(!t||gi(n,n[i],i,t))&&(delete n[i],r=!0)}}return U.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||gi(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return U.forEach(this,(r,i)=>{let a=U.findKey(n,i);if(a){t[a]=pi(r),delete t[i];return}let o=e?_i(i):String(i).trim();o!==i&&delete t[i],t[o]=pi(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return U.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&U.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(` +`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[di]=this[di]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=fi(e);t[r]||(vi(n,e),t[r]=!0)}return U.isArray(e)?e.forEach(r):r(e),this}};K.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),U.reduceDescriptors(K.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),U.freezeMethods(K);function yi(e,t){let n=this||ci,r=t||n,i=K.from(r.headers),a=r.data;return U.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function bi(e){return!!(e&&e.__CANCEL__)}var xi=class extends W{constructor(e,t,n){super(e??`canceled`,W.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function Si(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new W(`Request failed with status code `+n.status,[W.ERR_BAD_REQUEST,W.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ci(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function wi(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var Ei=(e,t,n=3)=>{let r=0,i=wi(50,250);return Ti(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},Di=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Oi=e=>(...t)=>U.asap(()=>e(...t)),ki=G.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,G.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(G.origin),G.navigator&&/(msie|trident)/i.test(G.navigator.userAgent)):()=>!0,Ai=G.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];U.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),U.isString(r)&&s.push(`path=${r}`),U.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),U.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function ji(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function Mi(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function Ni(e,t,n){let r=!ji(t);return e&&(r||n==0)?Mi(e,t):t}var Pi=e=>e instanceof K?{...e}:e;function q(e,t){t||={};let n={};function r(e,t,n,r){return U.isPlainObject(e)&&U.isPlainObject(t)?U.merge.call({caseless:r},e,t):U.isPlainObject(t)?U.merge({},t):U.isArray(t)?t.slice():t}function i(e,t,n,i){if(!U.isUndefined(t))return r(e,t,n,i);if(!U.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!U.isUndefined(t))return r(void 0,t)}function o(e,t){if(!U.isUndefined(t))return r(void 0,t);if(!U.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(Pi(e),Pi(t),n,!0)};return U.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=U.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);U.isUndefined(o)&&a!==s||(n[r]=o)}),n}var Fi=e=>{let t=q({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=K.from(o),t.url=qr(Ni(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),U.isFormData(n)){if(G.hasStandardBrowserEnv||G.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(U.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(G.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&ki(t.url))){let e=i&&a&&Ai.read(a);e&&o.set(i,e)}return t},Ii=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Fi(e),i=r.data,a=K.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=K.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());Si(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new W(`Request aborted`,W.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new W(t&&t.message?t.message:`Network Error`,W.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||Yr;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new W(t,i.clarifyTimeoutError?W.ETIMEDOUT:W.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&U.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),U.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=Ei(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=Ei(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new xi(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=Ci(r.url);if(_&&G.protocols.indexOf(_)===-1){n(new W(`Unsupported protocol `+_+`:`,W.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Li=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof W?t:new xi(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new W(`timeout of ${t}ms exceeded`,W.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>U.asap(o),s}},Ri=function*(e,t){let n=e.byteLength;if(!t||n{let i=zi(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},Hi=64*1024,{isFunction:Ui}=U,Wi=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Gi,TextEncoder:Ki}=U.global,qi=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ji=e=>{e=U.merge.call({skipUndefined:!0},Wi,e);let{fetch:t,Request:n,Response:r}=e,i=t?Ui(t):typeof fetch==`function`,a=Ui(n),o=Ui(r);if(!i)return!1;let s=i&&Ui(Gi),c=i&&(typeof Ki==`function`?(e=>t=>e.encode(t))(new Ki):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&qi(()=>{let e=!1,t=new Gi,r=new n(G.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&qi(()=>U.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new W(`Response type '${e}' is not supported`,W.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(U.isBlob(e))return e.size;if(U.isSpecCompliantForm(e))return(await new n(G.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(U.isArrayBufferView(e)||U.isArrayBuffer(e))return e.byteLength;if(U.isURLSearchParams(e)&&(e+=``),U.isString(e))return(await c(e)).byteLength},p=async(e,t)=>U.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=Fi(e),x=t||fetch;_=_?(_+``).toLowerCase():`text`;let S=Li([c,f&&f.toAbortSignal()],m),C=null,w=S&&S.unsubscribe&&(()=>{S.unsubscribe()}),ee;try{if(g&&l&&o!==`get`&&o!==`head`&&(ee=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(U.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=Di(ee,Ei(Oi(g)));s=Vi(e.body,Hi,t,n)}}U.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:S,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};C=a&&new n(i,c);let f=await(a?x(C,b):x(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&w)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=U.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&Di(t,Ei(Oi(h),!0))||[];f=new r(Vi(f.body,Hi,n,()=>{i&&i(),w&&w()}),e)}_||=`text`;let te=await d[U.findKey(d,_)||`text`](f,e);return!m&&w&&w(),await new Promise((t,n)=>{Si(t,n,{data:te,headers:K.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:C})})}catch(t){throw w&&w(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new W(`Network Error`,W.ERR_NETWORK,e,C,t&&t.response),{cause:t.cause||t}):W.from(t,t&&t.code,e,C,t&&t.response)}}},Yi=new Map,Xi=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=Yi;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:Ji(t)),l=c;return c};Xi();var Zi={http:null,xhr:Ii,fetch:{get:Xi}};U.forEach(Zi,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var Qi=e=>`- ${e}`,$i=e=>U.isFunction(e)||e===null||e===!1;function ea(e,t){e=U.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new W(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since : +`+e.map(Qi).join(` +`):` `+Qi(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var ta={getAdapter:ea,adapters:Zi};function na(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xi(null,e)}function ra(e){return na(e),e.headers=K.from(e.headers),e.data=yi.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),ta.getAdapter(e.adapter||ci.adapter,e)(e).then(function(t){return na(e),t.data=yi.call(e,e.transformResponse,t),t.headers=K.from(t.headers),t},function(t){return bi(t)||(na(e),t&&t.response&&(t.response.data=yi.call(e,e.transformResponse,t.response),t.response.headers=K.from(t.response.headers))),Promise.reject(t)})}var ia=`1.14.0`,aa={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{aa[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var oa={};aa.transitional=function(e,t,n){function r(e,t){return`[Axios v`+ia+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new W(r(i,` has been removed`+(t?` in `+t:``)),W.ERR_DEPRECATED);return t&&!oa[i]&&(oa[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},aa.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function sa(e,t,n){if(typeof e!=`object`)throw new W(`options must be an object`,W.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new W(`option `+a+` must be `+n,W.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new W(`Unknown option `+a,W.ERR_BAD_OPTION)}}var ca={assertOptions:sa,validators:aa},J=ca.validators,Y=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Jr,response:new Jr}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=t.stack?t.stack.replace(/^.+\n/,``):``;try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,``))&&(e.stack+=` +`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=q(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&ca.assertOptions(n,{silentJSONParsing:J.transitional(J.boolean),forcedJSONParsing:J.transitional(J.boolean),clarifyTimeoutError:J.transitional(J.boolean),legacyInterceptorReqResOrdering:J.transitional(J.boolean)},!1),r!=null&&(U.isFunction(r)?t.paramsSerializer={serialize:r}:ca.assertOptions(r,{encode:J.function,serialize:J.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),ca.assertOptions(t,{baseUrl:J.spelling(`baseURL`),withXsrfToken:J.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&U.merge(i.common,i[t.method]);i&&U.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=K.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||Yr;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[ra.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new xi(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function ua(e){return function(t){return e.apply(null,t)}}function da(e){return U.isObject(e)&&e.isAxiosError===!0}var fa={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(fa).forEach(([e,t])=>{fa[t]=e});function pa(e){let t=new Y(e),n=kn(Y.prototype.request,t);return U.extend(n,Y.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return pa(q(e,t))},n}var X=pa(ci);X.Axios=Y,X.CanceledError=xi,X.CancelToken=la,X.isCancel=bi,X.VERSION=ia,X.toFormData=Hr,X.AxiosError=W,X.Cancel=X.CanceledError,X.all=function(e){return Promise.all(e)},X.spread=ua,X.isAxiosError=da,X.mergeConfig=q,X.AxiosHeaders=K,X.formToJSON=e=>oi(U.isHTMLForm(e)?new FormData(e):e),X.getAdapter=ta.getAdapter,X.HttpStatusCode=fa,X.default=X;var ma=`pymc_jwt_token`,ha=`pymc_client_id`;function ga(){let e=localStorage.getItem(ha);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(ha,e)),e}function Z(){return localStorage.getItem(ma)}function _a(e){localStorage.setItem(ma,e)}function va(){localStorage.removeItem(ma)}function ya(){return Z()!==null}function ba(e){try{let t=e.split(`.`)[1].replace(/-/g,`+`).replace(/_/g,`/`),n=decodeURIComponent(atob(t).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``));return JSON.parse(n)}catch{return null}}function xa(){let e=Z();if(!e)return!0;let t=ba(e);return!t||!t.exp?!0:Date.now()>=t.exp*1e3-3e4}function Sa(){let e=Z();if(!e)return!1;let t=ba(e);if(!t||!t.exp)return!1;let n=t.exp*1e3-Date.now();return n>0&&n<3e5}function Ca(){let e=Z();if(!e)return null;let t=ba(e);return!t||!t.sub?null:t.sub}var wa=`modulepreload`,Ta=function(e){return`/`+e},Ea={},Q=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ta(t,n),t in Ea)return;Ea[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:wa,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Da=On({history:Yt(`/`),routes:[{path:`/setup`,name:`setup`,component:()=>Q(()=>import(`./Setup-CaLinAtC.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),meta:{requiresAuth:!1,requiresSetup:!1}},{path:`/login`,name:`login`,component:()=>Q(()=>import(`./Login-DTJPC25k.js`),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,12,16])),meta:{requiresAuth:!1}},{path:`/`,name:`dashboard`,component:()=>Q(()=>import(`./Dashboard-BQS_QL_q.js`),__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,10,11,12,18,19,20,21])),meta:{requiresAuth:!0}},{path:`/neighbors`,name:`neighbors`,component:()=>Q(()=>import(`./Neighbors-DSCosrf5.js`),__vite__mapDeps([22,1,23,3,4,24,5,19,9,8,7,25,20,26,27])),meta:{requiresAuth:!0}},{path:`/statistics`,name:`statistics`,component:()=>Q(()=>import(`./Statistics-BeGVnnkk.js`),__vite__mapDeps([28,18,3,5,4,29,1,30,8])),meta:{requiresAuth:!0}},{path:`/gps`,name:`gps-diagnostics`,component:()=>Q(()=>import(`./GPSDiagnostics-crPCBW12.js`),__vite__mapDeps([31,1,3,4,32])),meta:{requiresAuth:!0}},{path:`/system-stats`,name:`system-stats`,component:()=>Q(()=>import(`./SystemStats-sG4byBWD.js`),__vite__mapDeps([33,1,23,2,3,4,5,6,7,8,9,10,11,12,18,29,30,25,34])),meta:{requiresAuth:!0}},{path:`/sensors`,name:`sensors`,component:()=>Q(()=>import(`./Sensors-C31-xdDY.js`),__vite__mapDeps([35,2,1,3,4,5,6,7,8,9,10,11,12])),meta:{requiresAuth:!0}},{path:`/configuration`,name:`configuration`,component:()=>Q(()=>import(`./Configuration-DqetrFgk.js`),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,11,12,13,37,38,23,39,27,25,20,40])),meta:{requiresAuth:!0}},{path:`/cad-calibration`,name:`cad-calibration`,component:()=>Q(()=>import(`./CADCalibration-CMgcsyU9.js`),__vite__mapDeps([41,1,23,2,3,4,5,6,7,8,9,10,11,12,42,43])),meta:{requiresAuth:!0}},{path:`/sessions`,name:`sessions`,component:()=>Q(()=>import(`./Sessions-XCAfIBGI.js`),__vite__mapDeps([44,3,4,5])),meta:{requiresAuth:!0}},{path:`/room-servers`,name:`room-servers`,component:()=>Q(()=>import(`./RoomServers-DBObY362.js`),__vite__mapDeps([45,2,1,3,4,5,6,7,8,9,10,11,12,37,38,23,39,27,46,20])),meta:{requiresAuth:!0}},{path:`/companions`,name:`companions`,component:()=>Q(()=>import(`./Companions-CPdWnFPt.js`),__vite__mapDeps([47,2,1,3,4,5,6,7,8,9,10,11,12,37,46])),meta:{requiresAuth:!0}},{path:`/logs`,name:`logs`,component:()=>Q(()=>import(`./Logs-Dw5-qzdU.js`),__vite__mapDeps([48,3,5])),meta:{requiresAuth:!0}},{path:`/terminal`,name:`terminal`,component:()=>Q(()=>import(`./Terminal-IUdfvY-m.js`),__vite__mapDeps([49,1,3,4,6,9,8,11,50])),meta:{requiresAuth:!0}},{path:`/help`,name:`help`,component:()=>Q(()=>import(`./Help-CfDEEAoD.js`),__vite__mapDeps([51,3])),meta:{requiresAuth:!0}}]}),Oa=!1;async function ka(){if(Oa)return!1;try{let e=await fetch(`/api/needs_setup`,{headers:{Accept:`application/json`}});if(!e.ok)return console.error(`Setup check failed:`,e.status),!1;let t=(await e.json()).needs_setup===!0;return t||(Oa=!0),t}catch(e){return console.error(`Error checking setup status:`,e),!1}}Da.beforeEach(async e=>{if(await ka())return e.path===`/setup`?void 0:`/setup`;if(e.path===`/setup`)return`/login`;let t=e.meta.requiresAuth!==!1,n=ya();if(t&&!n)return`/login`;if(e.path===`/login`&&n)return`/`});var Aa=De(`appRuntime`,()=>{let e=g(typeof navigator>`u`?!0:navigator.onLine),t=g(typeof document>`u`?!0:document.visibilityState===`visible`),n=g(!1),r=g(null),i=g(!1),a=S(()=>e.value&&t.value&&n.value&&!i.value);function o(){n.value=!!Z()&&!xa(),n.value||(r.value=r.value??`expired`)}function s(){n.value=!0,r.value=null,i.value=!1}function c(t){e.value=t}function l(e){t.value=e}async function u(e){if(i.value)return;i.value=!0,r.value=e,n.value=!1;let{useWebSocketStore:t}=await Q(async()=>{let{useWebSocketStore:e}=await import(`./websocket-CFOZ2WXa.js`);return{useWebSocketStore:e}},__vite__mapDeps([52,10,3,7,8,9])),{usePacketStore:a}=await Q(async()=>{let{usePacketStore:e}=await import(`./packets-i0z-xors.js`);return{usePacketStore:e}},__vite__mapDeps([53,8,3])),{useSystemStore:o}=await Q(async()=>{let{useSystemStore:e}=await import(`./system-BivdkLQN.js`);return{useSystemStore:e}},__vite__mapDeps([54,9,3,8])),{useDataService:s}=await Q(async()=>{let{useDataService:e}=await import(`./dataService-BP1CezIa.js`);return{useDataService:e}},__vite__mapDeps([55,7,3,8,9])),c=t(),l=a(),u=o(),d=s();c.disconnect({preventReconnect:!0,silent:e!==`logout`}),l.reset(),u.reset(),d.reset(),va(),Da.currentRoute.value.path!==`/login`&&await Da.push(`/login`),i.value=!1}async function d(e){await u(e)}return{isOnline:e,isDocumentVisible:t,isAuthenticated:n,authFailureReason:r,canMaintainConnections:a,syncAuthState:o,markAuthenticated:s,setOnline:c,setDocumentVisible:l,stopSession:u,handleAuthFailure:d}}),ja=`/api`,Ma=!1,Na=null;async function Pa(){return Ma&&Na?Na:(Ma=!0,Na=(async()=>{try{let e=Z();if(!e)throw Error(`No token to refresh`);let t=ga(),n=await X.post(`/auth/refresh`,{client_id:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`}});if(n.data.success&&n.data.token){let e=n.data.token;return _a(e),e}else throw Error(`Token refresh failed`)}catch(e){throw console.error(`Token refresh error:`,e),await Aa().handleAuthFailure(`expired`),e}finally{Ma=!1,Na=null}})(),Na)}var $=X.create({baseURL:ja,timeout:1e4,headers:{"Content-Type":`application/json`}}),Fa=X.create({baseURL:``,timeout:1e4,headers:{"Content-Type":`application/json`}});Fa.interceptors.request.use(async e=>{if(e.url?.includes(`/auth/login`)||e.url?.includes(`/auth/refresh`))return e;let t=Z();if(t){if(Sa())try{let t=await Pa();return e.headers.Authorization=`Bearer ${t}`,e}catch(e){return Promise.reject(e)}if(xa())return Aa().handleAuthFailure(`expired`),Promise.reject(Error(`Token expired`));e.headers.Authorization=`Bearer ${t}`}return e},e=>(console.error(`Auth API Request Error:`,e),Promise.reject(e))),Fa.interceptors.response.use(e=>e,e=>{if(e.response?.status===401||e.response?.status===403){let t=(e.config?.headers?.Authorization)?.replace(`Bearer `,``),n=Z();(!t||t===n)&&Aa().handleAuthFailure(e.response?.status===403?`forbidden`:`unauthorized`)}return console.error(`Auth API Response Error:`,e.response?.data||e.message),Promise.reject(e)}),$.interceptors.request.use(async e=>{if(e.url?.includes(`/auth/login`))return e;let t=Z();if(t){if(Sa())try{let t=await Pa();return e.headers.Authorization=`Bearer ${t}`,e}catch(e){return Promise.reject(e)}if(xa())return Aa().handleAuthFailure(`expired`),Promise.reject(Error(`Token expired`));e.headers.Authorization=`Bearer ${t}`}return e},e=>(console.error(`API Request Error:`,e),Promise.reject(e))),$.interceptors.response.use(e=>e,e=>{if(e.response?.status===401||e.response?.status===403){let t=(e.config?.headers?.Authorization)?.replace(`Bearer `,``),n=Z();(!t||t===n)&&Aa().handleAuthFailure(e.response?.status===403?`forbidden`:`unauthorized`)}return console.error(`API Response Error:`,e.response?.data||e.message),Promise.reject(e)});var Ia=class{static async get(e,t,n){try{return(await $.get(e,{params:t,...n})).data}catch(e){throw this.handleError(e)}}static async post(e,t,n){try{return(await $.post(e,t,n)).data}catch(e){throw this.handleError(e)}}static async put(e,t,n){try{return(await $.put(e,t,n)).data}catch(e){throw this.handleError(e)}}static async delete(e,t){try{return(await $.delete(e,t)).data}catch(e){throw this.handleError(e)}}static async getTransportKeys(){return this.get(`transport_keys`)}static async sendAdvert(){return this.post(`send_advert`,{},{headers:{"Content-Type":`application/json`}})}static async getGpsDiagnostics(){return this.get(`gps`)}static async getSerialPorts(){return this.get(`serial_ports`)}static async createTransportKey(e,t,n,r,i){let a={name:e,flood_policy:t,parent_id:r,last_used:i};return n!==void 0&&(a.transport_key=n),this.post(`transport_keys`,a)}static async getTransportKey(e){return this.get(`transport_key/${e}`)}static async updateTransportKey(e,t,n,r,i,a){return this.put(`transport_key/${e}`,{name:t,flood_policy:n,transport_key:r,parent_id:i,last_used:a})}static async deleteTransportKey(e){return this.delete(`transport_key/${e}`)}static async updateUnscopedFloodPolicy(e){return this.post(`unscoped_flood_policy`,{unscoped_flood_allow:e})}static async getLogs(){try{return(await $.get(`logs`)).data}catch(e){throw this.handleError(e)}}static async deleteAdvert(e){return this.delete(`advert/${e}`)}static async pingNeighbor(e,t=10){return this.post(`ping_neighbor`,{target_id:e,timeout:t})}static async getIdentities(){return this.get(`identities`)}static async getIdentity(e){return this.get(`identity`,{name:e})}static async createIdentity(e){return this.post(`create_identity`,e)}static async updateIdentity(e){return this.put(`update_identity`,e)}static async deleteIdentity(e,t=`room_server`){let n=new URLSearchParams({name:e});return t===`companion`&&n.set(`type`,`companion`),this.delete(`delete_identity?${n.toString()}`)}static async sendRoomServerAdvert(e){return this.post(`send_room_server_advert`,{name:e})}static async importRepeaterContacts(e){return this.post(`companion/import_repeater_contacts`,e)}static async getACLInfo(){return this.get(`acl_info`)}static async getACLClients(e){return this.get(`acl_clients`,e)}static async removeACLClient(e){return this.post(`acl_remove_client`,e)}static async getACLStats(){return this.get(`acl_stats`)}static async getRoomMessages(e){return this.get(`room_messages`,e)}static async postRoomMessage(e){return this.post(`room_post_message`,e)}static async deleteRoomMessage(e){return this.delete(`room_message?room_name=${encodeURIComponent(e.room_name)}&message_id=${e.message_id}`)}static async clearRoomMessages(e){return this.delete(`room_messages?room_name=${encodeURIComponent(e)}`)}static async getRoomStats(e){return this.get(`room_stats`,e?{room_name:e}:void 0)}static async getRoomClients(e){return this.get(`room_clients`,{room_name:e})}static async exportConfig(e=!1){let t=e?`config_export?include_secrets=true`:`config_export`;return this.get(t)}static async importConfig(e){return this.post(`config_import`,{config:e})}static async exportIdentityKey(){return this.get(`identity_export`)}static async generateVanityKey(e,t=!1){return this.post(`generate_vanity_key`,{prefix:e,apply:t})}static async getDbStats(){return this.get(`db_stats`)}static async purgeTable(e){return this.post(`db_purge`,{tables:e})}static async vacuumDb(){return this.post(`db_vacuum`,{})}static handleError(e){if(X.isAxiosError(e)){if(e.response){let t=e.response.data?.error||e.response.data?.message||`HTTP ${e.response.status}`;return Error(t)}else if(e.request)return Error(`Network error - no response received`)}return Error(e instanceof Error?e.message:`Unknown error occurred`)}};export{De as _,Da as a,ga as c,xa as d,_a as f,ge as g,He as h,Aa as i,Z as l,Ue as m,$ as n,Q as o,Vt as p,Fa as r,va as s,Ia as t,Ca as u,Oe as v}; \ No newline at end of file diff --git a/repeater/web/html/assets/api-CbM6k1ZB.js b/repeater/web/html/assets/api-CbM6k1ZB.js deleted file mode 100644 index 0b84a7c4..00000000 --- a/repeater/web/html/assets/api-CbM6k1ZB.js +++ /dev/null @@ -1,7 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Setup-DvdSE7ue.js","assets/_plugin-vue_export-helper-B7aGp3iI.js","assets/index-BFltqMtv.js","assets/runtime-core.esm-bundler-HnidnMFy.js","assets/vue-router-Cr0wB7EX.js","assets/useTheme-DMOVV09x.js","assets/packets-C-dzvp0W.js","assets/system-BH4r-ii6.js","assets/websocket-nXR7EYbj.js","assets/index-Crl6CjFg.css","assets/Setup-DiRq9fgD.css","assets/Login-Yx7HUvzW.js","assets/Login-CRioMgum.css","assets/Dashboard-ClL05x7j.js","assets/chart-B1uYMRrx.js","assets/useSignalQuality-BfZWbBxN.js","assets/preferences-Bv8i60GL.js","assets/Dashboard-BLK8l9Tc.css","assets/Neighbors-CQcUQfDG.js","assets/chunk-DECur_0Z.js","assets/leaflet-src-PYB8oVmQ.js","assets/Neighbors-Cfo189NY.css","assets/leaflet-vh-t_kPv.css","assets/Statistics-S4HgWYku.js","assets/chartjs-adapter-date-fns.esm-DnBoPdP1.js","assets/chartjs-adapter-date-fns-BqJ94ASW.css","assets/plotly.min-Dl7ekyci.js","assets/Statistics-CsAO5q_U.css","assets/SystemStats-4wDqjB6x.js","assets/SystemStats-Dnc1_s5j.css","assets/Configuration-BoG9PyTQ.js","assets/ConfirmDialog-PLW-eI8u.js","assets/Configuration-zQuuYGWe.css","assets/CADCalibration-CK9zSc8M.js","assets/CADCalibration-gZQwotT3.css","assets/Sessions-DhR0b50N.js","assets/RoomServers-Cngso7KV.js","assets/MessageDialog-CEzYMZ-3.js","assets/Companions-Cm95T8nb.js","assets/Logs-DiVYCMnG.js","assets/Terminal-Dpu_GlNL.js","assets/Terminal-tmed9q5z.css","assets/Help-CaIFoQMt.js","assets/websocket-NnYyxr--.js","assets/packets-B_GG5R7y.js","assets/system-Cl32lKH8.js"])))=>i.map(i=>d[i]); -import{n as e}from"./chunk-DECur_0Z.js";import{o as t,z as n}from"./runtime-core.esm-bundler-HnidnMFy.js";import{n as r,o as i,t as a}from"./vue-router-Cr0wB7EX.js";function o(e,t){return function(){return e.apply(t,arguments)}}var{toString:s}=Object.prototype,{getPrototypeOf:c}=Object,{iterator:l,toStringTag:u}=Symbol,d=(e=>t=>{let n=s.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),f=e=>(e=e.toLowerCase(),t=>d(t)===e),p=e=>t=>typeof t===e,{isArray:m}=Array,h=p(`undefined`);function g(e){return e!==null&&!h(e)&&e.constructor!==null&&!h(e.constructor)&&b(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var _=f(`ArrayBuffer`);function v(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&_(e.buffer),t}var y=p(`string`),b=p(`function`),x=p(`number`),S=e=>typeof e==`object`&&!!e,C=e=>e===!0||e===!1,w=e=>{if(d(e)!==`object`)return!1;let t=c(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(u in e)&&!(l in e)},ee=e=>{if(!S(e)||g(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},te=f(`Date`),ne=f(`File`),re=e=>!!(e&&e.uri!==void 0),ie=e=>e&&e.getParts!==void 0,ae=f(`Blob`),oe=f(`FileList`),se=e=>S(e)&&b(e.pipe);function ce(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var le=ce(),ue=le.FormData===void 0?void 0:le.FormData,de=e=>{let t;return e&&(ue&&e instanceof ue||b(e.append)&&((t=d(e))===`formdata`||t===`object`&&b(e.toString)&&e.toString()===`[object FormData]`))},fe=f(`URLSearchParams`),[pe,me,he,ge]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(f),_e=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function T(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),m(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}var E=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,ye=e=>!h(e)&&e!==E;function be(){let{caseless:e,skipUndefined:t}=ye(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&ve(n,i)||i;w(n[a])&&w(r)?n[a]=be(n[a],r):w(r)?n[a]=be({},r):m(r)?n[a]=r.slice():(!t||!h(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e(T(t,(t,r)=>{n&&b(t)?Object.defineProperty(e,r,{value:o(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Se=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ce=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},we=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&c(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Te=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Ee=e=>{if(!e)return null;if(m(e))return e;let t=e.length;if(!x(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},De=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&c(Uint8Array)),Oe=(e,t)=>{let n=(e&&e[l]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},ke=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ae=f(`HTMLFormElement`),je=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),Me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ne=f(`RegExp`),Pe=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};T(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Fe=e=>{Pe(e,(t,n)=>{if(b(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(b(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Ie=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return m(e)?r(e):r(String(e).split(t)),n},Le=()=>{},Re=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ze(e){return!!(e&&b(e.append)&&e[u]===`FormData`&&e[l])}var Be=e=>{let t=Array(10),n=(e,r)=>{if(S(e)){if(t.indexOf(e)>=0)return;if(g(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=m(e)?[]:{};return T(e,(e,t)=>{let a=n(e,r+1);!h(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Ve=f(`AsyncFunction`),He=e=>e&&(S(e)||b(e))&&b(e.then)&&b(e.catch),Ue=((e,t)=>e?setImmediate:t?((e,t)=>(E.addEventListener(`message`,({source:n,data:r})=>{n===E&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),E.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,b(E.postMessage)),D={isArray:m,isArrayBuffer:_,isBuffer:g,isFormData:de,isArrayBufferView:v,isString:y,isNumber:x,isBoolean:C,isObject:S,isPlainObject:w,isEmptyObject:ee,isReadableStream:pe,isRequest:me,isResponse:he,isHeaders:ge,isUndefined:h,isDate:te,isFile:ne,isReactNativeBlob:re,isReactNative:ie,isBlob:ae,isRegExp:Ne,isFunction:b,isStream:se,isURLSearchParams:fe,isTypedArray:De,isFileList:oe,forEach:T,merge:be,extend:xe,trim:_e,stripBOM:Se,inherits:Ce,toFlatObject:we,kindOf:d,kindOfTest:f,endsWith:Te,toArray:Ee,forEachEntry:Oe,matchAll:ke,isHTMLForm:Ae,hasOwnProperty:Me,hasOwnProp:Me,reduceDescriptors:Pe,freezeMethods:Fe,toObjectSet:Ie,toCamelCase:je,noop:Le,toFiniteNumber:Re,findKey:ve,global:E,isContextDefined:ye,isSpecCompliantForm:ze,toJSONObject:Be,isAsyncFn:Ve,isThenable:He,setImmediate:Ue,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(E):typeof process<`u`&&process.nextTick||Ue,isIterable:e=>e!=null&&b(e[l])},O=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}};O.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,O.ERR_BAD_OPTION=`ERR_BAD_OPTION`,O.ECONNABORTED=`ECONNABORTED`,O.ETIMEDOUT=`ETIMEDOUT`,O.ERR_NETWORK=`ERR_NETWORK`,O.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,O.ERR_DEPRECATED=`ERR_DEPRECATED`,O.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,O.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,O.ERR_CANCELED=`ERR_CANCELED`,O.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,O.ERR_INVALID_URL=`ERR_INVALID_URL`;function k(e){return D.isPlainObject(e)||D.isArray(e)}function We(e){return D.endsWith(e,`[]`)?e.slice(0,-2):e}function A(e,t,n){return e?e.concat(t).map(function(e,t){return e=We(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function Ge(e){return D.isArray(e)&&!e.some(k)}var Ke=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function j(e,t,n){if(!D.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=D.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!D.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if(D.isDate(e))return e.toISOString();if(D.isBoolean(e))return e.toString();if(!s&&D.isBlob(e))throw new O(`Blob is not supported. Use a Buffer instead.`);return D.isArrayBuffer(e)||D.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(D.isReactNative(t)&&D.isReactNativeBlob(e))return t.append(A(i,n,a),c(e)),!1;if(e&&!i&&typeof e==`object`){if(D.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(D.isArray(e)&&Ge(e)||(D.isFileList(e)||D.endsWith(n,`[]`))&&(s=D.toArray(e)))return n=We(n),s.forEach(function(e,r){!(D.isUndefined(e)||e===null)&&t.append(o===!0?A([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return k(e)?!0:(t.append(A(i,n,a),c(e)),!1)}let u=[],d=Object.assign(Ke,{defaultVisitor:l,convertValue:c,isVisitable:k});function f(e,n){if(!D.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),D.forEach(e,function(e,r){(!(D.isUndefined(e)||e===null)&&i.call(t,e,D.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!D.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function qe(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Je(e,t){this._pairs=[],e&&j(e,this,t)}var Ye=Je.prototype;Ye.append=function(e,t){this._pairs.push([e,t])},Ye.toString=function(e){let t=e?function(t){return e.call(this,t,qe)}:qe;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function Xe(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function Ze(e,t,n){if(!t)return e;let r=n&&n.encode||Xe,i=D.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):D.isURLSearchParams(t)?t.toString():new Je(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var Qe=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){D.forEach(this.handlers,function(t){t!==null&&e(t)})}},$e={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},et={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:Je,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},tt=e({hasBrowserEnv:()=>nt,hasStandardBrowserEnv:()=>it,hasStandardBrowserWebWorkerEnv:()=>at,navigator:()=>rt,origin:()=>ot}),nt=typeof window<`u`&&typeof document<`u`,rt=typeof navigator==`object`&&navigator||void 0,it=nt&&(!rt||[`ReactNative`,`NativeScript`,`NS`].indexOf(rt.product)<0),at=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,ot=nt&&window.location.href||`http://localhost`,M={...tt,...et};function st(e,t){return j(e,new M.classes.URLSearchParams,{visitor:function(e,t,n,r){return M.isNode&&D.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function ct(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function lt(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r=e.length;return a=!a&&D.isArray(r)?r.length:a,s?(D.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!D.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&D.isArray(r[a])&&(r[a]=lt(r[a])),!o)}if(D.isFormData(e)&&D.isFunction(e.entries)){let n={};return D.forEachEntry(e,(e,r)=>{t(ct(e),r,n,0)}),n}return null}function dt(e,t,n){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var N={transitional:$e,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return r?JSON.stringify(ut(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return st(e,this.formSerializer).toString();if((a=D.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return j(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),dt(e)):e}],transformResponse:[function(e){let t=this.transitional||N.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?O.from(e,O.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:M.classes.FormData,Blob:M.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};D.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{N.headers[e]={}});var ft=D.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),pt=e=>{let t={},n,r,i;return e&&e.split(` -`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&ft[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},mt=Symbol(`internals`);function P(e){return e&&String(e).trim().toLowerCase()}function F(e){return e===!1||e==null?e:D.isArray(e)?e.map(F):String(e).replace(/[\r\n]+$/,``)}function ht(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var gt=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function _t(e,t,n,r,i){if(D.isFunction(r))return r.call(this,t,n);if(i&&(t=n),D.isString(t)){if(D.isString(r))return t.indexOf(r)!==-1;if(D.isRegExp(r))return r.test(t)}}function vt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function yt(e,t){let n=D.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var I=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=P(t);if(!i)throw Error(`header name must be a non-empty string`);let a=D.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=F(e))}let a=(e,t)=>D.forEach(e,(e,n)=>i(e,n,t));if(D.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(D.isString(e)&&(e=e.trim())&&!gt(e))a(pt(e),t);else if(D.isObject(e)&&D.isIterable(e)){let n={},r,i;for(let t of e){if(!D.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?D.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=P(e),e){let n=D.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return ht(e);if(D.isFunction(t))return t.call(this,e,n);if(D.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=P(e),e){let n=D.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||_t(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=P(e),e){let i=D.findKey(n,e);i&&(!t||_t(n,n[i],i,t))&&(delete n[i],r=!0)}}return D.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||_t(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return D.forEach(this,(r,i)=>{let a=D.findKey(n,i);if(a){t[a]=F(r),delete t[i];return}let o=e?vt(i):String(i).trim();o!==i&&delete t[i],t[o]=F(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return D.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&D.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(` -`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[mt]=this[mt]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=P(e);t[r]||(yt(n,e),t[r]=!0)}return D.isArray(e)?e.forEach(r):r(e),this}};I.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),D.reduceDescriptors(I.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),D.freezeMethods(I);function L(e,t){let n=this||N,r=t||n,i=I.from(r.headers),a=r.data;return D.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function bt(e){return!!(e&&e.__CANCEL__)}var R=class extends O{constructor(e,t,n){super(e??`canceled`,O.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function xt(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new O(`Request failed with status code `+n.status,[O.ERR_BAD_REQUEST,O.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function St(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function Ct(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var z=(e,t,n=3)=>{let r=0,i=Ct(50,250);return wt(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},Tt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Et=e=>(...t)=>D.asap(()=>e(...t)),Dt=M.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,M.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(M.origin),M.navigator&&/(msie|trident)/i.test(M.navigator.userAgent)):()=>!0,Ot=M.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];D.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),D.isString(r)&&s.push(`path=${r}`),D.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),D.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function kt(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function At(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function jt(e,t,n){let r=!kt(t);return e&&(r||n==0)?At(e,t):t}var Mt=e=>e instanceof I?{...e}:e;function B(e,t){t||={};let n={};function r(e,t,n,r){return D.isPlainObject(e)&&D.isPlainObject(t)?D.merge.call({caseless:r},e,t):D.isPlainObject(t)?D.merge({},t):D.isArray(t)?t.slice():t}function i(e,t,n,i){if(!D.isUndefined(t))return r(e,t,n,i);if(!D.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!D.isUndefined(t))return r(void 0,t)}function o(e,t){if(!D.isUndefined(t))return r(void 0,t);if(!D.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(Mt(e),Mt(t),n,!0)};return D.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=D.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);D.isUndefined(o)&&a!==s||(n[r]=o)}),n}var Nt=e=>{let t=B({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=I.from(o),t.url=Ze(jt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),D.isFormData(n)){if(M.hasStandardBrowserEnv||M.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(D.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(M.hasStandardBrowserEnv&&(r&&D.isFunction(r)&&(r=r(t)),r||r!==!1&&Dt(t.url))){let e=i&&a&&Ot.read(a);e&&o.set(i,e)}return t},Pt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Nt(e),i=r.data,a=I.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=I.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());xt(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new O(`Request aborted`,O.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new O(t&&t.message?t.message:`Network Error`,O.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||$e;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new O(t,i.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&D.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),D.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=z(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=z(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new R(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=St(r.url);if(_&&M.protocols.indexOf(_)===-1){n(new O(`Unsupported protocol `+_+`:`,O.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Ft=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof O?t:new R(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new O(`timeout of ${t}ms exceeded`,O.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>D.asap(o),s}},It=function*(e,t){let n=e.byteLength;if(!t||n{let i=Lt(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},Bt=64*1024,{isFunction:V}=D,Vt=(({Request:e,Response:t})=>({Request:e,Response:t}))(D.global),{ReadableStream:Ht,TextEncoder:Ut}=D.global,Wt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gt=e=>{e=D.merge.call({skipUndefined:!0},Vt,e);let{fetch:t,Request:n,Response:r}=e,i=t?V(t):typeof fetch==`function`,a=V(n),o=V(r);if(!i)return!1;let s=i&&V(Ht),c=i&&(typeof Ut==`function`?(e=>t=>e.encode(t))(new Ut):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&Wt(()=>{let e=!1,t=new Ht,r=new n(M.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&Wt(()=>D.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new O(`Response type '${e}' is not supported`,O.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new n(M.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e+=``),D.isString(e))return(await c(e)).byteLength},p=async(e,t)=>D.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=Nt(e),x=t||fetch;_=_?(_+``).toLowerCase():`text`;let S=Ft([c,f&&f.toAbortSignal()],m),C=null,w=S&&S.unsubscribe&&(()=>{S.unsubscribe()}),ee;try{if(g&&l&&o!==`get`&&o!==`head`&&(ee=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(D.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=Tt(ee,z(Et(g)));s=zt(e.body,Bt,t,n)}}D.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:S,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};C=a&&new n(i,c);let f=await(a?x(C,b):x(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&w)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=D.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&Tt(t,z(Et(h),!0))||[];f=new r(zt(f.body,Bt,n,()=>{i&&i(),w&&w()}),e)}_||=`text`;let te=await d[D.findKey(d,_)||`text`](f,e);return!m&&w&&w(),await new Promise((t,n)=>{xt(t,n,{data:te,headers:I.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:C})})}catch(t){throw w&&w(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new O(`Network Error`,O.ERR_NETWORK,e,C,t&&t.response),{cause:t.cause||t}):O.from(t,t&&t.code,e,C,t&&t.response)}}},Kt=new Map,qt=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=Kt;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:Gt(t)),l=c;return c};qt();var Jt={http:null,xhr:Pt,fetch:{get:qt}};D.forEach(Jt,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var Yt=e=>`- ${e}`,Xt=e=>D.isFunction(e)||e===null||e===!1;function Zt(e,t){e=D.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new O(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since : -`+e.map(Yt).join(` -`):` `+Yt(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var Qt={getAdapter:Zt,adapters:Jt};function $t(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new R(null,e)}function en(e){return $t(e),e.headers=I.from(e.headers),e.data=L.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),Qt.getAdapter(e.adapter||N.adapter,e)(e).then(function(t){return $t(e),t.data=L.call(e,e.transformResponse,t),t.headers=I.from(t.headers),t},function(t){return bt(t)||($t(e),t&&t.response&&(t.response.data=L.call(e,e.transformResponse,t.response),t.response.headers=I.from(t.response.headers))),Promise.reject(t)})}var tn=`1.14.0`,H={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{H[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var nn={};H.transitional=function(e,t,n){function r(e,t){return`[Axios v`+tn+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new O(r(i,` has been removed`+(t?` in `+t:``)),O.ERR_DEPRECATED);return t&&!nn[i]&&(nn[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},H.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function rn(e,t,n){if(typeof e!=`object`)throw new O(`options must be an object`,O.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new O(`option `+a+` must be `+n,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O(`Unknown option `+a,O.ERR_BAD_OPTION)}}var U={assertOptions:rn,validators:H},W=U.validators,G=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Qe,response:new Qe}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=t.stack?t.stack.replace(/^.+\n/,``):``;try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,``))&&(e.stack+=` -`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=B(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&U.assertOptions(n,{silentJSONParsing:W.transitional(W.boolean),forcedJSONParsing:W.transitional(W.boolean),clarifyTimeoutError:W.transitional(W.boolean),legacyInterceptorReqResOrdering:W.transitional(W.boolean)},!1),r!=null&&(D.isFunction(r)?t.paramsSerializer={serialize:r}:U.assertOptions(r,{encode:W.function,serialize:W.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),U.assertOptions(t,{baseUrl:W.spelling(`baseURL`),withXsrfToken:W.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&D.merge(i.common,i[t.method]);i&&D.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=I.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||$e;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[en.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new R(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function on(e){return function(t){return e.apply(null,t)}}function sn(e){return D.isObject(e)&&e.isAxiosError===!0}var cn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(cn).forEach(([e,t])=>{cn[t]=e});function ln(e){let t=new G(e),n=o(G.prototype.request,t);return D.extend(n,G.prototype,t,{allOwnKeys:!0}),D.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return ln(B(e,t))},n}var K=ln(N);K.Axios=G,K.CanceledError=R,K.CancelToken=an,K.isCancel=bt,K.VERSION=tn,K.toFormData=j,K.AxiosError=O,K.Cancel=K.CanceledError,K.all=function(e){return Promise.all(e)},K.spread=on,K.isAxiosError=sn,K.mergeConfig=B,K.AxiosHeaders=I,K.formToJSON=e=>ut(D.isHTMLForm(e)?new FormData(e):e),K.getAdapter=Qt.getAdapter,K.HttpStatusCode=cn,K.default=K;var un=`pymc_jwt_token`,dn=`pymc_client_id`;function fn(){let e=localStorage.getItem(dn);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(dn,e)),e}function q(){return localStorage.getItem(un)}function pn(e){localStorage.setItem(un,e)}function mn(){localStorage.removeItem(un)}function hn(){return q()!==null}function gn(e){try{let t=e.split(`.`)[1].replace(/-/g,`+`).replace(/_/g,`/`),n=decodeURIComponent(atob(t).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``));return JSON.parse(n)}catch{return null}}function J(){let e=q();if(!e)return!0;let t=gn(e);return!t||!t.exp?!0:Date.now()>=t.exp*1e3-3e4}function _n(){let e=q();if(!e)return!1;let t=gn(e);if(!t||!t.exp)return!1;let n=t.exp*1e3-Date.now();return n>0&&n<3e5}function vn(){let e=q();if(!e)return null;let t=gn(e);return!t||!t.sub?null:t.sub}var yn=`modulepreload`,bn=function(e){return`/`+e},xn={},Y=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=bn(t,n),t in xn)return;xn[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:yn,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},X=a({history:r(`/`),routes:[{path:`/setup`,name:`setup`,component:()=>Y(()=>import(`./Setup-DvdSE7ue.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),meta:{requiresAuth:!1,requiresSetup:!1}},{path:`/login`,name:`login`,component:()=>Y(()=>import(`./Login-Yx7HUvzW.js`),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9,12])),meta:{requiresAuth:!1}},{path:`/`,name:`dashboard`,component:()=>Y(()=>import(`./Dashboard-ClL05x7j.js`),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,14,15,16,17])),meta:{requiresAuth:!0}},{path:`/neighbors`,name:`neighbors`,component:()=>Y(()=>import(`./Neighbors-CQcUQfDG.js`),__vite__mapDeps([18,1,19,2,3,4,5,6,7,8,9,20,15,16,21,22])),meta:{requiresAuth:!0}},{path:`/statistics`,name:`statistics`,component:()=>Y(()=>import(`./Statistics-S4HgWYku.js`),__vite__mapDeps([23,1,19,2,3,4,5,6,7,8,9,14,24,25,26,16,27])),meta:{requiresAuth:!0}},{path:`/system-stats`,name:`system-stats`,component:()=>Y(()=>import(`./SystemStats-4wDqjB6x.js`),__vite__mapDeps([28,1,19,14,3,24,25,29])),meta:{requiresAuth:!0}},{path:`/configuration`,name:`configuration`,component:()=>Y(()=>import(`./Configuration-BoG9PyTQ.js`),__vite__mapDeps([30,1,19,2,3,4,5,6,7,8,9,31,16,32,22])),meta:{requiresAuth:!0}},{path:`/cad-calibration`,name:`cad-calibration`,component:()=>Y(()=>import(`./CADCalibration-CK9zSc8M.js`),__vite__mapDeps([33,1,19,3,26,7,4,34])),meta:{requiresAuth:!0}},{path:`/sessions`,name:`sessions`,component:()=>Y(()=>import(`./Sessions-DhR0b50N.js`),__vite__mapDeps([35,2,1,3,4,5,6,7,8,9])),meta:{requiresAuth:!0}},{path:`/room-servers`,name:`room-servers`,component:()=>Y(()=>import(`./RoomServers-Cngso7KV.js`),__vite__mapDeps([36,2,1,3,4,5,6,7,8,9,31,37,16])),meta:{requiresAuth:!0}},{path:`/companions`,name:`companions`,component:()=>Y(()=>import(`./Companions-Cm95T8nb.js`),__vite__mapDeps([38,2,1,3,4,5,6,7,8,9,31,37])),meta:{requiresAuth:!0}},{path:`/logs`,name:`logs`,component:()=>Y(()=>import(`./Logs-DiVYCMnG.js`),__vite__mapDeps([39,3])),meta:{requiresAuth:!0}},{path:`/terminal`,name:`terminal`,component:()=>Y(()=>import(`./Terminal-Dpu_GlNL.js`),__vite__mapDeps([40,1,2,3,4,5,6,7,8,9,41])),meta:{requiresAuth:!0}},{path:`/help`,name:`help`,component:()=>Y(()=>import(`./Help-CaIFoQMt.js`),__vite__mapDeps([42,3])),meta:{requiresAuth:!0}}]});async function Sn(){try{let e=await fetch(`/api/needs_setup`,{headers:{Accept:`application/json`}});return e.ok?(await e.json()).needs_setup===!0:(console.error(`Setup check failed:`,e.status),!1)}catch(e){return console.error(`Error checking setup status:`,e),!1}}X.beforeEach(async(e,t,n)=>{let r=e.meta.requiresAuth!==!1,i=hn();if(e.path!==`/setup`&&await Sn()){n(`/setup`);return}if(e.path===`/setup`&&!await Sn()){n(`/login`);return}r&&!i?n(`/login`):e.path===`/login`&&i?n(`/`):n()});var Z=i(`appRuntime`,()=>{let e=n(typeof navigator>`u`?!0:navigator.onLine),r=n(typeof document>`u`?!0:document.visibilityState===`visible`),i=n(!1),a=n(null),o=n(!1),s=t(()=>e.value&&r.value&&i.value&&!o.value);function c(){i.value=!!q()&&!J(),i.value||(a.value=a.value??`expired`)}function l(){i.value=!0,a.value=null,o.value=!1}function u(t){e.value=t}function d(e){r.value=e}async function f(e){if(o.value)return;o.value=!0,a.value=e,i.value=!1;let{useWebSocketStore:t}=await Y(async()=>{let{useWebSocketStore:e}=await import(`./websocket-NnYyxr--.js`);return{useWebSocketStore:e}},__vite__mapDeps([43,8,3,4,6,7])),{usePacketStore:n}=await Y(async()=>{let{usePacketStore:e}=await import(`./packets-B_GG5R7y.js`);return{usePacketStore:e}},__vite__mapDeps([44,6,3,4])),{useSystemStore:r}=await Y(async()=>{let{useSystemStore:e}=await import(`./system-Cl32lKH8.js`);return{useSystemStore:e}},__vite__mapDeps([45,7,3,4])),s=t(),c=n(),l=r();s.disconnect({preventReconnect:!0,silent:e!==`logout`}),c.reset(),l.reset(),mn(),X.currentRoute.value.path!==`/login`&&await X.push(`/login`),o.value=!1}async function p(e){await f(e)}return{isOnline:e,isDocumentVisible:r,isAuthenticated:i,authFailureReason:a,canMaintainConnections:s,syncAuthState:c,markAuthenticated:l,setOnline:u,setDocumentVisible:d,stopSession:f,handleAuthFailure:p}}),Cn=`/api`,wn=!1,Q=null;async function Tn(){return wn&&Q?Q:(wn=!0,Q=(async()=>{try{let e=q();if(!e)throw Error(`No token to refresh`);let t=fn(),n=await K.post(`/auth/refresh`,{client_id:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`}});if(n.data.success&&n.data.token){let e=n.data.token;return pn(e),e}else throw Error(`Token refresh failed`)}catch(e){throw console.error(`Token refresh error:`,e),await Z().handleAuthFailure(`expired`),e}finally{wn=!1,Q=null}})(),Q)}var $=K.create({baseURL:Cn,timeout:5e3,headers:{"Content-Type":`application/json`}}),En=K.create({baseURL:``,timeout:5e3,headers:{"Content-Type":`application/json`}});En.interceptors.request.use(async e=>{if(e.url?.includes(`/auth/login`)||e.url?.includes(`/auth/refresh`))return e;let t=q();if(t){if(_n())try{let t=await Tn();return e.headers.Authorization=`Bearer ${t}`,e}catch(e){return Promise.reject(e)}if(J())return Z().handleAuthFailure(`expired`),Promise.reject(Error(`Token expired`));e.headers.Authorization=`Bearer ${t}`}return e},e=>(console.error(`Auth API Request Error:`,e),Promise.reject(e))),En.interceptors.response.use(e=>e,e=>((e.response?.status===401||e.response?.status===403)&&Z().handleAuthFailure(e.response?.status===403?`forbidden`:`unauthorized`),console.error(`Auth API Response Error:`,e.response?.data||e.message),Promise.reject(e))),$.interceptors.request.use(async e=>{if(e.url?.includes(`/auth/login`))return e;let t=q();if(t){if(_n())try{let t=await Tn();return e.headers.Authorization=`Bearer ${t}`,e}catch(e){return Promise.reject(e)}if(J())return Z().handleAuthFailure(`expired`),Promise.reject(Error(`Token expired`));e.headers.Authorization=`Bearer ${t}`}return e},e=>(console.error(`API Request Error:`,e),Promise.reject(e))),$.interceptors.response.use(e=>e,e=>((e.response?.status===401||e.response?.status===403)&&Z().handleAuthFailure(e.response?.status===403?`forbidden`:`unauthorized`),console.error(`API Response Error:`,e.response?.data||e.message),Promise.reject(e)));var Dn=class{static async get(e,t){try{return(await $.get(e,{params:t})).data}catch(e){throw this.handleError(e)}}static async post(e,t,n){try{return(await $.post(e,t,n)).data}catch(e){throw this.handleError(e)}}static async put(e,t,n){try{return(await $.put(e,t,n)).data}catch(e){throw this.handleError(e)}}static async delete(e,t){try{return(await $.delete(e,t)).data}catch(e){throw this.handleError(e)}}static async getTransportKeys(){return this.get(`transport_keys`)}static async sendAdvert(){return this.post(`send_advert`,{},{headers:{"Content-Type":`application/json`}})}static async createTransportKey(e,t,n,r,i){let a={name:e,flood_policy:t,parent_id:r,last_used:i};return n!==void 0&&(a.transport_key=n),this.post(`transport_keys`,a)}static async getTransportKey(e){return this.get(`transport_key/${e}`)}static async updateTransportKey(e,t,n,r,i,a){return this.put(`transport_key/${e}`,{name:t,flood_policy:n,transport_key:r,parent_id:i,last_used:a})}static async deleteTransportKey(e){return this.delete(`transport_key/${e}`)}static async updateUnscopedFloodPolicy(e){return this.post(`unscoped_flood_policy`,{unscoped_flood_allow:e})}static async getLogs(){try{return(await $.get(`logs`)).data}catch(e){throw this.handleError(e)}}static async deleteAdvert(e){return this.delete(`advert/${e}`)}static async pingNeighbor(e,t=10){return this.post(`ping_neighbor`,{target_id:e,timeout:t})}static async getIdentities(){return this.get(`identities`)}static async getIdentity(e){return this.get(`identity`,{name:e})}static async createIdentity(e){return this.post(`create_identity`,e)}static async updateIdentity(e){return this.put(`update_identity`,e)}static async deleteIdentity(e,t=`room_server`){let n=new URLSearchParams({name:e});return t===`companion`&&n.set(`type`,`companion`),this.delete(`delete_identity?${n.toString()}`)}static async sendRoomServerAdvert(e){return this.post(`send_room_server_advert`,{name:e})}static async importRepeaterContacts(e){return this.post(`companion/import_repeater_contacts`,e)}static async getACLInfo(){return this.get(`acl_info`)}static async getACLClients(e){return this.get(`acl_clients`,e)}static async removeACLClient(e){return this.post(`acl_remove_client`,e)}static async getACLStats(){return this.get(`acl_stats`)}static async getRoomMessages(e){return this.get(`room_messages`,e)}static async postRoomMessage(e){return this.post(`room_post_message`,e)}static async deleteRoomMessage(e){return this.delete(`room_message?room_name=${encodeURIComponent(e.room_name)}&message_id=${e.message_id}`)}static async clearRoomMessages(e){return this.delete(`room_messages?room_name=${encodeURIComponent(e)}`)}static async getRoomStats(e){return this.get(`room_stats`,e?{room_name:e}:void 0)}static async getRoomClients(e){return this.get(`room_clients`,{room_name:e})}static async exportConfig(e=!1){let t=e?`config_export?include_secrets=true`:`config_export`;return this.get(t)}static async importConfig(e){return this.post(`config_import`,{config:e})}static async exportIdentityKey(){return this.get(`identity_export`)}static async generateVanityKey(e,t=!1){return this.post(`generate_vanity_key`,{prefix:e,apply:t})}static async getDbStats(){return this.get(`db_stats`)}static async purgeTable(e){return this.post(`db_purge`,{tables:e})}static async vacuumDb(){return this.post(`db_vacuum`,{})}static handleError(e){if(K.isAxiosError(e)){if(e.response){let t=e.response.data?.error||e.response.data?.message||`HTTP ${e.response.status}`;return Error(t)}else if(e.request)return Error(`Network error - no response received`)}return Error(e instanceof Error?e.message:`Unknown error occurred`)}};export{Y as a,q as c,J as d,pn as f,X as i,vn as l,En as n,mn as o,Z as r,fn as s,Dn as t,hn as u}; \ No newline at end of file diff --git a/repeater/web/html/assets/chart-B1uYMRrx.js b/repeater/web/html/assets/chart-B1uYMRrx.js deleted file mode 100644 index bc5f1554..00000000 --- a/repeater/web/html/assets/chart-B1uYMRrx.js +++ /dev/null @@ -1,3 +0,0 @@ -function e(e){return e+.5|0}var t=(e,t,n)=>Math.max(Math.min(e,n),t);function n(n){return t(e(n*2.55),0,255)}function r(n){return t(e(n*255),0,255)}function i(n){return t(e(n/2.55)/100,0,1)}function a(n){return t(e(n*100),0,100)}var o={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},s=[...`0123456789ABCDEF`],c=e=>s[e&15],l=e=>s[(e&240)>>4]+s[e&15],u=e=>(e&240)>>4==(e&15),d=e=>u(e.r)&&u(e.g)&&u(e.b)&&u(e.a);function f(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&o[e[1]]*17,g:255&o[e[2]]*17,b:255&o[e[3]]*17,a:t===5?o[e[4]]*17:255}:(t===7||t===9)&&(n={r:o[e[1]]<<4|o[e[2]],g:o[e[3]]<<4|o[e[4]],b:o[e[5]]<<4|o[e[6]],a:t===9?o[e[7]]<<4|o[e[8]]:255})),n}var p=(e,t)=>e<255?t(e):``;function m(e){var t=d(e)?c:l;return e?`#`+t(e.r)+t(e.g)+t(e.b)+p(e.a,t):void 0}var h=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function g(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function _(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function v(e,t,n){let r=g(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function y(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=y(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function x(e,t,n,i){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,i)).map(r)}function S(e,t,n){return x(g,e,t,n)}function C(e,t,n){return x(v,e,t,n)}function w(e,t,n){return x(_,e,t,n)}function T(e){return(e%360+360)%360}function E(e){let t=h.exec(e),i=255,a;if(!t)return;t[5]!==a&&(i=t[6]?n(+t[5]):r(+t[5]));let o=T(+t[2]),s=t[3]/100,c=t[4]/100;return a=t[1]===`hwb`?C(o,s,c):t[1]===`hsv`?w(o,s,c):S(o,s,c),{r:a[0],g:a[1],b:a[2],a:i}}function D(e,t){var n=b(e);n[0]=T(n[0]+t),n=S(n),e.r=n[0],e.g=n[1],e.b=n[2]}function ee(e){if(!e)return;let t=b(e),n=t[0],r=a(t[1]),o=a(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${o}%, ${i(e.a)})`:`hsl(${n}, ${r}%, ${o}%)`}var O={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},te={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function ne(){let e={},t=Object.keys(te),n=Object.keys(O),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var re;function ie(e){re||(re=ne(),re.transparent=[0,0,0,0]);let t=re[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var ae=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function oe(e){let r=ae.exec(e),i=255,a,o,s;if(r){if(r[7]!==a){let e=+r[7];i=r[8]?n(e):t(e*255,0,255)}return a=+r[1],o=+r[3],s=+r[5],a=255&(r[2]?n(a):t(a,0,255)),o=255&(r[4]?n(o):t(o,0,255)),s=255&(r[6]?n(s):t(s,0,255)),{r:a,g:o,b:s,a:i}}}function se(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${i(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var ce=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,le=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function ue(e,t,n){let a=le(i(e.r)),o=le(i(e.g)),s=le(i(e.b));return{r:r(ce(a+n*(le(i(t.r))-a))),g:r(ce(o+n*(le(i(t.g))-o))),b:r(ce(s+n*(le(i(t.b))-s))),a:e.a+n*(t.a-e.a)}}function de(e,t,n){if(e){let r=b(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=S(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function fe(e,t){return e&&Object.assign(t||{},e)}function pe(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=r(e[3]))):(t=fe(e,{r:0,g:0,b:0,a:1}),t.a=r(t.a)),t}function me(e){return e.charAt(0)===`r`?oe(e):E(e)}var he=class t{constructor(e){if(e instanceof t)return e;let n=typeof e,r;n===`object`?r=pe(e):n===`string`&&(r=f(e)||ie(e)||me(e)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=fe(this._rgb);return e&&(e.a=i(e.a)),e}set rgb(e){this._rgb=pe(e)}rgbString(){return this._valid?se(this._rgb):void 0}hexString(){return this._valid?m(this._rgb):void 0}hslString(){return this._valid?ee(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=ue(this._rgb,e._rgb,t)),this}clone(){return new t(this.rgb)}alpha(e){return this._rgb.a=r(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let t=this._rgb;return t.r=t.g=t.b=e(t.r*.3+t.g*.59+t.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return de(this._rgb,2,e),this}darken(e){return de(this._rgb,2,-e),this}saturate(e){return de(this._rgb,1,e),this}desaturate(e){return de(this._rgb,1,-e),this}rotate(e){return D(this._rgb,e),this}};function ge(){}var _e=(()=>{let e=0;return()=>e++})();function k(e){return e==null}function A(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function j(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function M(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function N(e,t){return M(e)?e:t}function P(e,t){return e===void 0?t:e}var ve=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,ye=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function F(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function I(e,t,n,r){let i,a,o;if(A(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function Oe(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function ke(e){let t=Oe(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function Ae(e,t){return(De[t]||(De[t]=ke(t)))(e)}function je(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Me=e=>e!==void 0,Ne=e=>typeof e==`function`,Pe=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function Fe(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var L=Math.PI,R=2*L,Ie=R+L,Le=1/0,Re=L/180,z=L/2,ze=L/4,Be=L*2/3,Ve=Math.log10,B=Math.sign;function He(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Ge(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Ke(e){return!Ge(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function qe(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Je(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function rt(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var it=(e,t,n,r)=>rt(e,n,r?r=>{let i=e[r][t];return ie[r][t]rt(e,n,r=>e[r][t]>=n);function ot(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+je(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function lt(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(st.forEach(t=>{delete e[t]}),delete e._chartjs)}function ut(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var dt=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function ft(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,dt.call(window,()=>{r=!1,e.apply(t,n)}))}}function pt(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var mt=e=>e===`start`?`left`:e===`end`?`right`:`center`,W=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,ht=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function gt(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(it(c,u,d).lo,n?r:it(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!k(e[s.axis]));i-=Math.max(0,e)}i=U(i,0,r-1)}if(m){let e=Math.max(it(c,o.axis,f,!0).hi+1,n?0:it(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!k(e[s.axis]));e+=Math.max(0,t)}a=U(e,i,r)-i}else a=r-i}return{start:i,count:a}}function _t(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var vt=e=>e===0||e===1,yt=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*R/n)),bt=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*R/n)+1,xt={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*z)+1,easeOutSine:e=>Math.sin(e*z),easeInOutSine:e=>-.5*(Math.cos(L*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>vt(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>vt(e)?e:yt(e,.075,.3),easeOutElastic:e=>vt(e)?e:bt(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return vt(e)?e:e<.5?.5*yt(e*2,t,n):.5+.5*bt(e*2-1,t,n)},easeInBack(e){let t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){let t=1.70158;return--e*e*((t+1)*e+t)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-xt.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?xt.easeInBounce(e*2)*.5:xt.easeOutBounce(e*2-1)*.5+.5};function St(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function Ct(e){return St(e)?e:new he(e)}function wt(e){return St(e)?e:new he(e).saturate(.5).darken(.1).hexString()}var Tt=[`x`,`y`,`borderWidth`,`radius`,`tension`],Et=[`color`,`borderColor`,`backgroundColor`];function Dt(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:Et},numbers:{type:`number`,properties:Tt}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function Ot(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var kt=new Map;function At(e,t){t||={};let n=e+JSON.stringify(t),r=kt.get(n);return r||(r=new Intl.NumberFormat(e,t),kt.set(n,r)),r}function jt(e,t,n){return At(t,n).format(e)}var Mt={values(e){return A(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Nt(e,n)}let o=Ve(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),jt(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Ve(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Mt.numeric.call(this,e,t,n):``}};function Nt(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Pt={formatters:Mt};function Ft(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Pt.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var It=Object.create(null),Lt=Object.create(null);function Rt(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>wt(t.backgroundColor),this.hoverBorderColor=(e,t)=>wt(t.borderColor),this.hoverColor=(e,t)=>wt(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return zt(this,e,t)}get(e){return Rt(this,e)}describe(e,t){return zt(Lt,e,t)}override(e,t){return zt(It,e,t)}route(e,t,n,r){let i=Rt(this,e),a=Rt(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return j(e)?Object.assign({},t,e):P(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[Dt,Ot,Ft]);function Bt(e){return!e||k(e.size)||k(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Vt(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Ht(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function K(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Zt(e,a),c=0;c+e||0;function sn(e,t){let n={},r=j(t),i=r?Object.keys(t):t,a=j(e)?r?n=>P(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=on(a(e));return n}function cn(e){return sn(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function ln(e){return sn(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function q(e){let t=cn(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function J(e,t){e||={},t||=G.font;let n=P(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=P(e.style,t.style);r&&!(``+r).match(rn)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:P(e.family,t.family),lineHeight:an(P(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:P(e.weight,t.weight),string:``};return i.string=Bt(i),i}function un(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function fn(e,t){return Object.assign(Object.create(e),t)}function pn(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=kn(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>pn([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return vn(n,r,()=>On(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return An(e).includes(t)},ownKeys(e){return An(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function mn(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:hn(e,r),setContext:t=>mn(e,t,n,r),override:i=>mn(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return vn(e,t,()=>yn(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function hn(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:Ne(n)?n:()=>n,isIndexable:Ne(r)?r:()=>r}}var gn=(e,t)=>e?e+je(t):t,_n=(e,t)=>j(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function vn(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function yn(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return Ne(s)&&o.isScriptable(t)&&(s=bn(t,s,e,n)),A(s)&&s.length&&(s=xn(t,s,e,o.isIndexable)),_n(t,s)&&(s=mn(s,i,a&&a[t],o)),s}function bn(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),_n(e,c)&&(c=Tn(i._scopes,i,e,c)),c}function xn(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(j(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Tn(r,i,e,c);t.push(mn(n,a,o&&o[e],s))}}return t}function Sn(e,t,n){return Ne(e)?e(t,n):e}var Cn=(e,t)=>e===!0?t:typeof e==`string`?Ae(t,e):void 0;function wn(e,t,n,r,i){for(let a of t){let t=Cn(n,a);if(t){e.add(t);let a=Sn(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Tn(e,t,n,r){let i=t._rootScopes,a=Sn(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=En(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=En(s,o,a,c,r),c===null)?!1:pn(Array.from(s),[``],i,a,()=>Dn(t,n,r))}function En(e,t,n,r,i){for(;n;)n=wn(e,t,n,r,i);return n}function Dn(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return A(i)&&j(n)?n:i||{}}function On(e,t,n,r){let i;for(let a of t)if(i=kn(gn(a,e),n),i!==void 0)return _n(e,i)?Tn(n,r,e,i):i}function kn(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function An(e){let t=e._keys;return t||=e._keys=jn(e._scopes),t}function jn(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}var Mn=2**-52||1e-14,Nn=(e,t)=>te===`x`?`y`:`x`;function Fn(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Qe(a,i),c=Qe(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function In(e,t,n){let r=e.length,i,a,o,s,c,l=Nn(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)Rn(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Kn(e,t){return Gn(e).getPropertyValue(t)}var qn=[`top`,`right`,`bottom`,`left`];function Jn(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=qn[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Yn=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Xn(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Yn(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Zn(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Gn(n),a=i.boxSizing===`border-box`,o=Jn(i,`padding`),s=Jn(i,`border`,`width`),{x:c,y:l,box:u}=Xn(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Qn(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Un(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Gn(a),s=Jn(o,`border`,`width`),c=Jn(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Wn(o.maxWidth,a,`clientWidth`),i=Wn(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Le,maxHeight:i||Le}}var $n=e=>Math.round(e*10)/10;function er(e,t,n,r){let i=Gn(e),a=Jn(i,`margin`),o=Wn(i.maxWidth,e,`clientWidth`)||Le,s=Wn(i.maxHeight,e,`clientHeight`)||Le,c=Qn(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Jn(i,`border`,`width`),t=Jn(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=$n(Math.min(l,o,c.maxWidth)),u=$n(Math.min(u,s,c.maxHeight)),l&&!u&&(u=$n(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=$n(Math.floor(u*r))),{width:l,height:u}}function tr(e,t,n){let r=t||1,i=$n(e.height*r),a=$n(e.width*r);e.height=$n(e.height),e.width=$n(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var nr=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Hn()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function rr(e,t){let n=Kn(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function ir(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function ar(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function or(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=ir(e,i,n),s=ir(i,a,n),c=ir(a,t,n);return ir(ir(o,s,n),ir(s,c,n),n)}var sr=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},cr=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function lr(e,t,n){return e?sr(t,n):cr()}function ur(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function dr(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function fr(e){return e===`angle`?{between:et,compare:$e,normalize:H}:{between:nt,compare:(e,t)=>e-t,normalize:e=>e}}function pr({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function mr(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=fr(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(pr({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(pr({start:g,end:d,loop:f,count:o,style:p})),m}function gr(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function vr(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function yr(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=_r(n,i,a,r);return r===!0?br(e,[{start:o,end:s,loop:a}],n,t):br(e,vr(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,dt.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Or=`transparent`,kr={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=Ct(e||Or),i=r.valid&&Ct(t||Or);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Ar=class{constructor(e,t,n,r){let i=t[n];r=un([e.to,r,i,e.from]);let a=un([e.from,i,r]);this._active=!0,this._fn=e.fn||kr[e.type||typeof a],this._easing=xt[e.easing]||xt.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=un([e.to,t,r,e.from]),this._from=un([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!j(i))return;let a={};for(let e of t)a[e]=i[e];(A(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Nr(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Mr(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Ar(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Dr.add(this._chart,n),!0}};function Mr(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Gr(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Vr(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function qr(e,t){return fn(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Jr(e,t,n){return fn(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Yr(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Xr=e=>e===`reset`||e===`none`,Zr=(e,t)=>t?e:Object.assign({},e),Qr=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Lr(n,!0),values:null},$r=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Br(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Yr(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=P(n.xAxisID,Kr(e,`x`)),a=t.yAxisID=P(n.yAxisID,Kr(e,`y`)),o=t.rAxisID=P(n.rAxisID,Kr(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&<(this._data,this),e._stacked&&Yr(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(j(t)){let e=this._cachedMeta;this._data=zr(t,e)}else if(n!==t){if(n){lt(n,this);let e=this._cachedMeta;Yr(e),e._parsed=[]}t&&Object.isExtensible(t)&&ct(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Br(t.vScale,t),t.stack!==n.stack&&(r=!0,Yr(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Gr(this,t._parsed),t._stacked=Br(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length?!0:n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=A(r[e])?this.parseArrayData(n,r,e,t):j(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Zr(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new jr(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Xr(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Xr(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Xr(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function ti(e){let t=e.iScale,n=ei(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(Me(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function ai(e,t,n,r){return A(e)?ii(e,t,n,r):t[n.axis]=n.parse(e,r),t}function oi(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):B(e)}function li(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(k(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[P(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;iet(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>et(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(z,u,f),_=m(L,l,d),v=m(L+z,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var _i=class extends $r{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(j(n[e])){let{key:e=`value`}=this._parsing;i=t=>+Ae(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*R:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=jt(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=k(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},yi=class extends $r{static id=`scatter`;static defaults={datasetElementType:!1,dataElementType:`point`,showLine:!1,fill:!1};static overrides={interaction:{mode:`point`},scales:{x:{type:`linear`},y:{type:`linear`}}};getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y);return{label:n[e]||``,value:`(`+o+`, `+s+`)`}}update(e){let t=this._cachedMeta,{data:n=[]}=t,r=this.chart._animationsDisabled,{start:i,count:a}=gt(t,n,r);if(this._drawStart=i,this._drawCount=a,_t(t)&&(i=0,a=n.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:i,_dataset:a}=t;i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!a._decimated,i.points=n;let o=this.resolveDatasetElementOptions(e);o.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:o},e)}else this.datasetElementType&&=(delete t.dataset,!1);this.updateElements(n,i,a,e)}addElements(){let{showLine:e}=this.options;!this.datasetElementType&&e&&(this.datasetElementType=this.chart.registry.getElement(`line`)),super.addElements()}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,l=this.resolveDataElementOptions(t,r),u=this.getSharedOptions(l),d=this.includeOptions(r,u),f=a.axis,p=o.axis,{spanGaps:m,segment:h}=this.options,g=Ke(m)?m:1/0,_=this.chart._animationsDisabled||i||r===`none`,v=t>0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}};function bi(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var xi={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return bi()}parse(){return bi()}format(){return bi()}add(){return bi()}diff(){return bi()}startOf(){return bi()}endOf(){return bi()}}};function Si(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?at:it;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!k(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!k(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Ci(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Ai={evaluateInteractionItems:Ci,modes:{index(e,t,n,r){let i=Zn(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Ti(e,i,a,r,o):Oi(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Zn(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Ti(e,i,a,r,o):Oi(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Ni(e,t){return e.filter(e=>ji.indexOf(e.pos)===-1&&e.box.axis===t)}function Pi(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Fi(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Pi(Mi(t,`left`),!0),i=Pi(Mi(t,`right`)),a=Pi(Mi(t,`top`),!0),o=Pi(Mi(t,`bottom`)),s=Ni(t,`x`),c=Ni(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Mi(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function zi(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Bi(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Vi(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!j(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Bi(o,a.getPadding());let s=Math.max(0,t.outerWidth-zi(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-zi(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Hi(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Ui(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Wi(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Bi(f,q(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Li(c.concat(l),d);Wi(s.fullSize,p,d,m),Wi(c,p,d,m),Wi(l,p,d,m)&&Wi(c,p,d,m),Hi(p),Ki(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Ki(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},I(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},qi=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Ji=class extends qi{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Yi=`$chartjs`,Xi={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Zi=e=>e===null||e===``;function Qi(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Yi]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Zi(i)){let t=rr(e,`width`);t!==void 0&&(e.width=t)}if(Zi(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=rr(e,`height`);t!==void 0&&(e.height=t)}return e}var $i=nr?{passive:!0}:!1;function ea(e,t,n){e&&e.addEventListener(t,n,$i)}function ta(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,$i)}function na(e,t){let n=Xi[e.type]||e.type,{x:r,y:i}=Zn(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ra(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ia(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ra(n.addedNodes,r),t&&=!ra(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function aa(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ra(n.removedNodes,r),t&&=!ra(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var oa=new Map,sa=0;function ca(){let e=window.devicePixelRatio;e!==sa&&(sa=e,oa.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function la(e,t){oa.size||window.addEventListener(`resize`,ca),oa.set(e,t)}function ua(e){oa.delete(e),oa.size||window.removeEventListener(`resize`,ca)}function da(e,t,n){let r=e.canvas,i=r&&Un(r);if(!i)return;let a=ft((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),la(e,a),o}function fa(e,t,n){n&&n.disconnect(),t===`resize`&&ua(e)}function pa(e,t,n){let r=e.canvas,i=ft(t=>{e.ctx!==null&&n(na(t,e))},e);return ea(r,t,i),i}var ma=class extends qi{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(Qi(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Yi])return!1;let n=t[Yi].initial;[`height`,`width`].forEach(e=>{let r=n[e];k(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Yi],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ia,detach:aa,resize:da}[t]||pa)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:fa,detach:fa,resize:fa}[t]||ta)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return er(e,t,n,r)}isAttached(e){let t=e&&Un(e);return!!(t&&t.isConnected)}};function ha(e){return!Hn()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Ji:ma}var ga=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Ke(this.x)&&Ke(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function _a(e,t){let n=e.options.ticks,r=va(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?ba(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return xa(t,l,a,o/i),l;let u=ya(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Sa(t,l,u,k(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function ba(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Ta=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Ea=(e,t)=>Math.min(t||e,e);function Da(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function ka(e,t){I(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:N(t,N(n,t)),max:N(n,N(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){F(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=dn(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=U(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Aa(e.grid)-t.padding-ja(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Ye(Math.min(Math.asin(U((l.highest.height+6)/o,-1,1)),Math.asin(U(s/c,-1,1))-Math.asin(U(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){F(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){F(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=ja(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Aa(i)+a):(e.height=this.maxHeight,e.width=Aa(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=V(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){F(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return tt(this._alignToPixels?Ut(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+(s?1:0),u=Aa(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Ut(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,D;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,D=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,D=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(j(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,D=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(j(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,E=e.right}let ee=P(r.ticks.maxTicksLimit,l),O=Math.max(1,Math.ceil(l/ee));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:D,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:ee,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-V(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);G.route(a,i,c,s)})}function Ba(e){return`id`in e&&`defaults`in e}var X=new class{constructor(){this.controllers=new La($r,`datasets`,!0),this.elements=new La(ga,`elements`),this.plugins=new La(Object,`plugins`),this.scales=new La(Ia,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):I(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=je(e);F(n[`before`+r],[],n),t[e](n),F(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Ha(e){let t={},n=[],r=Object.keys(X.plugins.items);for(let e=0;e1&&Ya(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Qa(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function $a(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return Qa(e,`x`,n[0])||Qa(e,`y`,n[0])}return{}}function eo(e,t){let n=It[e.type]||{scales:{}},r=t.scales||{},i=Ka(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!j(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=Za(t,o,$a(t,e),G.scales[o.type]),c=Ja(s,i),l=n.scales||{};a[t]=Te(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Ka(i,t),s=(It[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=qa(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),Te(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];Te(t,[G.scales[t.type],G.scale])}),a}function to(e){let t=e.options||={};t.plugins=P(t.plugins,{}),t.scales=eo(e,t)}function no(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ro(e){return e||={},e.data=no(e.data),to(e),e}var io=new Map,ao=new Set;function oo(e,t){let n=io.get(e);return n||(n=t(),io.set(e,n),ao.add(n)),n}var so=(e,t,n)=>{let r=Ae(t,n);r!==void 0&&e.add(r)},co=class{constructor(e){this._config=ro(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=no(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),to(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return oo(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return oo(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return oo(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return oo(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>so(s,e,t))),t.forEach(e=>so(s,r,e)),t.forEach(e=>so(s,It[i]||{},e)),t.forEach(e=>so(s,G,e)),t.forEach(e=>so(s,Lt,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),ao.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,It[t]||{},G.datasets[t]||{},{type:t},G,Lt]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=lo(this._resolverCache,e,r),s=a;if(fo(a,t)){i.$shared=!1,n=Ne(n)?n():n;let t=this.createResolver(e,n,o);s=mn(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=lo(this._resolverCache,e,n);return j(t)?mn(i,t,void 0,r):i}};function lo(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:pn(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var uo=e=>j(e)&&Object.getOwnPropertyNames(e).some(t=>Ne(e[t]));function fo(e,t){let{isScriptable:n,isIndexable:r}=hn(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(Ne(o)||uo(o))||a&&A(o))return!0}return!1}var po=`4.5.1`,mo=[`top`,`bottom`,`left`,`right`,`chartArea`];function ho(e,t){return e===`top`||e===`bottom`||mo.indexOf(e)===-1&&t===`x`}function go(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function _o(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),F(n&&n.onComplete,[e],t)}function vo(e){let t=e.chart,n=t.options.animation;F(n&&n.onProgress,[e],t)}function yo(e){return Hn()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var bo={},xo=e=>{let t=yo(e);return Object.values(bo).filter(e=>e.canvas===t).pop()};function So(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Co(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var wo=class{static defaults=G;static instances=bo;static overrides=It;static registry=X;static version=po;static getChart=xo;static register(...e){X.add(...e),To()}static unregister(...e){X.remove(...e),To()}constructor(e,t){let n=this.config=new co(t),r=yo(e),i=xo(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(ha(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=_e(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Va,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=pt(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],bo[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Dr.listen(this,`complete`,_o),Dr.listen(this,`progress`,vo),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return k(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return X}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():tr(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Wt(this.canvas,this.ctx),this}stop(){return Dr.stop(this),this}resize(e,t){Dr.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,tr(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),F(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){I(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=Za(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),I(i,t=>{let i=t.options,a=i.id,o=Za(a,i),s=P(i.type,t.dtype);(i.position===void 0||ho(i.position,o)!==ho(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(X.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),I(r,(e,t)=>{e||delete n[t]}),I(n,e=>{Y.configure(this,e,e.options),Y.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(go(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){I(this.scales,e=>{Y.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!Pe(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)So(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Y.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],I(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=Er(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&qt(t,r),e.controller.draw(),r&&Jt(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return K(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Ai.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=fn(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);Me(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Dr.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};I(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){I(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},I(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});be(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=Fe(e),c=Co(e,this._lastEvent,n,s);n&&(this._lastEvent=null,F(i.onHover,[e,o,this],this),s&&F(i.onClick,[e,o,this],this));let l=!be(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function To(){return I(wo.instances,e=>e._plugins.invalidate())}function Eo(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,H(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,H(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*H(r-n));if(u===`round`)e.arc(i,a,t,n-L/2,r+L/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+L/2)+i,c=-o*Math.sin(n+L/2)+a,l=o*Math.cos(r+L/2)+i,u=o*Math.sin(r+L/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Do(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+z,r-z),e.closePath(),e.clip()}function Oo(e){return sn(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function ko(e,t,n,r){let i=Oo(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return U(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:U(i.innerStart,0,o),innerEnd:U(i.innerEnd,0,o)}}function Ao(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function jo(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/L)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=ko(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,T=_-y/C,E=f+b,D=f+x,ee=g+b/E,O=_-x/D;if(e.beginPath(),a){let t=(w+T)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,T),y>0){let t=Ao(C,T,o,s);e.arc(t.x,t.y,y,T,_+z)}let n=Ao(D,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Ao(D,O,o,s);e.arc(t.x,t.y,x,_+z,O+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Ao(E,ee,o,s);e.arc(t.x,t.y,b,ee+Math.PI,g-z)}let i=Ao(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Ao(S,w,o,s);e.arc(t.x,t.y,v,g-z,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(T)*d+o,i=Math.sin(T)*d+s;e.lineTo(r,i)}e.closePath()}function Mo(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){jo(e,t,n,r,c,i);for(let t=0;t=L&&p===0&&u!==`miter`&&Eo(e,t,h),a||(jo(e,t,n,r,h,i),e.stroke())}var Po=class extends ga{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Ze(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=P(l,o-a),f=et(r,a,o)&&a!==o,p=d>=R||f,m=nt(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>R?Math.floor(n/R):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(L,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Mo(e,this,s,i,a),No(e,this,s,i,a),e.restore()}};function Fo(e,t,n=t){e.lineCap=P(n.borderCapStyle,t.borderCapStyle),e.setLineDash(P(n.borderDash,t.borderDash)),e.lineDashOffset=P(n.borderDashOffset,t.borderDashOffset),e.lineJoin=P(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=P(n.borderWidth,t.borderWidth),e.strokeStyle=P(n.borderColor,t.borderColor)}function Io(e,t,n){e.lineTo(n.x,n.y)}function Lo(e){return e.stepped?Yt:e.tension||e.cubicInterpolationMode===`monotone`?Xt:Io}function Ro(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Vo(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Bo:zo}function Ho(e){return e.stepped?ar:e.tension||e.cubicInterpolationMode===`monotone`?or:ir}function Uo(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Fo(e,t.options),e.stroke(i)}function Wo(e,t,n,r){let{segments:i,options:a}=t,o=Vo(t);for(let s of i)Fo(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Go=typeof Path2D==`function`;function Ko(e,t,n,r){Go&&!t.options.segment?Uo(e,t,n,r):Wo(e,t,n,r)}var qo=class extends ga{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Vn(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=yr(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=gr(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Ho(n),c,l;for(c=0,l=a.length;c{t=ls(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function ls(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function us(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function ds(e,t){let n=[],r=!1;return A(e)?(r=!0,n=e):n=cs(e,t),n.length?new qo({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function fs(e){return e&&e.fill!==!1}function ps(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!M(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function ms(e,t,n){let r=vs(e);if(j(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return M(i)&&Math.floor(i)===i?hs(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function hs(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function gs(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:j(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function _s(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:j(e)?e.value:t.getBaseValue(),r}function vs(e){let t=e.options,n=t.fill,r=P(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function ys(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=bs(t,n);s.push(ds({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&ks(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;fs(n)&&ks(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!fs(r)||n.drawTime!==`beforeDatasetDraw`||ks(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},Ls=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},Rs=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,zs=class extends ga{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=F(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=J(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=Ls(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=Bs(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=lr(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=W(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=W(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=W(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=W(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;qt(e,this),this._draw(),Jt(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=G.color,s=lr(e.rtl,this.left,this.width),c=J(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=Ls(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=P(n.lineWidth,1);if(r.fillStyle=P(n.fillStyle,o),r.lineCap=P(n.lineCap,`butt`),r.lineDashOffset=P(n.lineDashOffset,0),r.lineJoin=P(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=P(n.strokeStyle,o),r.setLineDash(P(n.lineDash,[])),a.usePointStyle)Kt(r,{radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},s.xPlus(e,p/2),t+d,a.pointStyleWidth&&p);else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=ln(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?tn(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){en(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:W(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:W(i,this.top+y+l,this.bottom-t[0].height),line:0},ur(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;if(s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=W(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=W(i,this.top+y+l,this.bottom-t[f.line].height)),g(s.x(S),C,o),S=ht(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=Us(o,e)+l}else f.y+=b}),dr(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=J(t.font),r=q(t.padding);if(!t.display)return;let i=lr(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=W(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+W(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=W(o,u,u+d);a.textAlign=i.textAlign(mt(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,en(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=J(e.font),n=q(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(nt(e,this.left,this.right)&&nt(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function Hs(e,t,n){let r=e;return typeof t.text!=`string`&&(r=Us(t,n)),r}function Us(e,t){return t*(e.text?e.text.length:0)}function Ws(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var Gs={id:`legend`,_element:zs,start(e,t,n){let r=e.legend=new zs({ctx:e.ctx,options:n,chart:e});Y.configure(e,r,n),Y.addBox(e,r)},stop(e){Y.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Y.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=q(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},Ks=class extends ga{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=A(n.text)?n.text.length:1;this._padding=q(n.padding);let i=r*J(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=W(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=W(o,r,t),s=L*-.5):(l=i-e,u=W(o,t,r),s=L*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=J(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);en(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:mt(t.align),textBaseline:`middle`,translation:[i,a]})}};function qs(e,t){let n=new Ks({ctx:e.ctx,options:t,chart:e});Y.configure(e,n,t),Y.addBox(e,n),e.titleBlock=n}var Js={id:`title`,_element:Ks,start(e,t,n){qs(e,n)},stop(e){let t=e.titleBlock;Y.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Y.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},Ys={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` -`):e}function Zs(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function Qs(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=J(t.bodyFont),l=J(t.titleFont),u=J(t.footerFont),d=a.length,f=i.length,p=r.length,m=q(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,I(e.title,y),n.font=c.string,I(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,I(r,e=>{I(e.before,y),I(e.lines,y),I(e.after,y)}),v=0,n.font=u.string,I(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function $s(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function ec(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function tc(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),ec(l,e,t,n)&&(l=`center`),l}function nc(e,t,n){let r=n.yAlign||t.yAlign||$s(e,n);return{xAlign:n.xAlign||t.xAlign||tc(e,t,n,r),yAlign:r}}function rc(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function ic(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function ac(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=ln(o),m=rc(t,s),h=ic(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:U(m,0,r.width-t.width),y:U(h,0,r.height-t.height)}}function oc(e,t,n){let r=q(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function sc(e){return Z([],Xs(e))}function cc(e,t,n){return fn(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function lc(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var uc={beforeTitle:ge,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=lc(n,e);Z(t.before,Xs(Q(i,`beforeLabel`,this,e))),Z(t.lines,Q(i,`label`,this,e)),Z(t.after,Xs(Q(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return sc(Q(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Q(n,`beforeFooter`,this,e),i=Q(n,`footer`,this,e),a=Q(n,`afterFooter`,this,e),o=[];return o=Z(o,Xs(r)),o=Z(o,Xs(i)),o=Z(o,Xs(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),I(o,t=>{let n=lc(e.callbacks,t);r.push(Q(n,`labelColor`,this,t)),i.push(Q(n,`labelPointStyle`,this,t)),a.push(Q(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=Ys[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=Qs(this,n),o=Object.assign({},e,t),s=nc(this.chart,n,o),c=ac(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=ln(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=lr(n.rtl,this.x,this.width);for(e.x=oc(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=J(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,tn(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),tn(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=J(n.bodyFont),d=u.lineHeight,f=0,p=lr(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=oc(this,h,n),t.fillStyle=n.bodyColor,I(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=Ys[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=Qs(this,e),o=Object.assign({},n,this._size),s=nc(t,e,o),c=ac(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=q(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),ur(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),dr(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!be(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!be(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=Ys[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},fc={id:`tooltip`,_element:dc,positioners:Ys,afterInit(e,t,n){n&&(e.tooltip=new dc({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:uc},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]},pc=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function mc(e,t,n,r){let i=e.indexOf(t);return i===-1?pc(e,t,n,r):i===e.lastIndexOf(t)?i:n}var hc=(e,t)=>e===null?null:U(Math.round(e),0,t);function gc(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function vc(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!k(a),_=!k(o),v=!k(c),y=(h-m)/(u+1),b=Ue((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Ue(w*b/p/f)*f),k(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&qe((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=He(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max(Xe(b),Xe(S));x=10**(k(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&He(n[n.length-1].value,o,yc(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function yc(e,t,{horizontal:n,minRotation:r}){let i=V(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var bc=class extends Ia{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return k(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=B(r),t=B(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=vc({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Je(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return jt(e,this.chart.options.locale,this.options.ticks.format)}},xc=class extends bc{static id=`linear`;static defaults={ticks:{callback:Pt.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=M(e)?e:0,this.max=M(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=V(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Sc=e=>Math.floor(Ve(e)),Cc=(e,t)=>10**(Sc(e)+t);function wc(e){return e/10**Sc(e)==1}function Tc(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Ec(e,t){let n=Sc(t-e);for(;Tc(e,t,n)>10;)n++;for(;Tc(e,t,n)<10;)n--;return Math.min(n,Sc(e))}function Dc(e,{min:t,max:n}){t=N(e.min,t);let r=[],i=Sc(t),a=Ec(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=N(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=N(e.max,f);return r.push({value:p,major:wc(p),significand:d}),r}(class extends Ia{static id=`logarithmic`;static defaults={ticks:{callback:Pt.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=bc.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return M(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=M(e)?Math.max(0,e):null,this.max=M(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!M(this._userMin)&&(this.min=e===Cc(this.min,0)?Cc(this.min,-1):Cc(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Cc(n,-1)),a(Cc(r,1)))),n<=0&&i(Cc(r,-1)),r<=0&&a(Cc(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Dc({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Je(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:jt(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Ve(e),this._valueRange=Ve(this.max)-Ve(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Ve(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}});function Oc(e){let t=e.ticks;if(t.display&&e.display){let e=q(t.backdropPadding);return P(t.font&&t.font.size,G.font.size)+e.height}return 0}function kc(e,t,n){return n=A(n)?n:[n],{w:Ht(e,t.string,n),h:n.length*t.lineHeight}}function Ac(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function jc(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?L/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function Nc(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Ye(H(c.angle+z))),u=Rc(c.y,s.h,l),d=Ic(l),f=Lc(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function Pc(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(K({x:n,y:r},t)||K({x:n,y:a},t)||K({x:i,y:r},t)||K({x:i,y:a},t))}function Fc(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Oc(a)/2,additionalAngle:o?L/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function zc(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!k(s)){let n=ln(t.borderRadius),c=q(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),tn(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function Bc(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));zc(n,a,t);let o=J(a.font),{x:s,y:c,textAlign:l}=t;en(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function Vc(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,R);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=F(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?jc(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=R/(this._pointLabels.length||1),n=this.options.startAngle||0;return H(e*t+V(n))}getDistanceFromCenterForValue(e){if(k(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(k(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);Hc(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=J(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=q(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}en(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}});var Wc={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},$=Object.keys(Wc);function Gc(e,t){return e-t}function Kc(e,t){if(k(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),M(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Ke(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function qc(e,t,n,r){let i=$.length;for(let a=$.indexOf(e);a=$.indexOf(n);a--){let n=$[a];if(Wc[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return $[n?$.indexOf(n):0]}function Yc(e){for(let t=$.indexOf(e)+1,n=$.length;t=t?n[r]:n[i];e[a]=!0}}function Zc(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function Qc(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=U(t,0,a),n=U(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||qc(i.minUnit,t,n,this._getLabelCapacity(t)),o=P(r.ticks.stepSize,1),s=a===`week`?i.isoWeekday:!1,c=Ke(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return F(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=it(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=it(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}(class extends $c{static id=`timeseries`;static defaults=$c.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=el(t,this.min),this._tableRange=el(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(el(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return el(this._table,n*this._tableRange+this._minPos,!0)}});export{fc as _,wo as a,qo as c,yi as d,$c as f,Js as g,Gs as h,_c as i,xc as l,Is as m,hi as n,_i as o,xi as p,as as r,vi as s,Po as t,Yo as u}; \ No newline at end of file diff --git a/repeater/web/html/assets/chartjs-adapter-date-fns-BKkkO1xH.css b/repeater/web/html/assets/chartjs-adapter-date-fns-BKkkO1xH.css new file mode 100644 index 00000000..b71f4cbe --- /dev/null +++ b/repeater/web/html/assets/chartjs-adapter-date-fns-BKkkO1xH.css @@ -0,0 +1 @@ +.sparkline-card[data-v-902d5054]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background:#ffffffbf;border:1px solid #0000000f;border-radius:12px;padding:12px 14px;transition:background .3s,border-color .3s,box-shadow .3s;overflow:hidden;box-shadow:0 4px 16px #0000000a,0 1px 3px #00000005}.dark .sparkline-card[data-v-902d5054]{background:#0006;border:1px solid #ffffff0d;box-shadow:0 4px 16px #0003}.card-header[data-v-902d5054]{justify-content:space-between;align-items:baseline;margin-bottom:8px;display:flex}.card-title[data-v-902d5054]{color:#4b5563b3;text-transform:uppercase;letter-spacing:.05em;font-size:11px;font-weight:500;transition:color .3s}.dark .card-title[data-v-902d5054]{color:#fff9}.card-subtitle[data-v-902d5054]{color:#4b556380;margin-top:2px;font-size:9px;font-weight:400;transition:color .3s}.dark .card-subtitle[data-v-902d5054]{color:#fff6}.card-value[data-v-902d5054]{font-variant-numeric:tabular-nums;font-size:22px;font-weight:700;line-height:1}.card-chart[data-v-902d5054]{width:100%;height:28px;overflow:hidden}.chart-svg[data-v-902d5054]{width:100%;height:100%}.chart-loader[data-v-902d5054],.chart-error[data-v-902d5054]{justify-content:center;align-items:center;height:100%;display:flex}.chart-retry-btn[data-v-902d5054]{color:#4b5563b3;cursor:pointer;background:#4b556314;border:1px solid #4b556326;border-radius:4px;padding:2px 8px;font-size:11px;transition:background .2s}.chart-retry-btn[data-v-902d5054]:hover{background:#4b556326}.dark .chart-retry-btn[data-v-902d5054]{color:#ffffff80;background:#ffffff0d;border-color:#ffffff1a}.dark .chart-retry-btn[data-v-902d5054]:hover{background:#ffffff1a}.chart-text[data-v-902d5054]{justify-content:center;align-items:center;height:100%;display:flex}.percent-value[data-v-902d5054]{color:#ffffff80;font-variant-numeric:tabular-nums;font-size:20px;font-weight:500}.sparkline-path[data-v-902d5054]{transition:d 1s ease-out}@media (width>=1024px){.sparkline-card[data-v-902d5054]{padding:14px 16px}.card-header[data-v-902d5054]{margin-bottom:10px}.card-title[data-v-902d5054]{font-size:12px}.card-value[data-v-902d5054]{font-size:26px}.card-chart[data-v-902d5054]{height:32px}.percent-value[data-v-902d5054]{font-size:24px}} diff --git a/repeater/web/html/assets/chartjs-adapter-date-fns-BqJ94ASW.css b/repeater/web/html/assets/chartjs-adapter-date-fns-BqJ94ASW.css deleted file mode 100644 index b8a69473..00000000 --- a/repeater/web/html/assets/chartjs-adapter-date-fns-BqJ94ASW.css +++ /dev/null @@ -1 +0,0 @@ -.sparkline-card[data-v-dfc36682]{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background:#ffffffbf;border:1px solid #0000000f;border-radius:12px;padding:12px 14px;transition:background .3s,border-color .3s,box-shadow .3s;overflow:hidden;box-shadow:0 4px 16px #0000000a,0 1px 3px #00000005}.dark .sparkline-card[data-v-dfc36682]{background:#0006;border:1px solid #ffffff0d;box-shadow:0 4px 16px #0003}.card-header[data-v-dfc36682]{justify-content:space-between;align-items:baseline;margin-bottom:8px;display:flex}.card-title[data-v-dfc36682]{color:#4b5563b3;text-transform:uppercase;letter-spacing:.05em;font-size:11px;font-weight:500;transition:color .3s}.dark .card-title[data-v-dfc36682]{color:#fff9}.card-subtitle[data-v-dfc36682]{color:#4b556380;margin-top:2px;font-size:9px;font-weight:400;transition:color .3s}.dark .card-subtitle[data-v-dfc36682]{color:#fff6}.card-value[data-v-dfc36682]{font-variant-numeric:tabular-nums;font-size:22px;font-weight:700;line-height:1}.card-chart[data-v-dfc36682]{width:100%;height:28px;overflow:hidden}.chart-svg[data-v-dfc36682]{width:100%;height:100%}.chart-loader[data-v-dfc36682]{justify-content:center;align-items:center;height:100%;display:flex}.loader-spinner[data-v-dfc36682]{border:2px solid #fff3;border-radius:50%;width:18px;height:18px;animation:1s linear infinite spin-dfc36682}.chart-text[data-v-dfc36682]{justify-content:center;align-items:center;height:100%;display:flex}.percent-value[data-v-dfc36682]{color:#ffffff80;font-variant-numeric:tabular-nums;font-size:20px;font-weight:500}.sparkline-path[data-v-dfc36682]{transition:d 1s ease-out}@keyframes spin-dfc36682{to{transform:rotate(360deg)}}@media (width>=1024px){.sparkline-card[data-v-dfc36682]{padding:14px 16px}.card-header[data-v-dfc36682]{margin-bottom:10px}.card-title[data-v-dfc36682]{font-size:12px}.card-value[data-v-dfc36682]{font-size:26px}.card-chart[data-v-dfc36682]{height:32px}.percent-value[data-v-dfc36682]{font-size:24px}} diff --git a/repeater/web/html/assets/chartjs-adapter-date-fns.esm-CUNlL-Mn.js b/repeater/web/html/assets/chartjs-adapter-date-fns.esm-CUNlL-Mn.js new file mode 100644 index 00000000..21f0f38e --- /dev/null +++ b/repeater/web/html/assets/chartjs-adapter-date-fns.esm-CUNlL-Mn.js @@ -0,0 +1 @@ +import{Ct as e,St as t,c as n,g as r,k as i,l as a,m as o,o as s,p as c,r as l,s as u,u as d}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{t as f}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as p}from"./Spinner-CcYauG9D.js";import{h as m}from"./ChartCard-Dv7_dbhW.js";var h={class:`sparkline-card`},ee={class:`card-header`},te={class:`card-title`},ne={class:`card-subtitle`},re={key:0,class:`card-chart`},ie={key:0,class:`chart-loader`},ae={key:1,class:`chart-error`},oe={key:2,class:`chart-text`},se={class:`percent-value`},ce=[`id`,`viewBox`],le=[`d`,`fill`],ue=[`d`,`stroke`],g=100,_=40,de=f(r({name:`SparklineChart`,__name:`Sparkline`,props:{title:{},value:{},color:{},data:{default:()=>[]},showChart:{type:Boolean,default:!0},variant:{default:`smooth`},loading:{type:Boolean,default:!1},error:{default:null},centerText:{default:``},subtitle:{default:``},minY:{default:void 0},maxY:{default:void 0}},emits:[`retry`],setup(r,{emit:f}){let m=r,de=f,fe=e=>{if(e.length<3)return e;let t=Math.min(15,Math.max(3,Math.floor(e.length*.2))),n=[];for(let r=0;re+t,0)/s.length)}let r=Math.min(10,n.length),i=n.length/r,a=[];for(let e=0;e!m.data||m.data.length===0?[]:m.variant===`smooth`?fe(m.data):m.data),pe=e=>{if(e.length<2)return``;let t=m.maxY??Math.max(...e),n=m.minY??Math.min(...e),r=t-n||1,i=m.variant===`classic`?4:2,a=``;return e.forEach((t,o)=>{let s=o/(e.length-1)*g,c=(t-n)/r,l=i+(_-i*2)*(1-c);if(o===0)a+=`M ${s.toFixed(2)} ${l.toFixed(2)}`;else{let t=((o-1)/(e.length-1)*g+s)/2;a+=` Q ${t.toFixed(2)} ${l.toFixed(2)} ${s.toFixed(2)} ${l.toFixed(2)}`}}),a},y=s(()=>pe(v.value)),b=s(()=>y.value?`${y.value} L ${g} ${_} L 0 ${_} Z`:``),me=s(()=>`sparkline-${m.title.replace(/\s+/g,`-`).toLowerCase()}`);return(s,f)=>(i(),d(`div`,h,[u(`div`,ee,[u(`div`,null,[u(`p`,te,e(r.title),1),u(`p`,ne,e(r.subtitle),1)]),u(`span`,{class:`card-value`,style:t({color:r.color})},[r.loading?(i(),n(p,{key:0,size:`sm`,color:`current`})):(i(),d(l,{key:1},[c(e(typeof r.value==`number`?r.value.toLocaleString():r.value),1)],64))],4)]),r.showChart?(i(),d(`div`,re,[r.loading&&r.variant===`classic`?(i(),d(`div`,ie,[o(p,{size:`sm`})])):r.error?(i(),d(`div`,ae,[u(`button`,{class:`chart-retry-btn`,onClick:f[0]||=e=>de(`retry`)},`↺ Retry`)])):r.centerText?(i(),d(`div`,oe,[u(`span`,se,e(r.centerText),1)])):(i(),d(`svg`,{key:3,id:me.value,class:`chart-svg`,viewBox:`0 0 ${g} ${_}`,preserveAspectRatio:`none`},[r.variant===`classic`?(i(),d(l,{key:0},[v.value.length>1?(i(),d(`path`,{key:0,d:b.value,fill:r.color,"fill-opacity":`0.8`,class:`sparkline-path`},null,8,le)):a(``,!0)],64)):(i(),d(l,{key:1},[v.value.length>1?(i(),d(`path`,{key:0,d:y.value,stroke:r.color,"stroke-width":`2.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,fill:`none`,class:`sparkline-path`},null,8,ue)):a(``,!0)],64))],8,ce))])):a(``,!0)]))}}),[[`__scopeId`,`data-v-902d5054`]]),fe=365.2425,v=6048e5,pe=864e5,y=6e4,b=36e5,me=1e3,he=3600*24;he*7,he*fe/12*3;var ge=Symbol.for(`constructDateFrom`);function x(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&ge in e?e[ge](t):e instanceof Date?new e.constructor(t):new Date(t)}function S(e,t){return x(t||e,e)}function C(e,t,n){let r=S(e,n?.in);return isNaN(t)?x(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function w(e,t,n){let r=S(e,n?.in);if(isNaN(t))return x(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=x(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}function T(e,t,n){return x(n?.in||e,+S(e)+t)}function _e(e,t,n){return T(e,t*b,n)}var ve={};function E(){return ve}function D(e,t){let n=E(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=S(e,t?.in),a=i.getDay(),o=(a=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function k(e){let t=S(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function A(e,...t){let n=x.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function j(e,t){let n=S(e,t?.in);return n.setHours(0,0,0,0),n}function be(e,t,n){let[r,i]=A(n?.in,e,t),a=j(r),o=j(i),s=+a-k(a),c=+o-k(o);return Math.round((s-c)/pe)}function xe(e,t){let n=ye(e,t),r=x(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),O(r)}function Se(e,t,n){let r=S(e,n?.in);return r.setTime(r.getTime()+t*y),r}function Ce(e,t,n){return w(e,t*3,n)}function we(e,t,n){return T(e,t*1e3,n)}function Te(e,t,n){return C(e,t*7,n)}function Ee(e,t,n){return w(e,t*12,n)}function M(e,t){let n=S(e)-+S(t);return n<0?-1:n>0?1:n}function De(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Oe(e){return!(!De(e)&&typeof e!=`number`||isNaN(+S(e)))}function ke(e,t,n){let[r,i]=A(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function Ae(e,t,n){let[r,i]=A(n?.in,e,t);return r.getFullYear()-i.getFullYear()}function je(e,t,n){let[r,i]=A(n?.in,e,t),a=Me(r,i),o=Math.abs(be(r,i));r.setDate(r.getDate()-a*o);let s=a*(o-Number(Me(r,i)===-a));return s===0?0:s}function Me(e,t){let n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function N(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function Ne(e,t,n){let[r,i]=A(n?.in,e,t),a=(r-+i)/b;return N(n?.roundingMethod)(a)}function P(e,t){return S(e)-+S(t)}function Pe(e,t,n){let r=P(e,t)/y;return N(n?.roundingMethod)(r)}function Fe(e,t){let n=S(e,t?.in);return n.setHours(23,59,59,999),n}function Ie(e,t){let n=S(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Le(e,t){let n=S(e,t?.in);return+Fe(n,t)==+Ie(n,t)}function Re(e,t,n){let[r,i,a]=A(n?.in,e,e,t),o=M(i,a),s=Math.abs(ke(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=M(i,a)===-o;Le(r)&&s===1&&M(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function ze(e,t,n){let r=Re(e,t,n)/3;return N(n?.roundingMethod)(r)}function Be(e,t,n){let r=P(e,t)/1e3;return N(n?.roundingMethod)(r)}function Ve(e,t,n){let r=je(e,t,n)/7;return N(n?.roundingMethod)(r)}function He(e,t,n){let[r,i]=A(n?.in,e,t),a=M(r,i),o=Math.abs(Ae(r,i));r.setFullYear(1584),i.setFullYear(1584);let s=a*(o-+(M(r,i)===-a));return s===0?0:s}function Ue(e,t){let n=S(e,t?.in),r=n.getMonth(),i=r-r%3;return n.setMonth(i,1),n.setHours(0,0,0,0),n}function We(e,t){let n=S(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Ge(e,t){let n=S(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Ke(e,t){let n=S(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function qe(e,t){let n=S(e,t?.in);return n.setMinutes(59,59,999),n}function Je(e,t){let n=E(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=S(e,t?.in),a=i.getDay(),o=(a{let r,i=Qe[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function F(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var et={date:F({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:F({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:F({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},tt={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},nt=(e,t,n,r)=>tt[e];function I(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var rt={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:I({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:I({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:I({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:I({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:I({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`})};function L(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?at(s,e=>e.test(o)):it(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function it(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function at(e,t){for(let n=0;n{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var st={code:`en-US`,formatDistance:$e,formatLong:et,formatRelative:nt,localize:rt,match:{ordinalNumber:ot({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:L({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:L({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:L({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:L({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:L({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}};function ct(e,t){let n=S(e,t?.in);return be(n,Ke(n))+1}function lt(e,t){let n=S(e,t?.in),r=O(n)-+xe(n);return Math.round(r/v)+1}function R(e,t){let n=S(e,t?.in),r=n.getFullYear(),i=E(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=x(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=D(o,t),c=x(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=D(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function ut(e,t){let n=E(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=R(e,t),a=x(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),D(a,t)}function dt(e,t){let n=S(e,t?.in),r=D(n,t)-+ut(n,t);return Math.round(r/v)+1}function z(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var B={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return z(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):z(n+1,2)},d(e,t){return z(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return z(e.getHours()%12||12,t.length)},H(e,t){return z(e.getHours(),t.length)},m(e,t){return z(e.getMinutes(),t.length)},s(e,t){return z(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return z(Math.trunc(r*10**(n-3)),t.length)}},V={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},ft={G:function(e,t,n){let r=e.getFullYear()>0?1:0;switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return B.y(e,t)},Y:function(e,t,n,r){let i=R(e,r),a=i>0?i:1-i;return t===`YY`?z(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):z(a,t.length)},R:function(e,t){return z(ye(e),t.length)},u:function(e,t){return z(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return z(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return z(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return B.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return z(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=dt(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):z(i,t.length)},I:function(e,t,n){let r=lt(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):z(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):B.d(e,t)},D:function(e,t,n){let r=ct(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):z(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return z(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return z(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return z(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?V.noon:r===0?V.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?V.evening:r>=12?V.afternoon:r>=4?V.morning:V.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return B.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):B.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):z(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):z(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):B.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):B.s(e,t)},S:function(e,t){return B.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return mt(r);case`XXXX`:case`XX`:return H(r);default:return H(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return mt(r);case`xxxx`:case`xx`:return H(r);default:return H(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+pt(r,`:`);default:return`GMT`+H(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+pt(r,`:`);default:return`GMT`+H(r,`:`)}},t:function(e,t,n){return z(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return z(+e,t.length)}};function pt(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+z(a,2)}function mt(e,t){return e%60==0?(e>0?`-`:`+`)+z(Math.abs(e)/60,2):H(e,t)}function H(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=z(Math.trunc(r/60),2),a=z(r%60,2);return n+i+t+a}var ht=(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`})}},gt=(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`})}},U={p:gt,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ht(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,ht(r,t)).replace(`{{time}}`,gt(i,t))}},_t=/^D+$/,vt=/^Y+$/,yt=[`D`,`DD`,`YY`,`YYYY`];function bt(e){return _t.test(e)}function xt(e){return vt.test(e)}function W(e,t,n){let r=St(e,t,n);if(console.warn(r),yt.includes(e))throw RangeError(r)}function St(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var Ct=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,wt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Tt=/^'([^]*?)'?$/,Et=/''/g,Dt=/[a-zA-Z]/;function Ot(e,t,n){let r=E(),i=n?.locale??r.locale??st,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=S(e,n?.in);if(!Oe(s))throw RangeError(`Invalid time value`);let c=t.match(wt).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=U[t];return n(e,i.formatLong)}return e}).join(``).match(Ct).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:kt(e)};if(ft[t])return{isToken:!0,value:e};if(t.match(Dt))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&xt(a)||!n?.useAdditionalDayOfYearTokens&&bt(a))&&W(a,t,String(e));let o=ft[a[0]];return o(s,a,i.localize,l)}).join(``)}function kt(e){let t=e.match(Tt);return t?t[1].replace(Et,`'`):e}function At(){return Object.assign({},E())}function jt(e,t){let n=S(e,t?.in).getDay();return n===0?7:n}function Mt(e,t){let n=Nt(t)?new t(0):x(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function Nt(e){return typeof e==`function`&&e.prototype?.constructor===e}var Pt=10,Ft=class{subPriority=0;validate(e,t){return!0}},It=class extends Ft{constructor(e,t,n,r,i){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=r,i&&(this.subPriority=i)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}},Lt=class extends Ft{priority=Pt;subPriority=-1;constructor(e,t){super(),this.context=e||(e=>x(t,e))}set(e,t){return t.timestampIsSet?e:x(e,Mt(e,this.context))}},G=class{run(e,t,n,r){let i=this.parse(e,t,n,r);return i?{setter:new It(i.value,this.validate,this.set,this.priority,this.subPriority),rest:i.rest}:null}validate(e,t,n){return!0}},Rt=class extends G{priority=140;parse(e,t,n){switch(t){case`G`:case`GG`:case`GGG`:return n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`});case`GGGGG`:return n.era(e,{width:`narrow`});default:return n.era(e,{width:`wide`})||n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`})}}set(e,t,n){return t.era=n,e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`R`,`u`,`t`,`T`]},K={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},q={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function J(e,t){return e&&{value:t(e.value),rest:e.rest}}function Y(e,t){let n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function X(e,t){let n=t.match(e);if(!n)return null;if(n[0]===`Z`)return{value:0,rest:t.slice(1)};let r=n[1]===`+`?1:-1,i=n[2]?parseInt(n[2],10):0,a=n[3]?parseInt(n[3],10):0,o=n[5]?parseInt(n[5],10):0;return{value:r*(i*b+a*y+o*me),rest:t.slice(n[0].length)}}function zt(e){return Y(K.anyDigitsSigned,e)}function Z(e,t){switch(e){case 1:return Y(K.singleDigit,t);case 2:return Y(K.twoDigits,t);case 3:return Y(K.threeDigits,t);case 4:return Y(K.fourDigits,t);default:return Y(RegExp(`^\\d{1,`+e+`}`),t)}}function Bt(e,t){switch(e){case 1:return Y(K.singleDigitSigned,t);case 2:return Y(K.twoDigitsSigned,t);case 3:return Y(K.threeDigitsSigned,t);case 4:return Y(K.fourDigitsSigned,t);default:return Y(RegExp(`^-?\\d{1,`+e+`}`),t)}}function Vt(e){switch(e){case`morning`:return 4;case`evening`:return 17;case`pm`:case`noon`:case`afternoon`:return 12;default:return 0}}function Ht(e,t){let n=t>0,r=n?t:1-t,i;if(r<=50)i=e||100;else{let t=r+50,n=Math.trunc(t/100)*100,a=e>=t%100;i=e+n-(a?100:0)}return n?i:1-i}function Ut(e){return e%400==0||e%4==0&&e%100!=0}var Wt=class extends G{priority=130;incompatibleTokens=[`Y`,`R`,`u`,`w`,`I`,`i`,`e`,`c`,`t`,`T`];parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`yy`});switch(t){case`y`:return J(Z(4,e),r);case`yo`:return J(n.ordinalNumber(e,{unit:`year`}),r);default:return J(Z(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n){let r=e.getFullYear();if(n.isTwoDigitYear){let t=Ht(n.year,r);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}let i=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(i,0,1),e.setHours(0,0,0,0),e}},Gt=class extends G{priority=130;parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`YY`});switch(t){case`Y`:return J(Z(4,e),r);case`Yo`:return J(n.ordinalNumber(e,{unit:`year`}),r);default:return J(Z(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n,r){let i=R(e,r);if(n.isTwoDigitYear){let t=Ht(n.year,i);return e.setFullYear(t,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),D(e,r)}let a=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(a,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),D(e,r)}incompatibleTokens=[`y`,`R`,`u`,`Q`,`q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]},Kt=class extends G{priority=130;parse(e,t){return Bt(t===`R`?4:t.length,e)}set(e,t,n){let r=x(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),O(r)}incompatibleTokens=[`G`,`y`,`Y`,`u`,`Q`,`q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},qt=class extends G{priority=130;parse(e,t){return Bt(t===`u`?4:t.length,e)}set(e,t,n){return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`G`,`y`,`Y`,`R`,`w`,`I`,`i`,`e`,`c`,`t`,`T`]},Jt=class extends G{priority=120;parse(e,t,n){switch(t){case`Q`:case`QQ`:return Z(t.length,e);case`Qo`:return n.ordinalNumber(e,{unit:`quarter`});case`QQQ`:return n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`});case`QQQQQ`:return n.quarter(e,{width:`narrow`,context:`formatting`});default:return n.quarter(e,{width:`wide`,context:`formatting`})||n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-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`]},Yt=class extends G{priority=120;parse(e,t,n){switch(t){case`q`:case`qq`:return Z(t.length,e);case`qo`:return n.ordinalNumber(e,{unit:`quarter`});case`qqq`:return n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`});case`qqqqq`:return n.quarter(e,{width:`narrow`,context:`standalone`});default:return n.quarter(e,{width:`wide`,context:`standalone`})||n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-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`]},Xt=class extends G{incompatibleTokens=[`Y`,`R`,`q`,`Q`,`L`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`];priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`M`:return J(Y(K.month,e),r);case`MM`:return J(Z(2,e),r);case`Mo`:return J(n.ordinalNumber(e,{unit:`month`}),r);case`MMM`:return n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`});case`MMMMM`:return n.month(e,{width:`narrow`,context:`formatting`});default:return n.month(e,{width:`wide`,context:`formatting`})||n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}},Zt=class extends G{priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`L`:return J(Y(K.month,e),r);case`LL`:return J(Z(2,e),r);case`Lo`:return J(n.ordinalNumber(e,{unit:`month`}),r);case`LLL`:return n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`});case`LLLLL`:return n.month(e,{width:`narrow`,context:`standalone`});default:return n.month(e,{width:`wide`,context:`standalone`})||n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]};function Qt(e,t,n){let r=S(e,n?.in),i=dt(r,n)-t;return r.setDate(r.getDate()-i*7),S(r,n?.in)}var $t=class extends G{priority=100;parse(e,t,n){switch(t){case`w`:return Y(K.week,e);case`wo`:return n.ordinalNumber(e,{unit:`week`});default:return Z(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n,r){return D(Qt(e,n,r),r)}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]};function en(e,t,n){let r=S(e,n?.in),i=lt(r,n)-t;return r.setDate(r.getDate()-i*7),r}var tn=class extends G{priority=100;parse(e,t,n){switch(t){case`I`:return Y(K.week,e);case`Io`:return n.ordinalNumber(e,{unit:`week`});default:return Z(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n){return O(en(e,n))}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},nn=[31,28,31,30,31,30,31,31,30,31,30,31],rn=[31,29,31,30,31,30,31,31,30,31,30,31],an=class extends G{priority=90;subPriority=1;parse(e,t,n){switch(t){case`d`:return Y(K.date,e);case`do`:return n.ordinalNumber(e,{unit:`date`});default:return Z(t.length,e)}}validate(e,t){let n=Ut(e.getFullYear()),r=e.getMonth();return n?t>=1&&t<=rn[r]:t>=1&&t<=nn[r]}set(e,t,n){return e.setDate(n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]},on=class extends G{priority=90;subpriority=1;parse(e,t,n){switch(t){case`D`:case`DD`:return Y(K.dayOfYear,e);case`Do`:return n.ordinalNumber(e,{unit:`date`});default:return Z(t.length,e)}}validate(e,t){return Ut(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,n){return e.setMonth(0,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`L`,`w`,`I`,`d`,`E`,`i`,`e`,`c`,`t`,`T`]};function sn(e,t,n){let r=E(),i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=S(e,n?.in),o=a.getDay(),s=(t%7+7)%7,c=7-i;return C(a,t<0||t>6?t-(o+c)%7:(s+c)%7-(o+c)%7,n)}var cn=class extends G{priority=90;parse(e,t,n){switch(t){case`E`:case`EE`:case`EEE`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`EEEEE`:return n.day(e,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=sn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`D`,`i`,`e`,`c`,`t`,`T`]},ln=class extends G{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`e`:case`ee`:return J(Z(t.length,e),i);case`eo`:return J(n.ordinalNumber(e,{unit:`day`}),i);case`eee`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`eeeee`:return n.day(e,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=sn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`c`,`t`,`T`]},un=class extends G{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`c`:case`cc`:return J(Z(t.length,e),i);case`co`:return J(n.ordinalNumber(e,{unit:`day`}),i);case`ccc`:return n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});case`ccccc`:return n.day(e,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});default:return n.day(e,{width:`wide`,context:`standalone`})||n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=sn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`e`,`t`,`T`]};function dn(e,t,n){let r=S(e,n?.in);return C(r,t-jt(r,n),n)}var fn=class extends G{priority=90;parse(e,t,n){let r=e=>e===0?7:e;switch(t){case`i`:case`ii`:return Z(t.length,e);case`io`:return n.ordinalNumber(e,{unit:`day`});case`iii`:return J(n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiii`:return J(n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiiii`:return J(n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);default:return J(n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r)}}validate(e,t){return t>=1&&t<=7}set(e,t,n){return e=dn(e,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`E`,`e`,`c`,`t`,`T`]},pn=class extends G{priority=80;parse(e,t,n){switch(t){case`a`:case`aa`:case`aaa`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`aaaaa`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(Vt(n),0,0,0),e}incompatibleTokens=[`b`,`B`,`H`,`k`,`t`,`T`]},mn=class extends G{priority=80;parse(e,t,n){switch(t){case`b`:case`bb`:case`bbb`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`bbbbb`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(Vt(n),0,0,0),e}incompatibleTokens=[`a`,`B`,`H`,`k`,`t`,`T`]},hn=class extends G{priority=80;parse(e,t,n){switch(t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`BBBBB`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(Vt(n),0,0,0),e}incompatibleTokens=[`a`,`b`,`t`,`T`]},gn=class extends G{priority=70;parse(e,t,n){switch(t){case`h`:return Y(K.hour12h,e);case`ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Z(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,n){let r=e.getHours()>=12;return r&&n<12?e.setHours(n+12,0,0,0):!r&&n===12?e.setHours(0,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`H`,`K`,`k`,`t`,`T`]},_n=class extends G{priority=70;parse(e,t,n){switch(t){case`H`:return Y(K.hour23h,e);case`Ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Z(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,n){return e.setHours(n,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`K`,`k`,`t`,`T`]},vn=class extends G{priority=70;parse(e,t,n){switch(t){case`K`:return Y(K.hour11h,e);case`Ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Z(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.getHours()>=12&&n<12?e.setHours(n+12,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`h`,`H`,`k`,`t`,`T`]},yn=class extends G{priority=70;parse(e,t,n){switch(t){case`k`:return Y(K.hour24h,e);case`ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Z(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,n){let r=n<=24?n%24:n;return e.setHours(r,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`H`,`K`,`t`,`T`]},bn=class extends G{priority=60;parse(e,t,n){switch(t){case`m`:return Y(K.minute,e);case`mo`:return n.ordinalNumber(e,{unit:`minute`});default:return Z(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setMinutes(n,0,0),e}incompatibleTokens=[`t`,`T`]},xn=class extends G{priority=50;parse(e,t,n){switch(t){case`s`:return Y(K.second,e);case`so`:return n.ordinalNumber(e,{unit:`second`});default:return Z(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setSeconds(n,0),e}incompatibleTokens=[`t`,`T`]},Sn=class extends G{priority=30;parse(e,t){return J(Z(t.length,e),e=>Math.trunc(e*10**(-t.length+3)))}set(e,t,n){return e.setMilliseconds(n),e}incompatibleTokens=[`t`,`T`]},Cn=class extends G{priority=10;parse(e,t){switch(t){case`X`:return X(q.basicOptionalMinutes,e);case`XX`:return X(q.basic,e);case`XXXX`:return X(q.basicOptionalSeconds,e);case`XXXXX`:return X(q.extendedOptionalSeconds,e);default:return X(q.extended,e)}}set(e,t,n){return t.timestampIsSet?e:x(e,e.getTime()-k(e)-n)}incompatibleTokens=[`t`,`T`,`x`]},wn=class extends G{priority=10;parse(e,t){switch(t){case`x`:return X(q.basicOptionalMinutes,e);case`xx`:return X(q.basic,e);case`xxxx`:return X(q.basicOptionalSeconds,e);case`xxxxx`:return X(q.extendedOptionalSeconds,e);default:return X(q.extended,e)}}set(e,t,n){return t.timestampIsSet?e:x(e,e.getTime()-k(e)-n)}incompatibleTokens=[`t`,`T`,`X`]},Tn=class extends G{priority=40;parse(e){return zt(e)}set(e,t,n){return[x(e,n*1e3),{timestampIsSet:!0}]}incompatibleTokens=`*`},En=class extends G{priority=20;parse(e){return zt(e)}set(e,t,n){return[x(e,n),{timestampIsSet:!0}]}incompatibleTokens=`*`},Dn={G:new Rt,y:new Wt,Y:new Gt,R:new Kt,u:new qt,Q:new Jt,q:new Yt,M:new Xt,L:new Zt,w:new $t,I:new tn,d:new an,D:new on,E:new cn,e:new ln,c:new un,i:new fn,a:new pn,b:new mn,B:new hn,h:new gn,H:new _n,K:new vn,k:new yn,m:new bn,s:new xn,S:new Sn,X:new Cn,x:new wn,t:new Tn,T:new En},On=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kn=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,An=/^'([^]*?)'?$/,jn=/''/g,Mn=/\S/,Nn=/[a-zA-Z]/;function Pn(e,t,n,r){let i=()=>x(r?.in||n,NaN),a=At(),o=r?.locale??a.locale??st,s=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,c=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0;if(!t)return e?i():S(n,r?.in);let l={firstWeekContainsDate:s,weekStartsOn:c,locale:o},u=[new Lt(r?.in,n)],d=t.match(kn).map(e=>{let t=e[0];if(t in U){let n=U[t];return n(e,o.formatLong)}return e}).join(``).match(On),f=[];for(let n of d){!r?.useAdditionalWeekYearTokens&&xt(n)&&W(n,t,e),!r?.useAdditionalDayOfYearTokens&&bt(n)&&W(n,t,e);let a=n[0],s=Dn[a];if(s){let{incompatibleTokens:t}=s;if(Array.isArray(t)){let e=f.find(e=>t.includes(e.token)||e.token===a);if(e)throw RangeError(`The format string mustn't contain \`${e.fullToken}\` and \`${n}\` at the same time`)}else if(s.incompatibleTokens===`*`&&f.length>0)throw RangeError(`The format string mustn't contain \`${n}\` and any other token at the same time`);f.push({token:a,fullToken:n});let r=s.run(e,n,o.match,l);if(!r)return i();u.push(r.setter),e=r.rest}else{if(a.match(Nn))throw RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");if(n===`''`?n=`'`:a===`'`&&(n=Fn(n)),e.indexOf(n)===0)e=e.slice(n.length);else return i()}}if(e.length>0&&Mn.test(e))return i();let p=u.map(e=>e.priority).sort((e,t)=>t-e).filter((e,t,n)=>n.indexOf(e)===t).map(e=>u.filter(t=>t.priority===e).sort((e,t)=>t.subPriority-e.subPriority)).map(e=>e[0]),m=S(n,r?.in);if(isNaN(+m))return i();let h={};for(let e of p){if(!e.validate(m,l))return i();let t=e.set(m,h,l);Array.isArray(t)?(m=t[0],Object.assign(h,t[1])):m=t}return m}function Fn(e){return e.match(An)[1].replace(jn,`'`)}function In(e,t){let n=S(e,t?.in);return n.setMinutes(0,0,0),n}function Ln(e,t){let n=S(e,t?.in);return n.setSeconds(0,0),n}function Rn(e,t){let n=S(e,t?.in);return n.setMilliseconds(0),n}function zn(e,t){let n=()=>x(t?.in,NaN),r=t?.additionalDigits??2,i=Un(e),a;if(i.date){let e=Wn(i.date,r);a=Gn(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=Kn(i.time),isNaN(s)))return n();if(i.timezone){if(c=Jn(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=S(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return S(o+s+c,t?.in)}var Q={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Bn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Vn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Hn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Un(e){let t={},n=e.split(Q.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],Q.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Q.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=Q.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function Wn(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function Gn(e,t){if(t===null)return new Date(NaN);let n=e.match(Bn);if(!n)return new Date(NaN);let r=!!n[4],i=$(n[1]),a=$(n[2])-1,o=$(n[3]),s=$(n[4]),c=$(n[5])-1;if(r)return er(t,s,c)?Yn(t,s,c):new Date(NaN);{let e=new Date(0);return!Qn(t,a,o)||!$n(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function $(e){return e?parseInt(e):1}function Kn(e){let t=e.match(Vn);if(!t)return NaN;let n=qn(t[1]),r=qn(t[2]),i=qn(t[3]);return tr(n,r,i)?n*b+r*y+i*1e3:NaN}function qn(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function Jn(e){if(e===`Z`)return 0;let t=e.match(Hn);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return nr(r,i)?n*(r*b+i*y):NaN}function Yn(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var Xn=[31,null,31,30,31,30,31,31,30,31,30,31];function Zn(e){return e%400==0||e%4==0&&e%100!=0}function Qn(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Xn[t]||(Zn(e)?29:28))}function $n(e,t){return t>=1&&t<=(Zn(e)?366:365)}function er(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function tr(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function nr(e,t){return t>=0&&t<=59}var rr={datetime:`MMM d, yyyy, h:mm:ss aaaa`,millisecond:`h:mm:ss.SSS aaaa`,second:`h:mm:ss aaaa`,minute:`h:mm aaaa`,hour:`ha`,day:`MMM d`,week:`PP`,month:`MMM yyyy`,quarter:`qqq - yyyy`,year:`yyyy`};m._date.override({_id:`date-fns`,formats:function(){return rr},parse:function(e,t){if(e==null)return null;let n=typeof e;return n===`number`||e instanceof Date?e=S(e):n===`string`&&(e=typeof t==`string`?Pn(e,t,new Date,this.options):zn(e,this.options)),Oe(e)?e.getTime():null},format:function(e,t){return Ot(e,t,this.options)},add:function(e,t,n){switch(n){case`millisecond`:return T(e,t);case`second`:return we(e,t);case`minute`:return Se(e,t);case`hour`:return _e(e,t);case`day`:return C(e,t);case`week`:return Te(e,t);case`month`:return w(e,t);case`quarter`:return Ce(e,t);case`year`:return Ee(e,t);default:return e}},diff:function(e,t,n){switch(n){case`millisecond`:return P(e,t);case`second`:return Be(e,t);case`minute`:return Pe(e,t);case`hour`:return Ne(e,t);case`day`:return je(e,t);case`week`:return Ve(e,t);case`month`:return Re(e,t);case`quarter`:return ze(e,t);case`year`:return He(e,t);default:return 0}},startOf:function(e,t,n){switch(t){case`second`:return Rn(e);case`minute`:return Ln(e);case`hour`:return In(e);case`day`:return j(e);case`week`:return D(e);case`isoWeek`:return D(e,{weekStartsOn:+n});case`month`:return We(e);case`quarter`:return Ue(e);case`year`:return Ke(e);default:return e}},endOf:function(e,t){switch(t){case`second`:return Ze(e);case`minute`:return Ye(e);case`hour`:return qe(e);case`day`:return Fe(e);case`week`:return Je(e);case`month`:return Ie(e);case`quarter`:return Xe(e);case`year`:return Ge(e);default:return e}}});export{de as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/chartjs-adapter-date-fns.esm-DnBoPdP1.js b/repeater/web/html/assets/chartjs-adapter-date-fns.esm-DnBoPdP1.js deleted file mode 100644 index a9c2e1d9..00000000 --- a/repeater/web/html/assets/chartjs-adapter-date-fns.esm-DnBoPdP1.js +++ /dev/null @@ -1 +0,0 @@ -import{ft as e,g as t,l as n,o as r,pt as i,r as a,s as o,u as s,w as c}from"./runtime-core.esm-bundler-HnidnMFy.js";import{t as l}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{p as u}from"./chart-B1uYMRrx.js";var ee={class:`sparkline-card`},d={class:`card-header`},te={class:`card-title`},f={key:0,class:`card-subtitle`},p={key:0,class:`card-chart`},ne={key:0,class:`chart-loader`},re={key:1,class:`chart-text`},ie={class:`percent-value`},ae=[`id`,`viewBox`],oe=[`d`,`fill`],se=[`d`,`stroke`],m=100,h=40,g=l(t({name:`SparklineChart`,__name:`Sparkline`,props:{title:{},value:{},color:{},data:{default:()=>[]},showChart:{type:Boolean,default:!0},variant:{default:`smooth`},loading:{type:Boolean,default:!1},centerText:{default:``},subtitle:{default:``}},setup(t){let l=t,u=e=>{if(e.length<3)return e;let t=Math.min(15,Math.max(3,Math.floor(e.length*.2))),n=[];for(let r=0;re+t,0)/s.length)}let r=Math.min(10,n.length),i=n.length/r,a=[];for(let e=0;e!l.data||l.data.length===0?[]:l.variant===`smooth`?u(l.data):l.data),ce=e=>{if(e.length<2)return``;let t=Math.max(...e),n=Math.min(...e),r=t-n||1,i=l.variant===`classic`?4:2,a=``;return e.forEach((t,o)=>{let s=o/(e.length-1)*m,c=(t-n)/r,l=i+(h-i*2)*(1-c);if(o===0)a+=`M ${s.toFixed(2)} ${l.toFixed(2)}`;else{let t=((o-1)/(e.length-1)*m+s)/2;a+=` Q ${t.toFixed(2)} ${l.toFixed(2)} ${s.toFixed(2)} ${l.toFixed(2)}`}}),a},_=r(()=>ce(g.value)),le=r(()=>_.value?`${_.value} L ${m} ${h} L 0 ${h} Z`:``),v=r(()=>`sparkline-${l.title.replace(/\s+/g,`-`).toLowerCase()}`);return(r,l)=>(c(),s(`div`,ee,[o(`div`,d,[o(`div`,null,[o(`p`,te,i(t.title),1),t.subtitle?(c(),s(`p`,f,i(t.subtitle),1)):n(``,!0)]),o(`span`,{class:`card-value`,style:e({color:t.color})},i(typeof t.value==`number`?t.value.toLocaleString():t.value),5)]),t.showChart?(c(),s(`div`,p,[t.loading&&t.variant===`classic`?(c(),s(`div`,ne,[o(`div`,{class:`loader-spinner`,style:e({borderTopColor:t.color})},null,4)])):t.centerText?(c(),s(`div`,re,[o(`span`,ie,i(t.centerText),1)])):(c(),s(`svg`,{key:2,id:v.value,class:`chart-svg`,viewBox:`0 0 ${m} ${h}`,preserveAspectRatio:`none`},[t.variant===`classic`?(c(),s(a,{key:0},[g.value.length>1?(c(),s(`path`,{key:0,d:le.value,fill:t.color,"fill-opacity":`0.8`,class:`sparkline-path`},null,8,oe)):n(``,!0)],64)):(c(),s(a,{key:1},[g.value.length>1?(c(),s(`path`,{key:0,d:_.value,stroke:t.color,"stroke-width":`2.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,fill:`none`,class:`sparkline-path`},null,8,se)):n(``,!0)],64))],8,ae))])):n(``,!0)]))}}),[[`__scopeId`,`data-v-dfc36682`]]),ce=365.2425,_=6048e5,le=864e5,v=6e4,y=36e5,ue=1e3,de=3600*24;de*7,de*ce/12*3;var fe=Symbol.for(`constructDateFrom`);function b(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&fe in e?e[fe](t):e instanceof Date?new e.constructor(t):new Date(t)}function x(e,t){return b(t||e,e)}function S(e,t,n){let r=x(e,n?.in);return isNaN(t)?b(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function C(e,t,n){let r=x(e,n?.in);if(isNaN(t))return b(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=b(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}function w(e,t,n){return b(n?.in||e,+x(e)+t)}function pe(e,t,n){return w(e,t*y,n)}var me={};function T(){return me}function E(e,t){let n=T(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=x(e,t?.in),a=i.getDay(),o=(a=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function O(e){let t=x(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function k(e,...t){let n=b.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function ge(e,t){let n=x(e,t?.in);return n.setHours(0,0,0,0),n}function _e(e,t,n){let[r,i]=k(n?.in,e,t),a=ge(r),o=ge(i),s=+a-O(a),c=+o-O(o);return Math.round((s-c)/le)}function ve(e,t){let n=he(e,t),r=b(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),D(r)}function ye(e,t,n){let r=x(e,n?.in);return r.setTime(r.getTime()+t*v),r}function be(e,t,n){return C(e,t*3,n)}function xe(e,t,n){return w(e,t*1e3,n)}function Se(e,t,n){return S(e,t*7,n)}function Ce(e,t,n){return C(e,t*12,n)}function A(e,t){let n=x(e)-+x(t);return n<0?-1:n>0?1:n}function we(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Te(e){return!(!we(e)&&typeof e!=`number`||isNaN(+x(e)))}function Ee(e,t,n){let[r,i]=k(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function De(e,t,n){let[r,i]=k(n?.in,e,t);return r.getFullYear()-i.getFullYear()}function Oe(e,t,n){let[r,i]=k(n?.in,e,t),a=ke(r,i),o=Math.abs(_e(r,i));r.setDate(r.getDate()-a*o);let s=a*(o-Number(ke(r,i)===-a));return s===0?0:s}function ke(e,t){let n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function j(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function Ae(e,t,n){let[r,i]=k(n?.in,e,t),a=(r-+i)/y;return j(n?.roundingMethod)(a)}function M(e,t){return x(e)-+x(t)}function je(e,t,n){let r=M(e,t)/v;return j(n?.roundingMethod)(r)}function Me(e,t){let n=x(e,t?.in);return n.setHours(23,59,59,999),n}function Ne(e,t){let n=x(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Pe(e,t){let n=x(e,t?.in);return+Me(n,t)==+Ne(n,t)}function Fe(e,t,n){let[r,i,a]=k(n?.in,e,e,t),o=A(i,a),s=Math.abs(Ee(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=A(i,a)===-o;Pe(r)&&s===1&&A(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function Ie(e,t,n){let r=Fe(e,t,n)/3;return j(n?.roundingMethod)(r)}function Le(e,t,n){let r=M(e,t)/1e3;return j(n?.roundingMethod)(r)}function Re(e,t,n){let r=Oe(e,t,n)/7;return j(n?.roundingMethod)(r)}function ze(e,t,n){let[r,i]=k(n?.in,e,t),a=A(r,i),o=Math.abs(De(r,i));r.setFullYear(1584),i.setFullYear(1584);let s=a*(o-+(A(r,i)===-a));return s===0?0:s}function Be(e,t){let n=x(e,t?.in),r=n.getMonth(),i=r-r%3;return n.setMonth(i,1),n.setHours(0,0,0,0),n}function Ve(e,t){let n=x(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function He(e,t){let n=x(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Ue(e,t){let n=x(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function We(e,t){let n=x(e,t?.in);return n.setMinutes(59,59,999),n}function Ge(e,t){let n=T(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=x(e,t?.in),a=i.getDay(),o=(a{let r,i=Ye[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function N(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Ze={date:N({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:N({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:N({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},Qe={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},$e=(e,t,n,r)=>Qe[e];function P(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var et={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:P({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:P({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:P({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:P({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:P({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`})};function F(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?nt(s,e=>e.test(o)):tt(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function tt(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function nt(e,t){for(let n=0;n{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var it={code:`en-US`,formatDistance:Xe,formatLong:Ze,formatRelative:$e,localize:et,match:{ordinalNumber:rt({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:F({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:F({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:F({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:F({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:F({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}};function at(e,t){let n=x(e,t?.in);return _e(n,Ue(n))+1}function ot(e,t){let n=x(e,t?.in),r=D(n)-+ve(n);return Math.round(r/_)+1}function I(e,t){let n=x(e,t?.in),r=n.getFullYear(),i=T(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=b(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=E(o,t),c=b(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=E(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function st(e,t){let n=T(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=I(e,t),a=b(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),E(a,t)}function ct(e,t){let n=x(e,t?.in),r=E(n,t)-+st(n,t);return Math.round(r/_)+1}function L(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var R={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return L(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):L(n+1,2)},d(e,t){return L(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return L(e.getHours()%12||12,t.length)},H(e,t){return L(e.getHours(),t.length)},m(e,t){return L(e.getMinutes(),t.length)},s(e,t){return L(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return L(Math.trunc(r*10**(n-3)),t.length)}},z={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},lt={G:function(e,t,n){let r=e.getFullYear()>0?1:0;switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return R.y(e,t)},Y:function(e,t,n,r){let i=I(e,r),a=i>0?i:1-i;return t===`YY`?L(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):L(a,t.length)},R:function(e,t){return L(he(e),t.length)},u:function(e,t){return L(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return L(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return L(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return R.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return L(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=ct(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):L(i,t.length)},I:function(e,t,n){let r=ot(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):L(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):R.d(e,t)},D:function(e,t,n){let r=at(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):L(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return L(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return L(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return L(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?z.noon:r===0?z.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?z.evening:r>=12?z.afternoon:r>=4?z.morning:z.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return R.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):R.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):L(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):L(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):R.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):R.s(e,t)},S:function(e,t){return R.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return dt(r);case`XXXX`:case`XX`:return B(r);default:return B(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return dt(r);case`xxxx`:case`xx`:return B(r);default:return B(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+ut(r,`:`);default:return`GMT`+B(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+ut(r,`:`);default:return`GMT`+B(r,`:`)}},t:function(e,t,n){return L(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return L(+e,t.length)}};function ut(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+L(a,2)}function dt(e,t){return e%60==0?(e>0?`-`:`+`)+L(Math.abs(e)/60,2):B(e,t)}function B(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=L(Math.trunc(r/60),2),a=L(r%60,2);return n+i+t+a}var ft=(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`})}},pt=(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`})}},V={p:pt,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ft(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,ft(r,t)).replace(`{{time}}`,pt(i,t))}},mt=/^D+$/,ht=/^Y+$/,gt=[`D`,`DD`,`YY`,`YYYY`];function _t(e){return mt.test(e)}function vt(e){return ht.test(e)}function H(e,t,n){let r=yt(e,t,n);if(console.warn(r),gt.includes(e))throw RangeError(r)}function yt(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var bt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,St=/^'([^]*?)'?$/,Ct=/''/g,wt=/[a-zA-Z]/;function Tt(e,t,n){let r=T(),i=n?.locale??r.locale??it,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=x(e,n?.in);if(!Te(s))throw RangeError(`Invalid time value`);let c=t.match(xt).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=V[t];return n(e,i.formatLong)}return e}).join(``).match(bt).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:Et(e)};if(lt[t])return{isToken:!0,value:e};if(t.match(wt))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&vt(a)||!n?.useAdditionalDayOfYearTokens&&_t(a))&&H(a,t,String(e));let o=lt[a[0]];return o(s,a,i.localize,l)}).join(``)}function Et(e){let t=e.match(St);return t?t[1].replace(Ct,`'`):e}function Dt(){return Object.assign({},T())}function Ot(e,t){let n=x(e,t?.in).getDay();return n===0?7:n}function kt(e,t){let n=At(t)?new t(0):b(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function At(e){return typeof e==`function`&&e.prototype?.constructor===e}var jt=10,Mt=class{subPriority=0;validate(e,t){return!0}},Nt=class extends Mt{constructor(e,t,n,r,i){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=r,i&&(this.subPriority=i)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}},Pt=class extends Mt{priority=jt;subPriority=-1;constructor(e,t){super(),this.context=e||(e=>b(t,e))}set(e,t){return t.timestampIsSet?e:b(e,kt(e,this.context))}},U=class{run(e,t,n,r){let i=this.parse(e,t,n,r);return i?{setter:new Nt(i.value,this.validate,this.set,this.priority,this.subPriority),rest:i.rest}:null}validate(e,t,n){return!0}},Ft=class extends U{priority=140;parse(e,t,n){switch(t){case`G`:case`GG`:case`GGG`:return n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`});case`GGGGG`:return n.era(e,{width:`narrow`});default:return n.era(e,{width:`wide`})||n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`})}}set(e,t,n){return t.era=n,e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`R`,`u`,`t`,`T`]},W={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},G={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function K(e,t){return e&&{value:t(e.value),rest:e.rest}}function q(e,t){let n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function J(e,t){let n=t.match(e);if(!n)return null;if(n[0]===`Z`)return{value:0,rest:t.slice(1)};let r=n[1]===`+`?1:-1,i=n[2]?parseInt(n[2],10):0,a=n[3]?parseInt(n[3],10):0,o=n[5]?parseInt(n[5],10):0;return{value:r*(i*y+a*v+o*ue),rest:t.slice(n[0].length)}}function It(e){return q(W.anyDigitsSigned,e)}function Y(e,t){switch(e){case 1:return q(W.singleDigit,t);case 2:return q(W.twoDigits,t);case 3:return q(W.threeDigits,t);case 4:return q(W.fourDigits,t);default:return q(RegExp(`^\\d{1,`+e+`}`),t)}}function Lt(e,t){switch(e){case 1:return q(W.singleDigitSigned,t);case 2:return q(W.twoDigitsSigned,t);case 3:return q(W.threeDigitsSigned,t);case 4:return q(W.fourDigitsSigned,t);default:return q(RegExp(`^-?\\d{1,`+e+`}`),t)}}function X(e){switch(e){case`morning`:return 4;case`evening`:return 17;case`pm`:case`noon`:case`afternoon`:return 12;default:return 0}}function Rt(e,t){let n=t>0,r=n?t:1-t,i;if(r<=50)i=e||100;else{let t=r+50,n=Math.trunc(t/100)*100,a=e>=t%100;i=e+n-(a?100:0)}return n?i:1-i}function zt(e){return e%400==0||e%4==0&&e%100!=0}var Bt=class extends U{priority=130;incompatibleTokens=[`Y`,`R`,`u`,`w`,`I`,`i`,`e`,`c`,`t`,`T`];parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`yy`});switch(t){case`y`:return K(Y(4,e),r);case`yo`:return K(n.ordinalNumber(e,{unit:`year`}),r);default:return K(Y(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n){let r=e.getFullYear();if(n.isTwoDigitYear){let t=Rt(n.year,r);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}let i=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(i,0,1),e.setHours(0,0,0,0),e}},Vt=class extends U{priority=130;parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`YY`});switch(t){case`Y`:return K(Y(4,e),r);case`Yo`:return K(n.ordinalNumber(e,{unit:`year`}),r);default:return K(Y(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n,r){let i=I(e,r);if(n.isTwoDigitYear){let t=Rt(n.year,i);return e.setFullYear(t,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),E(e,r)}let a=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(a,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),E(e,r)}incompatibleTokens=[`y`,`R`,`u`,`Q`,`q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]},Ht=class extends U{priority=130;parse(e,t){return Lt(t===`R`?4:t.length,e)}set(e,t,n){let r=b(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),D(r)}incompatibleTokens=[`G`,`y`,`Y`,`u`,`Q`,`q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},Ut=class extends U{priority=130;parse(e,t){return Lt(t===`u`?4:t.length,e)}set(e,t,n){return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`G`,`y`,`Y`,`R`,`w`,`I`,`i`,`e`,`c`,`t`,`T`]},Wt=class extends U{priority=120;parse(e,t,n){switch(t){case`Q`:case`QQ`:return Y(t.length,e);case`Qo`:return n.ordinalNumber(e,{unit:`quarter`});case`QQQ`:return n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`});case`QQQQQ`:return n.quarter(e,{width:`narrow`,context:`formatting`});default:return n.quarter(e,{width:`wide`,context:`formatting`})||n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-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`]},Gt=class extends U{priority=120;parse(e,t,n){switch(t){case`q`:case`qq`:return Y(t.length,e);case`qo`:return n.ordinalNumber(e,{unit:`quarter`});case`qqq`:return n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`});case`qqqqq`:return n.quarter(e,{width:`narrow`,context:`standalone`});default:return n.quarter(e,{width:`wide`,context:`standalone`})||n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-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`]},Kt=class extends U{incompatibleTokens=[`Y`,`R`,`q`,`Q`,`L`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`];priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`M`:return K(q(W.month,e),r);case`MM`:return K(Y(2,e),r);case`Mo`:return K(n.ordinalNumber(e,{unit:`month`}),r);case`MMM`:return n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`});case`MMMMM`:return n.month(e,{width:`narrow`,context:`formatting`});default:return n.month(e,{width:`wide`,context:`formatting`})||n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}},qt=class extends U{priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`L`:return K(q(W.month,e),r);case`LL`:return K(Y(2,e),r);case`Lo`:return K(n.ordinalNumber(e,{unit:`month`}),r);case`LLL`:return n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`});case`LLLLL`:return n.month(e,{width:`narrow`,context:`standalone`});default:return n.month(e,{width:`wide`,context:`standalone`})||n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]};function Jt(e,t,n){let r=x(e,n?.in),i=ct(r,n)-t;return r.setDate(r.getDate()-i*7),x(r,n?.in)}var Yt=class extends U{priority=100;parse(e,t,n){switch(t){case`w`:return q(W.week,e);case`wo`:return n.ordinalNumber(e,{unit:`week`});default:return Y(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n,r){return E(Jt(e,n,r),r)}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]};function Xt(e,t,n){let r=x(e,n?.in),i=ot(r,n)-t;return r.setDate(r.getDate()-i*7),r}var Zt=class extends U{priority=100;parse(e,t,n){switch(t){case`I`:return q(W.week,e);case`Io`:return n.ordinalNumber(e,{unit:`week`});default:return Y(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n){return D(Xt(e,n))}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},Qt=[31,28,31,30,31,30,31,31,30,31,30,31],$t=[31,29,31,30,31,30,31,31,30,31,30,31],en=class extends U{priority=90;subPriority=1;parse(e,t,n){switch(t){case`d`:return q(W.date,e);case`do`:return n.ordinalNumber(e,{unit:`date`});default:return Y(t.length,e)}}validate(e,t){let n=zt(e.getFullYear()),r=e.getMonth();return n?t>=1&&t<=$t[r]:t>=1&&t<=Qt[r]}set(e,t,n){return e.setDate(n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]},tn=class extends U{priority=90;subpriority=1;parse(e,t,n){switch(t){case`D`:case`DD`:return q(W.dayOfYear,e);case`Do`:return n.ordinalNumber(e,{unit:`date`});default:return Y(t.length,e)}}validate(e,t){return zt(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,n){return e.setMonth(0,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`L`,`w`,`I`,`d`,`E`,`i`,`e`,`c`,`t`,`T`]};function nn(e,t,n){let r=T(),i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=x(e,n?.in),o=a.getDay(),s=(t%7+7)%7,c=7-i;return S(a,t<0||t>6?t-(o+c)%7:(s+c)%7-(o+c)%7,n)}var rn=class extends U{priority=90;parse(e,t,n){switch(t){case`E`:case`EE`:case`EEE`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`EEEEE`:return n.day(e,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=nn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`D`,`i`,`e`,`c`,`t`,`T`]},an=class extends U{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`e`:case`ee`:return K(Y(t.length,e),i);case`eo`:return K(n.ordinalNumber(e,{unit:`day`}),i);case`eee`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`eeeee`:return n.day(e,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=nn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`c`,`t`,`T`]},on=class extends U{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`c`:case`cc`:return K(Y(t.length,e),i);case`co`:return K(n.ordinalNumber(e,{unit:`day`}),i);case`ccc`:return n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});case`ccccc`:return n.day(e,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});default:return n.day(e,{width:`wide`,context:`standalone`})||n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=nn(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`e`,`t`,`T`]};function sn(e,t,n){let r=x(e,n?.in);return S(r,t-Ot(r,n),n)}var cn=class extends U{priority=90;parse(e,t,n){let r=e=>e===0?7:e;switch(t){case`i`:case`ii`:return Y(t.length,e);case`io`:return n.ordinalNumber(e,{unit:`day`});case`iii`:return K(n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiii`:return K(n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiiii`:return K(n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);default:return K(n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r)}}validate(e,t){return t>=1&&t<=7}set(e,t,n){return e=sn(e,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`E`,`e`,`c`,`t`,`T`]},ln=class extends U{priority=80;parse(e,t,n){switch(t){case`a`:case`aa`:case`aaa`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`aaaaa`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(X(n),0,0,0),e}incompatibleTokens=[`b`,`B`,`H`,`k`,`t`,`T`]},un=class extends U{priority=80;parse(e,t,n){switch(t){case`b`:case`bb`:case`bbb`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`bbbbb`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(X(n),0,0,0),e}incompatibleTokens=[`a`,`B`,`H`,`k`,`t`,`T`]},dn=class extends U{priority=80;parse(e,t,n){switch(t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`BBBBB`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(X(n),0,0,0),e}incompatibleTokens=[`a`,`b`,`t`,`T`]},fn=class extends U{priority=70;parse(e,t,n){switch(t){case`h`:return q(W.hour12h,e);case`ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Y(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,n){let r=e.getHours()>=12;return r&&n<12?e.setHours(n+12,0,0,0):!r&&n===12?e.setHours(0,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`H`,`K`,`k`,`t`,`T`]},pn=class extends U{priority=70;parse(e,t,n){switch(t){case`H`:return q(W.hour23h,e);case`Ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Y(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,n){return e.setHours(n,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`K`,`k`,`t`,`T`]},mn=class extends U{priority=70;parse(e,t,n){switch(t){case`K`:return q(W.hour11h,e);case`Ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Y(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.getHours()>=12&&n<12?e.setHours(n+12,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`h`,`H`,`k`,`t`,`T`]},hn=class extends U{priority=70;parse(e,t,n){switch(t){case`k`:return q(W.hour24h,e);case`ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Y(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,n){let r=n<=24?n%24:n;return e.setHours(r,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`H`,`K`,`t`,`T`]},gn=class extends U{priority=60;parse(e,t,n){switch(t){case`m`:return q(W.minute,e);case`mo`:return n.ordinalNumber(e,{unit:`minute`});default:return Y(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setMinutes(n,0,0),e}incompatibleTokens=[`t`,`T`]},_n=class extends U{priority=50;parse(e,t,n){switch(t){case`s`:return q(W.second,e);case`so`:return n.ordinalNumber(e,{unit:`second`});default:return Y(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setSeconds(n,0),e}incompatibleTokens=[`t`,`T`]},vn=class extends U{priority=30;parse(e,t){return K(Y(t.length,e),e=>Math.trunc(e*10**(-t.length+3)))}set(e,t,n){return e.setMilliseconds(n),e}incompatibleTokens=[`t`,`T`]},yn=class extends U{priority=10;parse(e,t){switch(t){case`X`:return J(G.basicOptionalMinutes,e);case`XX`:return J(G.basic,e);case`XXXX`:return J(G.basicOptionalSeconds,e);case`XXXXX`:return J(G.extendedOptionalSeconds,e);default:return J(G.extended,e)}}set(e,t,n){return t.timestampIsSet?e:b(e,e.getTime()-O(e)-n)}incompatibleTokens=[`t`,`T`,`x`]},bn=class extends U{priority=10;parse(e,t){switch(t){case`x`:return J(G.basicOptionalMinutes,e);case`xx`:return J(G.basic,e);case`xxxx`:return J(G.basicOptionalSeconds,e);case`xxxxx`:return J(G.extendedOptionalSeconds,e);default:return J(G.extended,e)}}set(e,t,n){return t.timestampIsSet?e:b(e,e.getTime()-O(e)-n)}incompatibleTokens=[`t`,`T`,`X`]},xn=class extends U{priority=40;parse(e){return It(e)}set(e,t,n){return[b(e,n*1e3),{timestampIsSet:!0}]}incompatibleTokens=`*`},Sn=class extends U{priority=20;parse(e){return It(e)}set(e,t,n){return[b(e,n),{timestampIsSet:!0}]}incompatibleTokens=`*`},Cn={G:new Ft,y:new Bt,Y:new Vt,R:new Ht,u:new Ut,Q:new Wt,q:new Gt,M:new Kt,L:new qt,w:new Yt,I:new Zt,d:new en,D:new tn,E:new rn,e:new an,c:new on,i:new cn,a:new ln,b:new un,B:new dn,h:new fn,H:new pn,K:new mn,k:new hn,m:new gn,s:new _n,S:new vn,X:new yn,x:new bn,t:new xn,T:new Sn},wn=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Tn=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,En=/^'([^]*?)'?$/,Dn=/''/g,On=/\S/,kn=/[a-zA-Z]/;function An(e,t,n,r){let i=()=>b(r?.in||n,NaN),a=Dt(),o=r?.locale??a.locale??it,s=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,c=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0;if(!t)return e?i():x(n,r?.in);let l={firstWeekContainsDate:s,weekStartsOn:c,locale:o},u=[new Pt(r?.in,n)],ee=t.match(Tn).map(e=>{let t=e[0];if(t in V){let n=V[t];return n(e,o.formatLong)}return e}).join(``).match(wn),d=[];for(let n of ee){!r?.useAdditionalWeekYearTokens&&vt(n)&&H(n,t,e),!r?.useAdditionalDayOfYearTokens&&_t(n)&&H(n,t,e);let a=n[0],s=Cn[a];if(s){let{incompatibleTokens:t}=s;if(Array.isArray(t)){let e=d.find(e=>t.includes(e.token)||e.token===a);if(e)throw RangeError(`The format string mustn't contain \`${e.fullToken}\` and \`${n}\` at the same time`)}else if(s.incompatibleTokens===`*`&&d.length>0)throw RangeError(`The format string mustn't contain \`${n}\` and any other token at the same time`);d.push({token:a,fullToken:n});let r=s.run(e,n,o.match,l);if(!r)return i();u.push(r.setter),e=r.rest}else{if(a.match(kn))throw RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");if(n===`''`?n=`'`:a===`'`&&(n=jn(n)),e.indexOf(n)===0)e=e.slice(n.length);else return i()}}if(e.length>0&&On.test(e))return i();let te=u.map(e=>e.priority).sort((e,t)=>t-e).filter((e,t,n)=>n.indexOf(e)===t).map(e=>u.filter(t=>t.priority===e).sort((e,t)=>t.subPriority-e.subPriority)).map(e=>e[0]),f=x(n,r?.in);if(isNaN(+f))return i();let p={};for(let e of te){if(!e.validate(f,l))return i();let t=e.set(f,p,l);Array.isArray(t)?(f=t[0],Object.assign(p,t[1])):f=t}return f}function jn(e){return e.match(En)[1].replace(Dn,`'`)}function Mn(e,t){let n=x(e,t?.in);return n.setMinutes(0,0,0),n}function Nn(e,t){let n=x(e,t?.in);return n.setSeconds(0,0),n}function Pn(e,t){let n=x(e,t?.in);return n.setMilliseconds(0),n}function Fn(e,t){let n=()=>b(t?.in,NaN),r=t?.additionalDigits??2,i=zn(e),a;if(i.date){let e=Bn(i.date,r);a=Vn(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=Hn(i.time),isNaN(s)))return n();if(i.timezone){if(c=Un(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=x(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return x(o+s+c,t?.in)}var Z={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},In=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Ln=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Rn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function zn(e){let t={},n=e.split(Z.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],Z.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Z.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=Z.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function Bn(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function Vn(e,t){if(t===null)return new Date(NaN);let n=e.match(In);if(!n)return new Date(NaN);let r=!!n[4],i=Q(n[1]),a=Q(n[2])-1,o=Q(n[3]),s=Q(n[4]),c=Q(n[5])-1;if(r)return Yn(t,s,c)?Wn(t,s,c):new Date(NaN);{let e=new Date(0);return!qn(t,a,o)||!Jn(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function Q(e){return e?parseInt(e):1}function Hn(e){let t=e.match(Ln);if(!t)return NaN;let n=$(t[1]),r=$(t[2]),i=$(t[3]);return Xn(n,r,i)?n*y+r*v+i*1e3:NaN}function $(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function Un(e){if(e===`Z`)return 0;let t=e.match(Rn);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Zn(r,i)?n*(r*y+i*v):NaN}function Wn(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var Gn=[31,null,31,30,31,30,31,31,30,31,30,31];function Kn(e){return e%400==0||e%4==0&&e%100!=0}function qn(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Gn[t]||(Kn(e)?29:28))}function Jn(e,t){return t>=1&&t<=(Kn(e)?366:365)}function Yn(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Xn(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Zn(e,t){return t>=0&&t<=59}var Qn={datetime:`MMM d, yyyy, h:mm:ss aaaa`,millisecond:`h:mm:ss.SSS aaaa`,second:`h:mm:ss aaaa`,minute:`h:mm aaaa`,hour:`ha`,day:`MMM d`,week:`PP`,month:`MMM yyyy`,quarter:`qqq - yyyy`,year:`yyyy`};u._date.override({_id:`date-fns`,formats:function(){return Qn},parse:function(e,t){if(e==null)return null;let n=typeof e;return n===`number`||e instanceof Date?e=x(e):n===`string`&&(e=typeof t==`string`?An(e,t,new Date,this.options):Fn(e,this.options)),Te(e)?e.getTime():null},format:function(e,t){return Tt(e,t,this.options)},add:function(e,t,n){switch(n){case`millisecond`:return w(e,t);case`second`:return xe(e,t);case`minute`:return ye(e,t);case`hour`:return pe(e,t);case`day`:return S(e,t);case`week`:return Se(e,t);case`month`:return C(e,t);case`quarter`:return be(e,t);case`year`:return Ce(e,t);default:return e}},diff:function(e,t,n){switch(n){case`millisecond`:return M(e,t);case`second`:return Le(e,t);case`minute`:return je(e,t);case`hour`:return Ae(e,t);case`day`:return Oe(e,t);case`week`:return Re(e,t);case`month`:return Fe(e,t);case`quarter`:return Ie(e,t);case`year`:return ze(e,t);default:return 0}},startOf:function(e,t,n){switch(t){case`second`:return Pn(e);case`minute`:return Nn(e);case`hour`:return Mn(e);case`day`:return ge(e);case`week`:return E(e);case`isoWeek`:return E(e,{weekStartsOn:+n});case`month`:return Ve(e);case`quarter`:return Be(e);case`year`:return Ue(e);default:return e}},endOf:function(e,t){switch(t){case`second`:return Je(e);case`minute`:return Ke(e);case`hour`:return We(e);case`day`:return Me(e);case`week`:return Ge(e);case`month`:return Ne(e);case`quarter`:return qe(e);case`year`:return He(e);default:return e}}});export{g as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/constants-C3rXUIAq.js b/repeater/web/html/assets/constants-C3rXUIAq.js new file mode 100644 index 00000000..77ade1c8 --- /dev/null +++ b/repeater/web/html/assets/constants-C3rXUIAq.js @@ -0,0 +1 @@ +var e=`/api/needs_setup`,t=5e3,n=1e3;export{e as n,n as r,t}; \ No newline at end of file diff --git a/repeater/web/html/assets/dataService-BP1CezIa.js b/repeater/web/html/assets/dataService-BP1CezIa.js new file mode 100644 index 00000000..3494282d --- /dev/null +++ b/repeater/web/html/assets/dataService-BP1CezIa.js @@ -0,0 +1 @@ +import{t as e}from"./dataService-DelZA92b.js";export{e as useDataService}; \ No newline at end of file diff --git a/repeater/web/html/assets/dataService-DelZA92b.js b/repeater/web/html/assets/dataService-DelZA92b.js new file mode 100644 index 00000000..9b8d5b54 --- /dev/null +++ b/repeater/web/html/assets/dataService-DelZA92b.js @@ -0,0 +1 @@ +import{J as e,Y as t,o as n}from"./runtime-core.esm-bundler-C5QBTNWE.js";import{_ as r,t as i}from"./api-3gMnsCKh.js";import{t as a}from"./packets-KU2POtN6.js";import{t as o}from"./system-DbBvxitf.js";var s={0:`Unknown`,1:`Chat Node`,2:`Repeater`,3:`Room Server`,4:`Hybrid Node`},c=r(`neighbors`,()=>{let e=t({}),r=t(!1),a=t(null),o=t(48),c=n(()=>Object.values(e.value).flat()),l=n(()=>c.value.length);function u(e=10*6e4){return a.value===null?!0:Date.now()-a.value>e}async function d(t=o.value){r.value=!0,o.value=t;let n=Object.entries(s),c=await Promise.allSettled(n.map(async([e,n])=>{try{let r=[],a=0,o=0;for(;o<200;){let e=await i.get(`/adverts_by_contact_type?contact_type=${encodeURIComponent(n)}&hours=${t}&limit=500&offset=${a}`),s=e.success&&Array.isArray(e.data)?e.data:[];if(s.length===0||(r.push(...s),s.length<500))break;a+=500,o+=1}return{typeKey:e,adverts:r}}catch{return{typeKey:e,adverts:[]}}})),l={};for(let e of c)e.status===`fulfilled`&&e.value.adverts.length>0&&(l[e.value.typeKey]=e.value.adverts);e.value=l,a.value=Date.now(),r.value=!1}function f(){e.value={},r.value=!1,a.value=null,o.value=48}return{advertsByType:e,isLoading:r,lastFetched:a,currentHours:o,allAdverts:c,totalCount:l,isStale:u,fetchAll:d,reset:f}}),l={stats:3e4,packetStats:6e4,noiseFloor:15e3,recentPackets:3e4,sparklines:3e5,advertTier:6e4,neighbors:10*6e4},u=r(`dataService`,()=>{let n=o(),r=a(),s=c(),u=t({currentTier:`unknown`,advertsAllowed:0,advertsDropped:0,activePenalties:0}),d=t(!1),f=t(null),p=e({stats:`pending`,packetStats:`pending`,noiseFloor:`pending`,recentPackets:`pending`,sparklines:`pending`,advertTier:`pending`,neighbors:`pending`}),m=new Map,h=new Map,g=[],_=!1,v=null;async function y(e,t=2){for(let n=0;nsetTimeout(e,500*2**n))}throw Error(`unreachable`)}async function b(){try{let e=(await i.get(`/advert_rate_limit_stats`))?.data;u.value={currentTier:typeof e?.adaptive?.current_tier==`string`?e.adaptive.current_tier:`unknown`,advertsAllowed:e?.stats?.adverts_allowed||0,advertsDropped:e?.stats?.adverts_dropped||0,activePenalties:Object.keys(e?.active_penalties||{}).length},m.set(`advertTier`,Date.now())}catch{}}async function x(e){if(e===`neighbors`){if(!s.isStale())return}else{let t=m.get(e);if(t!==void 0&&Date.now()-t{m.set(`stats`,Date.now())});break;case`packetStats`:i=r.fetchPacketStats({hours:24}).then(()=>{m.set(`packetStats`,Date.now())});break;case`noiseFloor`:i=r.fetchNoiseFloorHistory({hours:24,limit:500}).then(()=>{m.set(`noiseFloor`,Date.now())});break;case`recentPackets`:i=r.fetchRecentPackets({limit:100}).then(()=>{m.set(`recentPackets`,Date.now())});break;case`sparklines`:i=r.initializeSparklineHistory().then(()=>{m.set(`sparklines`,Date.now())});break;case`advertTier`:i=b();break;case`neighbors`:i=s.fetchAll(s.currentHours).then(()=>{});break}return h.set(e,i),i.finally(()=>h.delete(e)),i}async function S(e,t){p[e]=`loading`;try{await t(),p[e]=`done`}catch{p[e]=`error`}}async function C(){if(!_){_=!0,d.value=!0,p.stats=`loading`,f.value=`requesting`;try{await y(()=>n.fetchStats({onFirstByte:()=>{f.value=`reading`}})),m.set(`stats`,Date.now()),p.stats=`done`}catch{p.stats=`error`,console.error(`[DataService] Failed to fetch stats after retries`)}finally{f.value=null}await Promise.allSettled([S(`packetStats`,()=>r.fetchPacketStats({hours:24}).then(()=>{m.set(`packetStats`,Date.now())})),S(`noiseFloor`,()=>r.fetchNoiseFloorHistory({hours:24,limit:500}).then(()=>{m.set(`noiseFloor`,Date.now())})),S(`recentPackets`,()=>r.fetchRecentPackets({limit:100}).then(()=>{m.set(`recentPackets`,Date.now())}))]),await Promise.allSettled([S(`sparklines`,()=>r.initializeSparklineHistory().then(()=>{m.set(`sparklines`,Date.now())})),S(`advertTier`,()=>b()),S(`neighbors`,()=>s.fetchAll(s.currentHours).then(()=>{}))]),d.value=!1,w()}}function w(){O(),g.push(window.setInterval(()=>void x(`advertTier`),3e4)),g.push(window.setInterval(()=>void x(`packetStats`),6e4)),g.push(window.setInterval(()=>void x(`noiseFloor`),15e3)),g.push(window.setInterval(()=>void x(`sparklines`),3e5)),g.push(window.setInterval(()=>{let e=n.lastUpdated?.getTime()??0;Date.now()-e>25e3&&x(`stats`)},3e4))}function T(){v=Math.floor(Date.now()/1e3)}async function E(e){try{let t=await i.get(`/filtered_packets`,{start_timestamp:e,limit:1e3});t.success&&t.data&&(r.mergeRecentPackets(t.data),m.set(`recentPackets`,Date.now()))}catch{}}async function D(){await new Promise(e=>setTimeout(e,3e3));let e=Math.floor(Date.now()/1e3)-600,t=v===null?e:Math.max(v,e);v=null,await Promise.allSettled([x(`stats`),x(`packetStats`),E(t)])}function O(){for(let e of g)clearInterval(e);g=[]}function k(){O(),_=!1,m.clear(),h.clear(),d.value=!1,Object.keys(p).forEach(e=>{p[e]=`pending`}),u.value={currentTier:`unknown`,advertsAllowed:0,advertsDropped:0,activePenalties:0}}return{advertTier:u,isBootstrapping:d,statsSubStatus:f,loadProgress:p,bootstrap:C,ensure:x,noteDisconnect:T,onReconnect:D,stopPolling:O,reset:k}});export{s as n,c as r,u as t}; \ No newline at end of file diff --git a/repeater/web/html/assets/formatters-CHyWlnnq.js b/repeater/web/html/assets/formatters-CHyWlnnq.js new file mode 100644 index 00000000..f29e9029 --- /dev/null +++ b/repeater/web/html/assets/formatters-CHyWlnnq.js @@ -0,0 +1 @@ +function e(e){return e==null?`N/A`:`${e} dBm`}function t(e){return e==null?`N/A`:`${e.toFixed(1)} dB`}var n={0:`Transport Flood`,1:`Flood`,2:`Direct`,3:`Transport Direct`};function r(e){return e==null?`Unknown`:n[e]??`Unknown`}function i(e){switch(e){case 2:return{text:`Direct`,bgColor:`bg-green-100 dark:bg-green-500/20`,borderColor:`border-green-500 dark:border-green-400/30`,textColor:`text-green-600 dark:text-green-400`};case 3:return{text:`Transport Direct`,bgColor:`bg-green-100 dark:bg-green-600/20`,borderColor:`border-green-600/40 dark:border-green-500/30`,textColor:`text-green-700 dark:text-green-500`};case 1:return{text:`Flood`,bgColor:`bg-yellow-100 dark:bg-yellow-500/20`,borderColor:`border-yellow-500 dark:border-yellow-400/30`,textColor:`text-yellow-600 dark:text-yellow-400`};case 0:return{text:`Transport Flood`,bgColor:`bg-orange-100 dark:bg-orange-500/20`,borderColor:`border-orange-500 dark:border-orange-400/30`,textColor:`text-orange-600 dark:text-orange-400`};default:return{text:`Unknown`,bgColor:`bg-gray-500/20`,borderColor:`border-gray-400/30`,textColor:`text-gray-400`}}}function a(e){return new Date(e*1e3).toLocaleString()}function o(e){return e?new Date(e*1e3).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`}):`—`}function s(e){if(!e)return`Never`;let t=new Date().getTime()-e.getTime(),n=Math.floor(t/(1e3*60)),r=Math.floor(t/(1e3*60*60)),i=Math.floor(t/(1e3*60*60*24)),a=Math.floor(i/365);return n<60?`${n}m ago`:r<24?`${r}h ago`:i<365?`${i}d ago`:`${a}y ago`}function c(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r<10?r.toFixed(1):Math.round(r)} ${t[n]}`}function l(e){return`${e.toFixed(1)} km`}function u(e){return`${e.slice(0,4)}...${e.slice(-4)}`}function d(e){return e?e.length<=16?e:`${e.slice(0,8)}...${e.slice(-8)}`:`No key`}export{e as a,s as c,d,u as i,a as l,o as n,r as o,l as r,t as s,c as t,i as u}; \ No newline at end of file diff --git a/repeater/web/html/assets/index-BFltqMtv.js b/repeater/web/html/assets/index-BFltqMtv.js deleted file mode 100644 index 76965c6f..00000000 --- a/repeater/web/html/assets/index-BFltqMtv.js +++ /dev/null @@ -1 +0,0 @@ -import{$ as e,A as t,C as n,D as r,E as i,G as a,J as o,K as s,O as c,Q as l,S as u,X as d,Y as f,Z as p,_ as m,a as h,at as g,b as _,c as v,ct as y,d as b,dt as x,et as S,f as C,ft as w,g as T,h as E,i as D,it as O,j as ee,k,l as A,lt as j,m as M,mt as te,n as ne,nt as N,o as P,ot as F,p as I,pt as L,q as R,r as z,rt as B,s as V,st as H,t as U,tt as W,u as G,ut as re,w as K,x as ie,z as q}from"./runtime-core.esm-bundler-HnidnMFy.js";import{a as ae,i as oe,r as se,s as ce}from"./vue-router-Cr0wB7EX.js";import{a as le,c as ue,i as de,l as fe,o as pe,r as J,t as Y,u as X}from"./api-CbM6k1ZB.js";import{t as me}from"./system-BH4r-ii6.js";import{t as he}from"./packets-C-dzvp0W.js";import{t as ge}from"./websocket-nXR7EYbj.js";import{t as Z}from"./_plugin-vue_export-helper-B7aGp3iI.js";import{t as _e}from"./useTheme-DMOVV09x.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ve=void 0,ye=typeof window<`u`&&window.trustedTypes;if(ye)try{ve=ye.createPolicy(`vue`,{createHTML:e=>e})}catch{}var be=ve?e=>ve.createHTML(e):e=>e,xe=`http://www.w3.org/2000/svg`,Se=`http://www.w3.org/1998/Math/MathML`,Q=typeof document<`u`?document:null,Ce=Q&&Q.createElement(`template`),we={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?Q.createElementNS(xe,e):t===`mathml`?Q.createElementNS(Se,e):n?Q.createElement(e,{is:n}):Q.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>Q.createTextNode(e),createComment:e=>Q.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Q.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===a||!(i=i.nextSibling)););else{Ce.innerHTML=be(r===`svg`?`${e}`:r===`mathml`?`${e}`:e);let i=Ce.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Te=`transition`,Ee=`animation`,De=Symbol(`_vtc`),Oe={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},ke=f({},ne,Oe),Ae=(e=>(e.displayName=`Transition`,e.props=ke,e))((e,{slots:t})=>m(U,Ne(e),t)),je=(t,n=[])=>{e(t)?t.forEach(e=>e(...n)):t&&t(...n)},Me=t=>t?e(t)?t.some(e=>e.length>1):t.length>1:!1;function Ne(e){let t={};for(let n in e)n in Oe||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:c=a,appearActiveClass:l=o,appearToClass:u=s,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:m=`${n}-leave-to`}=e,h=Pe(i),g=h&&h[0],_=h&&h[1],{onBeforeEnter:v,onEnter:y,onEnterCancelled:b,onLeave:x,onLeaveCancelled:S,onBeforeAppear:C=v,onAppear:w=y,onAppearCancelled:T=b}=t,E=(e,t,n,r)=>{e._enterCancelled=r,Le(e,t?u:s),Le(e,t?l:o),n&&n()},D=(e,t)=>{e._isLeaving=!1,Le(e,d),Le(e,m),Le(e,p),t&&t()},O=e=>(t,n)=>{let i=e?w:y,o=()=>E(t,e,n);je(i,[t,o]),Re(()=>{Le(t,e?c:a),Ie(t,e?u:s),Me(i)||Be(t,r,g,o)})};return f(t,{onBeforeEnter(e){je(v,[e]),Ie(e,a),Ie(e,o)},onBeforeAppear(e){je(C,[e]),Ie(e,c),Ie(e,l)},onEnter:O(!1),onAppear:O(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>D(e,t);Ie(e,d),e._enterCancelled?(Ie(e,p),We(e)):(We(e),Ie(e,p)),Re(()=>{e._isLeaving&&(Le(e,d),Ie(e,m),Me(x)||Be(e,r,_,n))}),je(x,[e,n])},onEnterCancelled(e){E(e,!1,void 0,!0),je(b,[e])},onAppearCancelled(e){E(e,!0,void 0,!0),je(T,[e])},onLeaveCancelled(e){D(e),je(S,[e])}})}function Pe(e){if(e==null)return null;if(N(e))return[Fe(e.enter),Fe(e.leave)];{let t=Fe(e);return[t,t]}}function Fe(e){return te(e)}function Ie(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[De]||(e[De]=new Set)).add(t)}function Le(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[De];n&&(n.delete(t),n.size||(e[De]=void 0))}function Re(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var ze=0;function Be(e,t,n,r){let i=e._endId=++ze,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=Ve(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u(n[e]||``).split(`, `),i=r(`${Te}Delay`),a=r(`${Te}Duration`),o=He(i,a),s=r(`${Ee}Delay`),c=r(`${Ee}Duration`),l=He(s,c),u=null,d=0,f=0;t===Te?o>0&&(u=Te,d=o,f=a.length):t===Ee?l>0&&(u=Ee,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?Te:Ee:null,f=u?u===Te?a.length:c.length:0);let p=u===Te&&/\b(?:transform|all)(?:,|$)/.test(r(`${Te}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function He(e,t){for(;e.lengthUe(t)+Ue(e[n])))}function Ue(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function We(e){return(e?e.ownerDocument:document).body.offsetHeight}function Ge(e,t,n){let r=e[De];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var Ke=Symbol(`_vod`),qe=Symbol(`_vsh`),Je={name:`show`,beforeMount(e,{value:t},{transition:n}){e[Ke]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):Ye(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),Ye(e,!0),r.enter(e)):r.leave(e,()=>{Ye(e,!1)}):Ye(e,t))},beforeUnmount(e,{value:t}){Ye(e,t)}};function Ye(e,t){e.style.display=t?e[Ke]:`none`,e[qe]=!t}var Xe=Symbol(``),Ze=/(?:^|;)\s*display\s*:/;function Qe(e,t,n){let r=e.style,i=F(n),a=!1;if(n&&!i){if(t)if(F(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??et(r,t,``)}else for(let e in t)n[e]??et(r,e,``);for(let e in n)e===`display`&&(a=!0),et(r,e,n[e])}else if(i){if(t!==n){let e=r[Xe];e&&(n+=`;`+e),r.cssText=n,a=Ze.test(n)}}else t&&e.removeAttribute(`style`);Ke in e&&(e[Ke]=a?r.display:``,e[qe]&&(r.display=`none`))}var $e=/\s*!important$/;function et(t,n,r){if(e(r))r.forEach(e=>et(t,n,e));else if(r??=``,n.startsWith(`--`))t.setProperty(n,r);else{let e=rt(t,n);$e.test(r)?t.setProperty(d(e),r.replace($e,``),`important`):t[e]=r}}var tt=[`Webkit`,`Moz`,`ms`],nt={};function rt(e,t){let n=nt[t];if(n)return n;let r=R(t);if(r!==`filter`&&r in e)return nt[t]=r;r=o(r);for(let n=0;npt||=(mt.then(()=>pt=0),Date.now());function gt(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;h(_t(e,n.value),t,5,[e])};return n.value=e,n.attached=ht(),n}function _t(t,n){if(e(n)){let e=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{e.call(t),t._stopped=!0},n.map(e=>t=>!t._stopped&&e&&e(t))}else return n}var vt=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,yt=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?Ge(e,r,o):t===`style`?Qe(e,n,r):B(t)?W(t)||ut(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):bt(e,t,r,o))?(ot(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&at(e,t,r,o,a,t!==`value`)):e._isVueCE&&(xt(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!F(r)))?ot(e,R(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),at(e,t,r,o))};function bt(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&vt(t)&&S(n));if(t===`spellcheck`||t===`draggable`||t===`translate`||t===`autocorrect`||t===`sandbox`&&e.tagName===`IFRAME`||t===`form`||t===`list`&&e.tagName===`INPUT`||t===`type`&&e.tagName===`TEXTAREA`)return!1;if(t===`width`||t===`height`){let t=e.tagName;if(t===`IMG`||t===`VIDEO`||t===`CANVAS`||t===`SOURCE`)return!1}return vt(t)&&F(n)?!1:t in e}function xt(e,t){let n=e._def.props;if(!n)return!1;let r=R(t);return Array.isArray(n)?n.some(e=>R(e)===r):Object.keys(n).some(e=>R(e)===r)}var St=t=>{let n=t.props[`onUpdate:modelValue`]||!1;return e(n)?e=>l(n,e):n};function Ct(e){e.target.composing=!0}function wt(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var $=Symbol(`_assign`);function Tt(e,t,n){return t&&(e=e.trim()),n&&(e=re(e)),e}var Et={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[$]=St(i);let a=r||i.props&&i.props.type===`number`;st(e,t?`change`:`input`,t=>{t.target.composing||e[$](Tt(e.value,n,a))}),(n||a)&&st(e,`change`,()=>{e.value=Tt(e.value,n,a)}),t||(st(e,`compositionstart`,Ct),st(e,`compositionend`,wt),st(e,`change`,wt))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[$]=St(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?re(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Dt={deep:!0,created(t,n,r){t[$]=St(r),st(t,`change`,()=>{let n=t._modelValue,r=Mt(t),i=t.checked,a=t[$];if(e(n)){let e=j(n,r),t=e!==-1;if(i&&!t)a(n.concat(r));else if(!i&&t){let t=[...n];t.splice(e,1),a(t)}}else if(O(n)){let e=new Set(n);i?e.add(r):e.delete(r),a(e)}else a(Nt(t,i))})},mounted:Ot,beforeUpdate(e,t,n){e[$]=St(n),Ot(e,t,n)}};function Ot(t,{value:n,oldValue:r},i){t._modelValue=n;let a;if(e(n))a=j(n,i.props.value)>-1;else if(O(n))a=n.has(i.props.value);else{if(n===r)return;a=y(n,Nt(t,!0))}t.checked!==a&&(t.checked=a)}var kt={created(e,{value:t},n){e.checked=y(t,n.props.value),e[$]=St(n),st(e,`change`,()=>{e[$](Mt(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[$]=St(r),t!==n&&(e.checked=y(t,r.props.value))}},At={deep:!0,created(e,{value:t,modifiers:{number:n}},r){let i=O(t);st(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?re(Mt(e)):Mt(e));e[$](e.multiple?i?new Set(t):t:t[0]),e._assigning=!0,_(()=>{e._assigning=!1})}),e[$]=St(r)},mounted(e,{value:t}){jt(e,t)},beforeUpdate(e,t,n){e[$]=St(n)},updated(e,{value:t}){e._assigning||jt(e,t)}};function jt(t,n){let r=t.multiple,i=e(n);if(!(r&&!i&&!O(n))){for(let e=0,a=t.options.length;eString(e)===String(o)):a.selected=j(n,o)>-1}else a.selected=n.has(o);else if(y(Mt(a),n)){t.selectedIndex!==e&&(t.selectedIndex=e);return}}!r&&t.selectedIndex!==-1&&(t.selectedIndex=-1)}}function Mt(e){return`_value`in e?e._value:e.value}function Nt(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Pt=[`ctrl`,`shift`,`alt`,`meta`],Ft={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>Pt.some(n=>e[`${n}Key`]&&!t.includes(n))},It=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=d(n.key);if(t.some(e=>e===r||Lt[e]===r))return e(n)}))},zt=f({patchProp:yt},we),Bt;function Vt(){return Bt||=b(zt)}var Ht=((...e)=>{let t=Vt().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Wt(e);if(!r)return;let i=t._component;!S(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Ut(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function Ut(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Wt(e){return F(e)?document.querySelector(e):e}var Gt=`/assets/pymclogo-ew909fnk.png`,Kt=`/assets/meshcore-DQNtEl5I.svg`;function qt(e,t){let n=J(),r=null,i=null,o=P(()=>(t.enabled===void 0?!0:a(t.enabled))&&n.canMaintainConnections),s=async()=>i||(i=Promise.resolve(e()).finally(()=>{i=null}),i),c=()=>{r!==null&&(clearInterval(r),r=null)},l=async()=>{c(),o.value&&(t.immediate!==!1&&await s(),r=window.setInterval(()=>{s()},t.intervalMs))};return k(o,e=>{e?l():c()},{immediate:!0}),ie(()=>{c()}),{start:l,stop:c,runNow:s}}var Jt={},Yt={width:`23`,height:`25`,viewBox:`0 0 23 25`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function Xt(e,t){return K(),G(`svg`,Yt,[...t[0]||=[V(`path`,{d:`M2.84279 2.25795C2.90709 1.12053 3.17879 0.625914 3.95795 0.228723C4.79631 -0.198778 6.11858 0.000168182 7.67449 0.788054C8.34465 1.12757 8.41289 1.13448 9.58736 0.983905C11.1485 0.783681 13.1582 0.784388 14.5991 0.985738C15.6887 1.13801 15.7603 1.1304 16.4321 0.790174C18.6406 -0.328212 20.3842 -0.255036 21.0156 0.982491C21.3308 1.6002 21.3893 3.20304 21.1449 4.52503C21.0094 5.25793 21.0238 5.34943 21.3502 5.83037C23.6466 9.21443 21.9919 14.6998 18.0569 16.7469C17.7558 16.9036 17.502 17.0005 17.2952 17.0795C16.6602 17.3219 16.4674 17.3956 16.7008 18.5117C16.8132 19.0486 16.9486 20.3833 17.0018 21.478C17.098 23.4567 17.0966 23.4705 16.7495 23.8742C16.2772 24.4233 15.5963 24.4326 15.135 23.8962C14.8341 23.5464 14.8047 23.3812 14.8047 22.0315C14.8047 20.037 14.5861 18.7113 14.0695 17.5753C13.4553 16.2235 13.9106 15.7194 15.3154 15.4173C17.268 14.9973 18.793 13.7923 19.643 11.9978C20.4511 10.2921 20.5729 7.93485 19.1119 6.50124C18.6964 6.00746 18.6674 5.56022 18.9641 4.21159C19.075 3.70754 19.168 3.05725 19.1707 2.76637C19.1749 2.30701 19.1331 2.23764 18.8509 2.23764C18.6724 2.23764 17.9902 2.49736 17.3352 2.81474L16.2897 3.32145C16.1947 3.36751 16.0883 3.38522 15.9834 3.37318C13.3251 3.06805 10.7991 3.06334 8.12774 3.37438C8.02244 3.38663 7.91563 3.36892 7.82025 3.32263L6.77535 2.81559C6.12027 2.49764 5.43813 2.23764 5.25963 2.23764C4.84693 2.23764 4.84072 2.54233 5.2169 4.35258C5.44669 5.45816 5.60133 5.70451 4.93703 6.58851C3.94131 7.91359 3.69258 9.55902 4.22654 11.2878C4.89952 13.4664 6.54749 14.9382 8.86436 15.4292C10.261 15.7253 10.6261 16.1115 10.0928 17.713C9.67293 18.9734 9.40748 19.2982 8.79738 19.2982C7.97649 19.2982 7.46228 18.5871 7.74527 17.843C7.86991 17.5151 7.83283 17.4801 7.06383 17.1996C4.71637 16.3437 2.9209 14.4254 2.10002 11.8959C1.46553 9.94098 1.74471 7.39642 2.76257 5.85843C3.10914 5.33477 3.1145 5.29036 2.95277 4.28787C2.86126 3.72037 2.81177 2.80699 2.84279 2.25795Z`,fill:`currentColor`},null,-1),V(`path`,{d:`M2.02306 16.5589C1.68479 16.0516 0.999227 15.9144 0.491814 16.2527C-0.0155884 16.591 -0.152708 17.2765 0.185564 17.7839C0.435301 18.1586 0.734065 18.4663 0.987777 18.72C1.03455 18.7668 1.08 18.8119 1.12438 18.856C1.3369 19.0671 1.52455 19.2535 1.71302 19.4748C2.12986 19.964 2.54572 20.623 2.78206 21.8047C2.88733 22.3311 3.26569 22.6147 3.47533 22.7386C3.70269 22.8728 3.9511 22.952 4.15552 23.0036C4.57369 23.109 5.08133 23.1638 5.56309 23.1957C6.09196 23.2308 6.665 23.2422 7.17743 23.2453C7.1778 23.8547 7.67202 24.3487 8.28162 24.3487C8.89146 24.3487 9.38582 23.8543 9.38582 23.2445V22.1403C9.38582 21.5305 8.89146 21.0361 8.28162 21.0361C8.17753 21.0361 8.06491 21.0364 7.94562 21.0369C7.29761 21.0389 6.45295 21.0414 5.70905 20.9922C5.35033 20.9684 5.05544 20.9347 4.8392 20.8936C4.50619 19.5863 3.96821 18.7165 3.39415 18.0426C3.14038 17.7448 2.87761 17.4842 2.66387 17.2722C2.62385 17.2326 2.58556 17.1946 2.54935 17.1584C2.30273 16.9118 2.1414 16.7365 2.02306 16.5589Z`,fill:`currentColor`},null,-1)]])}var Zt=Z(Jt,[[`render`,Xt]]),Qt={},$t={width:`17`,height:`24`,viewBox:`0 0 17 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function en(e,t){return K(),G(`svg`,$t,[...t[0]||=[C(``,12)]])}var tn=Z(Qt,[[`render`,en]]),nn={class:`glass-card p-5 relative overflow-hidden`},rn={key:0,class:`absolute inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-10 rounded-lg`},an={class:`flex items-baseline gap-2 mb-4`},on={class:`text-content-primary dark:text-content-primary text-2xl font-medium`},sn=[`viewBox`],cn=[`y1`,`y2`],ln=[`cx`,`cy`],un=200,dn=50,fn=4,pn=Z(T({__name:`RFNoiseFloor`,props:{limit:{default:void 0}},setup(e){let t=e,n=he(),r=me(),a=q(null),o=(e,t)=>{let n=t/100*(e.length-1),r=Math.floor(n),i=Math.ceil(n);return r===i?e[r]:e[r]+(e[i]-e[r])*(n-r)},c=P(()=>{let e=m.value;if(e.length===0)return[];let t=[...e].sort((e,t)=>e-t),n=o(t,2.5),r=o(t,97.5),i=r-n,a=Math.max(i*.05,.5),s=n-a,c=r+a,l=c-s||1;return e.map((t,n)=>{let r=fn+n/Math.max(e.length-1,1)*(un-fn*2),i=(Math.max(s,Math.min(c,t))-s)/l;return{x:r,y:dn-fn-i*(dn-fn*2)}})}),l=async()=>{try{let e={hours:1};t.limit&&(e.limit=t.limit),await Promise.all([n.fetchNoiseFloorHistory(e),n.fetchNoiseFloorStats({hours:1})])}catch(e){console.error(`Error fetching noise floor data:`,e)}},d=()=>{a.value||=window.setInterval(l,5e3)},f=()=>{a.value&&=(clearInterval(a.value),null)};u(()=>{l(),d()}),ie(()=>{f()});let p=P(()=>{let e=n.noiseFloorSparklineData;return e&&e.length>0?e[e.length-1]:n.noiseFloorStats?.avg_noise_floor??-116}),m=P(()=>n.noiseFloorSparklineData);return(e,t)=>(K(),G(`div`,nn,[s(r).cadCalibrationRunning?(K(),G(`div`,rn,[...t[0]||=[C(`
CAD Calibration

In Progress

`,1)]])):A(``,!0),t[2]||=V(`p`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase mb-2`},` RF NOISE FLOOR `,-1),V(`div`,an,[V(`span`,on,L(p.value),1),t[1]||=V(`span`,{class:`text-content-secondary dark:text-content-muted text-xs uppercase`},`dBm`,-1)]),(K(),G(`svg`,{class:`w-full h-[50px]`,viewBox:`0 0 ${un} ${dn}`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[(K(),G(z,null,i(3,e=>V(`line`,{key:`grid-`+e,x1:0,y1:e*dn/4,x2:un,y2:e*dn/4,stroke:`rgba(255, 255, 255, 0.1)`,"stroke-width":`1`},null,8,cn)),64)),(K(!0),G(z,null,i(c.value,(e,t)=>(K(),G(`circle`,{key:`point-`+t,cx:e.x,cy:e.y,r:`2.5`,fill:`rgba(245, 158, 11, 0.8)`,class:`transition-all duration-300`},null,8,ln))),128))],8,sn))]))}}),[[`__scopeId`,`data-v-92b94522`]]),mn={},hn={width:`800px`,height:`800px`,viewBox:`0 -1.5 20 20`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,class:`w-full h-full`};function gn(e,t){return K(),G(`svg`,hn,[...t[0]||=[V(`g`,{id:`Page-1`,stroke:`none`,"stroke-width":`1`,fill:`none`,"fill-rule":`evenodd`},[V(`g`,{transform:`translate(-420.000000, -3641.000000)`,fill:`currentColor`},[V(`g`,{id:`icons`,transform:`translate(56.000000, 160.000000)`},[V(`path`,{d:`M378.195439,3483.828 L376.781439,3485.242 C378.195439,3486.656 378.294439,3489.588 376.880439,3491.002 L378.294439,3492.417 C380.415439,3490.295 380.316439,3485.949 378.195439,3483.828 M381.023439,3481 L379.609439,3482.414 C382.438439,3485.242 382.537439,3491.002 379.708439,3493.831 L381.122439,3495.245 C385.365439,3491.002 384.559439,3484.535 381.023439,3481 M375.432439,3486.737 C375.409439,3486.711 375.392439,3486.682 375.367439,3486.656 L375.363439,3486.66 C374.582439,3485.879 373.243439,3485.952 372.536439,3486.659 C371.829439,3487.366 371.831439,3488.778 372.538439,3489.485 C372.547439,3489.494 372.558439,3489.499 372.567439,3489.508 C372.590439,3489.534 372.607439,3489.563 372.632439,3489.588 L372.636439,3489.585 C373.201439,3490.15 373.000439,3488.284 373.000439,3498 L375.000439,3498 C375.000439,3488.058 374.753439,3490.296 375.463439,3489.586 C376.170439,3488.879 376.168439,3487.467 375.461439,3486.76 C375.452439,3486.751 375.441439,3486.746 375.432439,3486.737 M371.119439,3485.242 L369.705439,3483.828 C367.584439,3485.949 367.683439,3490.295 369.804439,3492.417 L371.218439,3491.002 C369.804439,3489.588 369.705439,3486.656 371.119439,3485.242 M368.390439,3493.831 L366.976439,3495.245 C363.440439,3491.709 362.634439,3485.242 366.877439,3481 L368.291439,3482.414 C365.462439,3485.242 365.561439,3491.002 368.390439,3493.831`,id:`radio_tower-[#1019]`})])])],-1)]])}var _n=Z(mn,[[`render`,gn]]),vn={class:`text-center`},yn={class:`relative flex items-center justify-center mb-8`},bn={class:`relative w-32 h-32`},xn={class:`absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2`},Sn={key:0,class:`absolute inset-0 flex items-center justify-center`},Cn={key:1,class:`absolute inset-0 flex items-center justify-center`},wn={key:2,class:`absolute inset-0`},Tn={class:`mb-6`},En={key:0,class:`text-content-primary dark:text-content-primary text-lg`},Dn={key:1,class:`text-accent-green text-lg font-medium`},On={key:2,class:`text-secondary text-lg`},kn={key:3,class:`text-accent-red text-lg`},An={key:4,class:`text-content-secondary dark:text-content-muted`},jn={key:5,class:`mt-3`},Mn={key:0,class:`text-secondary text-sm`},Nn={key:1,class:`text-accent-red text-sm`},Pn={key:0,class:`flex gap-3`},Fn={key:1,class:`text-content-muted text-sm`},In=Z(T({name:`AdvertModal`,__name:`AdvertModal`,props:{isOpen:{type:Boolean},isLoading:{type:Boolean},isSuccess:{type:Boolean},error:{default:null}},emits:[`close`,`send`],setup(e,{emit:t}){let n=e,r=t,i=q(!1),a=q(!1),o=q(!1);k(()=>n.isOpen,e=>{e?(i.value=!0,setTimeout(()=>{a.value=!0},50)):(a.value=!1,o.value=!1,setTimeout(()=>{i.value=!1},300))},{immediate:!0}),k(()=>n.isLoading,e=>{e||setTimeout(()=>{o.value=!1},1e3)});let s=()=>{n.isLoading||r(`close`)},c=()=>{n.isLoading||(o.value=!0,r(`send`))},l=e=>e?.includes(`Network error - no response received`)||e?.includes(`timeout`);return(t,n)=>(K(),v(D,{to:`body`},[i.value?(K(),G(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center p-4`,onClick:It(s,[`self`])},[V(`div`,{class:x([`absolute inset-0 bg-black/60 backdrop-blur-sm transition-opacity duration-300`,a.value?`opacity-100`:`opacity-0`])},null,2),V(`div`,{class:x([`relative bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-8 max-w-md w-full transform transition-all duration-300 border border-stroke-subtle dark:border-white/10`,a.value?`scale-100 opacity-100`:`scale-95 opacity-0`])},[e.isLoading?A(``,!0):(K(),G(`button`,{key:0,onClick:s,class:`absolute top-4 right-4 text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors p-2`},[...n[0]||=[V(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])),V(`div`,vn,[n[6]||=V(`h2`,{class:`text-content-primary dark:text-content-primary text-xl font-semibold mb-6`},` Send Advertisement `,-1),V(`div`,yn,[V(`div`,bn,[V(`div`,xn,[M(_n,{class:x([`w-16 h-16 transition-all duration-500`,[e.isLoading?`animate-pulse`:``,e.isSuccess?`text-accent-green`:e.error&&!l(e.error)?`text-accent-red`:`text-primary`]]),style:w({filter:e.isLoading?`drop-shadow(0 0 8px currentColor)`:e.isSuccess?`drop-shadow(0 0 8px #A5E5B6)`:e.error&&!l(e.error)?`drop-shadow(0 0 8px #FB787B)`:`drop-shadow(0 0 4px #AAE8E8)`})},null,8,[`class`,`style`])]),e.isLoading||e.isSuccess?(K(),G(`div`,Sn,[V(`div`,{class:x([`absolute w-16 h-16 rounded-full border-2 animate-ping`,[e.isSuccess?`border-accent-green/60`:`border-primary/60`]]),style:{"animation-duration":`1.5s`}},null,2),V(`div`,{class:x([`absolute w-24 h-24 rounded-full border-2 animate-ping`,[e.isSuccess?`border-accent-green/40`:`border-primary/40`]]),style:{"animation-duration":`2s`,"animation-delay":`0.3s`}},null,2),V(`div`,{class:x([`absolute w-32 h-32 rounded-full border-2 animate-ping`,[e.isSuccess?`border-accent-green/20`:`border-primary/20`]]),style:{"animation-duration":`2.5s`,"animation-delay":`0.6s`}},null,2)])):A(``,!0),o.value?(K(),G(`div`,Cn,[...n[1]||=[V(`div`,{class:`absolute w-8 h-8 rounded-full border-4 border-secondary animate-ping-fast`},null,-1),V(`div`,{class:`absolute w-16 h-16 rounded-full border-3 border-secondary/70 animate-ping-fast`,style:{"animation-delay":`0.1s`}},null,-1),V(`div`,{class:`absolute w-24 h-24 rounded-full border-2 border-secondary/50 animate-ping-fast`,style:{"animation-delay":`0.2s`}},null,-1),V(`div`,{class:`absolute w-32 h-32 rounded-full border-2 border-secondary/30 animate-ping-fast`,style:{"animation-delay":`0.3s`}},null,-1)]])):A(``,!0),e.isLoading||e.isSuccess?(K(),G(`div`,wn,[V(`div`,{class:x([`absolute top-2 right-2 w-4 h-4 rounded-full transition-all duration-500 animate-pulse`,[e.isSuccess?`bg-accent-green shadow-lg shadow-accent-green/50`:`bg-primary/70 shadow-lg shadow-primary/30`]]),style:{"animation-delay":`0.5s`}},[...n[2]||=[V(`div`,{class:`w-2 h-2 bg-white rounded-full mx-auto mt-1`},null,-1)]],2),V(`div`,{class:x([`absolute bottom-2 left-2 w-4 h-4 rounded-full transition-all duration-500 animate-pulse`,[e.isSuccess?`bg-accent-green shadow-lg shadow-accent-green/50`:`bg-primary/70 shadow-lg shadow-primary/30`]]),style:{"animation-delay":`1s`}},[...n[3]||=[V(`div`,{class:`w-2 h-2 bg-white rounded-full mx-auto mt-1`},null,-1)]],2),V(`div`,{class:x([`absolute top-1/2 right-1 w-4 h-4 rounded-full transition-all duration-500 animate-pulse`,[e.isSuccess?`bg-accent-green shadow-lg shadow-accent-green/50`:`bg-primary/70 shadow-lg shadow-primary/30`]]),style:{"animation-delay":`1.5s`,transform:`translateY(-50%)`}},[...n[4]||=[V(`div`,{class:`w-2 h-2 bg-white rounded-full mx-auto mt-1`},null,-1)]],2),V(`div`,{class:x([`absolute top-3 left-3 w-4 h-4 rounded-full transition-all duration-500 animate-pulse`,[e.isSuccess?`bg-accent-green shadow-lg shadow-accent-green/50`:`bg-primary/70 shadow-lg shadow-primary/30`]]),style:{"animation-delay":`2s`}},[...n[5]||=[V(`div`,{class:`w-2 h-2 bg-white rounded-full mx-auto mt-1`},null,-1)]],2)])):A(``,!0)])]),V(`div`,Tn,[e.isLoading?(K(),G(`p`,En,` Broadcasting advertisement... `)):e.isSuccess?(K(),G(`p`,Dn,` Advertisement sent successfully! `)):e.error&&l(e.error)?(K(),G(`p`,On,` Advertisement likely sent `)):e.error?(K(),G(`p`,kn,`Failed to send advertisement`)):(K(),G(`p`,An,` This will broadcast your node's presence to nearby nodes. `)),e.error?(K(),G(`div`,jn,[l(e.error)?(K(),G(`p`,Mn,` Network timeout occurred, but the advertisement may have been successfully transmitted to nearby nodes. `)):(K(),G(`p`,Nn,L(e.error),1))])):A(``,!0)]),!e.isLoading&&!e.isSuccess?(K(),G(`div`,Pn,[V(`button`,{onClick:s,class:`flex-1 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 hover:border-primary rounded-[10px] px-6 py-3 text-content-primary dark:text-content-primary hover:bg-stroke-subtle dark:hover:bg-white/10 transition-all duration-200`},` Cancel `),V(`button`,{onClick:c,class:x([`flex-1 rounded-[10px] px-6 py-3 font-medium transition-all duration-200 shadow-lg`,[e.error&&l(e.error)?`bg-secondary hover:bg-secondary/90 text-background hover:shadow-secondary/20`:`bg-primary hover:bg-primary/90 text-background hover:shadow-primary/20`]])},L(e.error&&l(e.error)?`Try Again`:`Send Advertisement`),3)])):A(``,!0),e.isSuccess?(K(),G(`div`,Fn,`Closing automatically...`)):A(``,!0)])],2)])):A(``,!0)]))}}),[[`__scopeId`,`data-v-2c9f179a`]]),Ln={},Rn={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function zn(e,t){return K(),G(`svg`,Rn,[...t[0]||=[C(``,2)]])}var Bn=Z(Ln,[[`render`,zn]]),Vn={},Hn={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function Un(e,t){return K(),G(`svg`,Hn,[...t[0]||=[C(``,9)]])}var Wn=Z(Vn,[[`render`,Un]]),Gn={},Kn={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function qn(e,t){return K(),G(`svg`,Kn,[...t[0]||=[C(``,2)]])}var Jn=Z(Gn,[[`render`,qn]]),Yn={},Xn={width:`11`,height:`14`,viewBox:`0 0 11 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function Zn(e,t){return K(),G(`svg`,Xn,[...t[0]||=[V(`path`,{d:`M9.81633 1.99133L8.5085 0.683492C8.29229 0.466088 8.03511 0.293723 7.75185 0.176372C7.46859 0.059021 7.16486 -0.000985579 6.85825 -0.000175002H1.75C1.28587 -0.000175002 0.840752 0.184199 0.512563 0.512388C0.184375 0.840577 0 1.2857 0 1.74983V13.9998H10.5V3.64099C10.4985 3.02248 10.2528 2.4296 9.81633 1.99133ZM8.9915 2.81616C9.02083 2.84799 9.04829 2.88149 9.07375 2.91649H7.58333V1.42608C7.61834 1.45153 7.65184 1.479 7.68367 1.50833L8.9915 2.81616ZM1.16667 12.8332V1.74983C1.16667 1.59512 1.22812 1.44674 1.33752 1.33735C1.44692 1.22795 1.59529 1.16649 1.75 1.16649H6.41667V4.08316H9.33333V12.8332H1.16667ZM2.33333 9.33316H8.16667V5.83316H2.33333V9.33316ZM3.5 6.99983H7V8.16649H3.5V6.99983ZM2.33333 10.4998H8.16667V11.6665H2.33333V10.4998Z`,fill:`currentColor`},null,-1)]])}var Qn=Z(Yn,[[`render`,Zn]]),$n={},er={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function tr(e,t){return K(),G(`svg`,er,[...t[0]||=[V(`path`,{d:`M12.25 0H1.75C1.28587 0 0.840752 0.184375 0.512563 0.512563C0.184375 0.840752 0 1.28587 0 1.75V12.25C0 12.7141 0.184375 13.1592 0.512563 13.4874C0.840752 13.8156 1.28587 14 1.75 14H12.25C12.7141 14 13.1592 13.8156 13.4874 13.4874C13.8156 13.1592 14 12.7141 14 12.25V1.75C14 1.28587 13.8156 0.840752 13.4874 0.512563C13.1592 0.184375 12.7141 0 12.25 0ZM12.8333 12.25C12.8333 12.4047 12.7719 12.5531 12.6625 12.6625C12.5531 12.7719 12.4047 12.8333 12.25 12.8333H1.75C1.59529 12.8333 1.44692 12.7719 1.33752 12.6625C1.22812 12.5531 1.16667 12.4047 1.16667 12.25V1.75C1.16667 1.59529 1.22812 1.44692 1.33752 1.33752C1.44692 1.22812 1.59529 1.16667 1.75 1.16667H12.25C12.4047 1.16667 12.5531 1.22812 12.6625 1.33752C12.7719 1.44692 12.8333 1.59529 12.8333 1.75V12.25ZM3.23583 7.41317L5.23583 9.41317C5.29134 9.46685 5.35738 9.50892 5.43004 9.53689C5.5027 9.56485 5.58055 9.57812 5.65892 9.57579C5.73729 9.57347 5.81418 9.5556 5.88513 9.52325C5.95608 9.4909 6.01963 9.44476 6.07175 9.38792C6.12387 9.33108 6.16351 9.26467 6.18833 9.19237C6.21315 9.12007 6.22263 9.04335 6.21618 8.96725C6.20973 8.89115 6.18746 8.81722 6.15078 8.74965C6.11411 8.68207 6.06376 8.62223 6.00292 8.57383L4.66708 7.23617L6.00292 5.90033C6.10827 5.78972 6.16669 5.64161 6.16522 5.48792C6.16375 5.33423 6.10251 5.1873 5.99491 5.07882C5.88731 4.97034 5.74082 4.90791 5.58716 4.90522C5.4335 4.90254 5.28489 4.95982 5.17367 5.06417L3.17367 7.06417C3.06317 7.17386 3.00063 7.32313 3.00063 7.47867C3.00063 7.63421 3.06317 7.78348 3.17367 7.89317L3.23583 7.41317ZM8.75 10.5H7.58333C7.4286 10.5 7.28025 10.5615 7.17085 10.6709C7.06146 10.7803 7 10.9286 7 11.0833C7 11.2381 7.06146 11.3864 7.17085 11.4958C7.28025 11.6052 7.4286 11.6667 7.58333 11.6667H8.75C8.90473 11.6667 9.05308 11.6052 9.16248 11.4958C9.27188 11.3864 9.33333 11.2381 9.33333 11.0833C9.33333 10.9286 9.27188 10.7803 9.16248 10.6709C9.05308 10.5615 8.90473 10.5 8.75 10.5Z`,fill:`currentColor`},null,-1)]])}var nr=Z($n,[[`render`,tr]]),rr={},ir={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function ar(e,t){return K(),G(`svg`,ir,[...t[0]||=[C(``,2)]])}var or=Z(rr,[[`render`,ar]]),sr={name:`SystemIcon`},cr={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function lr(e,t,n,r,i,a){return K(),G(`svg`,cr,[...t[0]||=[C(``,5)]])}var ur=Z(sr,[[`render`,lr]]),dr={},fr={width:`11`,height:`14`,viewBox:`0 0 11 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function pr(e,t){return K(),G(`svg`,fr,[...t[0]||=[V(`path`,{d:`M10.5 14.0004H9.33333V11.0586C9.33287 10.6013 9.15099 10.1628 8.82761 9.83942C8.50422 9.51603 8.06575 9.33415 7.60842 9.33369H2.89158C2.43425 9.33415 1.99578 9.51603 1.67239 9.83942C1.34901 10.1628 1.16713 10.6013 1.16667 11.0586V14.0004H0V11.0586C0.000926233 10.292 0.305872 9.55705 0.847948 9.01497C1.39002 8.47289 2.12497 8.16795 2.89158 8.16702H7.60842C8.37503 8.16795 9.10998 8.47289 9.65205 9.01497C10.1941 9.55705 10.4991 10.292 10.5 11.0586V14.0004Z`,fill:`currentColor`},null,-1),V(`path`,{d:`M5.25 6.99997C4.55777 6.99997 3.88108 6.7947 3.30551 6.41011C2.72993 6.02553 2.28133 5.4789 2.01642 4.83936C1.75152 4.19982 1.6822 3.49609 1.81725 2.81716C1.9523 2.13822 2.28564 1.51458 2.77513 1.0251C3.26461 0.535614 3.88825 0.202271 4.56719 0.0672226C5.24612 -0.0678257 5.94985 0.00148598 6.58939 0.266393C7.22894 0.531299 7.77556 0.979903 8.16015 1.55548C8.54473 2.13105 8.75 2.80774 8.75 3.49997C8.74908 4.42794 8.38003 5.31765 7.72385 5.97382C7.06768 6.63 6.17798 6.99904 5.25 6.99997ZM5.25 1.16664C4.78851 1.16664 4.33739 1.30349 3.95367 1.55988C3.56996 1.81627 3.27089 2.18068 3.09428 2.60704C2.91768 3.0334 2.87147 3.50256 2.9615 3.95518C3.05153 4.4078 3.27376 4.82357 3.60009 5.14989C3.92641 5.47621 4.34217 5.69844 4.79479 5.78847C5.24741 5.8785 5.71657 5.83229 6.14293 5.65569C6.56929 5.47909 6.93371 5.18002 7.1901 4.7963C7.44649 4.41259 7.58334 3.96146 7.58334 3.49997C7.58334 2.88113 7.3375 2.28764 6.89992 1.85006C6.46233 1.41247 5.86884 1.16664 5.25 1.16664Z`,fill:`currentColor`},null,-1)]])}var mr=Z(dr,[[`render`,pr]]),hr={},gr={width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`};function _r(e,t){return K(),G(`svg`,gr,[...t[0]||=[C(``,2)]])}var vr=Z(hr,[[`render`,_r]]),yr={class:`w-[285px] flex-shrink-0 p-[15px] hidden lg:block`},br={class:`glass-card h-full p-6`},xr={class:`mb-12`},Sr={class:`text-content-secondary dark:text-content-muted text-sm`},Cr=[`title`],wr={class:`text-content-secondary dark:text-content-muted text-sm mt-1`},Tr={class:`mt-3 p-2 rounded-[10px] border border-stroke-subtle dark:border-white/10 bg-white dark:bg-white/5`},Er={class:`flex items-center justify-between`},Dr={class:`flex items-center gap-3 mt-1.5 text-[10px] text-content-muted dark:text-content-muted`},Or={class:`text-green-600 dark:text-green-400`},kr={class:`text-red-600 dark:text-red-400`},Ar={key:0,class:`text-orange-600 dark:text-orange-400`},jr={class:`mb-8`},Mr={class:`mb-8`},Nr={class:`space-y-2`},Pr=[`onClick`],Fr={class:`mb-8`},Ir={class:`space-y-2`},Lr=[`onClick`],Rr={class:`mb-8`},zr={class:`space-y-2`},Br=[`onClick`],Vr={class:`mb-8`},Hr={class:`space-y-2`},Ur=[`onClick`],Wr={class:`mb-4`},Gr={class:`flex rounded-[10px] overflow-hidden border border-stroke-subtle dark:border-white/10 bg-white dark:bg-white/5`},Kr=[`title`,`disabled`,`onClick`],qr=[`disabled`],Jr={class:`flex items-center gap-3`},Yr={class:`mb-4`},Xr={key:0,class:`mb-2 glass-card px-3 py-2 rounded-lg border border-blue-500/30 dark:border-blue-400/50 bg-blue-500/10 dark:bg-blue-400/20`},Zr={class:`flex items-center gap-2`},Qr={key:0,class:`mt-2 glass-card px-3 py-2 rounded-lg border border-stroke-subtle dark:border-stroke/30 space-y-2 text-xs animate-fade-in`},$r={class:`space-y-1`},ei={class:`flex items-center justify-between`},ti={class:`text-content-primary dark:text-content-primary font-mono`},ni={key:0,class:`pl-2 space-y-0.5 text-[10px] text-content-secondary dark:text-content-muted`},ri={key:0,class:`flex items-center gap-1`},ii={class:`bg-white/5 dark:bg-black/20 px-1 py-0.5 rounded`},ai={class:`space-y-1`},oi={class:`flex items-center justify-between`},si={class:`text-content-primary dark:text-content-primary font-mono`},ci={key:0,class:`pl-2 space-y-0.5 text-[10px] text-content-secondary dark:text-content-muted`},li={key:0,class:`flex items-center gap-1`},ui={class:`bg-white/5 dark:bg-black/20 px-1 py-0.5 rounded`},di={key:0,class:`mb-4`},fi={class:`text-content-secondary dark:text-content-muted text-xs mb-2`},pi={class:`text-content-primary dark:text-content-primary`},mi={class:`w-full h-1 bg-white/10 rounded-full overflow-hidden`},hi={class:`flex items-center gap-2 text-content-secondary dark:text-content-muted text-xs mb-3`},gi={class:`flex items-center justify-center gap-3`},_i={href:`https://github.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-primary/20 dark:hover:bg-primary/30 hover:border-primary/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`GitHub`},vi={href:`https://buymeacoffee.com/rightup`,target:`_blank`,class:`inline-flex items-center justify-center w-9 h-9 rounded-xl bg-content-primary dark:bg-white/10 border border-stroke-subtle dark:border-stroke/20 hover:bg-yellow-50 dark:hover:bg-yellow-500/20 hover:border-yellow-500/50 transition-all duration-300 hover:scale-110 group backdrop-blur-sm`,title:`Buy Me a Coffee`},yi=T({name:`SidebarNav`,__name:`Sidebar`,setup(e){let t=oe(),n=se(),r=me(),a=ge(),o=q(!1),l=q(!1),d=q(!1),f=q(!1),p=q(!1),m=q(null),h=q(`unknown`),g=q(0),_=q(0),y=q(0),b=async()=>{try{let e=(await Y.get(`/advert_rate_limit_stats`))?.data;h.value=typeof e?.adaptive?.current_tier==`string`?e.adaptive.current_tier:`unknown`,g.value=e?.stats?.adverts_allowed||0,_.value=e?.stats?.adverts_dropped||0,y.value=Object.keys(e?.active_penalties||{}).length}catch{h.value=`unknown`,g.value=0,_.value=0,y.value=0}};u(async()=>{await r.fetchStats(),await b()}),k(()=>a.isConnected,e=>{e&&r.fetchStats()}),qt(()=>r.fetchStats(),{intervalMs:5e3,enabled:()=>!a.isConnected,immediate:!1}),qt(b,{intervalMs:3e4,enabled:!0,immediate:!1});let S=P(()=>{switch(h.value){case`quiet`:return`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-500/50`;case`normal`:return`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-500/50`;case`busy`:return`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-500/50`;case`congested`:return`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/50`;default:return`bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-400 border-gray-500/50`}}),C={dashboard:Wn,neighbors:mr,statistics:or,"system-stats":ur,sessions:ur,configuration:Bn,"room-servers":Bn,companions:Bn,logs:Qn,terminal:nr,help:Jn},T=[{name:`Dashboard`,icon:`dashboard`,route:`/`},{name:`Neighbors`,icon:`neighbors`,route:`/neighbors`},{name:`Statistics`,icon:`statistics`,route:`/statistics`},{name:`System Stats`,icon:`system-stats`,route:`/system-stats`},{name:`Sessions`,icon:`sessions`,route:`/sessions`},{name:`Configuration`,icon:`configuration`,route:`/configuration`},{name:`Terminal`,icon:`terminal`,route:`/terminal`},{name:`Room Servers`,icon:`room-servers`,route:`/room-servers`},{name:`Companions`,icon:`companions`,route:`/companions`},{name:`Logs`,icon:`logs`,route:`/logs`},{name:`Help`,icon:`help`,route:`/help`}],E=[{id:`forward`,label:`Forward`,title:`Repeats packets and Room Server and Companion identities can TX.`},{id:`monitor`,label:`Monitor`,title:`Does not repeat packets, can Advert, Room Server and Companion identities can TX.`},{id:`no_tx`,label:`No TX`,title:`No packets transmitted.`}],D=P(()=>e=>n.path===e),O=e=>{t.push(e)},ee=async()=>{o.value=!0,m.value=null;try{await r.sendAdvert(),p.value=!0,setTimeout(()=>{j()},2e3)}catch(e){m.value=e instanceof Error?e.message:`Unknown error occurred`,console.error(`Failed to send advert:`,e)}finally{o.value=!1}},j=()=>{f.value=!1,p.value=!1,m.value=null,o.value=!1},te=async e=>{if(!l.value&&r.currentMode!==e){l.value=!0;try{await r.setMode(e)}catch(e){console.error(`Failed to set mode:`,e)}finally{l.value=!1}}},ne=async()=>{if(!d.value){d.value=!0;try{await r.toggleDutyCycle()}catch(e){console.error(`Failed to toggle duty cycle:`,e)}finally{d.value=!1}}},N=q(new Date().toLocaleTimeString());setInterval(()=>{N.value=new Date().toLocaleTimeString()},1e3);let F=P(()=>{let e=r.dutyCyclePercentage,t=`#A5E5B6`;return e>90?t=`#FB787B`:e>70&&(t=`#FFC246`),{width:e===0?`2px`:`${Math.max(e,2)}%`,backgroundColor:t}}),R=q(!1),B=P(()=>r.version.includes(`dev`)||r.coreVersion.includes(`dev`)),H=e=>{let t=e.match(/^([\d.]+)(\.dev(\d+))?((\+g)([a-f0-9]+))?$/);return t?{base:t[1],isDev:!!t[2],devNumber:t[3]||null,commit:t[6]||null}:{base:e,isDev:!1,devNumber:null,commit:null}},U=P(()=>H(r.version)),W=P(()=>H(r.coreVersion));return(e,t)=>(K(),G(z,null,[V(`aside`,yr,[V(`div`,br,[V(`div`,xr,[t[3]||=V(`div`,{class:`mb-3 flex justify-center`},[V(`img`,{src:`/assets/pymclogo-ew909fnk.png`,alt:`pyMC`,class:`h-[6.5rem]`})],-1),V(`p`,Sr,[I(L(s(r).nodeName)+` `,1),V(`span`,{class:x([`inline-block w-2 h-2 rounded-full ml-2`,s(r).statusBadge.text===`Active`?`bg-accent-green`:s(r).statusBadge.text===`Monitor Mode`?`bg-secondary`:`bg-accent-red`]),title:s(r).statusBadge.title},null,10,Cr)]),V(`p`,wr,` <`+L(s(r).pubKey)+`> `,1),V(`div`,Tr,[V(`div`,Er,[t[2]||=V(`span`,{class:`text-content-muted dark:text-content-muted text-[10px] uppercase tracking-wide`},`Adaptive`,-1),V(`div`,{class:x([`inline-flex items-center px-2 py-0.5 rounded-full border text-[10px] font-semibold`,S.value])},L(h.value.toUpperCase()),3)]),V(`div`,Dr,[V(`span`,Or,`OK: `+L(g.value),1),V(`span`,kr,`Drop: `+L(_.value),1),y.value>0?(K(),G(`span`,Ar,`Pen: `+L(y.value),1)):A(``,!0)])])]),t[21]||=V(`div`,{class:`border-t border-stroke-subtle dark:border-stroke mb-6`},null,-1),V(`div`,jr,[t[5]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-4`},`Actions`,-1),V(`button`,{onClick:t[0]||=e=>f.value=!0,class:`w-full bg-white dark:bg-white/10 rounded-[10px] py-3 px-4 flex items-center gap-2 text-sm font-medium text-[#212122] dark:text-white border border-stroke-subtle dark:border-white/10 hover:bg-gray-100 dark:hover:bg-white/20 transition-colors`},[...t[4]||=[V(`svg`,{class:`w-3.5 h-3.5`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[V(`path`,{d:`M7 0C5.61553 0 4.26216 0.410543 3.11101 1.17971C1.95987 1.94888 1.06266 3.04213 0.532846 4.32122C0.003033 5.6003 -0.13559 7.00777 0.134506 8.36563C0.404603 9.7235 1.07129 10.9708 2.05026 11.9497C3.02922 12.9287 4.2765 13.5954 5.63437 13.8655C6.99224 14.1356 8.3997 13.997 9.67879 13.4672C10.9579 12.9373 12.0511 12.0401 12.8203 10.889C13.5895 9.73785 14 8.38447 14 7C13.998 5.1441 13.2599 3.36479 11.9475 2.05247C10.6352 0.74015 8.8559 0.0020073 7 0V0ZM7 12.8333C5.84628 12.8333 4.71846 12.4912 3.75918 11.8502C2.79989 11.2093 2.05222 10.2982 1.61071 9.23232C1.16919 8.16642 1.05368 6.99353 1.27876 5.86197C1.50384 4.73042 2.05941 3.69102 2.87521 2.87521C3.69102 2.0594 4.73042 1.50383 5.86198 1.27875C6.99353 1.05367 8.16642 1.16919 9.23232 1.6107C10.2982 2.05221 11.2093 2.79989 11.8502 3.75917C12.4912 4.71846 12.8333 5.84628 12.8333 7C12.8316 8.54658 12.2165 10.0293 11.1229 11.1229C10.0293 12.2165 8.54658 12.8316 7 12.8333ZM8.16667 7C8.1676 7.20501 8.11448 7.40665 8.01268 7.58461C7.91087 7.76256 7.76397 7.91054 7.58677 8.01365C7.40957 8.11676 7.20833 8.17136 7.00332 8.17194C6.7983 8.17252 6.59675 8.11906 6.41897 8.01696C6.24119 7.91485 6.09346 7.7677 5.99065 7.59033C5.88784 7.41295 5.83358 7.21162 5.83335 7.0066C5.83312 6.80159 5.88691 6.60013 5.98932 6.42252C6.09172 6.24491 6.23912 6.09743 6.41667 5.99492V3.5H7.58334V5.99492C7.76016 6.09659 7.90713 6.24298 8.00952 6.41939C8.1119 6.5958 8.1661 6.79603 8.16667 7Z`,fill:`currentColor`})],-1),I(` Send Advert `,-1)]])]),V(`div`,Mr,[t[6]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-4`},`Monitoring`,-1),V(`div`,Nr,[(K(!0),G(z,null,i(T.slice(0,3),e=>(K(),G(`button`,{key:e.name,onClick:t=>O(e.route),class:x([D.value(e.route)?`bg-gradient-to-r from-cyan-400/90 to-cyan-500/90 dark:bg-primary/30 border-cyan-500 dark:border-primary/40 shadow-[0_4px_16px_rgba(6,182,212,0.4)] dark:shadow-[0_4px_12px_rgba(170,232,232,0.25)] text-white dark:text-primary font-semibold`:`text-content-primary dark:text-content-primary hover:bg-gradient-to-r hover:from-cyan-400/20 hover:to-cyan-500/20 dark:hover:bg-primary/5 hover:border-cyan-400/30 dark:hover:border-primary/20 hover:shadow-[0_2px_12px_rgba(6,182,212,0.2)] dark:hover:shadow-[0_2px_8px_rgba(170,232,232,0.15)] border border-stroke-subtle dark:border-transparent`,`w-full rounded-[10px] py-3 px-4 flex items-center gap-3 text-sm font-medium transition-all duration-200`])},[(K(),v(c(C[e.icon]),{class:x(D.value(e.route)?`w-3.5 h-3.5 text-white dark:text-primary [&_path]:fill-current`:`w-3.5 h-3.5 text-content-primary dark:text-content-primary [&_path]:fill-current`)},null,8,[`class`])),I(` `+L(e.name),1)],10,Pr))),128))])]),V(`div`,Fr,[t[7]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-4`},`System`,-1),V(`div`,Ir,[(K(!0),G(z,null,i(T.slice(3,7),e=>(K(),G(`button`,{key:e.name,onClick:t=>O(e.route),class:x([D.value(e.route)?`bg-gradient-to-r from-cyan-400/90 to-cyan-500/90 dark:bg-primary/30 border-cyan-500 dark:border-primary/40 shadow-[0_4px_16px_rgba(6,182,212,0.4)] dark:shadow-[0_4px_12px_rgba(170,232,232,0.25)] text-white dark:text-primary font-semibold`:`text-content-primary dark:text-content-primary hover:bg-gradient-to-r hover:from-cyan-400/20 hover:to-cyan-500/20 dark:hover:bg-primary/5 hover:border-cyan-400/30 dark:hover:border-primary/20 hover:shadow-[0_2px_12px_rgba(6,182,212,0.2)] dark:hover:shadow-[0_2px_8px_rgba(170,232,232,0.15)] border border-stroke-subtle dark:border-transparent`,`w-full rounded-[10px] py-3 px-4 flex items-center gap-3 text-sm font-medium transition-all duration-200`])},[(K(),v(c(C[e.icon]),{class:x(D.value(e.route)?`w-3.5 h-3.5 text-white dark:text-primary [&_path]:fill-current`:`w-3.5 h-3.5 text-content-primary dark:text-content-primary [&_path]:fill-current`)},null,8,[`class`])),I(` `+L(e.name),1)],10,Lr))),128))])]),V(`div`,Rr,[t[8]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-4`},` Room Servers & Companions `,-1),V(`div`,zr,[(K(!0),G(z,null,i(T.slice(7,9),e=>(K(),G(`button`,{key:e.name,onClick:t=>O(e.route),class:x([D.value(e.route)?`bg-gradient-to-r from-cyan-400/90 to-cyan-500/90 dark:bg-primary/30 border-cyan-500 dark:border-primary/40 shadow-[0_4px_16px_rgba(6,182,212,0.4)] dark:shadow-[0_4px_12px_rgba(170,232,232,0.25)] text-white dark:text-primary font-semibold`:`text-content-primary dark:text-content-primary hover:bg-gradient-to-r hover:from-cyan-400/20 hover:to-cyan-500/20 dark:hover:bg-primary/5 hover:border-cyan-400/30 dark:hover:border-primary/20 hover:shadow-[0_2px_12px_rgba(6,182,212,0.2)] dark:hover:shadow-[0_2px_8px_rgba(170,232,212,0.15)] border border-stroke-subtle dark:border-transparent`,`w-full rounded-[10px] py-3 px-4 flex items-center gap-3 text-sm font-medium transition-all duration-200`])},[(K(),v(c(C[e.icon]),{class:x(D.value(e.route)?`w-3.5 h-3.5 text-white dark:text-primary [&_path]:fill-current`:`w-3.5 h-3.5 text-content-primary dark:text-content-primary [&_path]:fill-current`)},null,8,[`class`])),I(` `+L(e.name),1)],10,Br))),128))])]),V(`div`,Vr,[t[9]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-4`},`Other`,-1),V(`div`,Hr,[(K(!0),G(z,null,i(T.slice(9),e=>(K(),G(`button`,{key:e.name,onClick:t=>O(e.route),class:x([D.value(e.route)?`bg-gradient-to-r from-cyan-400/90 to-cyan-500/90 dark:bg-primary/30 border-cyan-500 dark:border-primary/40 shadow-[0_4px_16px_rgba(6,182,212,0.4)] dark:shadow-[0_4px_12px_rgba(170,232,232,0.25)] text-white dark:text-primary font-semibold`:`text-content-primary dark:text-content-primary hover:bg-gradient-to-r hover:from-cyan-400/20 hover:to-cyan-500/20 dark:hover:bg-primary/5 hover:border-cyan-400/30 dark:hover:border-primary/20 hover:shadow-[0_2px_12px_rgba(6,182,212,0.2)] dark:hover:shadow-[0_2px_8px_rgba(170,232,232,0.15)] border border-stroke-subtle dark:border-transparent`,`w-full rounded-[10px] py-3 px-4 flex items-center gap-3 text-sm font-medium transition-all duration-200`])},[(K(),v(c(C[e.icon]),{class:x(D.value(e.route)?`w-3.5 h-3.5 text-white dark:text-primary [&_path]:fill-current`:`w-3.5 h-3.5 text-content-primary dark:text-content-primary [&_path]:fill-current`)},null,8,[`class`])),I(` `+L(e.name),1)],10,Ur))),128))])]),M(pn,{"current-value":s(r).noiseFloorDbm||-116,"update-interval":3e3,class:`mb-6`},null,8,[`current-value`]),V(`div`,Wr,[t[10]||=V(`p`,{class:`text-content-muted dark:text-content-muted text-xs uppercase mb-2`},`Mode`,-1),V(`div`,Gr,[(K(),G(z,null,i(E,e=>V(`button`,{key:e.id,type:`button`,title:e.title,disabled:l.value,onClick:t=>te(e.id),class:x([`flex-1 py-2.5 px-2 text-xs font-medium transition-all duration-200 border-r border-stroke-subtle dark:border-white/10 last:border-r-0`,l.value?`opacity-60 cursor-not-allowed`:`cursor-pointer`,s(r).currentMode===e.id?e.id===`forward`?`bg-mode-segment-forward text-accent-green`:e.id===`monitor`?`bg-amber-500/20 text-amber-600 dark:text-amber-400`:`bg-mode-segment-no-tx text-accent-red`:`text-content-primary dark:text-content-primary hover:bg-white/10 dark:hover:bg-white/10`])},L(l.value&&s(r).currentMode!==e.id?`…`:e.label),11,Kr)),64))])]),V(`button`,{onClick:ne,disabled:d.value,class:x([`p-4 flex items-center justify-between mb-4 w-full transition-all duration-200 cursor-pointer group`,s(r).dutyCycleButtonState.warning?`glass-card-orange hover:bg-accent-red/10`:`glass-card-green hover:bg-accent-green/10`])},[V(`div`,Jr,[M(vr,{class:`w-3.5 h-3.5 text-content-primary dark:text-content-primary group-hover:text-primary transition-colors`}),t[11]||=V(`span`,{class:`text-content-primary dark:text-content-primary text-sm group-hover:text-primary transition-colors`},`Duty Cycle`,-1)]),V(`span`,{class:x([`text-xs font-medium group-hover:text-white transition-colors`,s(r).dutyCycleButtonState.warning?`text-accent-red`:`text-primary`])},L(d.value?`Changing...`:s(r).dutyCycleEnabled?`Enabled`:`Disabled`),3)],10,qr),V(`div`,Yr,[B.value?(K(),G(`div`,Xr,[...t[12]||=[V(`div`,{class:`flex items-center justify-center gap-2`},[V(`svg`,{class:`w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`},[V(`path`,{"fill-rule":`evenodd`,d:`M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z`,"clip-rule":`evenodd`})]),V(`span`,{class:`text-blue-500 dark:text-blue-400 text-xs font-semibold`},`Development Build`)],-1)]])):A(``,!0),V(`div`,{onClick:t[1]||=e=>R.value=!R.value,class:`cursor-pointer transition-all duration-200 hover:scale-[1.02]`},[V(`div`,Zr,[V(`span`,{class:x([`glass-card px-2 py-1 text-xs font-medium rounded border transition-colors`,U.value.isDev?`text-yellow-600 dark:text-yellow-400 border-yellow-500/30 dark:border-yellow-500/30`:`text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke`])},` R:v`+L(U.value.base)+L(U.value.isDev?`-dev`+U.value.devNumber:``),3),V(`span`,{class:x([`glass-card px-2 py-1 text-xs font-medium rounded border transition-colors`,W.value.isDev?`text-yellow-600 dark:text-yellow-400 border-yellow-500/30 dark:border-yellow-500/30`:`text-content-secondary dark:text-content-muted border-stroke-subtle dark:border-stroke`])},` Core:v`+L(W.value.base)+L(W.value.isDev?`-dev`+W.value.devNumber:``),3),(K(),G(`svg`,{class:x([`w-3 h-3 text-content-muted transition-transform duration-200`,R.value?`rotate-180`:``]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...t[13]||=[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]],2))]),R.value?(K(),G(`div`,Qr,[V(`div`,$r,[V(`div`,ei,[t[14]||=V(`span`,{class:`text-content-muted font-medium`},`Repeater:`,-1),V(`span`,ti,`v`+L(U.value.base),1)]),U.value.isDev?(K(),G(`div`,ni,[V(`div`,null,`Dev Build: `+L(U.value.devNumber),1),U.value.commit?(K(),G(`div`,ri,[t[15]||=V(`span`,null,`Commit:`,-1),V(`code`,ii,L(U.value.commit),1)])):A(``,!0)])):A(``,!0)]),t[18]||=V(`div`,{class:`border-t border-stroke-subtle dark:border-stroke/20`},null,-1),V(`div`,ai,[V(`div`,oi,[t[16]||=V(`span`,{class:`text-content-muted font-medium`},`Core:`,-1),V(`span`,si,`v`+L(W.value.base),1)]),W.value.isDev?(K(),G(`div`,ci,[V(`div`,null,`Dev Build: `+L(W.value.devNumber),1),W.value.commit?(K(),G(`div`,li,[t[17]||=V(`span`,null,`Commit:`,-1),V(`code`,ui,L(W.value.commit),1)])):A(``,!0)])):A(``,!0)])])):A(``,!0)])]),t[22]||=V(`div`,{class:`border-t border-accent-green mb-4`},null,-1),s(r).dutyCycleEnabled?(K(),G(`div`,di,[V(`p`,fi,[t[19]||=I(` Duty Cycle: `,-1),V(`span`,pi,L(s(r).dutyCycleUtilization.toFixed(1))+`% / `+L(s(r).dutyCycleMax.toFixed(1))+`%`,1)]),V(`div`,mi,[V(`div`,{class:`h-full rounded-full transition-all duration-300`,style:w(F.value)},null,4)])])):A(``,!0),V(`div`,hi,[t[20]||=V(`svg`,{class:`w-3 h-3`,viewBox:`0 0 13 13`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[V(`path`,{d:`M6.5 13C5.59722 13 4.75174 12.8286 3.96355 12.4858C3.17537 12.143 2.48926 11.6795 1.90522 11.0955C1.32119 10.5115 0.85776 9.82535 0.514945 9.03717C0.172131 8.24898 0.000482491 7.40326 1.0101e-06 6.5C-0.000480471 5.59674 0.171168 4.75126 0.514945 3.96356C0.858723 3.17585 1.32191 2.48974 1.9045 1.90522C2.48709 1.3207 3.1732 0.857278 3.96283 0.514944C4.75246 0.172611 5.59818 0.000962963 6.5 0C7.48703 0 8.42303 0.210648 9.30799 0.631944C10.193 1.05324 10.9421 1.64907 11.5555 2.41944V1.44444C11.5555 1.23981 11.6249 1.06841 11.7635 0.930222C11.9022 0.792037 12.0736 0.722704 12.2778 0.722222C12.4819 0.721741 12.6536 0.791074 12.7927 0.930222C12.9319 1.06937 13.001 1.24078 13 1.44444V4.33333C13 4.53796 12.9307 4.70961 12.792 4.84828C12.6533 4.98694 12.4819 5.05604 12.2778 5.05556H9.38888C9.18425 5.05556 9.01285 4.98622 8.87466 4.84756C8.73647 4.70889 8.66714 4.53748 8.66666 4.33333C8.66618 4.12919 8.73551 3.95778 8.87466 3.81911C9.01381 3.68044 9.18521 3.61111 9.38888 3.61111H10.6528C10.1593 2.93704 9.55138 2.40741 8.82916 2.02222C8.10694 1.63704 7.33055 1.44444 6.5 1.44444C5.09166 1.44444 3.89711 1.93507 2.91633 2.91633C1.93555 3.89759 1.44493 5.09215 1.44444 6.5C1.44396 7.90785 1.93459 9.10265 2.91633 10.0844C3.89807 11.0661 5.09263 11.5565 6.5 11.5556C7.64351 11.5556 8.66666 11.2125 9.56944 10.5264C10.4722 9.84028 11.068 8.95555 11.3569 7.87222C11.4171 7.67963 11.5255 7.53519 11.6819 7.43889C11.8384 7.34259 12.013 7.30648 12.2055 7.33055C12.4102 7.35463 12.5727 7.44178 12.693 7.592C12.8134 7.74222 12.8495 7.90785 12.8014 8.08889C12.4523 9.5213 11.694 10.698 10.5264 11.6191C9.35879 12.5402 8.01666 13.0005 6.5 13ZM7.22222 6.21111L9.02777 8.01667C9.16018 8.14907 9.22638 8.31759 9.22638 8.52222C9.22638 8.72685 9.16018 8.89537 9.02777 9.02778C8.89536 9.16018 8.72685 9.22639 8.52222 9.22639C8.31759 9.22639 8.14907 9.16018 8.01666 9.02778L5.99444 7.00556C5.92222 6.93333 5.86805 6.8522 5.83194 6.76217C5.79583 6.67213 5.77777 6.57872 5.77777 6.48194V3.61111C5.77777 3.40648 5.84711 3.23507 5.98577 3.09689C6.12444 2.9587 6.29585 2.88937 6.5 2.88889C6.70414 2.88841 6.87579 2.95774 7.01494 3.09689C7.15409 3.23604 7.22318 3.40744 7.22222 3.61111V6.21111Z`,fill:`currentColor`})],-1),I(` Last Updated: `+L(N.value),1)]),t[23]||=V(`div`,{class:`flex flex-col items-center justify-center mb-4`},[V(`p`,{class:`text-content-muted dark:text-content-muted text-[10px] mb-1 tracking-wide uppercase opacity-70`},` Powered by `),V(`img`,{src:`/assets/meshcore-DQNtEl5I.svg`,alt:`MeshCore`,class:`h-4 opacity-70 dark:invert-0 invert`})],-1),V(`div`,gi,[V(`a`,_i,[M(Zt,{class:`w-5 h-5 text-white group-hover:text-primary transition-colors`})]),V(`a`,vi,[M(tn,{class:`w-5 h-5 text-white group-hover:text-yellow-500 transition-colors`})])])])]),M(In,{isOpen:f.value,isLoading:o.value,isSuccess:p.value,error:m.value,onClose:j,onSend:ee},null,8,[`isOpen`,`isLoading`,`isSuccess`,`error`])],64))}}),bi={class:`bg-white/95 dark:bg-black/20 backdrop-blur-xl border border-stroke dark:border-white/10 rounded-2xl h-full p-6 overflow-auto shadow-2xl`},xi={class:`mb-6 flex items-center justify-between`},Si={class:`text-content-secondary dark:text-[#C3C3C3] text-sm`},Ci=[`title`],wi={class:`text-content-secondary dark:text-[#C3C3C3] text-sm mt-1`},Ti={class:`mt-3 p-2 rounded-[10px] border border-stroke-subtle dark:border-white/10 bg-white dark:bg-white/5`},Ei={class:`flex items-center justify-between`},Di={class:`flex items-center gap-3 mt-1.5 text-[10px] text-content-muted`},Oi={class:`text-green-600 dark:text-green-400`},ki={class:`text-red-600 dark:text-red-400`},Ai={key:0,class:`text-orange-600 dark:text-orange-400`},ji={class:`mb-4`},Mi={class:`mb-4`},Ni={class:`space-y-2 mb-3`},Pi=[`onClick`],Fi={class:`mb-4`},Ii={class:`space-y-2 mb-3`},Li=[`onClick`],Ri={class:`mb-4`},zi={class:`space-y-2 mb-3`},Bi=[`onClick`],Vi={class:`mb-4`},Hi={class:`space-y-2 mb-3`},Ui=[`onClick`],Wi={class:`mb-3`},Gi={class:`flex rounded-[.625rem] overflow-hidden border border-stroke dark:border-white/10 bg-white dark:bg-white/5`},Ki=[`title`,`disabled`,`onClick`],qi=[`disabled`],Ji={class:`flex items-center gap-3`},Yi={class:`mb-4`},Xi={key:0,class:`mt-2 glass-card px-3 py-2 rounded-lg border border-stroke-subtle dark:border-stroke/30 space-y-2 text-xs animate-fade-in`},Zi={class:`space-y-1`},Qi={class:`flex items-center justify-between`},$i={class:`text-content-primary dark:text-content-primary font-mono`},ea={key:0,class:`pl-2 space-y-0.5 text-[10px] text-content-secondary dark:text-content-muted`},ta={key:0,class:`flex items-center gap-1`},na={class:`bg-white/5 dark:bg-black/20 px-1 py-0.5 rounded`},ra={class:`space-y-1`},ia={class:`flex items-center justify-between`},aa={class:`text-content-primary dark:text-content-primary font-mono`},oa={key:0,class:`pl-2 space-y-0.5 text-[10px] text-content-secondary dark:text-content-muted`},sa={key:0,class:`flex items-center gap-1`},ca={class:`bg-white/5 dark:bg-black/20 px-1 py-0.5 rounded`},la={key:1,class:`mb-4`},ua={class:`text-content-muted text-xs mb-2`},da={class:`text-content-primary dark:text-white`},fa={class:`w-full h-1 bg-stroke-subtle dark:bg-white/10 rounded-full overflow-hidden`},pa={class:`text-content-muted text-xs`},ma=T({name:`MobileSidebar`,__name:`MobileSidebar`,props:{showMobileSidebar:{type:Boolean}},emits:[`update:showMobileSidebar`,`close`],setup(e,{emit:t}){let r=E(()=>le(()=>import(`./RFNoiseFloor-DhLKjd9G.js`),[])),a=q(!1),o=e,l=t,d=oe(),f=se(),p=me();k(()=>o.showMobileSidebar,e=>{e&&!a.value?setTimeout(()=>{a.value=!0},100):e||(a.value=!1)});let m=q(!1),h=q(!1),g=q(!1),_=q(!1),y=q(!1),b=q(null),S=null,C=null,T=q(`unknown`),D=q(0),O=q(0),ee=q(0);u(()=>{S=window.setInterval(()=>{ce.value=new Date().toLocaleTimeString()},1e3),j(),C=window.setInterval(()=>{j()},3e4)}),n(()=>{S&&clearInterval(S),C&&clearInterval(C)});let j=async()=>{try{let e=(await Y.get(`/advert_rate_limit_stats`))?.data;T.value=typeof e?.adaptive?.current_tier==`string`?e.adaptive.current_tier:`unknown`,D.value=e?.stats?.adverts_allowed||0,O.value=e?.stats?.adverts_dropped||0,ee.value=Object.keys(e?.active_penalties||{}).length}catch{T.value=`unknown`,D.value=0,O.value=0,ee.value=0}},te=P(()=>{switch(T.value){case`quiet`:return`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-500/50`;case`normal`:return`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-500/50`;case`busy`:return`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-500/50`;case`congested`:return`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/50`;default:return`bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-400 border-gray-500/50`}}),ne={dashboard:Wn,neighbors:mr,statistics:or,"system-stats":ur,sessions:ur,configuration:Bn,"room-servers":Bn,companions:Bn,logs:Qn,terminal:nr,help:Jn},N=[{name:`Dashboard`,icon:`dashboard`,route:`/`},{name:`Neighbors`,icon:`neighbors`,route:`/neighbors`},{name:`Statistics`,icon:`statistics`,route:`/statistics`},{name:`System Stats`,icon:`system-stats`,route:`/system-stats`},{name:`Sessions`,icon:`sessions`,route:`/sessions`},{name:`Configuration`,icon:`configuration`,route:`/configuration`},{name:`Terminal`,icon:`terminal`,route:`/terminal`},{name:`Room Servers`,icon:`room-servers`,route:`/room-servers`},{name:`Companions`,icon:`companions`,route:`/companions`},{name:`Logs`,icon:`logs`,route:`/logs`},{name:`Help`,icon:`help`,route:`/help`}],F=[{id:`forward`,label:`Forward`,title:`Repeats packets and Room Server and Companion identities can TX.`},{id:`monitor`,label:`Monitor`,title:`Does not repeat packets, can Advert, Room Server and Companion identities can TX.`},{id:`no_tx`,label:`No TX`,title:`No packets transmitted.`}],R=P(()=>e=>f.path===e),B=e=>{d.push(e),H()},H=()=>{l(`update:showMobileSidebar`,!1)},U=()=>{pe(),d.push(`/login`),H()},W=async()=>{m.value=!0,b.value=null;try{await p.sendAdvert(),y.value=!0,setTimeout(()=>{re()},2e3)}catch(e){b.value=e instanceof Error?e.message:`Unknown error occurred`,console.error(`Failed to send advert:`,e)}finally{m.value=!1}},re=()=>{_.value=!1,y.value=!1,b.value=null,m.value=!1},ie=async e=>{if(!h.value&&p.currentMode!==e){h.value=!0;try{await p.setMode(e)}catch(e){console.error(`Failed to set mode:`,e)}finally{h.value=!1}}},ae=async()=>{if(!g.value){g.value=!0;try{await p.toggleDutyCycle()}catch(e){console.error(`Failed to toggle duty cycle:`,e)}finally{g.value=!1}}},ce=q(new Date().toLocaleTimeString()),ue=q(!1),de=P(()=>p.version.includes(`dev`)||p.coreVersion.includes(`dev`)),fe=e=>{let t=e.match(/^([\d.]+)(\.dev(\d+))?((\+g)([a-f0-9]+))?$/);return t?{base:t[1],isDev:!!t[2],devNumber:t[3]||null,commit:t[6]||null}:{base:e,isDev:!1,devNumber:null,commit:null}},J=P(()=>fe(p.version)),X=P(()=>fe(p.coreVersion)),he=P(()=>{let e=p.dutyCyclePercentage,t=`#A5E5B6`;return e>90?t=`#FB787B`:e>70&&(t=`#FFC246`),{width:e===0?`.125rem`:`${Math.max(e,2)}%`,backgroundColor:t}});return(t,n)=>(K(),G(z,null,[V(`div`,{class:x([`fixed inset-0 z-[1010] lg:hidden transition-opacity duration-300`,e.showMobileSidebar?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`])},[V(`div`,{class:`absolute inset-0 bg-black/30 backdrop-blur-sm dark:bg-black/30`,onClick:H}),V(`div`,{class:x([`absolute left-0 top-0 bottom-0 w-72 p-4 transition-transform duration-300`,e.showMobileSidebar?`translate-x-0`:`-translate-x-full`])},[V(`div`,bi,[V(`div`,xi,[V(`div`,null,[n[3]||=V(`div`,{class:`mb-2`},[V(`img`,{src:`/assets/pymclogo-ew909fnk.png`,alt:`pyMC`,class:`h-[5.2rem]`})],-1),V(`p`,Si,[I(L(s(p).nodeName)+` `,1),V(`span`,{class:x([`inline-block w-2 h-2 rounded-full ml-2`,s(p).statusBadge.text===`Active`?`bg-accent-green`:s(p).statusBadge.text===`Monitor Mode`?`bg-secondary`:`bg-accent-red`]),title:s(p).statusBadge.title},null,10,Ci)]),V(`p`,wi,` <`+L(s(p).pubKey)+`> `,1),V(`div`,Ti,[V(`div`,Ei,[n[2]||=V(`span`,{class:`text-content-muted text-[10px] uppercase tracking-wide`},`Adaptive`,-1),V(`div`,{class:x([`inline-flex items-center px-2 py-0.5 rounded-full border text-[10px] font-semibold`,te.value])},L(T.value.toUpperCase()),3)]),V(`div`,Di,[V(`span`,Oi,`OK: `+L(D.value),1),V(`span`,ki,`Drop: `+L(O.value),1),ee.value>0?(K(),G(`span`,Ai,`Pen: `+L(ee.value),1)):A(``,!0)])])]),V(`button`,{onClick:H,class:`text-content-primary dark:text-content-muted hover:text-content-heading dark:hover:text-white`},` ✕ `)]),n[20]||=V(`div`,{class:`border-t border-stroke dark:border-dark-border mb-4`},null,-1),V(`div`,ji,[n[5]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`Actions`,-1),V(`button`,{onClick:n[0]||=e=>{_.value=!0,H()},class:`w-full bg-white dark:bg-white/10 rounded-[.625rem] py-3 px-4 flex items-center gap-2 text-sm font-medium text-[#212122] dark:text-white border border-stroke-subtle dark:border-white/10 hover:bg-gray-100 dark:hover:bg-white/20 transition-colors mb-2`},[...n[4]||=[V(`svg`,{class:`w-3.5 h-3.5`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[V(`path`,{d:`M7 0C5.61553 0 4.26216 0.410543 3.11101 1.17971C1.95987 1.94888 1.06266 3.04213 0.532846 4.32122C0.003033 5.6003 -0.13559 7.00777 0.134506 8.36563C0.404603 9.7235 1.07129 10.9708 2.05026 11.9497C3.02922 12.9287 4.2765 13.5954 5.63437 13.8655C6.99224 14.1356 8.3997 13.997 9.67879 13.4672C10.9579 12.9373 12.0511 12.0401 12.8203 10.889C13.5895 9.73785 14 8.38447 14 7C13.998 5.1441 13.2599 3.36479 11.9475 2.05247C10.6352 0.74015 8.8559 0.0020073 7 0V0ZM7 12.8333C5.84628 12.8333 4.71846 12.4912 3.75918 11.8502C2.79989 11.2093 2.05222 10.2982 1.61071 9.23232C1.16919 8.16642 1.05368 6.99353 1.27876 5.86197C1.50384 4.73042 2.05941 3.69102 2.87521 2.87521C3.69102 2.0594 4.73042 1.50383 5.86198 1.27875C6.99353 1.05367 8.16642 1.16919 9.23232 1.6107C10.2982 2.05221 11.2093 2.79989 11.8502 3.75917C12.4912 4.71846 12.8333 5.84628 12.8333 7C12.8316 8.54658 12.2165 10.0293 11.1229 11.1229C10.0293 12.2165 8.54658 12.8316 7 12.8333ZM8.16667 7C8.1676 7.20501 8.11448 7.40665 8.01268 7.58461C7.91087 7.76256 7.76397 7.91054 7.58677 8.01365C7.40957 8.11676 7.20833 8.17136 7.00332 8.17194C6.7983 8.17252 6.59675 8.11906 6.41897 8.01696C6.24119 7.91485 6.09346 7.7677 5.99065 7.59033C5.88784 7.41295 5.83358 7.21162 5.83335 7.0066C5.83312 6.80159 5.88691 6.60013 5.98932 6.42252C6.09172 6.24491 6.23912 6.09743 6.41667 5.99492V3.5H7.58334V5.99492C7.76016 6.09659 7.90713 6.24298 8.00952 6.41939C8.1119 6.5958 8.1661 6.79603 8.16667 7Z`,fill:`currentColor`})],-1),I(` Send Advert `,-1)]])]),V(`div`,Mi,[n[6]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`Monitoring`,-1),V(`div`,Ni,[(K(!0),G(z,null,i(N.slice(0,3),e=>(K(),G(`button`,{key:e.name,onClick:t=>B(e.route),class:x([R.value(e.route)?`bg-primary/20 shadow-[0_0_.375rem_0_rgba(170,232,232,0.20)] text-primary`:`text-content-primary dark:text-white hover:bg-content-primary/10 dark:hover:bg-white/5`,`w-full rounded-[.625rem] py-3 px-4 flex items-center gap-3 text-sm transition-all`])},[(K(),v(c(ne[e.icon]),{class:`w-3.5 h-3.5`})),I(` `+L(e.name),1)],10,Pi))),128))])]),V(`div`,Fi,[n[7]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`System`,-1),V(`div`,Ii,[(K(!0),G(z,null,i(N.slice(3,7),e=>(K(),G(`button`,{key:e.name,onClick:t=>B(e.route),class:x([R.value(e.route)?`bg-primary/20 shadow-[0_0_.375rem_0_rgba(170,232,232,0.20)] text-primary`:`text-content-primary dark:text-white hover:bg-content-primary/10 dark:hover:bg-white/5`,`w-full rounded-[.625rem] py-3 px-4 flex items-center gap-3 text-sm transition-all`])},[(K(),v(c(ne[e.icon]),{class:`w-3.5 h-3.5`})),I(` `+L(e.name),1)],10,Li))),128))])]),V(`div`,Ri,[n[8]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`Room Servers & Companions`,-1),V(`div`,zi,[(K(!0),G(z,null,i(N.slice(7,9),e=>(K(),G(`button`,{key:e.name,onClick:t=>B(e.route),class:x([R.value(e.route)?`bg-primary/20 shadow-[0_0_.375rem_0_rgba(170,232,232,0.20)] text-primary`:`text-content-primary dark:text-white hover:bg-content-primary/10 dark:hover:bg-white/5`,`w-full rounded-[.625rem] py-3 px-4 flex items-center gap-3 text-sm transition-all`])},[(K(),v(c(ne[e.icon]),{class:`w-3.5 h-3.5`})),I(` `+L(e.name),1)],10,Bi))),128))])]),V(`div`,Vi,[n[9]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`Other`,-1),V(`div`,Hi,[(K(!0),G(z,null,i(N.slice(9),e=>(K(),G(`button`,{key:e.name,onClick:t=>B(e.route),class:x([R.value(e.route)?`bg-primary/20 shadow-[0_0_.375rem_0_rgba(170,232,232,0.20)] text-primary`:`text-content-primary dark:text-white hover:bg-content-primary/10 dark:hover:bg-white/5`,`w-full rounded-[.625rem] py-3 px-4 flex items-center gap-3 text-sm transition-all`])},[(K(),v(c(ne[e.icon]),{class:`w-3.5 h-3.5`})),I(` `+L(e.name),1)],10,Ui))),128))])]),a.value?(K(),v(s(r),{key:0,"current-value":s(p).noiseFloorDbm||-116,"update-interval":3e3,limit:50,class:`mb-4`},null,8,[`current-value`])):A(``,!0),V(`div`,Wi,[n[10]||=V(`p`,{class:`text-content-muted text-xs uppercase mb-2`},`Mode`,-1),V(`div`,Gi,[(K(),G(z,null,i(F,e=>V(`button`,{key:e.id,type:`button`,title:e.title,disabled:h.value,onClick:t=>ie(e.id),class:x([`flex-1 py-2.5 px-2 text-xs font-medium transition-all duration-200 border-r border-stroke dark:border-white/10 last:border-r-0`,h.value?`opacity-60 cursor-not-allowed`:`cursor-pointer`,s(p).currentMode===e.id?e.id===`forward`?`bg-mode-segment-forward text-accent-green`:e.id===`monitor`?`bg-amber-500/20 text-amber-600 dark:text-amber-400`:`bg-mode-segment-no-tx text-accent-red`:`text-content-primary dark:text-white hover:bg-white/10 dark:hover:bg-white/10`])},L(h.value&&s(p).currentMode!==e.id?`…`:e.label),11,Ki)),64))])]),V(`button`,{onClick:ae,disabled:g.value,class:x([`p-4 flex items-center justify-between mb-3 w-full transition-all duration-200 cursor-pointer group`,s(p).dutyCycleButtonState.warning?`glass-card-orange hover:bg-accent-red/10`:`glass-card-green hover:bg-accent-green/10`])},[V(`div`,Ji,[M(vr,{class:`w-3.5 h-3.5 text-content-primary dark:text-white group-hover:text-primary transition-colors`}),n[11]||=V(`span`,{class:`text-content-primary dark:text-white text-sm group-hover:text-primary transition-colors`},`Duty Cycle`,-1)]),V(`span`,{class:x([`text-xs font-medium group-hover:text-primary dark:group-hover:text-white transition-colors`,s(p).dutyCycleButtonState.warning?`text-accent-red`:`text-primary`])},L(g.value?`Changing...`:s(p).dutyCycleEnabled?`Enabled`:`Disabled`),3)],10,qi),V(`button`,{onClick:U,class:`w-full glass-card-orange hover:bg-accent-red/10 rounded-[.625rem] py-3 px-4 flex items-center justify-center gap-2 text-sm font-medium text-content-primary dark:text-white transition-all mb-4`},[...n[12]||=[V(`svg`,{class:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,xmlns:`http://www.w3.org/2000/svg`},[V(`path`,{d:`M13 3H15C16.1046 3 17 3.89543 17 5V15C17 16.1046 16.1046 17 15 17H13M8 7L4 10.5M4 10.5L8 14M4 10.5H13`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1),I(` Logout `,-1)]]),V(`div`,Yi,[V(`div`,{onClick:n[1]||=e=>ue.value=!ue.value,class:`flex items-center gap-2 cursor-pointer group`},[V(`span`,{class:x([`glass-card px-2 py-1 text-xs font-medium rounded border transition-all duration-200`,`border-stroke dark:border-dark-border`,J.value.isDev?`text-secondary bg-secondary-bg/20 dark:bg-secondary-bg/10 border-secondary/40`:`text-content-muted`])},` R:v`+L(J.value.base)+L(J.value.isDev?`.dev${J.value.devNumber}`:``),3),V(`span`,{class:x([`glass-card px-2 py-1 text-xs font-medium rounded border transition-all duration-200`,`border-stroke dark:border-dark-border`,X.value.isDev?`text-secondary bg-secondary-bg/20 dark:bg-secondary-bg/10 border-secondary/40`:`text-content-muted`])},` C:v`+L(X.value.base)+L(X.value.isDev?`.dev${X.value.devNumber}`:``),3),de.value?(K(),G(`svg`,{key:0,class:x([`w-3 h-3 text-content-muted transition-transform duration-200`,ue.value?`rotate-180`:``]),fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[...n[13]||=[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]],2)):A(``,!0)]),ue.value?(K(),G(`div`,Xi,[V(`div`,Zi,[V(`div`,Qi,[n[14]||=V(`span`,{class:`text-content-muted font-medium`},`Repeater:`,-1),V(`span`,$i,`v`+L(J.value.base),1)]),J.value.isDev?(K(),G(`div`,ea,[V(`div`,null,`Dev Build: `+L(J.value.devNumber),1),J.value.commit?(K(),G(`div`,ta,[n[15]||=V(`span`,null,`Commit:`,-1),V(`code`,na,L(J.value.commit),1)])):A(``,!0)])):A(``,!0)]),n[18]||=V(`div`,{class:`border-t border-stroke-subtle dark:border-stroke/20`},null,-1),V(`div`,ra,[V(`div`,ia,[n[16]||=V(`span`,{class:`text-content-muted font-medium`},`Core:`,-1),V(`span`,aa,`v`+L(X.value.base),1)]),X.value.isDev?(K(),G(`div`,oa,[V(`div`,null,`Dev Build: `+L(X.value.devNumber),1),X.value.commit?(K(),G(`div`,sa,[n[17]||=V(`span`,null,`Commit:`,-1),V(`code`,ca,L(X.value.commit),1)])):A(``,!0)])):A(``,!0)])])):A(``,!0)]),n[21]||=V(`div`,{class:`border-t border-accent-green mb-4`},null,-1),s(p).dutyCycleEnabled?(K(),G(`div`,la,[V(`p`,ua,[n[19]||=I(` Duty Cycle: `,-1),V(`span`,da,L(s(p).dutyCycleUtilization.toFixed(1))+`% / `+L(s(p).dutyCycleMax.toFixed(1))+`%`,1)]),V(`div`,fa,[V(`div`,{class:`h-full rounded-full transition-all duration-300`,style:w(he.value)},null,4)])])):A(``,!0),V(`p`,pa,`Last Updated: `+L(ce.value),1),n[22]||=V(`div`,{class:`flex flex-col items-center justify-center mt-4`},[V(`p`,{class:`text-content-muted text-[10px] mb-1 tracking-wide uppercase opacity-70`},` Powered by `),V(`img`,{src:`/assets/meshcore-DQNtEl5I.svg`,alt:`MeshCore`,class:`h-4 opacity-70 dark:invert-0 invert`})],-1)])],2)],2),M(In,{isOpen:_.value,isLoading:m.value,isSuccess:y.value,error:b.value,onClose:re,onSend:W},null,8,[`isOpen`,`isLoading`,`isSuccess`,`error`])],64))}}),ha=[`aria-label`,`title`],ga={key:0,xmlns:`http://www.w3.org/2000/svg`,class:`w-5 h-5 text-yellow-600 dark:text-yellow-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},_a={key:1,xmlns:`http://www.w3.org/2000/svg`,class:`w-5 h-5 text-content-secondary dark:text-content`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},va=T({__name:`ThemeToggle`,setup(e){let{theme:t,toggleTheme:n}=_e();return(e,r)=>(K(),G(`button`,{onClick:r[0]||=(...e)=>s(n)&&s(n)(...e),class:`w-[35px] h-[35px] rounded bg-background-mute dark:bg-surface-elevated flex items-center justify-center hover:bg-stroke-subtle dark:hover:bg-stroke/30 transition-colors`,"aria-label":s(t)===`dark`?`Switch to light mode`:`Switch to dark mode`,title:s(t)===`dark`?`Switch to light mode`:`Switch to dark mode`},[s(t)===`dark`?(K(),G(`svg`,ga,[...r[1]||=[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`},null,-1)]])):(K(),G(`svg`,_a,[...r[2]||=[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z`},null,-1)]]))],8,ha))}}),ya={class:`flex items-center justify-between p-6 pb-0 shrink-0`},ba={class:`p-6 space-y-5 overflow-y-auto flex-1`},xa={class:`grid grid-cols-2 gap-3`},Sa={class:`bg-background-mute dark:bg-background-mute rounded-xl p-3 border border-stroke-subtle dark:border-stroke/10`},Ca={class:`text-sm font-mono font-medium text-content-primary dark:text-content-primary`},wa={key:0,class:`flex items-center gap-1.5 mt-1`},Ta={key:0,class:`flex items-start gap-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/30 rounded-xl p-3`},Ea={class:`text-xs text-amber-800 dark:text-amber-300`},Da={class:`font-mono font-semibold`},Oa={key:1,class:`flex items-center gap-2 bg-green-50 dark:bg-surface border border-green-200 dark:border-accent-green/30 border-l-2 border-l-green-600 dark:border-l-accent-green rounded-xl p-3 text-sm text-green-800 dark:text-content-primary`},ka={key:2,class:`space-y-1`},Aa={class:`flex items-center gap-1`},ja={key:0,class:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin inline-block`},Ma={key:1,class:`text-content-muted`},Na={key:0,class:`bg-background-mute dark:bg-black/30 rounded-xl border border-stroke-subtle dark:border-stroke/10 overflow-hidden`},Pa={class:`max-h-52 overflow-y-auto divide-y divide-stroke-subtle dark:divide-stroke/10`},Fa=[`href`],Ia={class:`font-mono text-[10px] text-content-muted shrink-0 mt-0.5 pt-px`},La={class:`min-w-0 flex-1`},Ra={class:`text-xs text-content-primary truncate group-hover:text-primary transition-colors`},za={class:`text-[10px] text-content-muted mt-0.5`},Ba={class:`space-y-2`},Va={class:`flex gap-2`},Ha=[`disabled`],Ua=[`value`],Wa=[`disabled`],Ga={key:0,class:`text-xs text-accent-green`},Ka={key:1,class:`text-xs text-accent-red`},qa={key:3,class:`space-y-2`},Ja={class:`flex items-center justify-between`},Ya={key:0,class:`flex items-center gap-1 text-xs text-primary`},Xa={key:1,class:`flex items-center gap-1 text-xs text-primary`},Za={key:2,class:`flex items-center gap-1 text-xs text-yellow-500`},Qa={key:3,class:`text-xs text-accent-green font-medium`},$a={key:4,class:`text-xs text-accent-red font-medium`},eo={key:0,class:`w-2 h-4 bg-green-400 animate-pulse inline-block ml-1`},to={key:1,class:`flex items-center gap-2 mt-2 text-primary`},no={key:2,class:`flex items-center gap-2 mt-2 text-yellow-400`},ro={key:3,class:`text-content-muted animate-pulse`},io={key:0,class:`text-xs text-accent-red`},ao={key:4,class:`flex items-center gap-3 bg-primary/5 dark:bg-primary/10 border border-primary/20 rounded-xl p-3 text-sm text-primary`},oo={key:5},so={class:`flex items-center gap-3 bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-200 dark:border-yellow-500/30 rounded-xl p-3 text-sm text-yellow-800 dark:text-yellow-400`},co={class:`font-medium`},lo={class:`text-xs opacity-70 mt-0.5`},uo={key:6,class:`bg-green-50 dark:bg-surface-elevated border border-green-200 dark:border-accent-green/40 rounded-xl p-4`},fo={class:`flex items-center gap-3`},po={class:`text-xs text-gray-600 dark:text-content-muted mt-0.5`},mo={class:`font-mono font-semibold`},ho={key:7,class:`bg-red-50 dark:bg-accent-red/10 border border-accent-red/40 rounded-xl p-4 space-y-3`},go={class:`flex items-center gap-3`},_o={class:`flex-1 min-w-0`},vo={class:`text-xs text-accent-red/80 mt-0.5`},yo={key:0,class:`grid grid-cols-2 gap-2 text-xs`},bo={class:`bg-white/50 dark:bg-black/20 rounded-lg px-3 py-2`},xo={class:`font-mono font-semibold text-content-primary`},So={class:`bg-white/50 dark:bg-black/20 rounded-lg px-3 py-2`},Co={class:`font-mono font-semibold text-accent-red`},wo={class:`p-6 pt-0 flex items-center gap-3 shrink-0`},To=[`disabled`],Eo={key:0,class:`flex items-center justify-center gap-2`},Do={key:1,class:`flex items-center justify-center gap-2`},Oo={key:2},ko=T({__name:`UpdateModal`,props:{show:{type:Boolean},currentVersion:{default:``},latestVersion:{default:``},hasUpdate:{type:Boolean,default:!1},rateLimitUntil:{default:null}},emits:[`close`,`installed`,`version-updated`],setup(e,{emit:t}){let r=e,a=t,o=q(r.currentVersion),s=q(r.latestVersion),c=q(r.hasUpdate);k(()=>r.currentVersion,e=>{o.value=e}),k(()=>r.latestVersion,e=>{s.value=e}),k(()=>r.hasUpdate,e=>{c.value=e});let l=q([`main`]),u=q(`main`),d=q(``),f=q(``),p=q(!1),m=q(!1),h=q([]),g=q(!1),_=q(!0),y=q(`idle`),b=q(null),S=q([]),C=q(null),w=q(!1),T=q(null),E=q(null),O=null,j=q(!1),M=null,te=P(()=>y.value===`idle`||y.value===`error`||y.value===`verify-failed`),ne=P(()=>{switch(y.value){case`installing`:return`Installing…`;case`restarting`:return`Restarting…`;case`verified`:return`Installed ✓`;case`verify-failed`:return`Retry Install`;case`complete`:return`Installed ✓`;case`error`:return`Retry Install`;default:return c.value?`Install Update`:`Force Reinstall`}});function N(){C.value&&(C.value.scrollTop=C.value.scrollHeight)}function F(e){S.value.push(e),S.value.length>500&&S.value.splice(0,S.value.length-500),setTimeout(N,20)}function R(){O&&=(O.close(),null)}async function B(){g.value=!0,h.value=[];try{let e=await Y.get(`/update/changelog`);e.success&&Array.isArray(e.commits)&&(h.value=e.commits)}catch{}finally{g.value=!1}}async function H(){p.value=!0,f.value=``;try{let e=await Y.get(`/update/channels`);e.success&&Array.isArray(e.channels)&&(l.value=e.channels,u.value=e.current_channel??`main`)}catch{l.value=[`main`],f.value=`Could not load channels from GitHub`}finally{p.value=!1}}async function U(){if(u.value){d.value=``,f.value=``;try{let e=await Y.post(`/update/set_channel`,{channel:u.value});if(!e.success){f.value=e.error??`Failed to set channel`;return}d.value=`Switched to '${u.value}' — checking version…`,y.value=`idle`,b.value=null,S.value=[],m.value=!0,s.value=``,c.value=!1;try{await Y.post(`/update/check`);for(let e=0;e<24;e++){let e=await Y.get(`/update/status`);if(e.success&&e.state!==`checking`){o.value=e.current_version??o.value,s.value=e.latest_version??``,c.value=!!e.has_update,d.value=`Switched to '${u.value}'`,a(`version-updated`,{currentVersion:o.value,latestVersion:s.value,hasUpdate:c.value}),B();break}await new Promise(e=>setTimeout(e,500))}}catch{d.value=`Switched to '${u.value}' (version check failed)`}finally{m.value=!1}}catch(e){f.value=e?.message??`Failed to set channel`}}}async function W(){if(!te.value)return;y.value=`installing`,b.value=null,S.value=[];try{let e=await Y.post(`/update/install`,{force:!c.value});if(!e.success){y.value=`error`,b.value=e.error??`Failed to start install`;return}}catch(e){y.value=`error`,b.value=e?.message??`Network error`;return}R();let e=ue(),t=e?`/api/update/progress?token=${encodeURIComponent(e)}`:`/api/update/progress`;O=new EventSource(t),O.onmessage=e=>{try{let t=JSON.parse(e.data);switch(t.type){case`line`:{let e=t.line??``;F(e),e.includes(`Restarting service`)&&(j.value=!0,M||=setTimeout(()=>{M=null,(y.value===`installing`||y.value===`complete`)&&(R(),y.value=`restarting`,F(`[pyMC updater] Service is restarting — waiting for it to come back…`),re())},8e3));break}case`status`:t.state===`error`?y.value=`error`:t.state===`complete`&&(j.value=!0,y.value=`complete`);break;case`done`:R(),M&&=(clearTimeout(M),null),t.state===`complete`?(y.value=`restarting`,re()):(y.value=`error`,t.error&&(b.value=t.error));break}}catch{}},O.onerror=()=>{if(R(),M&&=(clearTimeout(M),null),j.value&&y.value!==`error`){y.value=`restarting`,F(`[pyMC updater] Connection lost — waiting for service restart…`),re();return}y.value===`installing`&&(y.value=`error`,b.value=`Progress stream disconnected`)}}async function re(){let e=s.value;E.value=`going-down`;let t=Date.now()+2e4,n=!1;for(;Date.now()setTimeout(e,1e3));try{await Y.get(`/update/status`)}catch{n=!0;break}}n||F(`[pyMC updater] Service did not appear to stop — assuming fast restart`),E.value=`coming-up`;let r=Date.now()+6e4;for(;Date.now()setTimeout(e,2e3));try{let t=await Y.get(`/update/status`);if(!t?.success)continue;E.value=`verifying`,await new Promise(e=>setTimeout(e,1200));let n=t.current_version??``;T.value=n,o.value=n||o.value,a(`version-updated`,{currentVersion:o.value,latestVersion:s.value,hasUpdate:!!t.has_update}),n&&e&&n===e?(y.value=`verified`,c.value=!1,E.value=null,a(`installed`)):(y.value=`verify-failed`,E.value=null);return}catch{}}y.value=`verify-failed`,E.value=null,b.value=`Service did not respond after restart — check logs`}k(()=>r.show,e=>{e?(y.value=`idle`,b.value=null,S.value=[],w.value=!1,T.value=null,E.value=null,j.value=!1,M&&=(clearTimeout(M),null),d.value=``,f.value=``,o.value=r.currentVersion,s.value=r.latestVersion,c.value=r.hasUpdate,H(),B()):R()}),n(()=>{R(),M&&=(clearTimeout(M),null)});function ie(e){e.target===e.currentTarget&&y.value!==`installing`&&y.value!==`restarting`&&a(`close`)}function ae(){window.location.reload()}return(e,t)=>(K(),v(D,{to:`body`},[r.show?(K(),G(`div`,{key:0,class:`fixed inset-0 bg-black/50 backdrop-blur-sm z-[99999] flex items-center justify-center p-4`,onClick:ie},[V(`div`,{class:`bg-white dark:bg-surface-elevated rounded-[20px] w-full max-w-lg border border-stroke-subtle dark:border-white/10 shadow-2xl flex flex-col max-h-[90vh]`,onClick:t[5]||=It(()=>{},[`stop`])},[V(`div`,ya,[t[7]||=V(`div`,{class:`flex items-center gap-3`},[V(`div`,{class:`w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center`},[V(`svg`,{class:`w-5 h-5 text-primary`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12`})])]),V(`div`,null,[V(`h3`,{class:`text-lg font-semibold text-content-primary dark:text-content-primary`},` OTA Update `),V(`p`,{class:`text-xs text-content-muted dark:text-content-muted`},` Update over the air from GitHub `)])],-1),y.value!==`installing`&&y.value!==`restarting`?(K(),G(`button`,{key:0,onClick:t[0]||=e=>a(`close`),class:`text-content-secondary hover:text-content-primary transition-colors`},[...t[6]||=[V(`svg`,{class:`w-6 h-6`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])):A(``,!0)]),V(`div`,ba,[V(`div`,xa,[V(`div`,Sa,[t[8]||=V(`p`,{class:`text-xs text-content-muted mb-1`},`Installed`,-1),V(`p`,Ca,L(o.value||`—`),1)]),V(`div`,{class:x([`bg-background-mute dark:bg-background-mute rounded-xl p-3 border border-stroke-subtle dark:border-stroke/10`,c.value?`border-l-2 border-l-accent-red`:`border-l-2 border-l-accent-green`])},[t[10]||=V(`p`,{class:`text-xs text-content-muted mb-1`},`On GitHub`,-1),m.value?(K(),G(`div`,wa,[...t[9]||=[V(`span`,{class:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin inline-block`},null,-1),V(`span`,{class:`text-xs text-content-muted`},`Checking…`,-1)]])):(K(),G(`p`,{key:1,class:x([`text-sm font-mono font-medium`,c.value?`text-accent-red`:`text-accent-green`])},L(s.value||`—`),3))],2)]),r.rateLimitUntil?(K(),G(`div`,Ta,[t[14]||=V(`svg`,{class:`w-4 h-4 shrink-0 mt-0.5 text-amber-600 dark:text-amber-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})],-1),V(`div`,Ea,[t[13]||=V(`p`,{class:`font-semibold mb-0.5`},`GitHub API rate limit reached`,-1),V(`p`,null,[t[11]||=I(` Version checks are paused until `,-1),V(`span`,Da,L(new Date(r.rateLimitUntil).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})),1),t[12]||=I(`. This is a GitHub limit, not a software issue. You can still install or switch channels manually. `,-1)])])])):A(``,!0),!c.value&&o.value&&!m.value?(K(),G(`div`,Oa,[...t[15]||=[V(`svg`,{class:`w-4 h-4 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 13l4 4L19 7`})],-1),I(` You are up to date. Use `,-1),V(`em`,{class:`mx-1`},`Force Reinstall`,-1),I(` to reinstall anyway. `,-1)]])):A(``,!0),h.value.length>0||g.value?(K(),G(`div`,ka,[V(`button`,{onClick:t[1]||=e=>_.value=!_.value,class:`flex items-center justify-between w-full text-xs font-medium text-content-secondary dark:text-content-secondary uppercase tracking-wide py-1 hover:text-content-primary transition-colors`},[t[17]||=V(`span`,null,`What's New`,-1),V(`span`,Aa,[g.value?(K(),G(`span`,ja)):(K(),G(`span`,Ma,L(h.value.length)+` commit`+L(h.value.length===1?``:`s`),1)),(K(),G(`svg`,{class:x([`w-3.5 h-3.5 text-content-muted transition-transform`,_.value?`rotate-180`:``]),viewBox:`0 0 20 20`,fill:`currentColor`},[...t[16]||=[V(`path`,{"fill-rule":`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,"clip-rule":`evenodd`},null,-1)]],2))])]),_.value?(K(),G(`div`,Na,[V(`div`,Pa,[(K(!0),G(z,null,i(h.value,e=>(K(),G(`a`,{key:e.sha,href:e.url,target:`_blank`,class:`flex gap-3 px-3 py-2.5 hover:bg-background-soft dark:hover:bg-surface/50 transition-colors group`},[V(`span`,Ia,L(e.short_sha),1),V(`div`,La,[V(`p`,Ra,L(e.title),1),V(`p`,za,L(e.author)+` · `+L(e.date?new Date(e.date).toLocaleDateString():``),1)]),t[18]||=V(`svg`,{class:`w-3 h-3 text-content-muted shrink-0 mt-1 opacity-0 group-hover:opacity-100 transition-opacity`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14`})],-1)],8,Fa))),128))])])):A(``,!0)])):A(``,!0),V(`div`,Ba,[t[19]||=V(`label`,{class:`text-xs font-medium text-content-secondary dark:text-content-secondary uppercase tracking-wide`},` Release Channel `,-1),V(`div`,Va,[ee(V(`select`,{"onUpdate:modelValue":t[2]||=e=>u.value=e,disabled:p.value||y.value===`installing`||m.value,class:`flex-1 bg-background-mute dark:bg-surface border border-stroke-subtle dark:border-stroke/20 rounded-xl px-3 py-2 text-sm text-content-primary dark:text-content-primary disabled:opacity-50 focus:outline-none focus:ring-1 focus:ring-primary`},[(K(!0),G(z,null,i(l.value,e=>(K(),G(`option`,{key:e,value:e},L(e),9,Ua))),128))],8,Ha),[[At,u.value]]),V(`button`,{onClick:U,disabled:p.value||y.value===`installing`||m.value,class:`px-4 py-2 bg-primary/10 hover:bg-primary/20 text-primary rounded-xl text-sm font-medium disabled:opacity-50 transition-colors`},L(p.value||m.value?`…`:`Apply`),9,Wa)]),d.value?(K(),G(`p`,Ga,L(d.value),1)):A(``,!0),f.value?(K(),G(`p`,Ka,L(f.value),1)):A(``,!0),t[20]||=V(`p`,{class:`text-xs text-content-muted`},[V(`em`,null,`main`),I(` = stable releases \xA0|\xA0 `),V(`em`,null,`dev`),I(` = latest commits (may be unstable) `)],-1)]),y.value===`installing`||y.value===`restarting`||S.value.length>0&&(w.value||y.value===`error`)?(K(),G(`div`,qa,[V(`div`,Ja,[t[24]||=V(`label`,{class:`text-xs font-medium text-content-secondary uppercase tracking-wide`},`Install Log`,-1),y.value===`installing`?(K(),G(`span`,Ya,[...t[21]||=[V(`span`,{class:`inline-block w-2 h-2 rounded-full bg-primary animate-pulse`},null,-1),I(` Running… `,-1)]])):y.value===`restarting`&&E.value===`verifying`?(K(),G(`span`,Xa,[...t[22]||=[V(`span`,{class:`inline-block w-2 h-2 rounded-full bg-primary animate-pulse`},null,-1),I(` Checking version… `,-1)]])):y.value===`restarting`?(K(),G(`span`,Za,[t[23]||=V(`span`,{class:`inline-block w-2 h-2 rounded-full bg-yellow-500 animate-pulse`},null,-1),I(` `+L(E.value===`going-down`?`Stopping service…`:`Waiting for service…`),1)])):y.value===`verified`?(K(),G(`span`,Qa,`Complete ✓`)):y.value===`verify-failed`||y.value===`error`?(K(),G(`span`,$a,`Failed ✗`)):A(``,!0)]),V(`div`,{ref_key:`logContainer`,ref:C,class:`bg-zinc-900 dark:bg-black/60 rounded-xl p-3 h-52 overflow-y-auto font-mono text-xs text-green-400 leading-relaxed border border-stroke/20`},[(K(!0),G(z,null,i(S.value,(e,t)=>(K(),G(`div`,{key:t,class:x([`whitespace-pre-wrap break-all`,{"text-accent-red":e.includes(`✗`)||e.includes(`error`)||e.includes(`ERROR`)||e.includes(`Failed`),"text-yellow-400":e.includes(`WARNING`)||e.includes(`⚠`),"text-accent-green":e.includes(`✓`)||e.includes(`Successfully`),"text-content-muted/60":e.includes(`keepalive`)}])},L(e),3))),128)),y.value===`installing`?(K(),G(`div`,eo)):A(``,!0),y.value===`restarting`&&E.value===`verifying`?(K(),G(`div`,to,[...t[25]||=[V(`span`,{class:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin inline-block`},null,-1),I(` Service is back — verifying version… `,-1)]])):y.value===`restarting`?(K(),G(`div`,no,[t[26]||=V(`span`,{class:`w-3 h-3 border-2 border-yellow-400 border-t-transparent rounded-full animate-spin inline-block`},null,-1),I(` `+L(E.value===`going-down`?`Waiting for service to stop…`:`Waiting for service to come back up…`),1)])):A(``,!0),S.value.length===0&&y.value===`installing`?(K(),G(`div`,ro,` Waiting for output… `)):A(``,!0)],512),b.value?(K(),G(`p`,io,L(b.value),1)):A(``,!0)])):A(``,!0),y.value===`restarting`&&E.value===`verifying`?(K(),G(`div`,ao,[...t[27]||=[V(`span`,{class:`w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`},null,-1),V(`div`,null,[V(`p`,{class:`font-medium`},`Checking version…`),V(`p`,{class:`text-xs opacity-70 mt-0.5`},` Confirming the installed version matches the target `)],-1)]])):y.value===`restarting`&&S.value.length===0?(K(),G(`div`,oo,[V(`div`,so,[t[28]||=V(`span`,{class:`w-4 h-4 border-2 border-yellow-500 border-t-transparent rounded-full animate-spin shrink-0`},null,-1),V(`div`,null,[V(`p`,co,L(E.value===`going-down`?`Stopping service…`:`Starting service…`),1),V(`p`,lo,L(E.value===`going-down`?`Waiting for the old process to exit`:`Waiting for the service to become healthy`),1)])])])):A(``,!0),y.value===`verified`?(K(),G(`div`,uo,[V(`div`,fo,[t[31]||=V(`div`,{class:`w-9 h-9 rounded-full bg-accent-green flex items-center justify-center shrink-0`},[V(`svg`,{class:`w-5 h-5 text-white`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`})])],-1),V(`div`,null,[t[30]||=V(`p`,{class:`font-semibold text-gray-900 dark:text-content-primary`},` Installed successfully! `,-1),V(`p`,po,[t[29]||=I(` Running version `,-1),V(`span`,mo,L(T.value),1)])])]),V(`button`,{onClick:ae,class:`mt-3 w-full py-2 px-4 rounded-xl text-sm font-semibold text-white bg-primary hover:bg-primary/90 transition-colors`},` Refresh Page to Load New Version `)])):A(``,!0),y.value===`verify-failed`?(K(),G(`div`,ho,[V(`div`,go,[t[33]||=V(`div`,{class:`w-9 h-9 rounded-full bg-accent-red/15 flex items-center justify-center shrink-0`},[V(`svg`,{class:`w-5 h-5 text-accent-red`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[V(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M6 18L18 6M6 6l12 12`})])],-1),V(`div`,_o,[t[32]||=V(`p`,{class:`font-semibold text-accent-red`},`Installation may have failed`,-1),V(`p`,vo,L(b.value||`Version mismatch after restart`),1)])]),T.value||s.value?(K(),G(`div`,yo,[V(`div`,bo,[t[34]||=V(`p`,{class:`text-content-muted mb-0.5`},`Expected`,-1),V(`p`,xo,L(s.value||`—`),1)]),V(`div`,So,[t[35]||=V(`p`,{class:`text-content-muted mb-0.5`},`Reported`,-1),V(`p`,Co,L(T.value||`unknown`),1)])])):A(``,!0),S.value.length>0?(K(),G(`button`,{key:1,onClick:t[3]||=e=>w.value=!w.value,class:`w-full text-xs text-accent-red/70 hover:text-accent-red underline underline-offset-2 hover:no-underline transition-all`},L(w.value?`Hide install log`:`View install log`),1)):A(``,!0)])):A(``,!0)]),V(`div`,wo,[V(`button`,{onClick:W,disabled:!te.value,class:x([`flex-1 py-3 rounded-xl font-semibold text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,y.value===`verified`||y.value===`complete`?`bg-accent-green/20 text-accent-green cursor-default`:y.value===`error`||y.value===`verify-failed`?`bg-accent-red hover:bg-accent-red/80 text-white`:y.value===`restarting`?`bg-yellow-500/20 text-yellow-600 cursor-default`:`bg-primary hover:bg-primary/80 text-white`])},[y.value===`installing`?(K(),G(`span`,Eo,[...t[36]||=[V(`span`,{class:`w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin`},null,-1),I(` Installing… `,-1)]])):y.value===`restarting`?(K(),G(`span`,Do,[...t[37]||=[V(`span`,{class:`w-4 h-4 border-2 border-yellow-600 border-t-transparent rounded-full animate-spin`},null,-1),I(` Restarting service… `,-1)]])):(K(),G(`span`,Oo,L(ne.value),1))],10,To),y.value!==`installing`&&y.value!==`restarting`?(K(),G(`button`,{key:0,onClick:t[4]||=e=>a(`close`),class:`px-6 py-3 rounded-xl border border-stroke-subtle dark:border-stroke/20 text-content-secondary hover:text-content-primary hover:bg-background-mute transition-colors text-sm`},` Close `)):A(``,!0)])])])):A(``,!0)]))}}),Ao={class:`glass-card p-3 sm:p-6 mb-5 rounded-[20px] relative z-10`},jo={class:`flex justify-between items-center`},Mo={class:`flex items-center gap-3`},No={class:`hidden sm:block`},Po={class:`text-content-primary dark:text-content-primary text-2xl lg:text-[35px] font-bold mb-1 sm:mb-2`},Fo={class:`flex items-center gap-3 sm:gap-4`},Io={class:`text-right`,style:{"min-width":`180px`}},Lo={key:0,class:`flex items-center gap-2 justify-end`},Ro={key:1,class:`space-y-1`},zo={class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},Bo={class:`text-primary font-medium`},Vo={key:0,class:`text-xs text-content-muted dark:text-content-muted/80`,style:{"min-height":`16px`}},Ho={key:0},Uo={key:2},Wo={key:0,class:`text-xs text-content-muted dark:text-content-muted/60 hidden sm:block`,style:{"min-height":`16px`}},Go={key:0,class:`absolute right-0 top-10 z-[100] w-48 bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-xl shadow-2xl overflow-hidden`},Ko=[`disabled`],qo={key:0,class:`w-4 h-4 text-content-secondary`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,xmlns:`http://www.w3.org/2000/svg`},Jo={key:1,class:`animate-spin rounded-full h-4 w-4 border-b-2 border-primary`},Yo={class:`flex items-center justify-between mb-3`},Xo={class:`flex items-center gap-2`},Zo=[`disabled`],Qo=[`disabled`],$o={class:`space-y-3 text-sm`},es={key:0,class:`bg-red-50 dark:bg-background-mute p-3 rounded-lg border border-accent-red/30 border-l-2 border-l-accent-red`},ts={class:`flex items-center justify-between`},ns={class:`text-accent-red font-bold`},rs={class:`text-xs text-content-muted dark:text-content-muted mt-1`},is={class:`mt-2 flex items-center gap-2`},as=[`disabled`],os={key:1,class:`flex items-start gap-2 bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/30 border-l-2 border-l-amber-500 rounded-lg p-3 text-xs text-amber-800 dark:text-amber-300`},ss={key:2,class:`bg-green-50 dark:bg-background-mute p-3 rounded-lg border border-stroke-subtle dark:border-stroke/10 border-l-2 border-l-accent-green`},cs={class:`flex items-center justify-between`},ls={class:`text-accent-green font-bold`},us={key:0,class:`text-xs text-content-muted dark:text-content-muted mt-1`},ds={class:`mt-2 flex items-center gap-2`},fs=[`disabled`],ps={key:3,class:`bg-background-mute dark:bg-background-mute p-3 rounded-lg border border-stroke-subtle dark:border-stroke/10`},ms={key:4,class:`bg-red-50 dark:bg-background-mute p-3 rounded-lg border border-accent-red/30 border-l-2 border-l-accent-red`},hs={class:`text-xs text-content-secondary dark:text-content-muted`},gs={class:`bg-background-mute dark:bg-background-mute p-3 rounded-lg border border-stroke-subtle dark:border-stroke/10 border-l-2 border-l-primary`},_s={class:`flex items-center justify-between`},vs={class:`text-primary font-bold`},ys={key:0,class:`text-xs text-content-muted dark:text-content-muted mt-1`},bs={class:`flex items-center justify-between`},xs={class:`text-content-primary dark:text-content-primary font-medium`},Ss={key:0,class:`mt-2`},Cs={class:`text-xs text-content-muted dark:text-content-muted`},ws={class:`text-content-secondary dark:text-content-secondary`},Ts={key:5,class:`bg-background-mute dark:bg-background-mute p-4 rounded-lg border border-stroke-subtle dark:border-stroke/10 text-center`},Es={key:6,class:`bg-background-mute dark:bg-background-mute p-3 rounded-lg border border-stroke-subtle dark:border-stroke/10 text-center`},Ds={key:0,class:`fixed inset-0 z-[9999] bg-black/60 backdrop-blur-sm flex items-center justify-center`},Os={class:`bg-surface dark:bg-surface-elevated rounded-2xl p-8 shadow-2xl max-w-sm w-full mx-4 text-center border border-stroke-subtle dark:border-stroke/20`},ks={key:0,class:`mb-4`},As={key:1,class:`mb-4`},js={class:`text-sm text-content-secondary dark:text-content-muted`},Ms={key:2,class:`mt-4 flex items-center justify-center gap-3`},Ns=Z(T({name:`TopBar`,__name:`TopBar`,emits:[`toggleMobileSidebar`],setup(e,{emit:t}){let n=t;oe();let r=me(),a=J(),o=q(!1),s=q(null),c=q(!1),l=q(!1),d=q(null),f=q(!1),p=q(``),m=q(!1),h=q({hasUpdate:!1,currentVersion:``,latestVersion:``,isChecking:!1,lastChecked:null,error:null,rateLimitUntil:null}),g=q({}),_=q(!0),y=q(null),b=q(fe()||`User`),S=[`Chat Node`,`Repeater`,`Room Server`];function w(e){let t=e.target;s.value&&!s.value.contains(t)&&(o.value=!1),d.value&&!d.value.contains(t)&&(l.value=!1)}let T=async()=>{try{_.value=!0;let e={};for(let t of S)try{let n=await Y.get(`/adverts_by_contact_type?contact_type=${encodeURIComponent(t)}&hours=168`);n.success&&Array.isArray(n.data)?e[t]=n.data:e[t]=[]}catch(n){console.error(`Error fetching ${t} nodes:`,n),e[t]=[]}g.value=e,y.value=new Date}catch(e){console.error(`Error updating tracked nodes:`,e)}finally{_.value=!1}},E=async(e=!1)=>{if(!h.value.isChecking)try{h.value.isChecking=!0,h.value.error=null,await Y.post(`/update/check`,e?{force:!0}:{});for(let e=0;e<20;e++){let e=await Y.get(`/update/status`);if(e.success&&e.state!==`checking`){h.value.currentVersion=e.current_version??``,h.value.latestVersion=e.latest_version??``,h.value.hasUpdate=!!e.has_update,h.value.lastChecked=new Date,h.value.error=e.error??null,h.value.rateLimitUntil=e.rate_limit_until??null;return}await new Promise(e=>setTimeout(e,500))}h.value.error=`Version check timed out`}catch(e){console.error(`Error checking for updates:`,e),h.value.error=e instanceof Error?e.message:`Failed to check for updates`}finally{h.value.isChecking=!1}},O=()=>{o.value=!1,E(),r.fetchStats()},ee=e=>{h.value.currentVersion=e.currentVersion,h.value.latestVersion=e.latestVersion,h.value.hasUpdate=e.hasUpdate,h.value.lastChecked=new Date},k=()=>{a.stopSession(`logout`)},j=async(e=20,t=2e3)=>{for(let n=0;nsetTimeout(e,t))}return!1},te=async()=>{if(!f.value){f.value=!0,m.value=!1,p.value=`Sending restart request...`,l.value=!1;try{let e=await Y.post(`/restart_service`,{});e.success?(p.value=`Service restarting, waiting for it to come back...`,await j()?(p.value=`Service is back! Reloading...`,setTimeout(()=>{window.location.reload()},500)):(p.value=`Service did not respond in time. Try reloading manually.`,m.value=!0)):(p.value=e.error||`Restart request failed`,m.value=!0)}catch(e){e.code===`ERR_NETWORK`||e.message?.includes(`Network error`)||e.response?.status===500||e.message?.includes(`500`)?(p.value=`Service restarting, waiting for it to come back...`,await j()?(p.value=`Service is back! Reloading...`,setTimeout(()=>{window.location.reload()},500)):(p.value=`Service did not respond in time. Try reloading manually.`,m.value=!0)):(p.value=e.message||`Restart request failed`,m.value=!0)}}},ne=()=>{f.value=!1,p.value=``,m.value=!1},N=()=>{window.location.reload()},F=P(()=>Object.values(g.value).reduce((e,t)=>e+t.length,0)),R=P(()=>S.map(e=>({type:e,count:g.value[e]?.length||0})).filter(e=>e.count>0)),B=P(()=>!0),H=e=>({"Chat Node":`text-blue-600 dark:text-blue-400`,Repeater:`text-accent-green`,"Room Server":`text-accent-purple`})[e]||`text-gray-400`,U=e=>{let t=g.value[e]||[];return t.length===0?`None`:t.reduce((e,t)=>t.last_seen>e.last_seen?t:e,t[0]).node_name||`Unknown Node`};u(()=>{document.addEventListener(`click`,w),T(),E()}),ie(()=>{document.removeEventListener(`click`,w)}),qt(T,{intervalMs:3e4,enabled:!0,immediate:!1}),qt(()=>E(),{intervalMs:6e5,enabled:!0,immediate:!1});let W=()=>{n(`toggleMobileSidebar`)};return(e,t)=>(K(),G(z,null,[V(`div`,Ao,[V(`div`,jo,[V(`div`,Mo,[V(`button`,{onClick:W,class:`lg:hidden w-10 h-10 rounded bg-background-mute dark:bg-surface-elevated flex items-center justify-center hover:bg-stroke-subtle dark:hover:bg-stroke/30 transition-colors`},[...t[10]||=[V(`svg`,{class:`w-5 h-5 text-content-secondary dark:text-content-primary`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},[V(`path`,{d:`M3 6h14M3 10h14M3 14h14`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1)]]),V(`div`,No,[V(`h1`,Po,` Hi `+L(b.value)+`👋 `,1)])]),V(`div`,Fo,[V(`div`,Io,[_.value?(K(),G(`div`,Lo,[...t[11]||=[V(`div`,{class:`animate-spin rounded-full h-3 w-3 border-b-2 border-primary`},null,-1),V(`p`,{class:`text-content-secondary dark:text-content-muted text-xs sm:text-sm`},` Loading... `,-1)]])):F.value>0?(K(),G(`div`,Ro,[V(`p`,zo,[t[12]||=I(` Tracking: `,-1),V(`span`,Bo,L(F.value)+` node`+L(F.value===1?``:`s`),1)]),R.value.length>0?(K(),G(`div`,Vo,[(K(!0),G(z,null,i(R.value,(e,t)=>(K(),G(`span`,{key:e.type,class:`inline`},[I(L(e.count)+` `+L(e.type)+L(e.count===1?``:`s`),1),t