"""Typed protocol definitions for gRPC proto messages used in tests.

These protocols avoid relying on generated *_pb2 stubs, which are excluded from
static analysis, while still providing precise attribute types for test asserts.
"""

from __future__ import annotations

from collections.abc import Mapping, Sequence
from typing import Protocol
from unittest.mock import MagicMock

from noteflow.grpc._mixins._types import GrpcContext


class CreateMeetingRequestProto(Protocol):
    @property
    def title(self) -> str: ...

    @property
    def metadata(self) -> Mapping[str, str]: ...

    @property
    def project_id(self) -> str: ...


class StopMeetingRequestProto(Protocol):
    @property
    def meeting_id(self) -> str: ...


class ListMeetingsRequestProto(Protocol):
    @property
    def limit(self) -> int: ...

    @property
    def offset(self) -> int: ...

    @property
    def sort_order(self) -> int: ...

    @property
    def states(self) -> Sequence[int]: ...

    @property
    def project_id(self) -> str: ...


class GetMeetingRequestProto(Protocol):
    @property
    def meeting_id(self) -> str: ...

    @property
    def include_segments(self) -> bool: ...

    @property
    def include_summary(self) -> bool: ...


class DeleteMeetingRequestProto(Protocol):
    @property
    def meeting_id(self) -> str: ...


class FinalSegmentProto(Protocol):
    text: str


class SummaryProto(Protocol):
    executive_summary: str


class MeetingProto(Protocol):
    id: str
    title: str
    state: int
    created_at: float
    metadata: Mapping[str, str]
    segments: Sequence[FinalSegmentProto]
    summary: SummaryProto | None


class ListMeetingsResponseProto(Protocol):
    total_count: int
    meetings: Sequence[MeetingProto]


class DeleteMeetingResponseProto(Protocol):
    success: bool


class MeetingServicerProtocol(Protocol):
    audio_writers: dict[str, MagicMock]

    async def CreateMeeting(
        self,
        request: CreateMeetingRequestProto,
        context: GrpcContext,
    ) -> MeetingProto: ...

    async def StopMeeting(
        self,
        request: StopMeetingRequestProto,
        context: GrpcContext,
    ) -> MeetingProto: ...

    async def ListMeetings(
        self,
        request: ListMeetingsRequestProto,
        context: GrpcContext,
    ) -> ListMeetingsResponseProto: ...

    async def GetMeeting(
        self,
        request: GetMeetingRequestProto,
        context: GrpcContext,
    ) -> MeetingProto: ...

    async def DeleteMeeting(
        self,
        request: DeleteMeetingRequestProto,
        context: GrpcContext,
    ) -> DeleteMeetingResponseProto: ...
