"""Title library Pydantic schemas."""

from __future__ import annotations

from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, Field


class TitleLibraryItemResponse(BaseModel):
    id: str
    user_id: str
    name: str
    text: str
    category: str = "default"
    description: str = ""
    tags: List[str] = Field(default_factory=list)
    usage_count: int = 0
    is_active: bool = True
    created_at: datetime
    updated_at: datetime


class ListTitleLibraryResponse(BaseModel):
    items: list[TitleLibraryItemResponse]
    total: int = 0


class CreateTitleLibraryRequest(BaseModel):
    name: str = Field(..., min_length=1, max_length=255)
    text: str = Field(..., min_length=1, max_length=500)
    category: str = "default"
    description: str = ""
    tags: List[str] = Field(default_factory=list)


class UpdateTitleLibraryRequest(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=255)
    text: Optional[str] = Field(None, min_length=1, max_length=500)
    category: Optional[str] = None
    description: Optional[str] = None
    tags: Optional[List[str]] = None
