"""Validation helpers for GUI processing mode constraints."""

from __future__ import annotations

from python_app.models.run_config_model import RunConfigModel


def validate_processing_mode_constraints(processing_mode: str, config: RunConfigModel) -> None:
    """Validate mode-specific constraints for current run configuration."""
    if processing_mode != "bscan":
        return

    any_native_switch = config.input_switch.driver_mode == "native" or config.output_switch.driver_mode == "native"
    if not any_native_switch:
        return

    combo_count = len({(int(combo.input), int(combo.output)) for combo in config.combos})
    if combo_count != 1:
        raise RuntimeError(
            f"B-scan with native switches requires exactly one run combo (now {combo_count})"
        )
