# Path: aioreactive/notification.py
# class Notification(Generic[TSource], ABC):
#     """Represents a message to a mailbox processor."""
# 
#     def __init__(self, kind: MsgKind):
#         self.kind = kind  # Message kind
# 
#     @abstractmethod
#     async def accept(
#         self,
#         asend: Callable[[TSource], Awaitable[None]],
#         athrow: Callable[[Exception], Awaitable[None]],
#         aclose: Callable[[], Awaitable[None]],
#     ) -> None:
#         raise NotImplementedError
# 
#     @abstractmethod
#     async def accept_observer(self, obv: AsyncObserver[TSource]) -> None:
#         raise NotImplementedError
# 
#     def __repr__(self) -> str:
#         return str(self)
# 
# Path: aioreactive/types.py
# class AsyncObservable(Generic[T_co]):
#     __slots__ = ()
# 
#     @abstractmethod
#     async def subscribe_async(self, observer: AsyncObserver[T_co]) -> AsyncDisposable:
#         raise NotImplementedError


from abc import ABC
from dataclasses import dataclass
from typing import Any, Iterable, NewType, TypeVar, get_origin
from expression.core import SupportsMatch
from expression.system import AsyncDisposable
from .notification import Notification
from .types import AsyncObservable
@dataclass
class OtherMsg(Msg[Notification[TOther]], SupportsMatch[TOther]):
    value: Notification[TOther]

    def __match__(self, pattern: Any) -> Iterable[Notification[TOther]]:
        origin: Any = get_origin(pattern)
        try:
            if isinstance(self, origin or pattern):
                return [self.value]
        except TypeError:
            pass
        return []


@dataclass
class DisposableMsg(Msg[AsyncDisposable], SupportsMatch[AsyncDisposable]):
    """Message containing a diposable."""

    disposable: AsyncDisposable

    def __match__(self, pattern: Any) -> Iterable[AsyncDisposable]:
        try:
            if isinstance(self, pattern):
                return [self.disposable]
        except TypeError:
            pass
        return []


@dataclass

# Path: aioreactive/notification.py
# class Notification(Generic[TSource], ABC):
#     """Represents a message to a mailbox processor."""
# 
#     def __init__(self, kind: MsgKind):
#         self.kind = kind  # Message kind
# 
#     @abstractmethod
#     async def accept(
#         self,
#         asend: Callable[[TSource], Awaitable[None]],
#         athrow: Callable[[Exception], Awaitable[None]],
#         aclose: Callable[[], Awaitable[None]],
#     ) -> None:
#         raise NotImplementedError
# 
#     @abstractmethod
#     async def accept_observer(self, obv: AsyncObserver[TSource]) -> None:
#         raise NotImplementedError
# 
#     def __repr__(self) -> str:
#         return str(self)
# 
# Path: aioreactive/types.py
# class AsyncObservable(Generic[T_co]):
#     __slots__ = ()
# 
#     @abstractmethod
#     async def subscribe_async(self, observer: AsyncObserver[T_co]) -> AsyncDisposable:
#         raise NotImplementedError


# Path: aioreactive/msg.py
from abc import ABC
from dataclasses import dataclass
from typing import Any, Iterable, NewType, TypeVar, get_origin
from expression.core import SupportsMatch
from expression.system import AsyncDisposable
from .notification import Notification
from .types import AsyncObservable

@dataclass
class OtherMsg(Msg[Notification[TOther]], SupportsMatch[TOther]):
    value: Notification[TOther]

    def __match__(self, pattern: Any) -> Iterable[Notification[TOther]]:
        origin: Any = get_origin(pattern)
        try:
            if isinstance(self, origin or pattern):
                return [self.value]
        except TypeError:
            pass
        return []


@dataclass
class DisposableMsg(Msg[AsyncDisposable], SupportsMatch[AsyncDisposable]):
    """Message containing a diposable."""

    disposable: AsyncDisposable

    def __match__(self, pattern: Any) -> Iterable[AsyncDisposable]:
        try:
            if isinstance(self, pattern):
                return [self.disposable]
        except TypeError:
            pass
        return []


@dataclass

class InnerObservableMsg(Msg[AsyncObservable[TSource]], SupportsMatch[AsyncObservable[TSource]]):