"""Truthful, deterministic mappings from established upstream semantics."""

from __future__ import annotations

from mountain_twin.analysis_contract import WeatherSourceType
from mountain_twin.history.contracts import EvidenceClass


def evidence_class_for_weather_source_type(
    source_type: WeatherSourceType | str | None,
) -> EvidenceClass:
    """Map only an explicit Weather source type; dates have no bearing here."""
    try:
        resolved = WeatherSourceType(source_type) if source_type is not None else None
    except ValueError:
        resolved = None
    return {
        WeatherSourceType.HISTORICAL_FORECAST: EvidenceClass.HISTORICAL_FORECAST,
        WeatherSourceType.FORECAST: EvidenceClass.FORECAST,
        WeatherSourceType.OBSERVATION: EvidenceClass.OBSERVED,
        WeatherSourceType.REANALYSIS: EvidenceClass.REANALYSIS,
    }.get(resolved, EvidenceClass.UNKNOWN)


def evidence_class_for_deterministic_astronomy() -> EvidenceClass:
    """Return the explicit class for established solar-astronomy output."""
    return EvidenceClass.DETERMINISTIC_ASTRONOMY


def evidence_class_for_terrain_derived() -> EvidenceClass:
    """Return the explicit class for established terrain-derived light/shadow."""
    return EvidenceClass.TERRAIN_DERIVED
