"""
Database models for Local Deep Research.
All models are organized by domain for better maintainability.
"""

from .active_research import UserActiveResearch
from .auth import User
from .base import Base
from .benchmark import (
    BenchmarkConfig,
    BenchmarkProgress,
    BenchmarkResult,
    BenchmarkRun,
    BenchmarkStatus,
    DatasetType,
)
from .chat import (
    ChatMessage,
    ChatMessageType,
    ChatProgressStep,
    ChatRole,
    ChatSession,
    ChatSessionStatus,
)
from .citation import Paper, PaperAppearance
from .journal import Journal
from .logs import ResearchLog
from .metrics import ModelUsage, ResearchRating, SearchCall, TokenUsage
from .providers import ProviderModel
from .queue import QueueStatus, TaskMetadata
from .queued_research import QueuedResearch
from .rate_limiting import RateLimitAttempt, RateLimitEstimate
from .reports import Report, ReportSection
from .research import (
    Research,
    ResearchHistory,
    ResearchMode,
    ResearchResource,
    ResearchStatus,
    ResearchStrategy,
    ResearchTask,
    SearchQuery,
    SearchResult,
)
from .settings import APIKey, Setting, SettingType, UserSettings
from .user_news_search_history import UserNewsSearchHistory
from .news import (
    NewsSubscription,
    SubscriptionFolder,
    NewsCard,
    UserRating,
    UserPreference,
    NewsInterest,
    CardType,
    RatingType,
    SubscriptionType,
    SubscriptionStatus,
)

# Import Library models - Unified architecture
from .library import (
    # New unified models
    SourceType,
    UploadBatch,
    Document,
    Collection,
    DocumentCollection,
    DownloadQueue,
    # Existing models
    DocumentChunk,
    LibraryStatistics,
    RAGIndex,
    CollectionFolder,
    CollectionFolderFile,
    RAGIndexStatus,
    # RAG document status
    RagDocumentStatus,
)

# Note: Text content is now directly in Document.text_content field
from .download_tracker import (
    DownloadTracker,
    DownloadDuplicates,
    DownloadAttempt,
)

# Import File Integrity models
from .file_integrity import (
    FileIntegrityRecord,
    FileVerificationFailure,
)

# Import Domain Classification model
from ...domain_classifier.models import DomainClassification

__all__ = [
    # Base
    "Base",
    # Active Research
    "UserActiveResearch",
    # Auth
    "User",
    # Queue
    "QueueStatus",
    "TaskMetadata",
    # Queued Research
    "QueuedResearch",
    # Benchmark
    "BenchmarkStatus",
    "DatasetType",
    "BenchmarkRun",
    "BenchmarkResult",
    "BenchmarkConfig",
    "BenchmarkProgress",
    # Papers (deduplicated academic papers)
    "Paper",
    "PaperAppearance",
    # Logs
    "ResearchLog",
    "Journal",
    # Metrics
    "TokenUsage",
    "ModelUsage",
    "ResearchRating",
    "SearchCall",
    # Providers
    "ProviderModel",
    # Rate Limiting
    "RateLimitAttempt",
    "RateLimitEstimate",
    # Reports
    "Report",
    "ReportSection",
    # Research
    "ResearchTask",
    "SearchQuery",
    "SearchResult",
    "ResearchHistory",
    "Research",
    "ResearchStrategy",
    "ResearchMode",
    "ResearchStatus",
    "ResearchResource",
    # Settings
    "UserSettings",
    "APIKey",
    "Setting",
    "SettingType",
    # User News Search History
    "UserNewsSearchHistory",
    # News Models
    "NewsSubscription",
    "SubscriptionFolder",
    "NewsCard",
    "UserRating",
    "UserPreference",
    "NewsInterest",
    "CardType",
    "RatingType",
    "SubscriptionType",
    "SubscriptionStatus",
    # Library Models - Unified Architecture
    "SourceType",
    "UploadBatch",
    "Document",
    "Collection",
    "DocumentCollection",
    "DownloadQueue",
    "DocumentChunk",
    "LibraryStatistics",
    "RAGIndex",
    "RAGIndexStatus",
    "CollectionFolder",
    "CollectionFolderFile",
    "RagDocumentStatus",
    # Download Tracker Models
    "DownloadTracker",
    "DownloadDuplicates",
    "DownloadAttempt",
    # File Integrity Models
    "FileIntegrityRecord",
    "FileVerificationFailure",
    # Chat Models
    "ChatSession",
    "ChatMessage",
    "ChatMessageType",
    "ChatProgressStep",
    "ChatRole",
    "ChatSessionStatus",
    # Domain Classification
    "DomainClassification",
]
