# Path: src/werkzeug/utils.py
# class cached_property(property, t.Generic[_T]):
#     """A :func:`property` that is only evaluated once. Subsequent access
#     returns the cached value. Setting the property sets the cached
#     value. Deleting the property clears the cached value, accessing it
#     again will evaluate it again.
# 
#     .. code-block:: python
# 
#         class Example:
#             @cached_property
#             def value(self):
#                 # calculate something important here
#                 return 42
# 
#         e = Example()
#         e.value  # evaluates
#         e.value  # uses cache
#         e.value = 16  # sets cache
#         del e.value  # clears cache
# 
#     If the class defines ``__slots__``, it must add ``_cache_{name}`` as
#     a slot. Alternatively, it can add ``__dict__``, but that's usually
#     not desirable.
# 
#     .. versionchanged:: 2.1
#         Works with ``__slots__``.
# 
#     .. versionchanged:: 2.0
#         ``del obj.name`` clears the cached value.
#     """
# 
#     def __init__(
#         self,
#         fget: t.Callable[[t.Any], _T],
#         name: t.Optional[str] = None,
#         doc: t.Optional[str] = None,
#     ) -> None:
#         super().__init__(fget, doc=doc)
#         self.__name__ = name or fget.__name__
#         self.slot_name = f"_cache_{self.__name__}"
#         self.__module__ = fget.__module__
# 
#     def __set__(self, obj: object, value: _T) -> None:
#         if hasattr(obj, "__dict__"):
#             obj.__dict__[self.__name__] = value
#         else:
#             setattr(obj, self.slot_name, value)
# 
#     def __get__(self, obj: object, type: type = None) -> _T:  # type: ignore
#         if obj is None:
#             return self  # type: ignore
# 
#         obj_dict = getattr(obj, "__dict__", None)
# 
#         if obj_dict is not None:
#             value: _T = obj_dict.get(self.__name__, _missing)
#         else:
#             value = getattr(obj, self.slot_name, _missing)  # type: ignore[arg-type]
# 
#         if value is _missing:
#             value = self.fget(obj)  # type: ignore
# 
#             if obj_dict is not None:
#                 obj.__dict__[self.__name__] = value
#             else:
#                 setattr(obj, self.slot_name, value)
# 
#         return value
# 
#     def __delete__(self, obj: object) -> None:
#         if hasattr(obj, "__dict__"):
#             del obj.__dict__[self.__name__]
#         else:
#             setattr(obj, self.slot_name, _missing)
# 
# Path: src/werkzeug/debug/console.py
# class Console:
#     """An interactive console."""
# 
#     def __init__(
#         self,
#         globals: t.Optional[t.Dict[str, t.Any]] = None,
#         locals: t.Optional[t.Dict[str, t.Any]] = None,
#     ) -> None:
#         if locals is None:
#             locals = {}
#         if globals is None:
#             globals = {}
#         self._ipy = _InteractiveConsole(globals, locals)
# 
#     def eval(self, code: str) -> str:
#         _local._current_ipy = self._ipy
#         old_sys_stdout = sys.stdout
#         try:
#             return self._ipy.runsource(code)
#         finally:
#             sys.stdout = old_sys_stdout


import itertools
import linecache
import os
import re
import sys
import sysconfig
import traceback
import typing as t
from html import escape
from ..utils import cached_property
from .console import Console
        "global_ns",
        "_cache_info",
        "_cache_is_library",
        "_cache_console",
    )

    def __init__(
        self,
        *,
        locals: t.Dict[str, t.Any],
        globals: t.Dict[str, t.Any],
        **kwargs: t.Any,
    ) -> None:
        super().__init__(locals=None, **kwargs)
        self.local_ns = locals
        self.global_ns = globals

    @cached_property
    def info(self) -> t.Optional[str]:
        return self.local_ns.get("__traceback_info__")

    @cached_property
    def is_library(self) -> bool:
        return any(
            self.filename.startswith(os.path.realpath(path))
            for path in sysconfig.get_paths().values()
        )

    @cached_property
    def console(self) -> Console:

# Path: src/werkzeug/utils.py
# class cached_property(property, t.Generic[_T]):
#     """A :func:`property` that is only evaluated once. Subsequent access
#     returns the cached value. Setting the property sets the cached
#     value. Deleting the property clears the cached value, accessing it
#     again will evaluate it again.
# 
#     .. code-block:: python
# 
#         class Example:
#             @cached_property
#             def value(self):
#                 # calculate something important here
#                 return 42
# 
#         e = Example()
#         e.value  # evaluates
#         e.value  # uses cache
#         e.value = 16  # sets cache
#         del e.value  # clears cache
# 
#     If the class defines ``__slots__``, it must add ``_cache_{name}`` as
#     a slot. Alternatively, it can add ``__dict__``, but that's usually
#     not desirable.
# 
#     .. versionchanged:: 2.1
#         Works with ``__slots__``.
# 
#     .. versionchanged:: 2.0
#         ``del obj.name`` clears the cached value.
#     """
# 
#     def __init__(
#         self,
#         fget: t.Callable[[t.Any], _T],
#         name: t.Optional[str] = None,
#         doc: t.Optional[str] = None,
#     ) -> None:
#         super().__init__(fget, doc=doc)
#         self.__name__ = name or fget.__name__
#         self.slot_name = f"_cache_{self.__name__}"
#         self.__module__ = fget.__module__
# 
#     def __set__(self, obj: object, value: _T) -> None:
#         if hasattr(obj, "__dict__"):
#             obj.__dict__[self.__name__] = value
#         else:
#             setattr(obj, self.slot_name, value)
# 
#     def __get__(self, obj: object, type: type = None) -> _T:  # type: ignore
#         if obj is None:
#             return self  # type: ignore
# 
#         obj_dict = getattr(obj, "__dict__", None)
# 
#         if obj_dict is not None:
#             value: _T = obj_dict.get(self.__name__, _missing)
#         else:
#             value = getattr(obj, self.slot_name, _missing)  # type: ignore[arg-type]
# 
#         if value is _missing:
#             value = self.fget(obj)  # type: ignore
# 
#             if obj_dict is not None:
#                 obj.__dict__[self.__name__] = value
#             else:
#                 setattr(obj, self.slot_name, value)
# 
#         return value
# 
#     def __delete__(self, obj: object) -> None:
#         if hasattr(obj, "__dict__"):
#             del obj.__dict__[self.__name__]
#         else:
#             setattr(obj, self.slot_name, _missing)
# 
# Path: src/werkzeug/debug/console.py
# class Console:
#     """An interactive console."""
# 
#     def __init__(
#         self,
#         globals: t.Optional[t.Dict[str, t.Any]] = None,
#         locals: t.Optional[t.Dict[str, t.Any]] = None,
#     ) -> None:
#         if locals is None:
#             locals = {}
#         if globals is None:
#             globals = {}
#         self._ipy = _InteractiveConsole(globals, locals)
# 
#     def eval(self, code: str) -> str:
#         _local._current_ipy = self._ipy
#         old_sys_stdout = sys.stdout
#         try:
#             return self._ipy.runsource(code)
#         finally:
#             sys.stdout = old_sys_stdout


# Path: src/werkzeug/debug/tbtools.py
import itertools
import linecache
import os
import re
import sys
import sysconfig
import traceback
import typing as t
from html import escape
from ..utils import cached_property
from .console import Console

        "global_ns",
        "_cache_info",
        "_cache_is_library",
        "_cache_console",
    )

    def __init__(
        self,
        *,
        locals: t.Dict[str, t.Any],
        globals: t.Dict[str, t.Any],
        **kwargs: t.Any,
    ) -> None:
        super().__init__(locals=None, **kwargs)
        self.local_ns = locals
        self.global_ns = globals

    @cached_property
    def info(self) -> t.Optional[str]:
        return self.local_ns.get("__traceback_info__")

    @cached_property
    def is_library(self) -> bool:
        return any(
            self.filename.startswith(os.path.realpath(path))
            for path in sysconfig.get_paths().values()
        )

    @cached_property
    def console(self) -> Console:

        return Console(self.global_ns, self.local_ns)