"""StopZone enum and stop-zone → confirm_type mapping (Phase A)."""

from __future__ import annotations

from enum import Enum

from .confirm_type import ConfirmType


class StopZone(str, Enum):
    """Six high-risk stop-zones requiring double confirmation."""

    PUBLISH = "publish"
    MONEY = "money"
    DESTROY = "destroy"
    SECRETS = "secrets"
    SYSTEM = "system"
    LEGAL = "legal"


STOP_ZONE_CONFIRM_TYPE: dict[StopZone, ConfirmType] = {
    StopZone.PUBLISH: ConfirmType.DOUBLE_CONFIRM,
    StopZone.MONEY: ConfirmType.DOUBLE_CONFIRM,
    StopZone.DESTROY: ConfirmType.DOUBLE_CONFIRM,
    StopZone.SECRETS: ConfirmType.DOUBLE_CONFIRM,
    StopZone.SYSTEM: ConfirmType.DOUBLE_CONFIRM,
    StopZone.LEGAL: ConfirmType.DOUBLE_CONFIRM,
}


def confirm_type_for_stop_zone(stop_zone: StopZone | str | None) -> ConfirmType:
    """Map a stop-zone tag to the required confirm type."""
    if stop_zone is None:
        return ConfirmType.NONE
    try:
        zone = stop_zone if isinstance(stop_zone, StopZone) else StopZone(str(stop_zone))
    except ValueError:
        return ConfirmType.NONE
    return STOP_ZONE_CONFIRM_TYPE.get(zone, ConfirmType.NONE)
