"""Configuration constants for electron-angle-patcher."""

from __future__ import annotations

from pathlib import Path
from typing import ClassVar


class Config:
    """Centralized configuration constants."""

    # Default paths
    DEFAULT_BRAVE_PATH = Path("/Applications/Brave Browser.app")
    DEFAULT_CHROME_PATH = Path("/Applications/Google Chrome.app")
    DEFAULT_LGHUB_PATH = Path("/Applications/lghub.app")

    # Scan directories
    STANDARD_SCAN_DIRS = [
        "~/Library/Application Support",
        "~/Library/Caches",
        "~/Library/Preferences",
        "~/Library/Containers",
        "~/Library/Application Support/Google",
    ]

    # Specific app paths that are often missed by generic scans
    SPECIFIC_APPS: ClassVar[dict[str, Path]] = {
        "Logitech G Hub (Standard)": Path(
            "~/Library/Application Support/lghub/Local State"
        ),
        "Logitech G Hub (Main Container)": Path(
            "~/Library/Containers/com.logitech.g-hub/Data/"
            "Library/Application Support/lghub/Local State"
        ),
        "Logitech G Hub (Helper)": Path(
            "~/Library/Containers/com.logitech.g-hub.peripheral-device-control/Data/"
            "Library/Application Support/lghub/Local State"
        ),
        "Microsoft Teams (Classic)": Path(
            "~/Library/Containers/com.microsoft.teams2/Data/"
            "Library/Application Support/Microsoft/MSTeams/EBWebView/Local State"
        ),
        "Microsoft Teams (New)": Path(
            "~/Library/Containers/com.microsoft.teams2/Data/"
            "Library/Application Support/Microsoft/Teams/EBWebView/Local State"
        ),
        "Microsoft Edge": Path("~/Library/Application Support/Microsoft Edge/Local State"),
    }

    # Directories to skip during scanning
    SKIP_DIRS = frozenset([
        ".Trash",
        "node_modules",
        "Library/Developer",
        "Library/Caches/Homebrew",
        "Library/Logs",
        "Library/Saved Application State",
        "Library/Group Containers",
    ])

    # Generic folder names to exclude when detecting app names
    GENERIC_FOLDER_NAMES = frozenset([
        "EBWebView", "User Data", "Default", "Application Support",
        "Caches", "Local State", "Data",
    ])

    # Network filesystem types to detect
    NETWORK_FS_TYPES = frozenset(["nfs", "smbfs", "afpfs", "cifs", "webdav"])

    # Skip patterns for deep scan (already handled by specific apps)
    DEEP_SCAN_SKIP_PATTERNS = frozenset(["lghub", "MSTeams", "Microsoft Edge"])
    STANDARD_SCAN_SKIP_PATTERNS = frozenset(["lghub", "msteams"])

    # File permissions
    EXECUTABLE_PERMISSIONS = 0o755

    # Wrapper script template
    WRAPPER_TEMPLATE = """#!/bin/bash
DIR="$(cd "$(dirname "$0")" && pwd)"
exec "$DIR/{original_executable}" {args} "$@"
"""
