
    є jwQ                     $   U d Z dZdZddlZddlZddlZ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mZmZmZmZ ej        dd         dk    rddlmZ nddlmZ ej        dk    rddlmZ nddlmZ ddlmZmZmZ eee e e f         ee e e f         ee e e f         f         Z!ee"d<   ee e e e e e f         Z#ee"d<   ee         Z$ee%         Z&ee'e$f         Z(dee'         dee
         fdZ)de
de'fdZ*de'de'de'fdZ+dZ,d-                    e,          Z.de.z   dz   Z/dVd e$d!ee0         de%fd"Z1d e&de%fd#Z2d e$de3fd$Z4d%e%de3fd&Z5d e$ddfd'Z6d e$d(ee%         de%fd)Z7d e&d*e0de%fd+Z8d e$de%fd,Z9d-e!d.e!de!fd/Z:d e$ddfd0Z;ed.e'de0fd1            Z<ed.e%de%fd2            Z<ed.e0de0fd3            Z<d.ee0e'e%f         dee0e%f         fd4Z<dWd6e'd7e0ddfd8Z=d6e'ddfd9Z>d:e'd;e'd<e'ddfd=Z?d:e'd;e'd<e'ddfd>Z@d?e'd<e'ddfd@ZAd?e'd<e'ddfdAZBdBe'dCe'dDeddfdEZCd6e'dFe'ddfdGZD	 dXdIe'dJeEe'ef         dKeEe'e'f         dLe3ddf
dMZFdNe0de'fdOZG G dP dQ          ZHe	 G dR dS                      ZIejJ         G dT dU                      ZKdS )Yz"Utility functions for PDF library.zMathieu Fenniakzbiziqe@mathieu.fenniak.net    N)	dataclass)datetimetimezone)DEFAULT_BUFFER_SIZE)SEEK_CUR)Pattern)IOAnyOptionalUnionoverload   )   
   )	TypeAlias)r      )Self   )STREAM_TRUNCATED_PREMATURELYDeprecationErrorPdfStreamErrorTransformationMatrixTypeCompressedTransformationMatrixtextreturnc                    | }| sd S | d                                          rd| z   } |                     d          r| dz  } |                     dd                              dd                              dd	          } t          |                     d          |                     d
                    }|dk    r|t          |           dz
  k    r| dz  } dD ]`}	 t          j        | |          }|                     d          r |                    t          j	                  }|c S # t          $ r Y ]w xY wt          d|           )Nr   zD:)Zz0000r   +r   ' -   00)zD:%YzD:%Y%mzD:%Y%m%dz
D:%Y%m%d%HzD:%Y%m%d%H%MD:%Y%m%d%H%M%SzD:%Y%m%d%H%M%S%zz+0000)tzinfozCan not convert date: )isdigitendswithreplacemaxfindlenr   strptimer   utc
ValueError)r   orgtextifds        `C:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pypdf/_utils.pyparse_iso8824_dater6   O   sh   G tAw d{}}Z   <<S!!))#s33;;CDDDDIIcNNDIIcNN++A1u c$ii!m#   	!$**A }}W%% 3IIX\I22HHH  	 	 	H	 7g77
8
88s   D((
D54D5dtc                 ,   |                      d          }| j        w|                                 }|J t          |                                          }t          t          |          d          \  }}|dz  }|dk    rdnd}|| |dd	|dd	z  }|S )
a  
    Convert a datetime object to PDF date string format.

    Converts datetime to the PDF date format D:YYYYMMDDHHmmSSOHH'mm
    as specified in the PDF Reference.

    Args:
        dt: A datetime object to convert.

    Returns:
        A date string in PDF format.
    r&   Ni  <   r   r    r#   02dr!   )strftimer'   	utcoffsetinttotal_secondsdivmodabs)r7   date_stroffsetr>   hours	remainderminutessigns           r5   format_iso8824_daterG   o   s     {{+,,H	y 8!!!F002233!#m"4"4d;;yr/#q(1ssct7U77777777O    header1header2c                 6   d}g }| |v r(|                     |                    |                      ||v r(|                     |                    |                     t          |          dk    rt          d| d|d          |t	          |                   S )N)z%PDF-1.3z%PDF-1.4z%PDF-1.5z%PDF-1.6z%PDF-1.7z%PDF-2.0r   zNeither z nor z are proper headers)appendindexr-   r0   r+   )rI   rJ   versionspdf_header_indicess       r5   _get_max_pdf_version_headerrP      s    H ( ;!!(.."9"9:::( ;!!(.."9"9:::
!# TRGRRGRRRSSSC*++,,rH   )       	   
          rH      [   ]streammaxcharsc                     d}	 |                      d          }|                                s|sn||z  }t          |          |k    rnF|S )a<  
    Read non-whitespace characters and return them.

    Stops upon encountering whitespace or when maxchars is reached.

    Args:
        stream: The data stream from which was read.
        maxchars: The maximum number of bytes returned; by default unlimited.

    Returns:
        The data which was read.

    rH   Tr   )readisspacer-   )rY   rZ   txttoks       r5   read_until_whitespacer`      sb     Ckk!nn;;== 	 	s
s88x 	 JrH   c                 ~    |                      d          }|t          v r|                      d          }|t          v |S )z
    Find and read the next non-whitespace character (ignores whitespace).

    Args:
        stream: The data stream from which was read.

    Returns:
        The data which was read.

    r   r\   WHITESPACESrY   r_   s     r5   read_non_whitespacere      sC     ++a..C

 kk!nn 
 JrH   c                     |                      d          }d}|t          v r#|dz  }|                      d          }|t          v #|dk    S )a  
    Similar to read_non_whitespace, but return a boolean if at least one
    whitespace character was read.

    Args:
        stream: The data stream from which was read.

    Returns:
        True if one or more whitespace was skipped, otherwise return False.

    r   r   rb   )rY   r_   cnts      r5   skip_over_whitespacerh      sW     ++a..C
C

 qkk!nn 
  7NrH   valuec                 4    t          d | D                       S )z
    Check if the given value consists of whitespace characters only.

    Args:
        value: The bytes to check.

    Returns:
        True if the value only has whitespace characters, otherwise return False.

    c              3   (   K   | ]}|t           v V  d S N)WHITESPACES_AS_BYTES).0bs     r5   	<genexpr>z+check_if_whitespace_only.<locals>.<genexpr>   s(      88Qq((888888rH   )all)ri   s    r5   check_if_whitespace_onlyrr      s!     88%888888rH   c                     |                      d          }|                     dd           |dk    r4|dvr2|                      d          }|dk    rt          d          |dv.d S d S d S )Nr      %)rS   rU   rH   zFile ended unexpectedly.)r\   seekr   rd   s     r5   skip_over_commentrw      s    
++a..C
KKA
d{ A' 	A++a..Ccz A$%?@@@ ' 	A 	A 	AA A	A 	ArH   regexc                 (   g }d}d}d}	 |                      |          }|sd                    |          S ||z   }|                    |          }|t          |          }	||	z
  |                                z   }
|                     |
|z
  t          |          z
  d           |                    |           d                    |          d|
         S |                    |           |t          |          z  }|dd         }|dk     r|dz  }
)	z
    Read until the regular expression pattern matched (ignore the match).
    Treats EOF on the underlying stream as the end of the token to be matched.

    Args:
        regex: re.Pattern

    Returns:
        The read bytes.

    r   rH      TNr   ii    )r\   joinsearchr-   startrv   rL   )rY   rx   parts	total_lentail
chunk_sizer_   bufmoverlapactual_starts              r5   read_until_regexr      s(    EIDJkk*%% 	#88E??" SjLL 	2$iiG$w.:LKKy03s88;Q???LL88E??=L=11SSXX	 344y 	1J)rH   to_readc                     |                                  |k     rt          d          |                     | t                     |                     |          }|                     | t                     |S )a  
    Given a stream at position X, read a block of size to_read ending at position X.

    This changes the stream's position to the beginning of where the block was
    read.

    Args:
        stream:
        to_read:

    Returns:
        The data which was read.

    z!Could not read malformed PDF file)tellr   rv   r   r\   )rY   r   r\   s      r5   read_block_backwardsr     sk     {{}}w B@AAA
KK(###;;wD
KK(###KrH   c                    g }d}|                                  dk    rt          t                    	 t          t          |                                            }|dk    rnt          | |          }t          |          dz
  }|s-|dk    r||         dvr|dz  }|dk    r
||         dv|dk    rd}|rF|                    ||dz   d                    |dk    r||         dv r|dz  }|dk    r
||         dv n|                    |           |dk    r|                     |dz   t                     nd
                    |ddd                   S )	a  
    Given a byte stream with current position X, return the previous line.

    All characters between the first CR/LF byte found before X
    (or, the start of the file, if no such byte is found) and position X
    After this call, the stream will be positioned one byte after the
    first non-CRLF character found beyond the first CR/LF byte before X,
    or, if no such byte is found, at the beginning of the stream.

    Args:
        stream: StreamType:

    Returns:
        The data which was read.

    Fr   Tr   s   
NrH   rt   )r   r   r   minr   r   r-   rL   rv   r   r{   )rY   line_content
found_crlfr   blockidxs         r5   read_previous_liner   7  s   " LJ{{}} ;9::: )6;;==99a< 	 %VW55%jj1n 	" ( uSz8 q ( uSz8 ax "!
 	'
 cAgii 0111( uSzW4 q ( uSzW4 
 &&&!8 	 KKa***A D 88L2&'''rH   aro   c                 :    t          fd| D                       S )Nc              3   ^   K   | ]&t          fd t           D                       V  'dS )c              3   f   K   | ]+}t          d  t          |          D                       V  ,dS )c              3   Z   K   | ]&\  }}t          |          t          |          z  V  'd S rl   )float)rn   r2   js      r5   rp   z6matrix_multiply.<locals>.<genexpr>.<genexpr>.<genexpr>u  s7      @@$!Q%((U1XX%@@@@@@rH   N)sumzip)rn   colrows     r5   rp   z,matrix_multiply.<locals>.<genexpr>.<genexpr>u  sB      TTSc@@#c3--@@@@@TTTTTTrH   N)tupler   )rn   r   ro   s    @r5   rp   z"matrix_multiply.<locals>.<genexpr>t  sZ         	TTTTCQRGTTTTT     rH   )r   )r   ro   s    `r5   matrix_multiplyr   q  s=              rH   c                    d}|                      | d           t          dd          5 }|                    |                     |                     |                    d           |                    |                     |                     ddd           n# 1 swxY w Y   |                      | d           dS )z5Create text file showing current location in context.i  r   zpypdf_pdfLocation.txtwbs   HEREN)rv   openwriter\   )rY   radius	output_fhs      r5   mark_locationr   z  s     F
KK	%t	,	, -	F++,,,   F++,,,- - - - - - - - - - - - - - - KKs   A&BB #B c                     d S rl    ro   s    r5   ord_r         CrH   c                     d S rl   r   r   s    r5   r   r     r   rH   c                     d S rl   r   r   s    r5   r   r     r   rH   c                 N    t          | t                    rt          |           S | S rl   )
isinstancestrordr   s    r5   r   r     s$    !S 1vvHrH   r   msg
stacklevelc                 >    t          j        | t          |           d S )N)r   )warningswarnDeprecationWarning)r   r   s     r5   	deprecater     s     M#)jAAAAAArH   c                      t          |           rl   )r   )r   s    r5   deprecationr     s    
3

rH   old_namenew_name
removed_inc                 8    t          |  d| d| dd           dS )zFIssue a warning that a feature will be removed, but has a replacement., is deprecated and will be removed in pypdf . Use 	 instead.   Nr   r   r   r   s      r5   deprecate_with_replacementr     s>    ffffS[fff	    rH   c                 6    t          |  d| d| d           dS )zMRaise an exception that a feature was already removed, but has a replacement.( is deprecated and was removed in pypdf r   r   Nr   r   s      r5   deprecation_with_replacementr     s:    bbZbbxbbb    rH   namec                 2    t          |  d| dd           dS )zCIssue a warning that a feature will be removed without replacement.r   .r   Nr   r   r   s     r5   deprecate_no_replacementr     s*    PP:PPPRSTTTTTrH   c                 0    t          |  d| d           dS )zJRaise an exception that a feature was already removed without replacement.r   r   Nr   r   s     r5   deprecation_no_replacementr     s'    4NNNNNOOOOOrH   messagesourcevaluesc                V    t          j        |                              | |           dS )z
    Use this instead of logger.error directly.

    That allows people to overwrite it more easily.

    See the docs on when to use which:
    https://pypdf.readthedocs.io/en/latest/user/suppress-warnings.html
    N)logging	getLoggererror)r   r   r   s      r5   logger_errorr     s+     f##GV44444rH   srcc                 T    t          j        |                              |            dS )a  
    Use this instead of logger.warning directly.

    That allows people to overwrite it more easily.

    ## Exception, warnings.warn, logger_warning
    - Exceptions should be used if the user should write code that deals with
      an error case, e.g. the PDF being completely broken.
    - warnings.warn should be used if the user needs to fix their code, e.g.
      DeprecationWarnings
    - logger_warning should be used if the user needs to know that an issue was
      handled by pypdf, e.g. a non-compliant PDF being read in a way that
      pypdf could apply a robustness fix to still read it. This applies mainly
      to strict=False mode.
    N)r   r   warning)r   r   s     r5   logger_warningr     s)      c""3'''''rH   F	func_namekwargsaliasesfailc                 (   |                                 D ]|\  }}||v rs|rt          | d| d          ||v rt          |  d| d| d| d| d
          |                    |          ||<   t	          j        | d| dt          d	           }d
S )z
    Helper function to deprecate arguments.

    Args:
        func_name: Name of the function to be deprecated
        kwargs:
        aliases:
        fail:

    z# is deprecated as an argument. Use z insteadz received both z and z as an argument. z is deprecated. Use r   r   )r   categoryr   N)itemsr   	TypeErrorpopr   r   r   )r   r   r   r   old_termnew_terms         r5   rename_kwargsr     s    &mmoo  (v 	 &VVHVVV   6!   / / / / / /$,/ /#/ / /  
  &zz(33F8MVVHVVV+    rH   bytesc                 f    | dk     r|  dS | dk     r	| dz  ddS | dk     r	| dz  ddS | dz  ddS )	Ni  z Bytei@B z.1fz kBi ʚ;z MBz GBr   )r   s    r5   _human_readable_bytesr     st    u} u} )%-(((((u} )%-(((((em$$$$$rH   c                   6    e Zd ZdZdddZddefdZdefdZdS )	classpropertyz
    Decorator that converts a method with a single cls argument into a property
    that can be accessed directly from the class.
    Nr   c                     || _         d S rl   fgetselfmethods     r5   __init__zclassproperty.__init__1  s    			rH   c                 ,    |                      |          S rl   r   )r   instanceclss      r5   __get__zclassproperty.__get__4  s    yy~~rH   c                     || _         | S rl   r   r   s     r5   getterzclassproperty.getter7  s    	rH   rl   )r   N)	__name__
__module____qualname____doc__r   r
   r   r   r   r   rH   r5   r   r   +  sr         
     S          rH   r   c                   p    e Zd ZU ddlmZ dZeed<   	 dZe	ed<   	 dZ
ee         ed<   	 d	efd
Zd	efdZdS )Filer   )IndirectObjectr"   r   rH   dataNindirect_referencer   c           	      t    | j         j         d| j         dt          t	          | j                             dS )Nz(name=z, data: ))	__class__r   r   r   r-   r  r   s    r5   __str__zFile.__str__M  s>    .)llllDYZ]^b^gZhZhDiDillllrH   c                 l    |                                  d d         dt          | j                   dz   S )Nrt   z, hash: r  )r  hashr  r  s    r5   __repr__zFile.__repr__P  s2    ||~~crc"%BTY%B%B%BBBrH   )r   r   r   genericr   r   r   __annotations__r  r   r  r   r  r
  r   rH   r5   r   r   <  s         ''''''D#NNN D% 480777m m m m mC# C C C C C CrH   r   c                       e Zd Z ej        d          ZdeddfdZdedee	e
ef                  fdZdedefdZde
fd	Zdedefd
ZdS )Versionz^(\d+)(.*)$version_strr   Nc                 H    || _         |                     |          | _        d S rl   )r  _parse_version
components)r   r  s     r5   r   zVersion.__init__X  s#    &--k::rH   c                 T   |                     d          }g }|D ]}t          j                            |          }|s|                    d|f           ;|                    d          }|                    d          }|d}|                    t          |          |f           |S )Nr   r   r   r   )splitr  COMPONENT_PATTERNmatchrL   groupr=   )r   r  r  parsed_components	componentr  integer_prefixsuffixs           r5   r  zVersion._parse_version\  s     &&s++
# 		D 		DI-33I>>E !((!Y888"[[^^N[[^^F #!"$$c.&9&96%BCCCC  rH   otherc                 P    t          |t                    sdS | j        |j        k    S )NF)r   r  r  )r   r  s     r5   __eq__zVersion.__eq__k  s)    %)) 	5%"222rH   c                 R    t          | j        t          | j                  f          S rl   )r	  r  r   r  r  s    r5   __hash__zVersion.__hash__p  s!    T^U4?%;%;<===rH   c                 Z   t          |t                    st          dt          |                     t	          | j        |j                  D ]3\  }}|\  }}|\  }}||k     r dS ||k    r dS ||k     r dS ||k    r dS 4t          | j                  t          |j                  k     S )Nz#Version cannot be compared against TF)r   r  r0   typer   r  r-   )r   r  self_componentother_component
self_valueself_suffixother_valueother_suffixs           r5   __lt__zVersion.__lt__t  s    %)) 	RP4;;PPQQQ/24?EDT/U/U 	 	+NO&4#J(7%KK' ttK' uu\) tt\) uu 4?##c%*:&;&;;;rH   )r   r   r   recompiler  r   r   listr   r=   r  objectboolr  r   r
   r)  r   rH   r5   r  r  T  s        "
>22;C ;D ; ; ; ;!# !$uS#X2G ! ! ! !3F 3t 3 3 3 3
># > > > ><C <D < < < < < <rH   r  rl   )r   )F)Lr   
__author____author_email__	functoolsr   r*  sysr   dataclassesr   r   r   ior   osr   r   typingr	   r
   r   r   r   version_infor   typing_extensionsr   errorsr   r   r   r   r   r   r  r   
StreamTyper   BinaryStreamTyper   StrByteTyper6   rG   rP   rc   r{   rm   WHITESPACES_AS_REGEXPr=   r`   re   r.  rh   rr   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dictr   r   r   r   total_orderingr  r   rH   r5   <module>r@     s  8 ) ( (
/       				 



  ! ! ! ! ! ! ' ' ' ' ' ' ' ' " " " " " "                          BQB7" ,       ++++++w '&&&&&&          ',	%
eUE&9 :E%PUBU<VV' )    -2	5%u,- 	    W
e9 CO$9Xc] 9x/A 9 9 9 9@H     2- -s -s - - - -& :xx,, 33d:  *  QV    2 0 U    "     (9E 9d 9 9 9 9Aj AT A A A A%Z % %5 % % % %P!1 C E    27(z 7(e 7( 7( 7( 7(t$<   	* 	 	 	 	 	 
C C    
 
E e    
 
C C    
E#sE/" uS%Z'8    B B3 BC B B B B B S  T           QU    3 # 3 SW    U3 UC UD U U U U
PS Pc Pd P P P P
	5# 	5# 	5 	5 	5 	5 	5 	5( (# ($ ( ( ( (( SX     cN 59#s(^ KO 	       F% % % % % %Z       " C C C C C C C C. 1< 1< 1< 1< 1< 1< 1< 1< 1< 1<rH   