"""This module contains the data classes for the presentation structure."""

import uuid
from typing import Any, Dict

from pydantic.v1 import BaseModel, Field, root_validator


class SlideContent(BaseModel, extra="allow"):
    "Slide content structure."
    layout: str = Field(..., title="Slide layout choice, i.e. Layout A, B, etc.")
    # question_answers: dict[str, str] = Field(..., title="Question and answer pairs")
    information_to_provide: dict[str, Any] = Field(
        ..., title="For the given slide layout chosen, a filled out JSON to provide"
    )
    layout_in_text: str = Field(
        default=None,
        title="From the selected layout, provide a description in text for the layout",
    )
    extra: Any = Field(
        default={},
        title="Extra information needed for the slide",
    )

    @root_validator(pre=True)
    @classmethod
    def build_extra(cls, values):
        "add extra information if needed."
        all_required_field_names = {
            field.alias for field in cls.__fields__.values() if field.alias != "extra"
        }  # to support alias

        extra: Dict[str, Any] = {}
        for field_name in list(values):
            if field_name not in all_required_field_names:
                extra[field_name] = values.pop(field_name)
        values["extra"] = extra
        return values


class SlideLLM(BaseModel):
    "Slide structure."
    title: str = Field(..., title="The title of the slide")
    content: str = Field(..., title="The content of the slide")
    data: str = Field(..., title="Data required for the slide to complete")
    design: str = Field(
        ...,
        title="""Design for the powerpoint slide with respect to the data
         and content assume a 4:3 aspect ratio and 1920x1080 resolution.""",
    )
    questions: list[str] = Field(
        ..., title="Questions needed to be answered to complete the slide"
    )
    slide_order: int = Field(..., title="The order of the slide in the section")
    isModified: bool = Field(default=False, title="Whether the slide is modified")


class SectionLLMWithSlides(BaseModel):
    "Section structure."
    title: str = Field(..., title="The title of the section")
    content: str | None = Field(
        default=None, title="What the content of the section should be"
    )
    slides: list[SlideLLM] | None = Field(
        default=None,
        title="list of slides for the section, include as many slides as deemed concise for the section",
    )
    section_order: int = Field(
        ..., title="The order of the section in the presentation"
    )


class Section_LLM(BaseModel):
    "Section structure."
    title: str = Field(..., title="The title of the section")
    content: str | None = Field(
        default=None, title="What the content of the section should be"
    )
    section_order: int = Field(
        ..., title="The order of the section in the presentation"
    )


class PresentationOutline(BaseModel):
    "Presentation structure."
    sections: list[Section_LLM] = Field(
        ..., title="list of sections in the presentation"
    )
