# retoor <retoor@molodetz.nl>

from __future__ import annotations

PHASE_PLANNING = "planning"
PHASE_SEARCHING = "searching"
PHASE_CRAWLING = "crawling"
PHASE_INDEXING = "indexing"
PHASE_ANALYSIS = "analysis"
PHASE_SYNTHESIS = "synthesis"

PHASE_ORDER: list[str] = [
    PHASE_PLANNING,
    PHASE_SEARCHING,
    PHASE_CRAWLING,
    PHASE_INDEXING,
    PHASE_ANALYSIS,
    PHASE_SYNTHESIS,
]

PHASE_LABELS: dict[str, str] = {
    PHASE_PLANNING: "Planning",
    PHASE_SEARCHING: "Searching",
    PHASE_CRAWLING: "Crawling",
    PHASE_INDEXING: "Indexing",
    PHASE_ANALYSIS: "Analysis",
    PHASE_SYNTHESIS: "Synthesis",
}

TOTAL_PHASES = len(PHASE_ORDER)
HEARTBEAT_SECONDS = 2.0


def phase_index(phase: str) -> int:
    try:
        return PHASE_ORDER.index(phase)
    except ValueError:
        return 0
