
    tf              	           d dl mZ d dl mZ d dl mZ d dlmZ	 d dl
mZmZ g dZeefZdedefd	Zdefd
Zdedeeef   fdZddedededefdZ	 ddedededefdZddededefdZddededefdZdedefdZy)    )	b64decode)	b64encode)encodebytes)Error)AnyUnion)_get_simd_name_get_simd_pathr   r   b64encode_as_stringr   flagsreturnc                     | dk(  sJ y)Nr   fallback )r   s    \/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/pybase64/_fallback.pyr	   r	      s    A::    c                       y)Nr   r   r   r   r   r
   r
      s    r   sc                 ^   t        | t              r	 | j                  d      S t        | t
              r| S 	 t        |       }|j                  st        d      |j                         S # t        $ r t	        d      w xY w# t        $ r# t        d| j                  j                  z        w xY w)Nasciiz4string argument should contain only ASCII characters1memoryview: underlying buffer is not C-contiguousz>argument should be a bytes-like object or ASCII string, not %r)
isinstancestrencodeUnicodeEncodeError
ValueError_bytes_types
memoryviewc_contiguousBufferErrortobytes	TypeError	__class____name__r   mvs     r   
_get_bytesr'      s    !S	X88G$$ !\"	
]QRRzz| " 	XVWW	X  
 {{334
 	

s   A( 1B  (A= ,B,Naltcharsvalidatec                 \   t        |       } |t        |      }|rt        |       dz  dk7  rt        d      t        | |d      }d}t        |       dkD  r0d}| d   dk(  r|dz  }| d	   dk(  r|dz  }d
t        |       dz  z  |z
  }|t        |      k7  rt        d      |S t        | |d      S )a  Decode bytes encoded with the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` or ASCII string to
    decode.

    Optional ``altchars`` must be a :term:`bytes-like object` or ASCII
    string of length 2 which specifies the alternative alphabet used instead
    of the '+' and '/' characters.

    If ``validate`` is ``False`` (the default), characters that are neither in
    the normal base-64 alphabet nor the alternative alphabet are discarded
    prior to the padding check.
    If ``validate`` is ``True``, these non-alphabet characters in the input
    result in a :exc:`binascii.Error`.

    The result is returned as a :class:`bytes` object.

    A :exc:`binascii.Error` is raised if ``s`` is incorrectly padded.
       r   zIncorrect paddingF)r)   =         zNon-base64 digit found)r'   lenBinAsciiErrorbuiltin_decode)r   r(   r)   resultexpected_lenpaddings         r   r   r   1   s    ( 	1Ah'q6A:? 3448e< q6A:Gu{1u{1A!,w6L3v;& 899!X66r   c                 0    t        t        | ||            S )a  Decode bytes encoded with the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` or ASCII string to
    decode.

    Optional ``altchars`` must be a :term:`bytes-like object` or ASCII
    string of length 2 which specifies the alternative alphabet used instead
    of the '+' and '/' characters.

    If ``validate`` is ``False`` (the default), characters that are neither in
    the normal base-64 alphabet nor the alternative alphabet are discarded
    prior to the padding check.
    If ``validate`` is ``True``, these non-alphabet characters in the input
    result in a :exc:`binascii.Error`.

    The result is returned as a :class:`bytearray` object.

    A :exc:`binascii.Error` is raised if ``s`` is incorrectly padded.
    )r(   r)   )	bytearrayr   )r   r(   r)   s      r   b64decode_as_bytearrayr9   ]   s    , Yq8hGHHr   c                 x    t        |       }|j                  st        d      |t        |      }t	        | |      S )a  Encode bytes using the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` to encode.

    Optional ``altchars`` must be a byte string of length 2 which specifies
    an alternative alphabet for the '+' and '/' characters.  This allows an
    application to e.g. generate url or filesystem safe Base64 strings.

    The result is returned as a :class:`bytes` object.
    r   )r   r   r    r'   builtin_encode)r   r(   r&   s      r   r   r   v   s=     
AB??MNNh'!X&&r   c                 8    t        | |      j                  d      S )a  Encode bytes using the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` to encode.

    Optional ``altchars`` must be a byte string of length 2 which specifies
    an alternative alphabet for the '+' and '/' characters.  This allows an
    application to e.g. generate url or filesystem safe Base64 strings.

    The result is returned as a :class:`str` object.
    r   )r   decode)r   r(   s     r   r   r      s     Q!((11r   c                 \    t        |       }|j                  st        d      t        |       S )a-  Encode bytes into a bytes object with newlines (b'\\n') inserted after
    every 76 bytes of output, and ensuring that there is a trailing newline,
    as per :rfc:`2045` (MIME).

    Argument ``s`` is a :term:`bytes-like object` to encode.

    The result is returned as a :class:`bytes` object.
    r   )r   r   r    builtin_encodebytesr%   s     r   r   r      s+     
AB??MNNq!!r   )NF)N)base64r   r3   r   r;   r   r?   binasciir   r2   typingr   r   __all__bytesr8   r   intr   r	   r
   r'   boolr9   r   r   r   r   <module>rG      s    . . 5 +  y!# # 
 
# 
%y 01 
()7 )7 )7d )7u )7Z 49I
II,0II2' ' 'u '&23 2# 2 2"3 "5 "r   