# generated by datamodel-codegen:
#   filename:  qr-payload-schema.json
#   timestamp: 2026-03-07T23:59:08+00:00

from __future__ import annotations

from enum import StrEnum
from typing import Literal

from pydantic import BaseModel, ConfigDict, Field, RootModel, conint


class SyncType(StrEnum):
    init = 'init'
    nar = 'nar'
    act = 'act'
    hlt = 'hlt'


class MarkerPosition(StrEnum):
    start = 'start'
    end = 'end'


class InitPayload(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
        populate_by_name=True,
    )
    t: Literal['init']
    language: str
    debug_overlay: bool | None = Field(None, alias='debugOverlay')
    font_size: int | None = Field(None, alias='fontSize')


class NarrationPayload(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
        populate_by_name=True,
    )
    t: Literal['nar']
    id: conint(ge=0)
    m: MarkerPosition
    tx: str | None = Field(
        None, description='Narration text (present on start markers)'
    )
    tr: dict[str, str] | None = Field(
        None, description='Translations keyed by language code'
    )


class ScreenActionType(StrEnum):
    highlight = 'highlight'
    navigate = 'navigate'
    input = 'input'
    scroll = 'scroll'
    wait = 'wait'
    animate = 'animate'
    title = 'title'


class Tm(StrEnum):
    elastic = 'elastic'
    timed = 'timed'


class ActionPayload(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
        populate_by_name=True,
    )
    t: Literal['act']
    id: conint(ge=0)
    m: MarkerPosition
    st: ScreenActionType | None = None
    desc: str | None = Field(None, description='Action description')
    tm: Tm | None = Field(None, description='Timing mode (omitted when casted)')
    dur: conint(ge=0) | None = Field(
        None, description='Duration in ms (required when timing is timed)'
    )


class HighlightPayload(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
        populate_by_name=True,
    )
    t: Literal['hlt']
    id: conint(ge=0)
    m: MarkerPosition


class ContinuationWrapper(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
        populate_by_name=True,
    )
    field_c: list[int] = Field(
        ...,
        alias='_c',
        description='[sequenceIndex, totalFrames]',
        max_length=2,
        min_length=2,
    )
    d: str = Field(..., description='Chunk of the original payload')


class Model(
    RootModel[
        InitPayload
        | NarrationPayload
        | ActionPayload
        | HighlightPayload
        | ContinuationWrapper
    ]
):
    root: (
        InitPayload
        | NarrationPayload
        | ActionPayload
        | HighlightPayload
        | ContinuationWrapper
    ) = Field(
        ...,
        description='QR code payload schema for screencast-narrator sync frames. This defines the API contract between recording clients and the detection pipeline.',
    )
