
    $|h&                         d Z ddlZddlZdedefdZ ej
                  dej                        Z ej
                  dej                        ZdedefdZ	y)	zhPython implementation of ASCII85/ASCIIHex decoder (Adobe version).

This code is in the public domain.

    Ndatareturnc                    dx}}d}t        |       D ]  }t        |f      }|dk\  rB|dk  r=|dz  }|dz  t        |      dz
  z   }|dk(  s8|t        j                  d	|      z  }dx}}V|d
k(  r|dk(  sJ t        |             |dz  }v|dk(  s||r:t        d|z
        D ]
  }|dz  dz   } |t        j                  d	|      d|dz
   z  } |S  |S )ap  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_s          O/var/www/html/test/engine/venv/lib/python3.12/site-packages/pdfminer/ascii85.pyascii85decoder      s    IA
C$Z 1$K9dFAB#a&2+&AAvv{{4++	A$Y6!3q6!6;C$Yq1u $ABA$v{{4+Ga!e44J#" Jr   s   ([a-f\d]{2})s#   ^(?:[a-f\d]{2}|\s)*([a-f\d])[\s>]*$c                     dt         dt         fd}d}t        j                  |       D ]  }| ||      z  } t        j	                  |       }|r| ||j                  d      dz         z  }|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                 2    t        | d      }t        |f      S )N   )intr   )r    r   s     r   decodezasciihexdecode.<locals>.decode;   s    2JaT{r   r   r	      0)r   hex_refindalltrail_researchgroup)r   r$   r   r    ms        r   asciihexdecoder,   1   sv    % E  C^^D! vay 	Avaggaj4'((Jr   )
__doc__rer   r   r   compile
IGNORECASEr&   r(   r,    r   r   <module>r2      si    
  % B 
$bmm	42::=r}}M 5 r   