# generated by datamodel-codegen:
#   filename:  core/overlay.json
#   timestamp: 2026-02-27T02:10:10+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import AnyUrl, ConfigDict, Field


class Unit(Enum):
    px = 'px'
    fraction = 'fraction'


class Bounds(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    height: Annotated[float, Field(description='Height of the overlay', ge=0.0)]
    unit: Annotated[
        Unit,
        Field(
            description="'px' = absolute pixels from asset top-left. 'fraction' = proportional to asset dimensions (x/y: 0.0 = asset edge, 1.0 = opposite edge; width/height: 0.12 = 12% of asset dimension)."
        ),
    ]
    width: Annotated[float, Field(description='Width of the overlay', ge=0.0)]
    x: Annotated[float, Field(description="Horizontal offset from the asset's left edge")]
    y: Annotated[float, Field(description="Vertical offset from the asset's top edge")]


class Visual(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    dark: Annotated[
        AnyUrl | None,
        Field(description='URL to the overlay graphic for use on dark backgrounds (SVG or PNG)'),
    ] = None
    light: Annotated[
        AnyUrl | None,
        Field(
            description='URL to the overlay graphic for use on light/bright backgrounds (SVG or PNG)'
        ),
    ] = None
    url: Annotated[
        AnyUrl | None,
        Field(
            description='URL to a theme-neutral overlay graphic (SVG or PNG). Use when a single file works for all backgrounds, e.g. an SVG using CSS custom properties or currentColor.'
        ),
    ] = None


class Overlay(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    bounds: Annotated[
        Bounds,
        Field(
            description="Position and size of the overlay relative to the asset's own top-left corner. See 'unit' for coordinate interpretation."
        ),
    ]
    description: Annotated[
        str | None,
        Field(
            description='Human-readable explanation of what this overlay is and how buyers should account for it'
        ),
    ] = None
    id: Annotated[
        str,
        Field(
            description="Identifier for this overlay (e.g., 'play_pause', 'volume', 'publisher_logo', 'carousel_prev', 'carousel_next')"
        ),
    ]
    visual: Annotated[
        Visual | None,
        Field(
            description='Optional visual reference for this overlay element. Useful for creative agents compositing previews and for buyers understanding what will appear over their content. Must include at least one of: url, light, or dark.'
        ),
    ] = None
