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

from app.models.base import Base, TimestampMixin


class VideoEngine(Base, TimestampMixin):
    __tablename__ = "video_engines"

    id: Mapped[str] = mapped_column(String(32), primary_key=True)
    name: Mapped[str] = mapped_column(String(64), nullable=False)
    provider: Mapped[str] = mapped_column(String(32), nullable=False)
    api_base: Mapped[str] = mapped_column(String(512), nullable=False)
    api_key: Mapped[str] = mapped_column(String(256), default="")
    model_name: Mapped[str] = mapped_column(String(128), default="")
    supported_ratios: Mapped[str] = mapped_column(String(256), default='["16:9","4:3","1:1","3:4","9:16","21:9"]')
    supported_resolutions: Mapped[str] = mapped_column(String(256), default='["480p","720p","1080p"]')
    supported_durations: Mapped[str] = mapped_column(String(256), nullable=True, default='[4,5,6,7,8,9,10,11,12,13,14,15]')
    max_duration: Mapped[int] = mapped_column(Integer, default=15)
    generate_url: Mapped[str | None] = mapped_column(String(512), nullable=True, default="")
    query_url: Mapped[str | None] = mapped_column(String(512), nullable=True, default="")
    is_active: Mapped[bool] = mapped_column(Boolean, default=True)
    priority: Mapped[int] = mapped_column(Integer, default=0)
