from __future__ import annotations

from typing import Any, Callable

BACKENDS: dict[str, type] = {}
SURROGATES: dict[str, type] = {}
ACQUISITIONS: dict[str, type] = {}


def register_backend(name: str, cls: type) -> None:
    BACKENDS[name.lower()] = cls


def register_surrogate(name: str, cls: type) -> None:
    SURROGATES[name.lower()] = cls


def register_acquisition(name: str, cls: type) -> None:
    ACQUISITIONS[name.lower()] = cls


def get_backend(name: str) -> type:
    key = name.lower()
    if key not in BACKENDS:
        raise ValueError(f"Unknown backend/model [{name}]. Available: {sorted(BACKENDS)}")
    return BACKENDS[key]


def get_surrogate(name: str) -> type:
    key = name.lower()
    if key not in SURROGATES:
        raise ValueError(f"Unknown surrogate [{name}]. Available: {sorted(SURROGATES)}")
    return SURROGATES[key]


def get_acquisition(name: str) -> type:
    key = name.lower()
    if key not in ACQUISITIONS:
        raise ValueError(f"Unknown acquisition [{name}]. Available: {sorted(ACQUISITIONS)}")
    return ACQUISITIONS[key]
