# Path: src/jinja2/runtime.py
# class Undefined:
#     """The default undefined type.  This undefined type can be printed and
#     iterated over, but every other access will raise an :exc:`UndefinedError`:
# 
#     >>> foo = Undefined(name='foo')
#     >>> str(foo)
#     ''
#     >>> not foo
#     True
#     >>> foo + 42
#     Traceback (most recent call last):
#       ...
#     jinja2.exceptions.UndefinedError: 'foo' is undefined
#     """
# 
#     __slots__ = (
#         "_undefined_hint",
#         "_undefined_obj",
#         "_undefined_name",
#         "_undefined_exception",
#     )
# 
#     def __init__(
#         self,
#         hint: t.Optional[str] = None,
#         obj: t.Any = missing,
#         name: t.Optional[str] = None,
#         exc: t.Type[TemplateRuntimeError] = UndefinedError,
#     ) -> None:
#         self._undefined_hint = hint
#         self._undefined_obj = obj
#         self._undefined_name = name
#         self._undefined_exception = exc
# 
#     @property
#     def _undefined_message(self) -> str:
#         """Build a message about the undefined value based on how it was
#         accessed.
#         """
#         if self._undefined_hint:
#             return self._undefined_hint
# 
#         if self._undefined_obj is missing:
#             return f"{self._undefined_name!r} is undefined"
# 
#         if not isinstance(self._undefined_name, str):
#             return (
#                 f"{object_type_repr(self._undefined_obj)} has no"
#                 f" element {self._undefined_name!r}"
#             )
# 
#         return (
#             f"{object_type_repr(self._undefined_obj)!r} has no"
#             f" attribute {self._undefined_name!r}"
#         )
# 
#     @internalcode
#     def _fail_with_undefined_error(
#         self, *args: t.Any, **kwargs: t.Any
#     ) -> "te.NoReturn":
#         """Raise an :exc:`UndefinedError` when operations are performed
#         on the undefined value.
#         """
#         raise self._undefined_exception(self._undefined_message)
# 
#     @internalcode
#     def __getattr__(self, name: str) -> t.Any:
#         if name[:2] == "__":
#             raise AttributeError(name)
# 
#         return self._fail_with_undefined_error()
# 
#     __add__ = __radd__ = __sub__ = __rsub__ = _fail_with_undefined_error
#     __mul__ = __rmul__ = __div__ = __rdiv__ = _fail_with_undefined_error
#     __truediv__ = __rtruediv__ = _fail_with_undefined_error
#     __floordiv__ = __rfloordiv__ = _fail_with_undefined_error
#     __mod__ = __rmod__ = _fail_with_undefined_error
#     __pos__ = __neg__ = _fail_with_undefined_error
#     __call__ = __getitem__ = _fail_with_undefined_error
#     __lt__ = __le__ = __gt__ = __ge__ = _fail_with_undefined_error
#     __int__ = __float__ = __complex__ = _fail_with_undefined_error
#     __pow__ = __rpow__ = _fail_with_undefined_error
# 
#     def __eq__(self, other: t.Any) -> bool:
#         return type(self) is type(other)
# 
#     def __ne__(self, other: t.Any) -> bool:
#         return not self.__eq__(other)
# 
#     def __hash__(self) -> int:
#         return id(type(self))
# 
#     def __str__(self) -> str:
#         return ""
# 
#     def __len__(self) -> int:
#         return 0
# 
#     def __iter__(self) -> t.Iterator[t.Any]:
#         yield from ()
# 
#     async def __aiter__(self) -> t.AsyncIterator[t.Any]:
#         for _ in ():
#             yield
# 
#     def __bool__(self) -> bool:
#         return False
# 
#     def __repr__(self) -> str:
#         return "Undefined"
# 
# Path: src/jinja2/utils.py
# def pass_environment(f: F) -> F:
#     """Pass the :class:`~jinja2.Environment` as the first argument to
#     the decorated function when called while rendering a template.
# 
#     Can be used on functions, filters, and tests.
# 
#     .. versionadded:: 3.0.0
#         Replaces ``environmentfunction`` and ``environmentfilter``.
#     """
#     f.jinja_pass_arg = _PassArg.environment  # type: ignore
#     return f


import operator
import typing as t
from collections import abc
from numbers import Number
from .runtime import Undefined
from .utils import pass_environment
    from .environment import Environment

    See the :func:`default` filter for a simple way to set undefined
    variables.
    """
    return not isinstance(value, Undefined)


def test_undefined(value: t.Any) -> bool:
    """Like :func:`defined` but the other way round."""
    return isinstance(value, Undefined)


@pass_environment
def test_filter(env: "Environment", value: str) -> bool:
    """Check if a filter exists by name. Useful if a filter may be
    optionally available.

    .. code-block:: jinja

        {% if 'markdown' is filter %}
            {{ value | markdown }}
        {% else %}
            {{ value }}
        {% endif %}

    .. versionadded:: 3.0
    """
    return value in env.filters



# Path: src/jinja2/runtime.py
# class Undefined:
#     """The default undefined type.  This undefined type can be printed and
#     iterated over, but every other access will raise an :exc:`UndefinedError`:
# 
#     >>> foo = Undefined(name='foo')
#     >>> str(foo)
#     ''
#     >>> not foo
#     True
#     >>> foo + 42
#     Traceback (most recent call last):
#       ...
#     jinja2.exceptions.UndefinedError: 'foo' is undefined
#     """
# 
#     __slots__ = (
#         "_undefined_hint",
#         "_undefined_obj",
#         "_undefined_name",
#         "_undefined_exception",
#     )
# 
#     def __init__(
#         self,
#         hint: t.Optional[str] = None,
#         obj: t.Any = missing,
#         name: t.Optional[str] = None,
#         exc: t.Type[TemplateRuntimeError] = UndefinedError,
#     ) -> None:
#         self._undefined_hint = hint
#         self._undefined_obj = obj
#         self._undefined_name = name
#         self._undefined_exception = exc
# 
#     @property
#     def _undefined_message(self) -> str:
#         """Build a message about the undefined value based on how it was
#         accessed.
#         """
#         if self._undefined_hint:
#             return self._undefined_hint
# 
#         if self._undefined_obj is missing:
#             return f"{self._undefined_name!r} is undefined"
# 
#         if not isinstance(self._undefined_name, str):
#             return (
#                 f"{object_type_repr(self._undefined_obj)} has no"
#                 f" element {self._undefined_name!r}"
#             )
# 
#         return (
#             f"{object_type_repr(self._undefined_obj)!r} has no"
#             f" attribute {self._undefined_name!r}"
#         )
# 
#     @internalcode
#     def _fail_with_undefined_error(
#         self, *args: t.Any, **kwargs: t.Any
#     ) -> "te.NoReturn":
#         """Raise an :exc:`UndefinedError` when operations are performed
#         on the undefined value.
#         """
#         raise self._undefined_exception(self._undefined_message)
# 
#     @internalcode
#     def __getattr__(self, name: str) -> t.Any:
#         if name[:2] == "__":
#             raise AttributeError(name)
# 
#         return self._fail_with_undefined_error()
# 
#     __add__ = __radd__ = __sub__ = __rsub__ = _fail_with_undefined_error
#     __mul__ = __rmul__ = __div__ = __rdiv__ = _fail_with_undefined_error
#     __truediv__ = __rtruediv__ = _fail_with_undefined_error
#     __floordiv__ = __rfloordiv__ = _fail_with_undefined_error
#     __mod__ = __rmod__ = _fail_with_undefined_error
#     __pos__ = __neg__ = _fail_with_undefined_error
#     __call__ = __getitem__ = _fail_with_undefined_error
#     __lt__ = __le__ = __gt__ = __ge__ = _fail_with_undefined_error
#     __int__ = __float__ = __complex__ = _fail_with_undefined_error
#     __pow__ = __rpow__ = _fail_with_undefined_error
# 
#     def __eq__(self, other: t.Any) -> bool:
#         return type(self) is type(other)
# 
#     def __ne__(self, other: t.Any) -> bool:
#         return not self.__eq__(other)
# 
#     def __hash__(self) -> int:
#         return id(type(self))
# 
#     def __str__(self) -> str:
#         return ""
# 
#     def __len__(self) -> int:
#         return 0
# 
#     def __iter__(self) -> t.Iterator[t.Any]:
#         yield from ()
# 
#     async def __aiter__(self) -> t.AsyncIterator[t.Any]:
#         for _ in ():
#             yield
# 
#     def __bool__(self) -> bool:
#         return False
# 
#     def __repr__(self) -> str:
#         return "Undefined"
# 
# Path: src/jinja2/utils.py
# def pass_environment(f: F) -> F:
#     """Pass the :class:`~jinja2.Environment` as the first argument to
#     the decorated function when called while rendering a template.
# 
#     Can be used on functions, filters, and tests.
# 
#     .. versionadded:: 3.0.0
#         Replaces ``environmentfunction`` and ``environmentfilter``.
#     """
#     f.jinja_pass_arg = _PassArg.environment  # type: ignore
#     return f


# Path: src/jinja2/tests.py
import operator
import typing as t
from collections import abc
from numbers import Number
from .runtime import Undefined
from .utils import pass_environment
    from .environment import Environment


    See the :func:`default` filter for a simple way to set undefined
    variables.
    """
    return not isinstance(value, Undefined)


def test_undefined(value: t.Any) -> bool:
    """Like :func:`defined` but the other way round."""
    return isinstance(value, Undefined)


@pass_environment
def test_filter(env: "Environment", value: str) -> bool:
    """Check if a filter exists by name. Useful if a filter may be
    optionally available.

    .. code-block:: jinja

        {% if 'markdown' is filter %}
            {{ value | markdown }}
        {% else %}
            {{ value }}
        {% endif %}

    .. versionadded:: 3.0
    """
    return value in env.filters



@pass_environment