o
    ‡®f1  ã                   @   sX   d Z ddlZddlZdedefdd„Ze dej¡Ze dej¡Zdedefd	d
„Z	dS )zi Python implementation of ASCII85/ASCIIHex decoder (Adobe version).

This code is in the public domain.

é    NÚdataÚreturnc                 C   sè   d }}d}t | ƒD ]g}t|fƒ}d|kr8|dkr8|d7 }|d t|ƒd  }|dkr7|t d	|¡7 }d }}q
|d
krK|dksFJ t|ƒƒ‚|d7 }q
|dkrq|rntd| ƒD ]}|d d }qW|t d	|¡d|d … 7 } |S q
|S )au  
    In ASCII85 encoding, every four bytes are encoded with five ASCII
    letters, using 85 different types of characters (as 256**4 < 85**5).
    When the length of the original bytes is not a multiple of 4, a special
    rule is used for round up.

    The Adobe's ASCII85 implementation is slightly different from
    its original in handling the last characters.

    r   ó    ó   !ó   ué   éU   é!   é   z>Ló   zs       ó   ~éT   N)ÚiterÚbytesÚordÚstructÚpackÚstrÚrange)r   ÚnÚbÚoutÚiÚcÚ_© r   úI/home/ubuntu/webapp/venv/lib/python3.10/site-packages/pdfminer/ascii85.pyÚascii85decode   s.   
€
úr   s   ([a-f\d]{2})s#   ^(?:[a-f\d]{2}|\s)*([a-f\d])[\s>]*$c                 C   sZ   dt dt fdd„}d}t | ¡D ]}|||ƒ7 }qt | ¡}|r+||| d¡d ƒ7 }|S )aæ  
    ASCIIHexDecode filter: PDFReference v1.4 section 3.3.1
    For each pair of ASCII hexadecimal digits (0-9 and A-F or a-f), the
    ASCIIHexDecode filter produces one byte of binary data. All white-space
    characters are ignored. A right angle bracket character (>) indicates
    EOD. Any other characters will cause an error. If the filter encounters
    the EOD marker after reading an odd number of hexadecimal digits, it
    will behave as if a 0 followed the last digit.
    Úxr   c                 S   s   t | dƒ}t|fƒS )Né   )Úintr   )r   r   r   r   r   Údecode=   s   

zasciihexdecode.<locals>.decoder   r   ó   0)r   Úhex_reÚfindallÚtrail_reÚsearchÚgroup)r   r!   r   r   Úmr   r   r   Úasciihexdecode2   s   
r)   )
Ú__doc__Úrer   r   r   ÚcompileÚ
IGNORECASEr#   r%   r)   r   r   r   r   Ú<module>   s    "