o
    hw	                     @   s   d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
 ddlmZ deeef defd	d
ZdedefddZdeeeef  dee fddZdedefddZdedee fddZdedefddZdS )    )AnyListOptionalUnion)	PDFObjRef)	PSLiteralPDFDocEncoding   )MalformedPDFExceptionsreturnc                 C   sh   t | tr| drt| dd ddS zdd | D }dd	d |D W S  ty3   t|  Y S w )
zg
    Decodes a PDFDocEncoding string to Unicode.
    Adds py3 compatibility to pdfminer's version.
    s      Nzutf-16beignorec                 s   s&    | ]}t |trt|n|V  qd S N)
isinstancestrord).0c r   P/var/www/html/venv/lib/python3.10/site-packages/pdfplumber/utils/pdfinternals.py	<genexpr>   s   $ zdecode_text.<locals>.<genexpr> c                 s   s    | ]}t | V  qd S r   r   )r   or   r   r   r          )r   bytes
startswithr   join
IndexError)r   Zordsr   r   r   decode_text
   s   r    objc                 C   s   t | dr	|  } t| trttt| S t| trt| jS t| t	t
fr*t| S t| tr@|  D ]
\}}t|| |< q3| S | S )z(Recursively resolve the metadata values.resolve)hasattrr"   r   listmapresolve_and_decoder   r    namer   r   dictitems)r!   kvr   r   r   r&      s   




r&   _listc                 C   s   dd | D S )Nc                 S   s$   g | ]}t |trt|jn|qS r   )r   r   r    r'   )r   valuer   r   r   
<listcomp>+   s    z#decode_psl_list.<locals>.<listcomp>r   )r,   r   r   r   decode_psl_list*   s   r/   xc                 C   s   t | tr	|  S | S r   )r   r   r"   )r0   r   r   r   r"   1   s   
r"   dc                 C   s0   t | tsd S | d}t |trt|jS |S )NType)r   r(   getr   r    r'   )r1   tr   r   r   get_dict_type8   s   



r5   c              
      s   t | tr'|  }t|dkr| S zt|W S  ty& } zt|d}~ww t | ttfr9t	| dd | D S t | t
rTt| dkrGdgng   fdd|  D S | S )	zF
    Recursively resolves the given object and all the internals.
    ZPageNc                 s   s    | ]}t |V  qd S r   resolve_all)r   r+   r   r   r   r   R   r   zresolve_all.<locals>.<genexpr>ZAnnotZParentc                    s&   i | ]\}}|| v r|nt |qS r   r6   )r   r*   r+   
exceptionsr   r   
<dictcomp>U   s   & zresolve_all.<locals>.<dictcomp>)r   r   r"   r5   r7   RecursionErrorr   r$   tupletyper(   r)   )r0   resolveder   r8   r   r7   B   s    


r7   N)typingr   r   r   r   Zpdfminer.pdftypesr   Zpdfminer.psparserr   Zpdfminer.utilsr	   r9   r   r   r   r    r&   r/   r"   r5   r7   r   r   r   r   <module>   s    "
