"""Data models for document operations.

Uses lazy loading via __getattr__ to maintain import performance.
"""

from typing import TYPE_CHECKING, Any


if TYPE_CHECKING:
    from pinecone.models.documents.search import Document, DocumentSearchResponse, Usage
    from pinecone.models.documents.upsert import DocumentUpsertResponse

__all__ = [
    "Document",
    "DocumentSearchResponse",
    "DocumentUpsertResponse",
    "Usage",
]

_LAZY_IMPORTS = {
    "Document": "pinecone.models.documents.search",
    "DocumentSearchResponse": "pinecone.models.documents.search",
    "Usage": "pinecone.models.documents.search",
    "DocumentUpsertResponse": "pinecone.models.documents.upsert",
}


def __getattr__(name: str) -> Any:
    """Lazy-load models on first access."""
    if name in _LAZY_IMPORTS:
        # PLC0415: import should be at the top-level of a file (ruff error)
        # Intentionally inside __getattr__ for lazy loading performance.
        from importlib import import_module

        module = import_module(_LAZY_IMPORTS[name])
        return getattr(module, name)
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
