"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .imagegenerationresponse import ImageUsage, ImageUsageTypedDict
from r9s.types import BaseModel
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class ImageEditEventDataTypedDict(TypedDict):
    """Image edit event data - the actual payload in SSE data field"""

    # Common fields
    b64_json: NotRequired[str]
    created_at: NotRequired[int]
    size: NotRequired[str]
    quality: NotRequired[str]
    background: NotRequired[str]
    output_format: NotRequired[str]

    # Partial image specific
    partial_image_index: NotRequired[int]

    # Completed event specific
    usage: NotRequired[ImageUsageTypedDict]


class ImageEditEventData(BaseModel):
    """Image edit event data - the actual payload in SSE data field"""

    # Common fields
    b64_json: Optional[str] = None
    r"""Base64-encoded image data"""

    created_at: Optional[int] = None
    r"""Unix timestamp"""

    size: Optional[str] = None
    r"""Image size (e.g., '1024x1536')"""

    quality: Optional[str] = None
    r"""Quality setting"""

    background: Optional[str] = None
    r"""Background setting"""

    output_format: Optional[str] = None
    r"""Output format (png/jpeg/webp)"""

    # Partial image specific
    partial_image_index: Optional[int] = None
    r"""Index of partial image (only in partial_image events)"""

    # Completed event specific
    usage: Optional[ImageUsage] = None
    r"""Token usage statistics (only in completed events)"""

    # Catch-all for any additional fields
    class Config:
        extra = "allow"


class EditImageResponseBodyTypedDict(TypedDict):
    """SSE stream response wrapper - the full SSE event structure"""

    event: str
    r"""SSE event type (e.g., 'image_edit.partial_image', 'image_edit.completed')"""

    data: ImageEditEventDataTypedDict
    r"""Event data payload"""

    id: NotRequired[str]
    retry: NotRequired[int]


class EditImageResponseBody(BaseModel):
    """SSE stream response wrapper - the full SSE event structure"""

    event: str
    r"""SSE event type (e.g., 'image_edit.partial_image', 'image_edit.completed')"""

    data: ImageEditEventData
    r"""Event data payload"""

    id: Optional[str] = None
    r"""SSE event ID"""

    retry: Optional[int] = None
    r"""SSE reconnection time (milliseconds)"""
