"""Auto-generated by bindgen. Do not edit."""
# ruff: noqa: E501, F401, I001
# fmt: off

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, ClassVar, Optional, TYPE_CHECKING, Union

from wasmtime.component import Variant as _WitVariant
from wasmtime.component import VariantCase as _WitVariantCase

from .messages import Message


@dataclass(kw_only=True)
class TriggerParams:
    """Context passed to the trigger on each call."""
    trigger_id: str
    message_count: int
    last_message: Message | None


class TriggerError:
    """Why a trigger evaluation failed."""
    if TYPE_CHECKING:
        Unknown: ClassVar[type["_TriggerError_Unknown"]]
        Failed: ClassVar[type["_TriggerError_Failed"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "TriggerError": ...

class _TriggerError_Unknown(_WitVariantCase, TriggerError):
    """No trigger registered for the given id."""
    tag = 'unknown'
TriggerError.Unknown = _TriggerError_Unknown  # type: ignore[attr-defined]

class _TriggerError_Failed(_WitVariantCase, TriggerError):
    """Trigger raised an exception."""
    tag = 'failed'
TriggerError.Failed = _TriggerError_Failed  # type: ignore[attr-defined]

TriggerError._CASES = {  # type: ignore[attr-defined]
    'unknown': TriggerError.Unknown,
    'failed': TriggerError.Failed,
}


def _TriggerError_lift(raw: _WitVariant) -> TriggerError:
    cls = TriggerError._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown TriggerError arm: {raw.tag!r}')
    return cls(raw.payload)
TriggerError.lift = staticmethod(_TriggerError_lift)  # type: ignore[attr-defined]
