"""Data files bundled with the proxmox-template-builder package."""

from __future__ import annotations

import os
from pathlib import Path


def get_data_path() -> Path:
    """Return the absolute path to the tui/data/ directory."""
    return Path(__file__).parent


def get_scripts_path() -> Path:
    """Return path to bundled shell scripts."""
    return get_data_path() / "scripts"


def get_config_path() -> Path:
    """Return path to bundled configuration files."""
    return get_data_path() / "config"


def get_packer_path() -> Path:
    """Return path to bundled packer templates."""
    return get_data_path() / "packer"


def get_ansible_path() -> Path:
    """Return path to bundled ansible playbooks."""
    return get_data_path() / "ansible"


def get_cloud_init_path() -> Path:
    """Return path to bundled cloud-init templates."""
    return get_data_path() / "cloud-init"


def get_tests_path() -> Path:
    """Return path to bundled test scripts."""
    return get_data_path() / "tests"


def get_user_config_path() -> Path:
    """Return path to user's external config override directory.

    Resolution order:
        1. $PROXMOX_BUILDER_CONFIG_DIR environment variable
        2. $XDG_CONFIG_HOME/proxmox-template-builder/
        3. ~/.config/proxmox-template-builder/
    """
    env_path = os.environ.get("PROXMOX_BUILDER_CONFIG_DIR")
    if env_path:
        return Path(env_path)
    xdg_config = os.environ.get("XDG_CONFIG_HOME")
    if xdg_config:
        return Path(xdg_config) / "proxmox-template-builder"
    return Path.home() / ".config" / "proxmox-template-builder"
