Ë
    ¼Ó^jL  ã                  ór  — d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZ  G d„ de«      Z	 d	 	 	 	 	 	 	 	 	 	 	 dd„Zee_         ej                   d«      d	k(  r ej"                  d
e«       n ej"                  de«       dd„Zd„ df	 	 	 	 	 	 	 	 	 	 	 dd„Z ed«      Z G d„ de
e   «      Zddd„Zy)é    )ÚannotationsN)ÚCallable)ÚAnyÚGenericÚTypeVarc                  ó   — e Zd ZdZy)ÚSupervisionWarningszßSupervision warning category.
    Set the deprecation warnings visibility for Supervision library.
    You can set the environment variable SUPERVISON_DEPRECATION_WARNING to '0' to
    disable the deprecation warnings.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úe/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/utils/internal.pyr	   r	      s   „ ñð 	r   r	   c                ó&   — |j                   › d| › d�S )zw
    Format a warning the same way as the default formatter, but also include the
    category name in the output.
    z: ú
)r
   )ÚmessageÚcategoryÚfilenameÚlinenoÚlines        r   Úformat_warningr      s   € ð ×ÑÐ   7 )¨2Ð.Ð.r   ÚSUPERVISON_DEPRECATION_WARNINGÚ0ÚignoreÚalwaysc                ó<   — t        j                  | t        d¬«       y)zˆ
    Issue a warning that a function is deprecated.

    Args:
        message: The message to display when the function is called.
    é   )r   Ú
stacklevelN)ÚwarningsÚwarnr	   ©r   s    r   Úwarn_deprecatedr#   +   s   € ô ‡M�M�'Ô$7ÀAÖFr   c                ó   — | S ©Nr   )Úxs    r   ú<lambda>r'   8   s   € °1€ r   z]Warning: '{old_parameter}' in '{function_name}' is deprecated: use '{new_parameter}' instead.c                ó$   ‡ ‡‡‡‡— dˆˆˆˆ ˆfd„}|S )aD  
    A decorator to mark a function's parameter as deprecated and issue a warning when
    used.

    Args:
        old_parameter: The name of the deprecated parameter.
        new_parameter: The name of the parameter that should be used instead.
        map_function: A function used to map the value of the old
            parameter to the new parameter. Defaults to the identity function.
        warning_message: The warning message to be displayed when the
            deprecated parameter is used. Defaults to a generic warning message with
            placeholders for the old parameter, new parameter, and function name.
        **message_kwargs: Additional keyword arguments that can be used to customize
            the warning message.

    Returns:
        A decorator function that can be applied to mark a function's
            parameter as deprecated.

    Examples:
        ```pycon
        >>> from supervision.utils.internal import deprecated_parameter
        >>> import warnings
        >>> @deprecated_parameter(
        ...     old_parameter='old_name',
        ...     new_parameter='new_name'
        ... )
        ... def example_function(new_name=None):
        ...     return new_name
        >>> # Calling with new parameter works normally
        >>> example_function(new_name='value')
        'value'
        >>> # Calling with old parameter triggers warning but still works
        >>> with warnings.catch_warnings(record=True):
        ...     result = example_function(old_name='deprecated_value')
        ...     print(result)
        deprecated_value

        ```
    c                óP   •‡ — t        j                  ‰ «      dˆ ˆˆˆˆˆfd„«       }|S )Nc            	     ó   •— ‰|v r‚| r:t        | d   d«      r+| d   j                  j                  }|› d‰j                  › �}n‰j                  }t         ‰	j                  d|‰‰dœ‰¤Ž¬«        ‰|j                  ‰«      «      |‰<    ‰| i |¤ŽS )Nr   Ú	__class__ú.)Úfunction_nameÚold_parameterÚnew_parameterr"   r   )Úhasattrr+   r
   r#   ÚformatÚpop)
ÚargsÚkwargsÚ
class_namer-   ÚfuncÚmap_functionÚmessage_kwargsr/   r.   Úwarning_messages
       €€€€€€r   Úwrapperz8deprecated_parameter.<locals>.decorator.<locals>.wrapperg   s§   ø€ à Ñ&ÙœG D¨¡G¨[Ô9Ø!% a¡×!2Ñ!2×!;Ñ!;�JØ'1 l°!°D·M±M°?Ð$C‘Mà$(§M¡M�MäØ2˜O×2Ñ2ð Ø&3Ø&3Ø&3ñð )ñ	õñ )5°V·Z±ZÀÓ5NÓ(O��}Ñ%á˜Ð( Ñ(Ð(r   )r3   r   r4   r   Úreturnr   )Ú	functoolsÚwraps)r6   r:   r7   r8   r/   r.   r9   s   ` €€€€€r   Ú	decoratorz'deprecated_parameter.<locals>.decoratorf   s*   ù€ Ü	�‰˜Ó	÷	)ñ 	)ó 
ð	)ð* ˆr   )r6   úCallable[..., Any]r;   r?   r   )r.   r/   r7   r9   r8   r>   s   ````` r   Údeprecated_parameterr@   5   s   ü€ ÷bñ ð2 Ðr   ÚTc                  ó"   — e Zd ZdZdd„Zddd„Zy)Úclasspropertya  
    A decorator that combines @classmethod and @property.
    It allows a method to be accessed as a property of the class,
    rather than an instance, similar to a classmethod.

    Usage:
        @classproperty
        def my_method(cls):
            ...
    c                ó   — || _         y)z^
        Args:
            The function that is called when the property is accessed.
        N)Úfget)ÚselfrE   s     r   Ú__init__zclassproperty.__init__‘   s   € ð
 ˆ�	r   Nc                óR   — | j                   €t        d«      ‚| j                  |«      S )aŸ  
        Override the __get__ method to return the result of the function call.

        Args:
            owner_self: The instance through which the attribute was accessed, or None.
                Irrelevant for class properties.
            owner_cls: The class through which the attribute was accessed.

        Returns:
            The result of calling the function stored in 'fget' with 'owner_cls'.
        zunreadable attribute)rE   ÚAttributeError)rF   Ú
owner_selfÚ	owner_clss      r   Ú__get__zclassproperty.__get__˜   s)   € ð �9‰9ÐÜ Ð!7Ó8Ð8Ø�y‰y˜Ó#Ð#r   )rE   zCallable[..., T]r%   )rJ   r   rK   ztype | Noner;   rA   )r
   r   r   r   rG   rL   r   r   r   rC   rC   …   s   „ ñ	óõ$r   rC   c                ój  — t        | t        «      rt        d«      ‚t        j                  | «      D ��ch c]#  \  }}t        |«      s|j                  d«      s|’Œ% }}}|sFt        j                  | j                  «      D ��ch c]  \  }}t        |t        «      r|’Œ }}}||z  }|S c c}}w c c}}w )aN  
    Get the public variables of a class instance.

    Args:
        instance: The instance of a class
        include_properties: Whether to include properties in the result

    Usage:
        ```pycon
        >>> from supervision.utils.internal import get_instance_variables
        >>> import numpy as np
        >>> from supervision import Detections
        >>> detections = Detections(xyxy=np.array([[1, 2, 3, 4]]))
        >>> variables = get_instance_variables(detections)
        >>> 'xyxy' in variables
        True
        >>> 'data' in variables
        True

        ```
    z0Only class instances are supported, not classes.Ú_)	Ú
isinstanceÚtypeÚ
ValueErrorÚinspectÚ
getmembersÚcallableÚ
startswithr+   Úproperty)ÚinstanceÚinclude_propertiesÚnameÚvalÚfieldsÚ
propertiess         r   Úget_instance_variablesr]   ©   s¸   € ô, �(œDÔ!ÜÐKÓLÐLô !×+Ñ+¨HÓ5÷áˆD�#Ü˜Œ} T§_¡_°SÔ%9ò 	ð€Fñ ñ ô %×/Ñ/°×0BÑ0BÓC÷
á��cÜ˜#œxÔ(ò ð
ˆ
ñ 
ð
 	�*Ñˆà€Mùóùó
s   ´(B)ÂB/r%   )r   zWarning | strr   ztype[Warning]r   Ústrr   Úintr   z
str | Noner;   r^   )r   r^   r;   ÚNone)r.   r^   r/   r^   r7   úCallable[[Any], Any]r9   r^   r8   r   r;   ra   )F)rW   r   rX   Úboolr;   zset[str])Ú
__future__r   r<   rR   Úosr    Úcollections.abcr   Útypingr   r   r   ÚWarningr	   r   ÚformatwarningÚgetenvÚsimplefilterr#   r@   rA   rC   r]   r   r   r   ú<module>rk      s%  ðÝ "ã Û Û 	Û Ý $ß (Ñ (ô	˜'ô 	ð ð/Øð/àð/ð ð/ð ð	/ð
 ð/ð 	ó/ð (€Ô à€2‡9�9Ð-Ó.°#Ò5Ø€H×Ñ˜(Ð$7Õ8à€H×Ñ˜(Ð$7Ô8óGñ *5ð1ð	JØðJàðJð 'ðJð ð	Jð ðJð óJñZ ˆCƒL€ô!$�G˜A‘Jô !$õH'r   