"""Primitive types, enums, and constants shared across Filare models."""

from enum import Enum, IntEnum
from typing import Tuple, Union

# Each type alias has its legal values described in comments where used.
PlainText = str  # Text not containing HTML tags nor newlines
Designator = PlainText  # Case insensitive unique name of connector or cable

# Type combinations
Pin = Union[int, PlainText]  # Pin identifier
PinIndex = int  # Zero-based pin index
Wire = Union[int, PlainText]  # Wire number or Literal['s'] for shield
NoneOrMorePins = Union[
    Pin, Tuple[Pin, ...], None
]  # None, one, or a tuple of pin identifiers
NoneOrMorePinIndices = Union[
    PinIndex, Tuple[PinIndex, ...], None
]  # None, one, or a tuple of zero-based pin indices
OneOrMoreWires = Union[Wire, Tuple[Wire, ...]]  # One or a tuple of wires

Side = Enum("Side", "LEFT RIGHT")

AUTOGENERATED_PREFIX = "AUTOGENERATED_"

BomCategory = IntEnum(  # to enforce ordering in BOM
    "BomEntry", "CONNECTOR CABLE WIRE PIN ADDITIONAL BUNDLE"
)
QtyMultiplierConnector = Enum(
    "QtyMultiplierConnector", "PINCOUNT POPULATED CONNECTIONS"
)
QtyMultiplierCable = Enum(
    "QtyMultiplierCable", "WIRECOUNT TERMINATION LENGTH TOTAL_LENGTH"
)

__all__ = [
    "AUTOGENERATED_PREFIX",
    "BomCategory",
    "Designator",
    "NoneOrMorePinIndices",
    "NoneOrMorePins",
    "OneOrMoreWires",
    "Pin",
    "PinIndex",
    "PlainText",
    "QtyMultiplierCable",
    "QtyMultiplierConnector",
    "Side",
    "Wire",
]
