import uuid

from sqlmodel import Field, SQLModel


class ChairSide:
    """Allowed chair side positions."""

    TOP = "top"
    BOTTOM = "bottom"
    LEFT = "left"
    RIGHT = "right"
    AROUND = "around"


class ChairBase(SQLModel):
    slot_index: int = Field(ge=0, nullable=False)
    side: str = Field(nullable=False)
    enabled: bool = Field(default=True, nullable=False)


class Chair(ChairBase, table=True):
    __tablename__ = "chair"  # pyright: ignore[reportAssignmentType]

    id: str = Field(
        default_factory=lambda: str(uuid.uuid4()),
        primary_key=True,
    )
    table_id: str = Field(
        foreign_key="floor_table.id",
        index=True,
        nullable=False,
    )
    restaurant_id: str = Field(foreign_key="restaurant.id", index=True, nullable=False)


class ChairRead(ChairBase):
    id: str
    table_id: str


class ChairUpdate(SQLModel):
    """Partial update — only ``enabled`` can be toggled."""

    enabled: bool
