"""Tag-related schemas."""

from __future__ import annotations

from pydantic import BaseModel

__all__ = [
    "TagCount",
    "TagsListResponse",
    "AutoTagRequest",
    "AutoTagResponse",
    "AutoTagSample",
    "TagsUpdateRequest",
    "TagsUpdateResponse",
    "TagRenameRequest",
    "TagMergeRequest",
    "TagOpSampleOut",
    "TagOpResponse",
]


class TagCount(BaseModel):
    tag: str
    count: int


class TagsListResponse(BaseModel):
    tags: list[TagCount]
    total: int
    offset: int = 0
    limit: int = 0


class AutoTagRequest(BaseModel):
    source_filter: str | None = None
    max_tags: int = 5
    overwrite: bool = False
    dry_run: bool = True


class AutoTagSample(BaseModel):
    chunk_id: str
    source_file: str
    content_preview: str
    current_tags: list[str]
    suggested_tags: list[str]


class AutoTagResponse(BaseModel):
    total_chunks: int
    tagged_chunks: int
    skipped_chunks: int
    dry_run: bool
    samples: list[AutoTagSample] = []


class TagsUpdateRequest(BaseModel):
    tags: list[str]


class TagsUpdateResponse(BaseModel):
    id: str
    tags: list[str]


class TagRenameRequest(BaseModel):
    new_name: str


class TagMergeRequest(BaseModel):
    sources: list[str]
    target: str


class TagOpSampleOut(BaseModel):
    chunk_id: str
    source_file: str
    content_preview: str
    current_tags: list[str]


class TagOpResponse(BaseModel):
    tag: str
    affected_chunks: int
    dry_run: bool
    samples: list[TagOpSampleOut] = []
