"""Unsupported project repository implementations for memory mode.

Provide repository interfaces that raise NotImplementedError for
operations requiring database persistence.
"""

from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING
from uuid import UUID

_ERR_PROJECTS_DB = "Projects require database persistence"

if TYPE_CHECKING:
    from noteflow.domain.entities.project import Project, ProjectSettings
    from noteflow.domain.identity import ProjectMembership, ProjectRole


class UnsupportedProjectRepository:
    """Project repository that raises for unsupported operations.

    Use in memory mode where projects require database persistence.
    """

    async def get(self, project_id: UUID) -> Project | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def get_by_slug(
        self,
        workspace_id: UUID,
        slug: str,
    ) -> Project | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def get_default_for_workspace(
        self,
        workspace_id: UUID,
    ) -> Project | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def create(
        self,
        project_id: UUID,
        workspace_id: UUID,
        name: str,
        slug: str | None = None,
        description: str | None = None,
        is_default: bool = False,
        settings: ProjectSettings | None = None,
    ) -> Project:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def update(self, project: Project) -> Project:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def archive(self, project_id: UUID) -> Project | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def restore(self, project_id: UUID) -> Project | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def delete(self, project_id: UUID) -> bool:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def list_for_workspace(
        self,
        workspace_id: UUID,
        include_archived: bool = False,
        limit: int = 50,
        offset: int = 0,
    ) -> Sequence[Project]:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def count_for_workspace(
        self,
        workspace_id: UUID,
        include_archived: bool = False,
    ) -> int:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)


class UnsupportedProjectMembershipRepository:
    """Project membership repository that raises for unsupported operations.

    Use in memory mode where project memberships require database persistence.
    """

    async def get(
        self,
        project_id: UUID,
        user_id: UUID,
    ) -> ProjectMembership | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def add(
        self,
        project_id: UUID,
        user_id: UUID,
        role: ProjectRole,
    ) -> ProjectMembership:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def update_role(
        self,
        project_id: UUID,
        user_id: UUID,
        role: ProjectRole,
    ) -> ProjectMembership | None:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def remove(
        self,
        project_id: UUID,
        user_id: UUID,
    ) -> bool:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def list_for_project(
        self,
        project_id: UUID,
        limit: int = 100,
        offset: int = 0,
    ) -> Sequence[ProjectMembership]:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def list_for_user(
        self,
        user_id: UUID,
        workspace_id: UUID | None = None,
        limit: int = 100,
        offset: int = 0,
    ) -> Sequence[ProjectMembership]:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def bulk_add(
        self,
        project_id: UUID,
        memberships: Sequence[tuple[UUID, ProjectRole]],
    ) -> Sequence[ProjectMembership]:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)

    async def count_for_project(
        self,
        project_id: UUID,
    ) -> int:
        """Not supported in memory mode."""
        raise NotImplementedError(_ERR_PROJECTS_DB)
