
    HAiN                        % S r SrSrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
J
r
Jr  SSKJr  SSKJr  SS	KJrJrJrJrJrJrJrJrJr  \R4                  SS
 S:  a  SSKJr  OSSKJr  \R4                  S:  a  SSKJr  OSSKJr  SSKJrJ r J!r!  \\\"\"\"4   \\"\"\"4   \\"\"\"4   4   r#\\$S'   \\"\"\"\"\"\"4   r%\\$S'   \\   r&\\'\&4   r(S\\'   S\\
   4S jr)S\
S\'4S jr*S\'S\'S\'4S jr+Sr,SR[                  \,5      r.S\.-   S-   r/SPS\&S \\0   S\14S! jjr2S\&S\14S" jr3S\&S\44S# jr5S$\1S\44S% jr6S\&SS4S& jr7S\&S'\\1   S\14S( jr8S\&S)\0S\14S* jr9S\&S\14S+ jr:S,\#S-\#S\#4S. jr;S\&SS4S/ jr<\S-\'S\04S0 j5       r=\S-\1S\14S1 j5       r=\S-\0S\04S2 j5       r=S-\\0\'\14   S\\0\14   4S3 jr=SQS4\'S5\0SS4S6 jjr>S4\'SS4S7 jr?S8\'S9\'S:\'SS4S; jr@S8\'S9\'S:\'SS4S< jrAS=\'S:\'SS4S> jrBS=\'S:\'SS4S? jrCS4\'S@\'SS4SA jrDS4\'S@\'SS4SB jrE SRSC\'SD\\'\4   SE\\'\'4   SF\4SS4
SG jjrFSH\0S\'4SI jrG " SJ SK5      rH\	 " SL SM5      5       rI\R                   " SN SO5      5       rKg)Sz"Utility functions for PDF library.zMathieu Fenniakzbiziqe@mathieu.fenniak.net    N)	dataclass)datetimetimezone)DEFAULT_BUFFER_SIZE)SEEK_CUR)	IOAnyDictListOptionalPatternTupleUnionoverload   )   
   )	TypeAlias)r      )Self   )STREAM_TRUNCATED_PREMATURELYDeprecationErrorPdfStreamErrorTransformationMatrixTypeCompressedTransformationMatrixtextreturnc                 X   U nU c  g U S   R                  5       (       a  SU -   n U R                  S5      (       a  U S-  n U R                  SS5      R                  SS5      R                  SS	5      n [        U R	                  S5      U R	                  S
5      5      nUS:  a  U[        U 5      S-
  :w  a  U S-  n S HO  n [        R                  " X5      nU R                  S5      (       a  UR                  [        R                  S9nUs  $    [        SU 35      e! [         a     Mn  f = f)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        H/var/www/html/land-ocr/venv/lib/python3.13/site-packages/pypdf/_utils.pyparse_iso8824_dater9   Q   s   G|Awd{}}Z  <<S!))#s3;;CDDDIIcNDIIcN+A1uc$i!m#	!!$*A }}W%%IIX\\I2H!" -gY7
88  		s   >D
D)(D)dtc                    U R                  S5      nU R                  bb  U R                  5       nUc   e[        UR	                  5       5      n[        [        U5      S5      u  pEUS-  nUS:  a  SOSnX US SUS S3-  nU$ )	z
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)   i  <   r   r#   r&   02dr$   )strftimer*   	utcoffsetinttotal_secondsdivmodabs)r:   date_stroffsetrA   hours	remainderminutessigns           r8   format_iso8824_daterJ   q   s     {{+,H	yy!!!F0023!#m"4d;r/#q(scfU3KqQ77O    header1header2c                     Sn/ nX;   a   UR                  UR                  U 5      5        X;   a   UR                  UR                  U5      5        [        U5      S:X  a  [        SU < SU< S35      eU[	        U5         $ )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indexr0   r3   r.   )rL   rM   versionspdf_header_indicess       r8   _get_max_pdf_version_headerrS      s    H !!(.."9:!!(.."9:
!#8G;eG;>QRSSC*+,,rK   )       	   
          rK      [   ]streammaxcharsc                     Sn U R                  S5      nUR                  5       (       d  U(       d   U$ X#-  n[        U5      U:X  a   U$ MH  )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.

rK   r   )readisspacer0   )r\   r]   txttoks       r8   read_until_whitespacerc      sR     C
kk!n;;== J 	
s8xJ rK   c                 v    U R                  S5      nU[        ;   a  U R                  S5      nU[        ;   a  M  U$ )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r\   rb   s     r8   read_non_whitespacerh      s5     ++a.C

kk!n 
JrK   c                     U R                  S5      nSnU[        ;   a"  US-  nU R                  S5      nU[        ;   a  M"  US:  $ )z
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   re   )r\   rb   cnts      r8   skip_over_whitespacerk      sI     ++a.C
C

qkk!n 
 7NrK   valuec                 &    [        S U  5       5      $ )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   2   #    U  H  o[         ;   v   M     g 7fN)WHITESPACES_AS_BYTES).0bs     r8   	<genexpr>+check_if_whitespace_only.<locals>.<genexpr>   s     8%Q((%s   )all)rl   s    r8   check_if_whitespace_onlyrv      s     8%888rK   c                     U R                  S5      nU R                  SS5        US:X  a2  US;  a+  U R                  S5      nUS:X  a  [        S5      eUS;  a  M*  g g g )Nr      %)rV   rX   rK   zFile ended unexpectedly.)r_   seekr   rg   s     r8   skip_over_commentr{      s[    
++a.C
KKA
d{'++a.Ccz$%?@@ ' rK   regexc                    Sn U R                  S5      nU(       d  U$ UR                  X#-   5      nUbP  U R                  UR                  5       [	        U5      [	        U5      -   -
  S5        X#-   SUR                  5        n U$ X#-  nM  )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.

rK      Nr   )r_   searchrz   startr0   )r\   r|   namerb   ms        r8   read_until_regexr      s     D
kk"oKLL$=KK	SYS%9:A>J!''),DK 	 rK   to_readc                     U R                  5       U:  a  [        S5      eU R                  U* [        5        U R	                  U5      nU R                  U* [        5        U$ )z
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   rz   r   r_   )r\   r   r_   s      r8   read_block_backwardsr     sQ     {{}w@AA
KK(#;;wD
KK(#KrK   c                 H   / nSnU R                  5       S:X  a  [        [        5      e [        [        U R                  5       5      nUS:X  a  O[        X5      n[        U5      S-
  nU(       d+  US:  a  XE   S;  a  US-  nUS:  a
  XE   S;  a  M  US:  a  SnU(       a:  UR                  XES-   S 5        US:  a  XE   S;   a  US-  nUS:  a
  XE   S;   a  M  OUR                  U5        US:  a  U R                  US-   [        5        OM  SR                  USSS2   5      $ )	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   
NrK   rx   )r   r   r   minr   r   r0   rO   rz   r   join)r\   line_content
found_crlfr   blockidxs         r8   read_previous_liner   +  s4   " LJ{{}9::
)6;;=9a< %V5%j1n (uz8q (uz8ax!

 Agi 01(uzW4q (uzW4
 &!8 KKa*A D 88L2&''rK   arr   c                 .   ^ [        U4S jU  5       5      $ )Nc              3   \   >^#    U  H   m[        U4S  j[        T6  5       5      v   M"     g7f)c              3   \   >#    U  H!  n[        S  [        TU5       5       5      v   M#     g7f)c              3   T   #    U  H  u  p[        U5      [        U5      -  v   M      g 7fro   )float)rq   r5   js      r8   rs   6matrix_multiply.<locals>.<genexpr>.<genexpr>.<genexpr>i  s     @-$!%(U1X%-s   &(N)sumzip)rq   colrows     r8   rs   ,matrix_multiply.<locals>.<genexpr>.<genexpr>i  s%     TGSc@#c3-@@@Gs   ),N)tupler   )rq   r   rr   s    @r8   rs   "matrix_multiply.<locals>.<genexpr>h  s+      C 	TCQRGTTTs   (,)r   )r   rr   s    `r8   matrix_multiplyr   e  s        rK   c                 B   SnU R                  U* S5        [        SS5       nUR                  U R                  U5      5        UR                  S5        UR                  U R                  U5      5        SSS5        U R                  U* S5        g! , (       d  f       N"= f)z5Create text file showing current location in context.i  r   zpypdf_pdfLocation.txtwbs   HEREN)rz   openwriter_   )r\   radius	output_fhs      r8   mark_locationr   n  s|     F
KK	%t	,	F+, F+, 
- KK	 
-	,s   AB
Bc                     g ro    rr   s    r8   ord_r   z      rK   c                     g ro   r   r   s    r8   r   r     r   rK   c                     g ro   r   r   s    r8   r   r     r   rK   c                 F    [        U [        5      (       a  [        U 5      $ U $ ro   )
isinstancestrordr   s    r8   r   r     s    !S1vHrK   msg
stacklevelc                 8    [         R                  " U [        US9  g )N)r   )warningswarnDeprecationWarning)r   r   s     r8   	deprecater     s    MM#)jArK   c                     [        U 5      ero   )r   )r   s    r8   deprecationr     s    
3
rK   old_namenew_name
removed_inc                 .    [        U  SU SU S3S5        g)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      r8   deprecate_with_replacementr     s'    *@FS[R\\ef	rK   c                 ,    [        U  SU SU S35        g)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      r8   deprecation_with_replacementr     s"    *<ZLxjXabrK   r   c                 (    [        U  SU S3S5        g)zCIssue a warning that a feature will be removed without replacement.r   .r   Nr   r   r   s     r8   deprecate_no_replacementr     s    B:,aPRSTrK   c                 &    [        U  SU S35        g)zJRaise an exception that a feature was already removed without replacement.r   r   Nr   r   s     r8   deprecation_no_replacementr     s    4&@ANOrK   srcc                 N    [         R                  " U5      R                  U 5        g)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   s     r8   logger_errorr     s     c  %rK   c                 N    [         R                  " U5      R                  U 5        g)aa  
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   warningr   s     r8   logger_warningr     s      c""3'rK   	func_namekwargsaliasesfailc                    UR                  5        Hv  u  pEXA;   d  M  U(       a  [        U SU S35      eXQ;   a  [        U  SU SU SU SU S3
5      eUR                  U5      X'   [        R
                  " U SU S3[        SS	9  Mx     g
)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   )messagecategoryr   N)itemsr   	TypeErrorpopr   r   r   )r   r   r   r   old_termnew_terms         r8   rename_kwargsr     s     &mmo&j CH:XV  ! k
%z J$$,: .#*I/ 
  &zz(3FMMj CH:XV+ .rK   bytesc                 f    U S:  a  U  S3$ U S:  a	  U S-  S S3$ U S:  a	  U S-  S S3$ U S-  S S3$ )	Ni  z Bytei@B z.1fz kBi ʚ;z MBz GBr   )r   s    r8   _human_readable_bytesr     s_    u}u}%-$C((u}%-$C((emC $$rK   c                   F    \ rS rSrSrS	S
S jjrS	S\4S jjrS\4S jr	Sr
g)classpropertyi  z{
Decorator that converts a method with a single cls argument into a property
that can be accessed directly from the class.
Nr   c                     Xl         g ro   fgetselfmethods     r8   __init__classproperty.__init__%  s    	rK   c                 $    U R                  U5      $ ro   r   )r   instanceclss      r8   __get__classproperty.__get__(  s    yy~rK   c                     Xl         U $ ro   r   r   s     r8   getterclassproperty.getter+  s    	rK   r   ro   )r   N)__name__
__module____qualname____firstlineno____doc__r   r	   r   r   r   __static_attributes__r   rK   r8   r   r     s$    
S  rK   r   c                   t    \ rS rSr% SSKJr  Sr\\S'    Sr	\
\S'    Sr\\   \S	'    S
\4S jrS
\4S jrSrg)Filei0  r   )IndirectObjectr%   r   rK   dataNindirect_referencer   c           	          U R                   R                   SU R                   S[        [	        U R
                  5      5       S3$ )Nz(name=z, data: ))	__class__r   r   r   r0   r  r   s    r8   __str__File.__str__A  s?    ..))*&8DYZ]^b^g^gZhDiCjjkllrK   c                 \    U R                  5       S S S[        U R                  5       S3-   $ )Nrx   z, hash: r  )r  hashr  r
  s    r8   __repr__File.__repr__D  s,    ||~cr"xTYY/@%BBBrK   r   )r   r   r   r   genericr  r   r   __annotations__r  r   r  r   r  r  r  r   rK   r8   r  r  0  sW    'D#N D% 4807m mC# CrK   r  c                       \ rS rSr\R
                  " S5      rS\SS4S jrS\S\	\
\\4      4S jrS\S\4S	 jrS\4S
 jrS\S\4S jrSrg)VersioniH  z^(\d+)(.*)$version_strr   Nc                 <    Xl         U R                  U5      U l        g ro   )r  _parse_version
components)r   r  s     r8   r   Version.__init__L  s    &--k:rK   c                 :   UR                  S5      n/ nU H  n[        R                  R                  U5      nU(       d  UR	                  SU45        M>  UR                  S5      nUR                  S5      nUc  SnUR	                  [        U5      U45        M     U$ )Nr   r   r   r   )splitr  COMPONENT_PATTERNmatchrO   groupr@   )r   r  r  parsed_components	componentr  integer_prefixsuffixs           r8   r  Version._parse_versionP  s     &&s+
#I--33I>E!((!Y8"[[^N[[^F%!"$$c.&96%BC $ ! rK   otherc                 `    [        U[        5      (       d  gU R                  UR                  :H  $ )NF)r   r  r  )r   r$  s     r8   __eq__Version.__eq___  s'    %))%"2"222rK   c                 V    [        U R                  [        U R                  5      45      $ ro   )r  r	  r   r  r
  s    r8   __hash__Version.__hash__d  s    T^^U4??%;<==rK   c                 J   [        U[        5      (       d  [        S[        U5       35      e[	        U R
                  UR
                  5       H)  u  p#Uu  pEUu  pgXF:  a    gXF:  a    gXW:  a    gXW:  d  M)    g   [        U R
                  5      [        UR
                  5      :  $ )Nz#Version cannot be compared against TF)r   r  r3   typer   r  r0   )r   r$  self_componentother_component
self_valueself_suffixother_valueother_suffixs           r8   __lt__Version.__lt__h  s    %))B4;-PQQ/24??EDTDT/U+N&4#J(7%K'')) 0V 4??#c%*:*:&;;;rK   )r  r  )r   r   r   r   recompiler  r   r   r   r   r@   r  objectboolr&  r)  r	   r3  r  r   rK   r8   r  r  H  sv    

>2;C ;D ;!# !$uS#X2G !3F 3t 3
># ><C <D <rK   r  ro   )r   )F)Lr   
__author____author_email__	functoolsr   r5  sysr   dataclassesr   r   r   ior   osr   typingr   r	   r
   r   r   r   r   r   r   version_infor   typing_extensionsr   errorsr   r   r   r   r   r  r   
StreamTyper   StrByteTyper9   rJ   rS   rf   r   rp   WHITESPACES_AS_REGEXPr@   r   rc   rh   r8  rk   rv   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  total_orderingr  r   rK   r8   <module>rH     se  8 )
/    	 
  ! ' " 
 
 
 BQ7" +w&  ',	%
eUE&9 :E%PUBU<VV' )  -2	5%u,- 	  W
CO$9Xc] 9x/A 9@H  2- -s -s -& :xx, 33d: *  QV 2
 u "  (9E 9d 9Aj AT AZ  5 4 c e 27(z 7(e 7(t$<	* 	 	 
C C  
 
E e  
 
C C  
E#sE/" uS%Z'8 B3 BC B B S  T     QU 3 # 3 SW U3 UC UD U
PS Pc Pd P
	&c 	& 	& 	&( (# ($ (( SX   cN 59#s(^ KO 	 F% % %Z " C C C. 1< 1< 1<rK   