"""Curated quote collection used by the TUI throbber."""

from pathlib import Path

_DATA_PATH = Path(__file__).with_name("data").joinpath("throbber_quotes.txt")
_FALLBACK_QUOTES: tuple[str, ...] = (
    "\"I'm sorry, Dave. I'm afraid I can't do that.\" — HAL 9000",
    (
        '"Any sufficiently advanced technology is indistinguishable from magic." '
        "— Arthur C. Clarke"
    ),
    '"Logic is the beginning of wisdom, not the end." — Spock',
)


def _load_quotes() -> tuple[str, ...]:
    """Load the throbber quotes from the data file.

    Falls back to a small default set if the data file cannot be read so the
    widget continues to operate during packaging or test environments.
    """

    try:
        lines = _DATA_PATH.read_text(encoding="utf-8").splitlines()
    except FileNotFoundError:
        return _FALLBACK_QUOTES

    quotes = tuple(line.strip() for line in lines if line.strip())
    if quotes:
        return quotes
    return _FALLBACK_QUOTES


THROBBER_QUOTES: tuple[str, ...] = _load_quotes()


__all__ = ["THROBBER_QUOTES"]
