"""Persona bar widget."""

from __future__ import annotations

import importlib
from typing import Any


def _load_static_base() -> type[Any]:
    try:
        return importlib.import_module("textual.widgets").Static
    except Exception:  # pragma: no cover - optional dependency

        class _FallbackStatic:
            def __init__(self, *args: object, **kwargs: object) -> None:
                self._text = ""

            def update(self, text: str) -> None:
                self._text = text

        return _FallbackStatic


_StaticBase = _load_static_base()


class PersonaBar(_StaticBase):
    """Displays active persona and preset metadata."""

    def set_content(
        self,
        *,
        persona_name: str,
        actor_name: str,
        preset_name: str,
        scope_text: str,
    ) -> None:
        self.update(f"{persona_name} | {actor_name} | {preset_name} | {scope_text}")
