"""State machine utilities for core app."""

from .builder import (
    StateTransitionBuilder,
    determine_method_name_for_transition,
)
from .callback_base import (
    BaseTransitionCallback,
    CallbackStage,
    ErrorTransitionCallback,
    PostTransitionCallback,
    PreTransitionCallback,
    TransitionCallbackRegistry,
    TransitionContext,
    callback_registry,
)
from .config import (
    CallbackConfig,
    callback_config,
    get_callback_config,
)
from .decorators import (
    TransitionMethodFactory,
    generate_transition_decorator,
    register_method_callbacks,
    with_callbacks,
)
from .exceptions import (
    ERROR_MESSAGES,
    TransitionNotAvailable,
    TransitionPermissionDenied,
    TransitionValidationError,
    format_transition_error,
    get_permission_error_message,
    get_state_error_message,
    raise_permission_denied,
    raise_validation_error,
)
from .fields import RichFSMField
from .guards import (
    ADMIN_ROLES,
    ESCALATION_LEVEL_ROLES,
    MODERATOR_ROLES,
    SUPERUSER_ROLES,
    # Role constants
    VALID_ROLES,
    AssignmentGuard,
    CompositeGuard,
    # Registry
    GuardRegistry,
    MetadataGuard,
    OwnershipGuard,
    # Guard classes
    PermissionGuard,
    StateGuard,
    create_assignment_guard,
    create_composite_guard,
    create_ownership_guard,
    create_permission_guard,
    # Guard extraction and creation
    extract_guards_from_metadata,
    # Role checking functions
    get_user_role,
    guard_registry,
    has_permission,
    has_role,
    is_admin_or_above,
    is_moderator_or_above,
    is_superuser_role,
    validate_guard_metadata,
)
from .integration import (
    StateMachineModelMixin,
    apply_state_machine,
    state_machine_model,
)
from .mixins import StateMachineMixin
from .monitoring import (
    CallbackMonitor,
    TimedCallbackExecution,
    callback_monitor,
)
from .registry import (
    TransitionInfo,
    TransitionRegistry,
    discover_and_register_callbacks,
    register_cache_invalidation,
    register_callback,
    register_notification_callback,
    register_related_update,
    register_transition_callbacks,
    registry_instance,
)
from .signals import (
    on_post_transition,
    on_pre_transition,
    on_transition,
    on_transition_error,
    post_state_transition,
    pre_state_transition,
    register_transition_handler,
    state_transition_failed,
)
from .validators import MetadataValidator, ValidationResult

__all__ = [
    # Fields and mixins
    "RichFSMField",
    "StateMachineMixin",
    # Builder
    "StateTransitionBuilder",
    "determine_method_name_for_transition",
    # Decorators
    "generate_transition_decorator",
    "TransitionMethodFactory",
    "with_callbacks",
    "register_method_callbacks",
    # Registry
    "TransitionRegistry",
    "TransitionInfo",
    "registry_instance",
    "register_callback",
    "register_notification_callback",
    "register_cache_invalidation",
    "register_related_update",
    "register_transition_callbacks",
    "discover_and_register_callbacks",
    # Callbacks
    "BaseTransitionCallback",
    "PreTransitionCallback",
    "PostTransitionCallback",
    "ErrorTransitionCallback",
    "TransitionContext",
    "TransitionCallbackRegistry",
    "callback_registry",
    "CallbackStage",
    # Signals
    "pre_state_transition",
    "post_state_transition",
    "state_transition_failed",
    "register_transition_handler",
    "on_transition",
    "on_pre_transition",
    "on_post_transition",
    "on_transition_error",
    # Config
    "CallbackConfig",
    "callback_config",
    "get_callback_config",
    # Monitoring
    "CallbackMonitor",
    "callback_monitor",
    "TimedCallbackExecution",
    # Validators
    "MetadataValidator",
    "ValidationResult",
    # Role constants
    "VALID_ROLES",
    "MODERATOR_ROLES",
    "ADMIN_ROLES",
    "SUPERUSER_ROLES",
    "ESCALATION_LEVEL_ROLES",
    # Guard classes
    "PermissionGuard",
    "OwnershipGuard",
    "AssignmentGuard",
    "StateGuard",
    "MetadataGuard",
    "CompositeGuard",
    # Guard extraction and creation
    "extract_guards_from_metadata",
    "create_permission_guard",
    "create_ownership_guard",
    "create_assignment_guard",
    "create_composite_guard",
    "validate_guard_metadata",
    # Guard registry
    "GuardRegistry",
    "guard_registry",
    # Role checking functions
    "get_user_role",
    "has_role",
    "is_moderator_or_above",
    "is_admin_or_above",
    "is_superuser_role",
    "has_permission",
    # Exceptions
    "TransitionPermissionDenied",
    "TransitionValidationError",
    "TransitionNotAvailable",
    "ERROR_MESSAGES",
    "get_permission_error_message",
    "get_state_error_message",
    "format_transition_error",
    "raise_permission_denied",
    "raise_validation_error",
    # Integration
    "apply_state_machine",
    "StateMachineModelMixin",
    "state_machine_model",
]
