from app.core.exceptions import ValidationError
from app.flows.base import BaseFlow
from app.flows.products import ALL_FLOWS

FLOWS: dict[str, BaseFlow] = {flow_class.name: flow_class() for flow_class in ALL_FLOWS}
FLOW_NAMES: tuple[str, ...] = tuple(FLOWS.keys())


def get_flow(name: str) -> BaseFlow:
    flow = FLOWS.get((name or "").strip())
    if not flow:
        raise ValidationError("unknown_flow")
    return flow
