"Standard PPT settings / configs"

from typing import Any

from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
from pptx.util import Inches
from pydantic import BaseModel, field_validator


class SlideWorkArea(BaseModel):
    "Configure the Slide work area"
    height: int = Inches(6)
    width: int = Inches(12.47)
    top: int = Inches(1.04)
    left: int = Inches(0.43)


class DefaultSettings(BaseModel):
    "Default settings for the slide"
    font: str | None = "arial.ttf"
    font_size: int | None = 12
    font_color: Any | None = None  # black
    light_font_color: Any | None = None  # white

    @field_validator("font", mode="before")
    @classmethod
    def check_font(cls, font):
        "Check if the font is valid"
        if ".ttf" not in font:
            font = font + ".ttf"
        return font

    @field_validator("font_color", mode="before")
    @classmethod
    def check_font_color(cls, font_color):
        "Check if the font color is valid"
        # if none, then set to black
        if font_color is None:
            return RGBColor(0, 0, 0)
        return font_color

    @field_validator("light_font_color", mode="before")
    @classmethod
    def check_light_font_color(cls, light_font_color):
        "Check if the font color is valid"
        # if none, then set to white
        if light_font_color is None:
            return RGBColor(255, 255, 255)
        return light_font_color
