
    +Si                         d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ  ej                  d      Z e j"                  e      Zd	ed
efdZded
dfdZ G d d      Zy)    N)Iterable)ClassVarcast)glyphname2unicode)ENCODINGPDFKeyError)	PSLiteralz[0-9a-fA-F]+namereturnc           	         t        | t              st        d|  dt        |              | j	                  d      d   } | j	                  d      }t        |      dkD  rdj                  t        t        |            S | t        v r	t        |    S | j                  d      r| j                  d      }t        j                  |      rt        |      d	z  dk(  rt        dt        |      d	      D cg c]  }t        |||d	z    d
       }}|D ]  }t!        |        t        t"        |      }dj                  |      S | j                  d      r`| j                  d      }t        j                  |      r:d	t        |      cxk  rdk  r&n n#t        |d
      }t!        |       t#        |      S t        d|  d      c c}w )a  Converts Adobe glyph names to Unicode numbers.

    In contrast to the specification, this raises a KeyError instead of return
    an empty string when the key is unknown.
    This way the caller must explicitly define what to do
    when there is not a match.

    Reference:
    https://github.com/adobe-type-tools/agl-specification#2-the-mapping

    :returns unicode character if name resembles something,
    otherwise a KeyError
    z Could not convert unicode name "z?" to character because it should be of type str but is of type .r   _    uni      )baseu   z6" to character because it does not match specification)
isinstancestrr	   typesplitlenjoinmapname2unicoder   
startswithstripHEXADECIMALmatchrangeint#raise_key_error_for_invalid_unicodechr)	r   
componentsname_without_uniiunicode_digitsdigit
charactersname_without_uunicode_digits	            \/var/www/html/leadgen/airagagent/rag_env/lib/python3.12/site-packages/pdfminer/encodingdb.pyr   r      s    dC .tf 577;DzlD
 	

 ::c?1DCJ
:wws<455	"	" &&		::e,-.37G3H13LPQ3Q q#&6"7; $QQ/b9N  ( ;3E:;S.1J77:&&		C^,c.6I1NQ1NR8M/>}%%

*4& 1* 	* #s   .F=r/   c                 >    d| cxk  rdk  rn yt        d|  d      y)zUnicode values should not be in the range D800 through DFFF because
    that is used for surrogate pairs in UTF-16

    :raises KeyError if unicode digit is invalid
    i  i   zUnicode digit z8 is invalid because it is in the range D800 through DFFFNr   )r/   s    r0   r&   r&   H   s4     }$u$]O ,3 3
 	
 %    c            
       T   e Zd ZU i Zeeeef      ed<   i Z	eeeef      ed<   i Z
eeeef      ed<   i Zeeeef      ed<   eD ]-  \  ZZZZZ ee      Zereee<   eree	e<   eree
e<   es)eee<   / ee	e
edZeeeeeef   f      ed<   e	 dded	ee   dz  d
eeef   fd       Zy)
EncodingDBstd2unicodemac2unicodewin2unicodepdf2unicode)StandardEncodingMacRomanEncodingWinAnsiEncodingPDFDocEncoding	encodingsNr   diffr   c                    | j                   j                  || j                        }|ri|j                         }d}|D ]R  }t	        |t
              r|}t	        |t              s'	 t        t        t        |j                              ||<   |dz  }T |S # t        t        f$ r(}t        j                  t        |             Y d }~;d }~ww xY w)Nr   r   )r=   getr5   copyr   r%   r
   r   r   r   r   KeyError
ValueErrorlogdebug)clsr   r>   cid2unicodecidxes          r0   get_encodingzEncodingDB.get_encodingl   s     mm''coo>%**,KC a%C9-*+7S!&&8I+JC( 1HC  %j1 *		#a&))*s   %&BC#CC)N)__name__
__module____qualname__r5   r   dictr%   r   __annotations__r6   r7   r8   r   r   stdmacwinpdfr   cr=   classmethodr   objectrK    r2   r0   r4   r4   U   s0   ,.K$sCx.).,.K$sCx.).,.K$sCx.).,.K$sCx.).$, 	! c3S K K K K	! ('&%	6IxS$sCx.012   )- v% 
c3h	 r2   r4   )loggingrecollections.abcr   typingr   r   pdfminer.glyphlistr   pdfminer.latin_encr   pdfminer.pdfexceptionsr	   pdfminer.psparserr
   compiler"   	getLoggerrL   rD   r   r   r%   r&   r4   rX   r2   r0   <module>rc      sp     	 $ ! 0 ' . 'bjj)g!5s 5s 5p

s 

t 

* *r2   