"""Audio capture template and engine schemas."""

from datetime import datetime
from typing import Dict, List, Optional

from pydantic import BaseModel, Field


class AudioTemplateCreate(BaseModel):
    """Request to create an audio capture template."""

    name: str = Field(description="Template name", min_length=1, max_length=100)
    engine_type: str = Field(description="Audio engine type (e.g., 'wasapi', 'sounddevice')", min_length=1)
    engine_config: Dict = Field(default_factory=dict, description="Engine-specific configuration")
    description: Optional[str] = Field(None, description="Template description", max_length=500)
    tags: List[str] = Field(default_factory=list, description="User-defined tags")


class AudioTemplateUpdate(BaseModel):
    """Request to update an audio template."""

    name: Optional[str] = Field(None, description="Template name", min_length=1, max_length=100)
    engine_type: Optional[str] = Field(None, description="Audio engine type")
    engine_config: Optional[Dict] = Field(None, description="Engine-specific configuration")
    description: Optional[str] = Field(None, description="Template description", max_length=500)
    tags: Optional[List[str]] = None


class AudioTemplateResponse(BaseModel):
    """Audio template information response."""

    id: str = Field(description="Template ID")
    name: str = Field(description="Template name")
    engine_type: str = Field(description="Engine type identifier")
    engine_config: Dict = Field(description="Engine-specific configuration")
    tags: List[str] = Field(default_factory=list, description="User-defined tags")
    created_at: datetime = Field(description="Creation timestamp")
    updated_at: datetime = Field(description="Last update timestamp")
    description: Optional[str] = Field(None, description="Template description")


class AudioTemplateListResponse(BaseModel):
    """List of audio templates response."""

    templates: List[AudioTemplateResponse] = Field(description="List of audio templates")
    count: int = Field(description="Number of templates")


class AudioEngineInfo(BaseModel):
    """Audio capture engine information."""

    type: str = Field(description="Engine type identifier (e.g., 'wasapi', 'sounddevice')")
    name: str = Field(description="Human-readable engine name")
    default_config: Dict = Field(description="Default configuration for this engine")
    available: bool = Field(description="Whether engine is available on this system")


class AudioEngineListResponse(BaseModel):
    """List of audio engines response."""

    engines: List[AudioEngineInfo] = Field(description="Available audio engines")
    count: int = Field(description="Number of engines")
