"""
Example training base profiles — point to default templates and optional dimension filters.

Future: DB-backed training types may reference profile keys; this registry is code-only.
"""

from __future__ import annotations

from typing import Dict, Optional

from data_layer.training_profile.models import TrainingBaseProfile

_PROFILES: Dict[str, TrainingBaseProfile] = {}


def _register(p: TrainingBaseProfile) -> None:
    if p.key in _PROFILES:
        raise ValueError(f"Duplicate training base profile key: {p.key}")
    _PROFILES[p.key] = p


def get_training_base_profile(key: str) -> TrainingBaseProfile:
    if key not in _PROFILES:
        raise KeyError(f"Unknown training base profile: {key}")
    return _PROFILES[key]


def try_get_training_base_profile(key: str) -> Optional[TrainingBaseProfile]:
    return _PROFILES.get(key)


def list_training_base_profile_keys() -> tuple[str, ...]:
    return tuple(sorted(_PROFILES.keys()))


_register(
    TrainingBaseProfile(
        key="scaffold_aerobic_base",
        label="Scaffold: aerobic base profile",
        default_template_id="scaffold_example_aerobic_v1",
        allowed_dimension_keys=None,
    )
)

_register(
    TrainingBaseProfile(
        key="scaffold_strength_base",
        label="Scaffold: strength base profile",
        default_template_id="scaffold_example_strength_v1",
        allowed_dimension_keys=frozenset({"effort"}),
    )
)
