
    Ng1                         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	dS )	zi Python 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    rF|dk    r@|dz  }|dz  t          |          dz
  z   }|dk    r|t          j        d	|          z  }dx}}^|d
k    r#|dk    sJ t          |                      |dz  }|dk    rD|r@t          d|z
            D ]
}|dz  dz   }|t          j        d	|          d|dz
           z  } n|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_s          L/var/www/html/ai-engine/env/lib/python3.11/site-packages/pdfminer/ascii85.pyascii85decoder      s*    IA
C$ZZ  1$KK199dFAB#a&&2+&AAvvv{4+++	A$YY6663q66666;CC$YY 5q1u $ $ABAAv{4++Ga!eG44E  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                              |           D ]}| ||          z  }t                              |           }|r$| ||                    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                 B    t          | d          }t          |f          S )N   )intr   )r    r   s     r   decodezasciihexdecode.<locals>.decode=   s    2JJaT{{r   r   r	      0)r   hex_refindalltrail_researchgroup)r   r$   r   r    ms        r   asciihexdecoder,   2   s    % E     C^^D!!  vvayyA )vvaggajj4'(((Jr   )
__doc__rer   r   r   compile
IGNORECASEr&   r(   r,    r   r   <module>r2      s     
			  %    D 
$bm	4	42:=r}MM 5      r   