"""Pydantic schemas for the Tags plugin."""

from __future__ import annotations

from pydantic import BaseModel, Field


class TagCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=100)
    color: str = Field("#6B7280", max_length=7)


class TagUpdate(BaseModel):
    name: str | None = Field(None, min_length=1, max_length=100)
    color: str | None = Field(None, max_length=7)


class TagResponse(BaseModel):
    id: str
    name: str
    color: str
    entity_count: int = 0


class TagAssignRequest(BaseModel):
    tag_id: str
    entity_type: str = Field(..., pattern="^(contact|file|folder)$")
    entity_id: str


class TagUnassignRequest(BaseModel):
    tag_id: str
    entity_type: str = Field(..., pattern="^(contact|file|folder)$")
    entity_id: str


class TagBulkAssignRequest(BaseModel):
    tag_ids: list[str] = Field(..., min_length=1)
    entity_type: str = Field(..., pattern="^(contact|file|folder)$")
    entity_id: str


class TagAssignmentResponse(BaseModel):
    id: str
    tag_id: str
    entity_type: str
    entity_id: str


class EntityListResponse(BaseModel):
    entity_type: str
    entity_id: str
