U
    ˜ARd  ã                   @   s<   d dl Z d dlmZmZ G dd„ deƒZG dd„ deƒZdS )é    N)ÚOptionalÚUnionc                   @   s   e Zd ZdS )ÚJSNumberBoundsExceptionN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú7/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/js_number.pyr      s   r   c                   @   sd   e Zd ZdZdZdZdZdZe Ze	de
ee ddœdd	„ƒZe	ee
ef ee ddœd
d„ƒZdS )ÚJSNumberz7Utility class for exposing JavaScript Number constants.l   ÿÿÿÿ lüÿÿÿÿÿÿÿ gÿÿÿÿÿÿïg       N)ÚvalueÚ
value_nameÚreturnc                 C   sF   |dkrd}|| j k r(td||f ƒ‚n|| jkrBtd||f ƒ‚dS )aö  Validate that an int value can be represented with perfect precision
        by a JavaScript Number.

        Parameters
        ----------
        value : int
        value_name : str or None
            The name of the value parameter. If specified, this will be used
            in any exception that is thrown.

        Raises
        ------
        JSNumberBoundsException
            Raised with a human-readable explanation if the value falls outside
            JavaScript int bounds.

        Nr   z#%s (%s) must be >= -((1 << 53) - 1)z %s (%s) must be <= (1 << 53) - 1)ÚMIN_SAFE_INTEGERr   ÚMAX_SAFE_INTEGER©Úclsr   r   r   r   r	   Úvalidate_int_bounds+   s    

ÿ

ÿzJSNumber.validate_int_boundsc                 C   sh   |dkrd}t |tjtfƒs.td||f ƒ‚n6|| jk rJtd||f ƒ‚n|| jkrdtd||f ƒ‚dS )aÜ  Validate that a float value can be represented by a JavaScript Number.

        Parameters
        ----------
        value : float
        value_name : str or None
            The name of the value parameter. If specified, this will be used
            in any exception that is thrown.

        Raises
        ------
        JSNumberBoundsException
            Raised with a human-readable explanation if the value falls outside
            JavaScript float bounds.

        Nr   z%s (%s) is not a floatz%s (%s) must be >= -1.797e+308z%s (%s) must be <= 1.797e+308)Ú
isinstanceÚnumbersÚIntegralÚfloatr   ÚMIN_NEGATIVE_VALUEÚ	MAX_VALUEr   r   r   r	   Úvalidate_float_boundsJ   s    
ÿ

ÿ

ÿzJSNumber.validate_float_bounds)N)r   r   r   Ú__doc__r   r   r   Z	MIN_VALUEr   ÚclassmethodÚintr   Ústrr   r   r   r   r   r   r   r	   r
      s   
 þr
   )r   Útypingr   r   Ú	Exceptionr   Úobjectr
   r   r   r   r	   Ú<module>   s   