"""Frozen dataclasses for the H5P semantics intermediate representation."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional, Tuple


@dataclass(frozen=True)
class OptionIR:
    """A single option (or body) field in an H5P directive."""

    name: str
    field_name: str
    field_type: str
    label: str
    description: str
    required: bool
    default: Any
    choices: Tuple[Tuple[str, str], ...]


@dataclass(frozen=True)
class StructuralChildIR:
    """A list-of-group field producing a child directive."""

    directive_name: str
    entity: str
    body: Optional[OptionIR]
    options: Tuple[OptionIR, ...]
    min_count: int
    max_count: Optional[int]


@dataclass(frozen=True)
class LibraryChildIR:
    """A list-of-library field referencing dependent directives."""

    directive_name: str
    entity: str
    libraries: Tuple[str, ...]


@dataclass(frozen=True)
class DirectiveIR:
    """Complete IR for one H5P content type directive."""

    machine_name: str
    directive_name: str
    library: str
    body: Optional[OptionIR]
    options: Tuple[OptionIR, ...]
    structural_children: Tuple[StructuralChildIR, ...]
    library_children: Tuple[LibraryChildIR, ...]
