from __future__ import annotations

from datetime import date

from sqlalchemy import Boolean, Date, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from .base import Base


class Tournament(Base):
    """SQLAlchemy ORM model for Tournaments"""

    __tablename__ = "Tournaments"

    # Primary Key
    OverviewPage: Mapped[str] = mapped_column(String, primary_key=True)

    # Basic Information
    Name: Mapped[str | None] = mapped_column(String, default=None)
    StandardName: Mapped[str | None] = mapped_column(String, default=None)
    StandardName_Redirect: Mapped[str | None] = mapped_column(String, default=None)
    BasePage: Mapped[str | None] = mapped_column(String, default=None)

    # Date Information
    DateStart: Mapped[date | None] = mapped_column(Date, default=None)
    Date: Mapped[date | None] = mapped_column(Date, default=None)
    DateStartFuzzy: Mapped[date | None] = mapped_column(default=None)
    Year: Mapped[str | None] = mapped_column(String, default=None)

    # League/Competition Information
    League: Mapped[str | None] = mapped_column(String, default=None)
    LeagueIconKey: Mapped[str | None] = mapped_column(String, default=None)
    Split: Mapped[str | None] = mapped_column(String, default=None)
    SplitNumber: Mapped[int | None] = mapped_column(Integer, default=None)
    SplitMainPage: Mapped[str | None] = mapped_column(String, default=None)
    TournamentLevel: Mapped[str | None] = mapped_column(String, default=None)

    # Location Information
    Region: Mapped[str | None] = mapped_column(String, default=None)
    Country: Mapped[str | None] = mapped_column(String, default=None)
    ClosestTimezone: Mapped[str | None] = mapped_column(String, default=None)

    # Financial Information
    Prizepool: Mapped[str | None] = mapped_column(String, default=None)
    Currency: Mapped[str | None] = mapped_column(String, default=None)

    # Organization Information
    Organizer: Mapped[str | None] = mapped_column(String, default=None)
    Organizers: Mapped[str | None] = mapped_column(Text, default=None)
    Sponsors: Mapped[str | None] = mapped_column(String, default=None)

    # Documentation/Links
    Rulebook: Mapped[str | None] = mapped_column(String, default=None)
    Links: Mapped[str | None] = mapped_column(String, default=None)
    ScrapeLink: Mapped[str | None] = mapped_column(Text, default=None)

    # Event Classification
    EventType: Mapped[str | None] = mapped_column(String, default=None)

    # Alternative Names and Tags (stored as comma-delimited strings)
    AlternativeNames: Mapped[str | None] = mapped_column(String, default=None)
    Tags: Mapped[str | None] = mapped_column(String, default=None)

    # Boolean Flags
    IsQualifier: Mapped[bool | None] = mapped_column(Boolean, default=None)
    IsPlayoffs: Mapped[bool | None] = mapped_column(Boolean, default=None)
    IsOfficial: Mapped[bool | None] = mapped_column(Boolean, default=None)
    SuppressTopSchedule: Mapped[bool | None] = mapped_column(Boolean, default=None)
