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

from pydantic import BaseModel


class CategoryInBlog(BaseModel):
    slug: str
    title: str


class CategoryList(BaseModel):
    identifier: str
    slug: str
    title: str
    image_media_identifier: str
    blogs_count: Optional[int] = None
    image_data: Optional[Dict[str, Any]] = None
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None


class BlogList(BaseModel):
    identifier: str
    slug: str
    title: str
    subtitle: str
    summary: str
    published_at: Optional[datetime] = None
    time_to_read: Optional[int] = None
    tags: Optional[List[str] | Dict[str, Any]] = None
    extra_data: Optional[Dict[str, Any]] = None
    visit_count: Optional[int] = None
    categories: Optional[List[CategoryInBlog]] = None
    image_data: Optional[Dict[str, Any]] = None
    author_data: Optional[Dict[str, Any]] = None
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None


class BlogRetrieve(BlogList):
    description: Optional[str] = None


class BlogSearch(BaseModel):
    image_data: Optional[Dict[str, Any]] = None
    author_data: Optional[Dict[str, Any]] = None
    title: str
    time_to_read: Optional[int] = None
    slug: str
    subtitle: str
    summary: str
    categories: Optional[List[CategoryInBlog]] = None


class BlogSitemap(BaseModel):
    slug: str
    updated_at: datetime


class Comment(BaseModel):
    id: int
    user_identifier: str
    name: str
    content: str
    parent: Optional[int] = None
    is_active: bool
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None


class Rate(BaseModel):
    user_identifier: str
    rate: float
    is_active: bool
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
