"""SxEngine request detection utilities."""

from quart import request


def is_htmx_request() -> bool:
    """Check if the current request is an SxEngine request."""
    return request.headers.get("SX-Request", "").lower() == "true"


def is_sx_request() -> bool:
    """Check if the current request is an SxEngine request."""
    return request.headers.get("SX-Request", "").lower() == "true"


def get_htmx_target() -> str | None:
    """Get the target element ID from SX request headers."""
    return request.headers.get("SX-Target")


def get_htmx_trigger() -> str | None:
    """Get the trigger element ID from request headers."""
    return request.headers.get("HX-Trigger")


def should_return_fragment() -> bool:
    """Determine if we should return a fragment vs full page."""
    return is_htmx_request()
