Ë
    hË5jv  ã                  óT   — d dl mZ d dlmZ d dlmZ d dlmZ d	d„Zd
d„Z	ed„ «       Z
y)é    )Úannotations)Úcontextmanager)ÚLiteral)Ú_corec                ó4   — t        j                  | dk(  «       y)až  Set global object conversion mode.

    This controls how PDF scalar values (integers, booleans, reals) are
    returned when accessing PDF objects.

    Args:
        mode: Conversion mode.
            - ``'implicit'`` (default): Automatically convert PDF integers to
              Python ``int``, booleans to ``bool``, and reals to ``Decimal``.
              This is the legacy behavior.
            - ``'explicit'``: Return PDF scalars as ``pikepdf.Integer``,
              ``pikepdf.Boolean``, and ``pikepdf.Real`` objects. This enables
              better type safety and static type checking.

    Example:
        >>> pikepdf.set_object_conversion_mode('explicit')
        >>> pdf = pikepdf.open('test.pdf')
        >>> count = pdf.Root.Count
        >>> isinstance(count, pikepdf.Integer)  # True in explicit mode
        True
        >>> int(count)  # Convert to Python int
        5

    .. versionadded:: 10.1
    ÚexplicitN)r   Ú_set_explicit_conversion_mode)Úmodes    úL/var/www/html/qr/venv/lib/python3.12/site-packages/pikepdf/_explicit_conv.pyÚset_object_conversion_moder      s   € ô4 
×'Ñ'¨°
Ñ(:Õ;ó    c                 ó2   — t        j                  «       rdS dS )aá  Get current effective object conversion mode.

    This returns the mode that is currently in effect for the calling thread,
    taking into account both the global setting and any active
    :func:`explicit_conversion` context managers.

    Returns:
        The current effective conversion mode: ``'implicit'`` or ``'explicit'``.

    .. versionadded:: 10.1

    .. versionchanged:: 10.2
        Now returns the effective mode, including thread-local context manager state.
    r   Úimplicit)r   Ú_get_effective_explicit_mode© r   r   Úget_object_conversion_moder   +   s   € ô ×;Ñ;Ô=ˆ:ÐMÀ:ÐMr   c               #  ó˜   K  — t        j                  «        	 d–— t        j                  «        y# t        j                  «        w xY w­w)a&  Context manager for explicit conversion mode.

    Within this context, PDF scalar values will be returned as
    ``pikepdf.Integer``, ``pikepdf.Boolean``, and ``pikepdf.Real`` objects
    instead of being automatically converted to Python native types.

    This context manager is thread-local: it only affects the current thread
    and takes precedence over the global setting from
    :func:`set_object_conversion_mode`. Nested context managers are supported.

    Example:
        >>> with pikepdf.explicit_conversion():
        ...     pdf = pikepdf.open('test.pdf')
        ...     count = pdf.Root.Count
        ...     isinstance(count, pikepdf.Integer)
        True

    .. versionadded:: 10.1

    .. versionchanged:: 10.2
        Now thread-local and takes precedence over global setting.
    N)r   Ú_enter_thread_explicit_modeÚ_exit_thread_explicit_moder   r   r   Úexplicit_conversionr   =   s4   è ø€ ô0 
×%Ñ%Ô'ð+Ûä×(Ñ(Õ*øŒ×(Ñ(Õ*üs   ‚A
˜1 œA
±AÁA
N)r
   úLiteral['implicit', 'explicit']ÚreturnÚNone)r   r   )Ú
__future__r   Ú
contextlibr   Útypingr   Úpikepdfr   r   r   r   r   r   r   ú<module>r      s4   ðõ
 #õ &Ý å ó<ó:Nð$ ñ+ó ñ+r   