"""Base class for content renderers used in the chat panel."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from rich.console import RenderableType
class ContentRenderer(ABC):
"""Render a single WebSocket event or chat message into a Rich renderable."""
@abstractmethod
def accepts(self, msg: dict) -> bool:
"""Return True if this renderer can handle the event/message."""
raise NotImplementedError
@abstractmethod
def render(self, msg: dict) -> "RenderableType":
"""Return a Rich renderable."""
raise NotImplementedError