from __future__ import annotations

from typing import Iterable, Optional, Protocol


class RepoPort(Protocol):
    # Auth
    def create_user(self, username: str, email: str, password: str) -> bool: ...
    def verify_login(self, email: str, password: str) -> bool: ...
    def get_user_id_by_email(self, email: str) -> int | None: ...
    def get_username_by_email(self, email: str) -> str | None: ...

    # Preferences
    def set_favorite_genres(self, user_id: int, genres: Iterable[str]) -> None: ...
    def get_favorite_genres(self, user_id: int) -> list[str]: ...

    # Watchlist
    def add_watchlist(self, user_id: int, title: str) -> bool: ...
    def remove_watchlist(self, user_id: int, title: str) -> None: ...
    def clear_watchlist(self, user_id: int) -> None: ...
    def list_watchlist(self, user_id: int) -> list[str]: ...

    # Watched
    def add_watched(self, user_id: int, title: str) -> bool: ...
    def remove_watched(self, user_id: int, title: str) -> None: ...
    def clear_watched(self, user_id: int) -> None: ...
    def list_watched(self, user_id: int) -> list[str]: ...

    # Feedback (optional feature, but you implemented it ✅)
    def save_feedback(
        self,
        user_id: int,
        title: str,
        liked: Optional[bool] = None,
        rating: Optional[int] = None,
        ts: Optional[str] = None,
    ) -> None: ...

    def get_feedback(self, user_id: int) -> dict[str, dict]: ...


class MovieInfoPort(Protocol):
    def search_by_title(self, title: str) -> dict: ...