Ë
    vl�jbƒ  ã                   óz  — d dl Z d dlZd dlmZmZmZ d dlmZmZm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$  ejJ                  e&«      Z' G d
„ d«      Z( G d„ d«      Z) G d„ d«      Z* G d„ d«      Z+ G d„ de*«      Z, G d„ de,«      Z- G d„ de-«      Z. G d„ de-«      Z/ G d„ de,«      Z0 G d„ de*e+«      Z1 G d„ de,e+«      Z2 ed e*¬!«      Z3 G d"„ d#e,ee3   «      Z4 G d$„ d%e4e3   «      Z5 G d&„ d'e5e3   e+«      Z6e	e2e1f   Z7 G d(„ d)e6e7   «      Z8 G d*„ d+e8«      Z9 G d,„ d-e8«      Z: G d.„ d/e6e8   «      Z; G d0„ d1e;«      Z< G d2„ d3e;«      Z=e	e;d4f   Z> G d5„ d4e6e>   «      Z? G d6„ d7e?«      Z@ G d8„ d9e?«      ZA G d:„ d;e4e,   «      ZB G d<„ d=eB«      ZC G d>„ d?eB«      ZDy)@é    N)ÚIterableÚIteratorÚSequence)ÚGenericÚTypeVarÚUnionÚcast)ÚPDFColorSpace)ÚPDFTypeErrorÚPDFValueError)ÚPDFFont)ÚColorÚPDFGraphicState)Ú	PDFStream)ÚINFÚLTComponentTÚMatrixÚPathSegmentÚPlaneÚPointÚRectÚapply_matrix_rectÚbbox2strÚfsplitÚ	get_boundÚ
matrix2strÚuniqc                   ó&   — e Zd Zddeddfd„Zdd„Zy)ÚIndexAssignerÚindexÚreturnNc                 ó   — || _         y ©N©r    )Úselfr    s     úE/var/www/html/pp/venv/lib/python3.12/site-packages/pdfminer/layout.pyÚ__init__zIndexAssigner.__init__$   s	   € Øˆ�
ó    c                 óÄ   — t        |t        «      r'| j                  |_        | xj                  dz  c_        y t        |t        «      r|D ]  }| j	                  |«       Œ y y ©Né   )Ú
isinstanceÚ	LTTextBoxr    ÚLTTextGroupÚrun)r%   ÚobjÚxs      r&   r/   zIndexAssigner.run'   sM   € Ü�cœ9Ô%ØŸ
™
ˆCŒIØ�JŠJ˜!‰OŽJÜ˜œ[Ô)Øò �Ø—‘˜•ñð *r(   ©r   )r0   ÚLTItemr!   N)Ú__name__Ú
__module__Ú__qualname__Úintr'   r/   © r(   r&   r   r   #   s   „ ñ˜cð ¨$ó ôr(   r   c                   ób   — e Zd ZdZ	 	 	 	 	 	 	 ddedededededz  ded	ed
dfd„Zdd„Zd
efd„Z	y)ÚLAParamsa  Parameters for layout analysis

    :param line_overlap: If two characters have more overlap than this they
        are considered to be on the same line. The overlap is specified
        relative to the minimum height of both characters.
    :param char_margin: If two characters are closer together than this
        margin they are considered part of the same line. The margin is
        specified relative to the width of the character.
    :param word_margin: If two characters on the same line are further apart
        than this margin then they are considered to be two separate words, and
        an intermediate space will be added for readability. The margin is
        specified relative to the width of the character.
    :param line_margin: If two lines are are close together they are
        considered to be part of the same paragraph. The margin is
        specified relative to the height of a line.
    :param boxes_flow: Specifies how much a horizontal and vertical position
        of a text matters when determining the order of text boxes. The value
        should be within the range of -1.0 (only horizontal position
        matters) to +1.0 (only vertical position matters). You can also pass
        `None` to disable advanced layout analysis, and instead return text
        based on the position of the bottom left corner of the text box.
    :param detect_vertical: If vertical text should be considered during
        layout analysis
    :param all_texts: If layout analysis should be performed on text in
        figures.
    Úline_overlapÚchar_marginÚline_marginÚword_marginÚ
boxes_flowNÚdetect_verticalÚ	all_textsr!   c                 ó†   — || _         || _        || _        || _        || _        || _        || _        | j                  «        y r#   )r;   r<   r=   r>   r?   r@   rA   Ú	_validate)r%   r;   r<   r=   r>   r?   r@   rA   s           r&   r'   zLAParams.__init__L   sD   € ð )ˆÔØ&ˆÔØ&ˆÔØ&ˆÔØ$ˆŒØ.ˆÔØ"ˆŒà�‰Õr(   c                 óÐ   — | j                   �Zd}t        | j                   t        t        f«      st	        |«      ‚d| j                   cxk  rdk  st        |«      ‚ t        |«      ‚y y )Nz@LAParam boxes_flow should be None, or a number between -1 and +1éÿÿÿÿr+   )r?   r,   r7   Úfloatr   r   )r%   Úboxes_flow_err_msgs     r&   rC   zLAParams._validate`   sl   € Ø�?‰?Ð&àRð ô ˜tŸ™´´e°Ô=Ü"Ð#5Ó6Ð6Ø˜Ÿ™Ô-¨AÒ-Ü#Ð$6Ó7Ð7ð .Ü#Ð$6Ó7Ð7ð .ð 'r(   c           	      óv   — d| j                   d›d| j                  d›d| j                  d›d| j                  ›d�	S )Nz<LAParams: char_margin=z.1fz, line_margin=z, word_margin=z all_texts=ú>)r<   r=   r>   rA   ©r%   s    r&   Ú__repr__zLAParams.__repr__j   sS   € à% d×&6Ñ&6°sÐ%;ð <Ø×+Ñ+¨CÐ0ð 1Ø×+Ñ+¨CÐ0ð 1ØŸ™Ð*¨!ð-ð	
r(   )ç      à?g       @rL   gš™™™™™¹?rL   FF©r!   N)
r4   r5   r6   Ú__doc__rF   Úboolr'   rC   ÚstrrK   r8   r(   r&   r:   r:   0   s†   „ ñð: "Ø Ø Ø Ø#&Ø %Øñàðð ðð ð	ð
 ðð ˜D‘Lðð ðð ðð 
óó(8ð
˜#ô 
r(   r:   c                   ó    — e Zd ZdZdeddfd„Zy)r3   z)Interface for things that can be analyzedÚlaparamsr!   Nc                  ó   — y)zPerform the layout analysis.Nr8   ©r%   rR   s     r&   ÚanalyzezLTItem.analyzev   s   � r(   )r4   r5   r6   rN   r:   rU   r8   r(   r&   r3   r3   s   s   „ Ù3ð+ ð +¨Tô +r(   r3   c                   ó(   — e Zd ZdZdefd„Zdefd„Zy)ÚLTTextz#Interface for things that have textr!   c                 óX   — d| j                   j                  › d| j                  «       ›d�S ©Nú<ú rI   )Ú	__class__r4   Úget_textrJ   s    r&   rK   zLTText.__repr__}   s)   € Ø�4—>‘>×*Ñ*Ð+¨1¨T¯]©]«_Ð,?¸qÐAÐAr(   c                 ó   — t         ‚)zText contained in this object©ÚNotImplementedErrorrJ   s    r&   r]   zLTText.get_text€   s   € ä!Ð!r(   N)r4   r5   r6   rN   rP   rK   r]   r8   r(   r&   rW   rW   z   s   „ Ù-ðB˜#ó Bð"˜#ô "r(   rW   c                   óè   — e Zd ZdZdeddfd„Zdefd„Zdede	fd„Z
dede	fd	„Zdede	fd
„Zdede	fd„Zdeddfd„Zde	fd„Zdd de	fd„Zdd defd„Zdd defd„Zdd de	fd„Zdd defd„Zdd defd„Zy)ÚLTComponentzObject with a bounding boxÚbboxr!   Nc                 óP   — t         j                  | «       | j                  |«       y r#   )r3   r'   Úset_bbox©r%   rc   s     r&   r'   zLTComponent.__init__ˆ   s   € Ü�‰˜ÔØ�‰�dÕr(   c                 ób   — d| j                   j                  › dt        | j                  «      › d�S rY   )r\   r4   r   rc   rJ   s    r&   rK   zLTComponent.__repr__Œ   s,   € Ø�4—>‘>×*Ñ*Ð+¨1¬X°d·i±iÓ-@Ð,AÀÐCÐCr(   Ú_c                 ó   — t         ‚r#   ©r   ©r%   rh   s     r&   Ú__lt__zLTComponent.__lt__�   ó   € ÜÐr(   c                 ó   — t         ‚r#   rj   rk   s     r&   Ú__le__zLTComponent.__le__“   rm   r(   c                 ó   — t         ‚r#   rj   rk   s     r&   Ú__gt__zLTComponent.__gt__–   rm   r(   c                 ó   — t         ‚r#   rj   rk   s     r&   Ú__ge__zLTComponent.__ge__™   rm   r(   c                 ó€   — |\  }}}}|| _         || _        || _        || _        ||z
  | _        ||z
  | _        || _        y r#   )Úx0Úy0Úx1Úy1ÚwidthÚheightrc   )r%   rc   ru   rv   rw   rx   s         r&   re   zLTComponent.set_bboxœ   sI   € ØÑˆˆR��RØˆŒØˆŒØˆŒØˆŒØ˜"‘WˆŒ
Ø˜2‘gˆŒØˆ�	r(   c                 óB   — | j                   dk  xs | j                  dk  S ©Nr   )ry   rz   rJ   s    r&   Úis_emptyzLTComponent.is_empty¦   s   € Ø�z‰z˜Q‰Ò2 $§+¡+°Ñ"2Ð2r(   r0   c                 ó¼   — t        |t        «      sJ t        t        |«      «      «       ‚|j                  | j
                  k  xr | j                  |j
                  k  S r#   )r,   rb   rP   Útyperu   rw   ©r%   r0   s     r&   Úis_hoverlapzLTComponent.is_hoverlap©   óD   € Ü˜#œ{Ô+Ð;¬S´°c³«^Ó;Ð+Ø�v‰v˜Ÿ™Ñ Ò6 T§W¡W°·±Ñ%6Ð6r(   c                 ó  — t        |t        «      sJ t        t        |«      «      «       ‚| j	                  |«      ryt        t        | j                  |j                  z
  «      t        | j                  |j                  z
  «      «      S r|   ©	r,   rb   rP   r   r�   ÚminÚabsru   rw   r€   s     r&   Ú	hdistancezLTComponent.hdistance­   óa   € Ü˜#œ{Ô+Ð;¬S´°c³«^Ó;Ð+Ø×Ñ˜CÔ Øä”s˜4Ÿ7™7 S§V¡VÑ+Ó,¬c°$·'±'¸C¿F¹FÑ2BÓ.CÓDÐDr(   c                 ó  — t        |t        «      sJ t        t        |«      «      «       ‚| j	                  |«      rLt        t        | j                  |j                  z
  «      t        | j                  |j                  z
  «      «      S yr|   r„   r€   s     r&   ÚhoverlapzLTComponent.hoverlap´   óa   € Ü˜#œ{Ô+Ð;¬S´°c³«^Ó;Ð+Ø×Ñ˜CÔ Ü”s˜4Ÿ7™7 S§V¡VÑ+Ó,¬c°$·'±'¸C¿F¹FÑ2BÓ.CÓDÐDàr(   c                 ó¼   — t        |t        «      sJ t        t        |«      «      «       ‚|j                  | j
                  k  xr | j                  |j
                  k  S r#   )r,   rb   rP   r   rv   rx   r€   s     r&   Úis_voverlapzLTComponent.is_voverlap»   r‚   r(   c                 ó  — t        |t        «      sJ t        t        |«      «      «       ‚| j	                  |«      ryt        t        | j                  |j                  z
  «      t        | j                  |j                  z
  «      «      S r|   ©	r,   rb   rP   r   r�   r…   r†   rv   rx   r€   s     r&   Ú	vdistancezLTComponent.vdistance¿   rˆ   r(   c                 ó  — t        |t        «      sJ t        t        |«      «      «       ‚| j	                  |«      rLt        t        | j                  |j                  z
  «      t        | j                  |j                  z
  «      «      S yr|   r�   r€   s     r&   ÚvoverlapzLTComponent.voverlapÆ   r‹   r(   )r4   r5   r6   rN   r   r'   rP   rK   ÚobjectrO   rl   ro   rq   rs   re   r}   r�   rF   r‡   rŠ   r�   r�   r’   r8   r(   r&   rb   rb   …   s	  „ Ù$ð˜Tð  dó ðD˜#ó Dð˜ð  4ó ð˜ð  4ó ð˜ð  4ó ð˜ð  4ó ð˜Tð  dó ð3˜$ó 3ð7˜}ð 7°ó 7ðE˜]ð E¨uó Eð˜Mð ¨eó ð7˜}ð 7°ó 7ðE˜]ð E¨uó Eð˜Mð ¨eô r(   rb   c                   óŠ   — e Zd ZdZ	 	 	 	 	 	 	 ddedee   dededededz  d	edz  d
ee	   dz  de
eef   dz  ddfd„Zdefd„Zy)ÚLTCurvezàA generic Bezier curve

    The parameter `original_path` contains the original
    pathing information from the pdf (e.g. for reconstructing Bezier Curves).

    `dashing_style` contains the Dashing information if any.
    NÚ	linewidthÚptsÚstrokeÚfillÚevenoddÚstroking_colorÚnon_stroking_colorÚoriginal_pathÚdashing_styler!   c
                 óÀ   — t         j                  | t        |«      «       || _        || _        || _        || _        || _        || _        || _	        || _
        |	| _        y r#   )rb   r'   r   r—   r–   r˜   r™   rš   r›   rœ   r�   rž   )
r%   r–   r—   r˜   r™   rš   r›   rœ   r�   rž   s
             r&   r'   zLTCurve.__init__×   s[   € ô 	×Ñ˜T¤9¨S£>Ô2ØˆŒØ"ˆŒØˆŒØˆŒ	ØˆŒØ,ˆÔØ"4ˆÔØ*ˆÔØ*ˆÕr(   c                 óF   — dj                  d„ | j                  D «       «      S )Nú,c              3   ó:   K  — | ]  } d j                   |Ž –— Œ y­w)z{:.3f},{:.3f}N)Úformat)Ú.0Úps     r&   ú	<genexpr>z"LTCurve.get_pts.<locals>.<genexpr>ï   s   è ø€ ÒE°qÐ.˜×.Ñ.°Ô2ÑEùs   ‚)Újoinr—   rJ   s    r&   Úget_ptszLTCurve.get_ptsî   s   € Ø�x‰xÑE¸D¿H¹HÔEÓEÐEr(   ©FFFNNNN)r4   r5   r6   rN   rF   Úlistr   rO   r   r   Útupler“   r'   rP   r¨   r8   r(   r&   r•   r•   Î   s·   „ ñð ØØØ'+Ø+/Ø26Ø6:ñ+àð+ð �%‰[ð+ð ð	+ð
 ð+ð ð+ð  ™ð+ð " D™Lð+ð ˜KÑ(¨4Ñ/ð+ð ˜V V˜^Ñ,¨tÑ3ð+ð 
ó+ð.F˜ô Fr(   r•   c                   ó|   — e Zd ZdZ	 	 	 	 	 	 	 ddedededededed	edz  d
edz  dee	   dz  de
eef   dz  ddfd„Zy)ÚLTLinezOA single straight line.

    Could be used for separating text or figures.
    Nr–   Úp0Úp1r˜   r™   rš   r›   rœ   r�   rž   r!   c                 óD   — t         j                  | |||g||||||	|
«
       y r#   ©r•   r'   )r%   r–   r®   r¯   r˜   r™   rš   r›   rœ   r�   rž   s              r&   r'   zLTLine.__init__ø   s4   € ô 	×ÑØØØ�ˆHØØØØØØØõ	
r(   r©   )r4   r5   r6   rN   rF   r   rO   r   rª   r   r«   r“   r'   r8   r(   r&   r­   r­   ò   s¯   „ ñð ØØØ'+Ø+/Ø26Ø6:ñ
àð
ð ð
ð ð	
ð
 ð
ð ð
ð ð
ð  ™ð
ð " D™Lð
ð ˜KÑ(¨4Ñ/ð
ð ˜V V˜^Ñ,¨tÑ3ð
ð 
ô
r(   r­   c                   óx   — e Zd ZdZ	 	 	 	 	 	 	 ddededededededz  d	edz  d
ee	   dz  de
eef   dz  ddfd„Zy)ÚLTRectzMA rectangle.

    Could be used for framing another pictures or figures.
    Nr–   rc   r˜   r™   rš   r›   rœ   r�   rž   r!   c
                 óf   — |\  }
}}}t         j                  | ||
|f||f||f|
|fg|||||||	«
       y r#   r±   )r%   r–   rc   r˜   r™   rš   r›   rœ   r�   rž   ru   rv   rw   rx   s                 r&   r'   zLTRect.__init__  sW   € ð  ÑˆˆR��RÜ×ÑØØØ�"ˆX˜˜B�x " b ¨B°¨8Ð4ØØØØØØØõ	
r(   r©   )r4   r5   r6   rN   rF   r   rO   r   rª   r   r«   r“   r'   r8   r(   r&   r³   r³     s¥   „ ñð ØØØ'+Ø+/Ø26Ø6:ñ
àð
ð ð
ð ð	
ð
 ð
ð ð
ð  ™ð
ð " D™Lð
ð ˜KÑ(¨4Ñ/ð
ð ˜V V˜^Ñ,¨tÑ3ð
ð 
ô
r(   r³   c                   ó4   — e Zd ZdZdedededdfd„Zdefd„Zy)	ÚLTImagezKAn image object.

    Embedded images can be in JPEG, Bitmap or JBIG2.
    ÚnameÚstreamrc   r!   Nc                 óz  — t         j                  | |«       || _        || _        |j	                  d«      |j	                  d«      f| _        |j	                  d«      | _        |j	                  dd«      | _        |j	                  d«      | _        t        | j                  t        «      s| j                  g| _        y y )N)ÚWÚWidth)ÚHÚHeight)ÚIMÚ	ImageMask)ÚBPCÚBitsPerComponentr+   )ÚCSÚ
ColorSpace)rb   r'   r·   r¸   Úget_anyÚsrcsizeÚ	imagemaskÚbitsÚ
colorspacer,   rª   )r%   r·   r¸   rc   s       r&   r'   zLTImage.__init__:  s”   € Ü×Ñ˜T 4Ô(ØˆŒ	ØˆŒØŸ™ ~Ó6¸¿¹ÀÓ8WÐXˆŒØŸ™Ð(;Ó<ˆŒØ—N‘NÐ#>ÀÓBˆŒ	Ø Ÿ.™.Ð)=Ó>ˆŒÜ˜$Ÿ/™/¬4Ô0Ø#Ÿ™Ð/ˆD�Oð 1r(   c           	      ó–   — d| j                   j                  › d| j                  › dt        | j                  «      › d| j
                  ›d�	S ©NrZ   ú(ú) r[   rI   )r\   r4   r·   r   rc   rÅ   rJ   s    r&   rK   zLTImage.__repr__E  sF   € à�—‘×'Ñ'Ð(¨¨$¯)©)¨°BÜ˜Ÿ	™	Ó"Ð# 1 T§\¡\Ð$4°Að7ð	
r(   )	r4   r5   r6   rN   rP   r   r   r'   rK   r8   r(   r&   r¶   r¶   4  s4   „ ñð
	0˜Sð 	0¨)ð 	0¸4ð 	0ÀDó 	0ð
˜#ô 
r(   r¶   c                   ó,   — e Zd ZdZdeddfd„Zdefd„Zy)ÚLTAnnoa  Actual letter in the text as a Unicode string.

    Note that, while a LTChar object has actual boundaries, LTAnno objects does
    not, as these are "virtual" characters, inserted by a layout analyzer
    according to the relationship between two characters (e.g. a space).
    Útextr!   Nc                 ó   — || _         y r#   ©Ú_text)r%   rÏ   s     r&   r'   zLTAnno.__init__T  s	   € Øˆ�
r(   c                 ó   — | j                   S r#   rÑ   rJ   s    r&   r]   zLTAnno.get_textW  ó   € Ø�z‰zÐr(   )r4   r5   r6   rN   rP   r'   r]   r8   r(   r&   rÎ   rÎ   L  s&   „ ñð˜Sð  Tó ð˜#ô r(   rÎ   c                   ór   — e Zd ZdZdededededededed	eeed
z  ef   z  de	de
dd
fd„Zdefd„Zdefd„Zy
)ÚLTCharz.Actual letter in the text as a Unicode string.ÚmatrixÚfontÚfontsizeÚscalingÚriserÏ   Ú	textwidthÚtextdispNÚncsÚgraphicstater!   c                 ó  — t         j                  | «       || _        || _        |j                  | _        |	| _        |
| _        ||z  |z  | _        |j                  «       rPt        |t        «      sJ ‚|\  }}|€|dz  n||z  dz  }d|z
  |z  dz  }| ||z   | j                  z   | |z   ||z   f}n,|j                  «       |z  }d||z   | j                  ||z   |z   f}| j                  \  }}}}}}||z  |z  dkD  xr ||z  dk  | _        t        | j                  |«      \  }}}}||k  r||}}||k  r||}}t        j                  | ||||f«       |j                  «       r| j                  | _        y | j"                  | _        y )NrL   gü©ñÒMbP?iè  r   )rW   r'   rÒ   r×   ÚfontnamerÞ   rß   ÚadvÚis_verticalr,   r«   Úget_descentÚuprightr   rb   ry   Úsizerz   )r%   r×   rØ   rÙ   rÚ   rÛ   rÏ   rÜ   rÝ   rÞ   rß   ÚvxÚvyrc   ÚdescentÚaÚbÚcÚdÚ_eÚ_fru   rv   rw   rx   s                            r&   r'   zLTChar.__init__^  sŸ  € ô 	�‰˜ÔØˆŒ
ØˆŒØŸ™ˆŒØˆŒØ(ˆÔØ˜xÑ'¨'Ñ1ˆŒà×ÑÔä˜h¬Ô.Ð.Ð.Ø‰HˆR�Ø#% :�˜C’°2¸±=À5Ñ3HˆBØ˜‘)˜xÑ'¨%Ñ/ˆBØ�C˜˜d™ T§X¡XÑ-°¨s°X©~¸rÀD¹yÐI‰Dð ×&Ñ&Ó(¨8Ñ3ˆGØ�w ‘~ t§x¡x°¸4±À(Ñ1JÐKˆDØ#Ÿ{™{ÑˆˆAˆq�!�R˜Ø˜1‘u˜w‘¨Ñ*Ò9¨q°1©u¸©zˆŒÜ,¨T¯[©[¸$Ó?ÑˆˆR��RØ�Š7Ø˜B�ˆRØ�Š7Ø˜B�ˆRÜ×Ñ˜T B¨¨B°Ð#3Ô4Ø×ÑÔØŸ
™
ˆD�IàŸ™ˆD�Ir(   c                 óä   — d| j                   j                  › dt        | j                  «      › dt	        | j
                  «      › d| j                  ›d| j                  › d| j                  «       ›d�S )NrZ   r[   ú matrix=z font=z adv=z text=rI   )	r\   r4   r   rc   r   r×   rá   râ   r]   rJ   s    r&   rK   zLTChar.__repr__‹  sr   € à�—‘×'Ñ'Ð(¨¬(°4·9±9Ó*=Ð)>ð ?Ü  §¡Ó-Ð.ð /Ø—M‘MÐ$ð %Ø—8‘8�*ð Ø—M‘M“OÐ& að	)ð	
r(   c                 ó   — | j                   S r#   rÑ   rJ   s    r&   r]   zLTChar.get_text”  rÔ   r(   )r4   r5   r6   rN   r   r   rF   rP   r«   r
   r   r'   rK   r]   r8   r(   r&   rÖ   rÖ   [  s¢   „ Ù8ð+$àð+$ð ð+$ð ð	+$ð
 ð+$ð ð+$ð ð+$ð ð+$ð ˜% ¨¡¨eÐ 3Ñ4Ñ4ð+$ð ð+$ð &ð+$ð 
ó+$ðZ
˜#ó 
ð˜#ô r(   rÖ   ÚLTItemT)Úboundc                   ót   — e Zd ZdZdeddfd„Zdee   fd„Zde	fd„Z
deddfd	„Zd
ee   ddfd„Zdeddfd„Zy)ÚLTContainerz(Object that can be extended and analyzedrc   r!   Nc                 ó>   — t         j                  | |«       g | _        y r#   )rb   r'   Ú_objsrf   s     r&   r'   zLTContainer.__init__ž  s   € Ü×Ñ˜T 4Ô(Ø$&ˆ�
r(   c                 ó,   — t        | j                  «      S r#   )Úiterrø   rJ   s    r&   Ú__iter__zLTContainer.__iter__¢  s   € Ü�D—J‘JÓÐr(   c                 ó,   — t        | j                  «      S r#   )Úlenrø   rJ   s    r&   Ú__len__zLTContainer.__len__¥  s   € Ü�4—:‘:‹Ðr(   r0   c                 ó:   — | j                   j                  |«       y r#   )rø   Úappendr€   s     r&   ÚaddzLTContainer.add¨  s   € Ø�
‰
×Ñ˜#Õr(   Úobjsc                 ó4   — |D ]  }| j                  |«       Œ y r#   )r  )r%   r  r0   s      r&   ÚextendzLTContainer.extend«  s   € Øò 	ˆCØ�H‰H�S�Mñ	r(   rR   c                 óH   — | j                   D ]  }|j                  |«       Œ y r#   )rø   rU   ©r%   rR   r0   s      r&   rU   zLTContainer.analyze¯  s!   € Ø—:‘:ò 	"ˆCØ�K‰K˜Õ!ñ	"r(   )r4   r5   r6   rN   r   r'   r   ró   rû   r7   rþ   r  r   r  r:   rU   r8   r(   r&   rö   rö   ›  ss   „ Ù2ð'˜Tð ' dó 'ð ˜( 7Ñ+ó  ð˜ó ð�wð  4ó ð˜8 GÑ,ð °ó ð" ð "¨Tô "r(   rö   c                   ó$   — e Zd Zdd„Zdeddfd„Zy)ÚLTExpandableContainerr!   Nc                 ó`   — t         j                  | t        ­t        ­t         t         f«       y r#   )rö   r'   r   rJ   s    r&   r'   zLTExpandableContainer.__init__µ  s#   € Ü×Ñ˜T¤S D¬3¨$´°´s°dÐ#;Õ<r(   r0   c           	      óf  — t         j                  | t        t        |«      «       | j	                  t        | j                  |j                  «      t        | j                  |j                  «      t        | j                  |j                  «      t        | j                  |j                  «      f«       y r#   )rö   r  r	   ró   re   r…   ru   rv   Úmaxrw   rx   r€   s     r&   r  zLTExpandableContainer.addº  sp   € Ü�‰˜œd¤7¨CÓ0Ô1Ø�‰ä�D—G‘G˜SŸV™VÓ$Ü�D—G‘G˜SŸV™VÓ$Ü�D—G‘G˜SŸV™VÓ$Ü�D—G‘G˜SŸV™VÓ$ð	õ	
r(   rM   )r4   r5   r6   r'   rb   r  r8   r(   r&   r  r  ´  s   „ ó=ð
	
�{ð 	
 tô 	
r(   r  c                   ó    — e Zd Zdd„Zdefd„Zy)ÚLTTextContainerr!   Nc                 óX   — t         j                  | «       t        j                  | «       y r#   )rW   r'   r  rJ   s    r&   r'   zLTTextContainer.__init__Ç  s   € Ü�‰˜ÔÜ×&Ñ& tÕ,r(   c                 ó2   — dj                  d„ | D «       «      S )NÚ c              3   óz   K  — | ]3  }t        |t        «      sŒt        t        |«      j                  «       –— Œ5 y ­wr#   )r,   rW   r	   r]   )r¤   r0   s     r&   r¦   z+LTTextContainer.get_text.<locals>.<genexpr>Ì  s.   è ø€ ò 
Ø-0¼JÀsÌFÕ<SŒD”˜Ó×&Ñ&×(ñ
ùs   ‚;˜#;)r§   rJ   s    r&   r]   zLTTextContainer.get_textË  s    € Ø�w‰wñ 
Ø48ô
ó 
ð 	
r(   rM   )r4   r5   r6   r'   rP   r]   r8   r(   r&   r  r  Æ  s   „ ó-ð
˜#ô 
r(   r  c                   óx   ‡ — e Zd ZdZdeddfˆ fd„Zdefd„Zdeddfd„Z	d	e
e   d
eded    fd„Zdefˆ fd„Zˆ xZS )Ú
LTTextLinez¶Contains a list of LTChar objects that represent a single text line.

    The characters are aligned either horizontally or vertically, depending on
    the text's writing mode.
    r>   r!   Nc                 ó0   •— t         ‰| �  «        || _        y r#   )Úsuperr'   r>   )r%   r>   r\   s     €r&   r'   zLTTextLine.__init__Û  s   ø€ Ü‰ÑÔØ&ˆÕr(   c                 ó„   — d| j                   j                  › dt        | j                  «      › d| j	                  «       ›d�S rY   )r\   r4   r   rc   r]   rJ   s    r&   rK   zLTTextLine.__repr__ß  s:   € Ø�4—>‘>×*Ñ*Ð+¨1¬X°d·i±iÓ-@Ð,AÀÀ4Ç=Á=Ã?ÐBUÐUVÐWÐWr(   rR   c                 ó†   — | j                   D ]  }|j                  |«       Œ t        j                  | t	        d«      «       y )Nú
)rø   rU   rö   r  rÎ   r  s      r&   rU   zLTTextLine.analyzeâ  s3   € Ø—:‘:ò 	"ˆCØ�K‰K˜Õ!ð	"ä�‰˜œf T›lÕ+r(   ÚplaneÚratioc                 ó   — t         ‚r#   r_   )r%   r  r  s      r&   Úfind_neighborszLTTextLine.find_neighborsç  s
   € ô
 "Ð!r(   c                 ó`   •— t         ‰| �  «       xs | j                  «       j                  «       S r#   )r  r}   r]   Úisspace)r%   r\   s    €r&   r}   zLTTextLine.is_emptyî  s%   ø€ Ü‰wÑÓ!Ò> T§]¡]£_×%<Ñ%<Ó%>Ð>r(   )r4   r5   r6   rN   rF   r'   rP   rK   r:   rU   r   r   rª   r  rO   r}   Ú__classcell__©r\   s   @r&   r  r  Ô  sx   ø„ ñð' Eð '¨dõ 'ðX˜#ó Xð, ð ,¨Tó ,ð
"à�\Ñ"ð"ð ð"ð 
ˆlÑ	ó	"ð?˜$÷ ?ñ ?r(   r  c                   ó²   ‡ — e Zd Zdeddfd„Zdeddfˆ fd„Zdee   dede	e
   fd	„Zdd
ededefd„Zdd
ededefd„Z	 dd
ededefd„Zdd
ededefd„Zˆ xZS )ÚLTTextLineHorizontalr>   r!   Nc                 óH   — t         j                  | |«       t        ­| _        y r#   )r  r'   r   Ú_x1©r%   r>   s     r&   r'   zLTTextLineHorizontal.__init__ó  ó   € Ü×Ñ˜D +Ô.Ü˜$ˆ�r(   r0   c                 óN  •— t        |t        «      rt| j                  rh| j                  t        |j                  |j
                  «      z  }| j                  |j                  |z
  k  rt        j                  | t        d«      «       |j                  | _        t        ‰| �%  |«       y ©Nr[   )r,   rÖ   r>   r  ry   rz   r$  ru   rö   r  rÎ   rw   r  ©r%   r0   Úmarginr\   s      €r&   r  zLTTextLineHorizontal.addù  sq   ø€ Ü�cœ6Ô" t×'7Ò'7Ø×%Ñ%¬¨C¯I©I°s·z±zÓ(BÑBˆFØ�x‰x˜#Ÿ&™& 6™/Ò)Ü—‘ ¤f¨S£kÔ2Ø—6‘6ˆŒÜ‰‰�CÕr(   r  r  c                 óˆ  — || j                   z  }|j                  | j                  | j                  |z
  | j                  | j
                  |z   f«      }|D �cg c]`  }t        |t        «      rN| j                  ||¬«      r;| j                  ||¬«      s&| j                  ||¬«      s| j                  ||¬«      r|‘Œb c}S c c}w )aB  Finds neighboring LTTextLineHorizontals in the plane.

        Returns a list of other LTTestLineHorizontals in the plane which are
        close to self. "Close" can be controlled by ratio. The returned objects
        will be the same height as self, and also either left-, right-, or
        centrally-aligned.
        ©Ú	tolerance)rz   Úfindru   rv   rw   rx   r,   r"  Ú_is_same_height_asÚ_is_left_aligned_withÚ_is_right_aligned_withÚ_is_centrally_aligned_with©r%   r  r  rí   r  r0   s         r&   r  z#LTTextLineHorizontal.find_neighbors  sº   € ð �D—K‘KÑˆØ�z‰z˜4Ÿ7™7 D§G¡G¨a¡K°·±¸$¿'¹'ÀA¹+ÐFÓGˆð ö
àä˜3Ô 4Ô5Ø×+Ñ+¨C¸1Ð+Ô=à×.Ñ.¨s¸aÐ.Ô@Ø×2Ñ2°3À!Ð2ÔDØ×6Ñ6°sÀaÐ6ÔHò ò
ð 	
ùò 
ó   ÁA%B?Úotherr-  c                 óL   — t        |j                  | j                  z
  «      |k  S )z<Whether the left-hand edge of `other` is within `tolerance`.)r†   ru   ©r%   r5  r-  s      r&   r0  z*LTTextLineHorizontal._is_left_aligned_with  ó   € ä�5—8‘8˜dŸg™gÑ%Ó&¨)Ñ3Ð3r(   c                 óL   — t        |j                  | j                  z
  «      |k  S )z=Whether the right-hand edge of `other` is within `tolerance`.)r†   rw   r7  s      r&   r1  z+LTTextLineHorizontal._is_right_aligned_with!  r8  r(   c                 óŒ   — t        |j                  |j                  z   dz  | j                  | j                  z   dz  z
  «      |k  S )z?Whether the horizontal center of `other` is within `tolerance`.é   )r†   ru   rw   r7  s      r&   r2  z/LTTextLineHorizontal._is_centrally_aligned_with%  ó=   € ô �E—H‘H˜uŸx™xÑ'¨1Ñ,°·±¸$¿'¹'Ñ0AÀQÑ/FÑFÓGÈ9ÑTÐTr(   c                 óL   — t        |j                  | j                  z
  «      |k  S r#   )r†   rz   r7  s      r&   r/  z'LTTextLineHorizontal._is_same_height_as-  s   € Ü�5—<‘< $§+¡+Ñ-Ó.°)Ñ;Ð;r(   r2   )r4   r5   r6   rF   r'   rb   r  r   r   rª   r  r  rO   r0  r1  r2  r/  r  r   s   @r&   r"  r"  ò  sÎ   ø„ ð Eð ¨dó ð�{ð  tõ ð
à�\Ñ"ð
ð ð
ð 
ˆjÑ	ó	
ñ84¨;ð 4À5ð 4ÐQUó 4ñ4¨Kð 4ÀEð 4ÐRVó 4ð ñUàðUð ðUð 
ó	Uñ<¨ð <Àð <Èd÷ <r(   r"  c                   ó°   ‡ — e Zd Zdeddfd„Zdeddfˆ fd„Zdee   dede	e
   fd	„Zdd
ededefd„Zdd
ededefd„Z	 dd
ededefd„Zd
ededefd„Zˆ xZS )ÚLTTextLineVerticalr>   r!   Nc                 óH   — t         j                  | |«       t         | _        y r#   )r  r'   r   Ú_y0r%  s     r&   r'   zLTTextLineVertical.__init__2  r&  r(   r0   c                 óN  •— t        |t        «      rt| j                  rh| j                  t        |j                  |j
                  «      z  }|j                  |z   | j                  k  rt        j                  | t        d«      «       |j                  | _        t        ‰| �%  |«       y r(  )r,   rÖ   r>   r  ry   rz   rx   rA  rö   r  rÎ   rv   r  r)  s      €r&   r  zLTTextLineVertical.add8  sq   ø€ Ü�cœ6Ô" t×'7Ò'7Ø×%Ñ%¬¨C¯I©I°s·z±zÓ(BÑBˆFØ�v‰v˜‰ §¡Ò)Ü—‘ ¤f¨S£kÔ2Ø—6‘6ˆŒÜ‰‰�CÕr(   r  r  c                 óˆ  — || j                   z  }|j                  | j                  |z
  | j                  | j                  |z   | j
                  f«      }|D �cg c]`  }t        |t        «      rN| j                  ||¬«      r;| j                  ||¬«      s&| j                  ||¬«      s| j                  ||¬«      r|‘Œb c}S c c}w )a>  Finds neighboring LTTextLineVerticals in the plane.

        Returns a list of other LTTextLineVerticals in the plane which are
        close to self. "Close" can be controlled by ratio. The returned objects
        will be the same width as self, and also either upper-, lower-, or
        centrally-aligned.
        r,  )ry   r.  ru   rv   rw   rx   r,   r?  Ú_is_same_width_asÚ_is_lower_aligned_withÚ_is_upper_aligned_withr2  r3  s         r&   r  z!LTTextLineVertical.find_neighbors@  sº   € ð �D—J‘JÑˆØ�z‰z˜4Ÿ7™7 Q™;¨¯©°·±¸1±¸d¿g¹gÐFÓGˆð ö
àä˜3Ô 2Ô3Ø×*Ñ*¨3¸!Ð*Ô<à×/Ñ/°¸qÐ/ÔAØ×2Ñ2°3À!Ð2ÔDØ×6Ñ6°sÀaÐ6ÔHò ò
ð 	
ùò 
r4  r5  r-  c                 óL   — t        |j                  | j                  z
  «      |k  S )z8Whether the lower edge of `other` is within `tolerance`.)r†   rv   r7  s      r&   rE  z)LTTextLineVertical._is_lower_aligned_with\  r8  r(   c                 óL   — t        |j                  | j                  z
  «      |k  S )z8Whether the upper edge of `other` is within `tolerance`.)r†   rx   r7  s      r&   rF  z)LTTextLineVertical._is_upper_aligned_with`  r8  r(   c                 óŒ   — t        |j                  |j                  z   dz  | j                  | j                  z   dz  z
  «      |k  S )z=Whether the vertical center of `other` is within `tolerance`.r;  )r†   rv   rx   r7  s      r&   r2  z-LTTextLineVertical._is_centrally_aligned_withd  r<  r(   c                 óL   — t        |j                  | j                  z
  «      |k  S r#   )r†   ry   r7  s      r&   rD  z$LTTextLineVertical._is_same_width_asl  s   € Ü�5—;‘; §¡Ñ+Ó,°	Ñ9Ð9r(   r2   )r4   r5   r6   rF   r'   rb   r  r   r   rª   r  r  rO   rE  rF  r2  rD  r  r   s   @r&   r?  r?  1  sÎ   ø„ ð Eð ¨dó ð�{ð  tõ ð
à�\Ñ"ð
ð ð
ð 
ˆjÑ	ó	
ñ84¨Kð 4ÀEð 4ÐRVó 4ñ4¨Kð 4ÀEð 4ÐRVó 4ð ñUàðUð ðUð 
ó	Uð: {ð :¸uð :È÷ :r(   r?  c                   ó0   — e Zd ZdZdd„Zdefd„Zdefd„Zy)r-   zìRepresents a group of text chunks in a rectangular area.

    Note that this box is created by geometric analysis and does not
    necessarily represents a logical boundary of the text. It contains a list
    of LTTextLine objects.
    r!   Nc                 ó<   — t         j                  | «       d| _        y )NrE   )r  r'   r    rJ   s    r&   r'   zLTTextBox.__init__x  s   € Ü× Ñ  Ô&Øˆ�
r(   c           	      óž   — d| j                   j                  › d| j                  › dt        | j                  «      › d| j                  «       ›d�	S rÊ   )r\   r4   r    r   rc   r]   rJ   s    r&   rK   zLTTextBox.__repr__|  sH   € à�—‘×'Ñ'Ð(¨¨$¯*©*¨°RÜ˜Ÿ	™	Ó"Ð# 1 T§]¡]£_Ð$7°qð:ð	
r(   c                 ó   — t         ‚r#   r_   rJ   s    r&   Úget_writing_modezLTTextBox.get_writing_mode‚  s   € Ü!Ð!r(   rM   )r4   r5   r6   rN   r'   rP   rK   rO  r8   r(   r&   r-   r-   p  s$   „ ñóð
˜#ó 
ð" #ô "r(   r-   c                   ó4   ‡ — e Zd Zdeddfˆ fd„Zdefd„Zˆ xZS )ÚLTTextBoxHorizontalrR   r!   Nc                 ó^   •— t         ‰| �  |«       | j                  j                  d„ ¬«       y )Nc                 ó   — | j                    S r#   )rx   ©r0   s    r&   ú<lambda>z-LTTextBoxHorizontal.analyze.<locals>.<lambda>‰  ó   € ¨¯©¨€ r(   ©Úkey©r  rU   rø   Úsort©r%   rR   r\   s     €r&   rU   zLTTextBoxHorizontal.analyze‡  ó"   ø€ Ü‰‰˜Ô!Ø�
‰
�‰Ñ/ˆÕ0r(   c                  ó   — y)Nzlr-tbr8   rJ   s    r&   rO  z$LTTextBoxHorizontal.get_writing_mode‹  ó   € Ør(   ©r4   r5   r6   r:   rU   rP   rO  r  r   s   @r&   rQ  rQ  †  ó"   ø„ ð1 ð 1¨Tõ 1ð #÷ r(   rQ  c                   ó4   ‡ — e Zd Zdeddfˆ fd„Zdefd„Zˆ xZS )ÚLTTextBoxVerticalrR   r!   Nc                 ó^   •— t         ‰| �  |«       | j                  j                  d„ ¬«       y )Nc                 ó   — | j                    S r#   )rw   rT  s    r&   rU  z+LTTextBoxVertical.analyze.<locals>.<lambda>’  rV  r(   rW  rY  r[  s     €r&   rU   zLTTextBoxVertical.analyze�  r\  r(   c                  ó   — y)Nztb-rlr8   rJ   s    r&   rO  z"LTTextBoxVertical.get_writing_mode”  r^  r(   r_  r   s   @r&   rb  rb  �  r`  r(   rb  r.   c                   ó.   ‡ — e Zd Zdee   ddfˆ fd„Zˆ xZS )r.   r  r!   Nc                 óD   •— t         ‰| �  «        | j                  |«       y r#   )r  r'   r  )r%   r  r\   s     €r&   r'   zLTTextGroup.__init__œ  s   ø€ Ü‰ÑÔØ�‰�DÕr(   )r4   r5   r6   r   ÚTextGroupElementr'   r  r   s   @r&   r.   r.   ›  s!   ø„ ð˜XÐ&6Ñ7ð ¸D÷ ñ r(   c                   ó(   ‡ — e Zd Zdeddfˆ fd„Zˆ xZS )ÚLTTextGroupLRTBrR   r!   Nc                 ó˜   •‡— t         ‰| �  |«       |j                  €J ‚|j                  Š| j                  j	                  ˆfd„¬«       y )Nc                 óh   •— d‰z
  | j                   z  d‰z   | j                  | j                  z   z  z
  S r*   )ru   rv   rx   ©r0   r?   s    €r&   rU  z)LTTextGroupLRTB.analyze.<locals>.<lambda>¨  s1   ø€ ˜Q ™^¨s¯v©vÑ5Ø�:‰~ #§&¡&¨3¯6©6¡/Ñ2ñ3€ r(   rW  ©r  rU   r?   rø   rZ  ©r%   rR   r?   r\   s     @€r&   rU   zLTTextGroupLRTB.analyze¢  sF   ù€ Ü‰‰˜Ô!Ø×"Ñ"Ð.Ð.Ð.Ø×(Ñ(ˆ
à�
‰
�‰ó3ð 	õ 	
r(   ©r4   r5   r6   r:   rU   r  r   s   @r&   rj  rj  ¡  ó   ø„ ð
 ð 
¨T÷ 
ñ 
r(   rj  c                   ó(   ‡ — e Zd Zdeddfˆ fd„Zˆ xZS )ÚLTTextGroupTBRLrR   r!   Nc                 ó˜   •‡— t         ‰| �  |«       |j                  €J ‚|j                  Š| j                  j	                  ˆfd„¬«       y )Nc                 ój   •— d‰z    | j                   | j                  z   z  d‰z
  | j                  z  z
  S r*   )ru   rw   rx   rm  s    €r&   rU  z)LTTextGroupTBRL.analyze.<locals>.<lambda>´  s4   ø€ ˜a *™nÐ-°·±¸#¿&¹&±ÑAØ�:‰~ §¡Ñ'ñ(€ r(   rW  rn  ro  s     @€r&   rU   zLTTextGroupTBRL.analyze®  sF   ù€ Ü‰‰˜Ô!Ø×"Ñ"Ð.Ð.Ð.Ø×(Ñ(ˆ
à�
‰
�‰ó(ð 	õ 	
r(   rp  r   s   @r&   rs  rs  ­  rq  r(   rs  c                   óŒ   — e Zd Zdeddfd„Zdedee   dee	   fd„Z
dedee	   dee   fd	„Zded
ee   dee   fd„Zdeddfd„Zy)ÚLTLayoutContainerrc   r!   Nc                 ó>   — t         j                  | |«       d | _        y r#   )rö   r'   Úgroupsrf   s     r&   r'   zLTLayoutContainer.__init__º  s   € Ü×Ñ˜T 4Ô(Ø04ˆ�r(   rR   r  c              #   ó¾  K  — d }d }|D �]  }|��|j                  |«      xr€ t        |j                  |j                  «      |j                  z  |j	                  |«      k  xr? |j                  |«      t        |j                  |j                  «      |j                  z  k  }|j                  xr“ |j                  |«      xr€ t        |j                  |j                  «      |j                  z  |j                  |«      k  xr? |j                  |«      t        |j                  |j                  «      |j                  z  k  }|rt        |t        «      s|r"t        |t        «      r|j!                  |«       n­|�|–— d }n¤|r:|s8t        |j"                  «      }|j!                  |«       |j!                  |«       nh|r:|s8t        |j"                  «      }|j!                  |«       |j!                  |«       n,t        |j"                  «      }|j!                  |«       |–— d }|}�Œ" |€*t        |j"                  «      }|€J ‚|j!                  |«       |–— y ­wr#   )r�   r…   rz   r;   r’   r‡   r  ry   r<   r@   r�   rŠ   r�   r,   r"  r?  r  r>   )r%   rR   r  Úobj0ÚlineÚobj1ÚhalignÚvaligns           r&   Úgroup_objectszLTLayoutContainer.group_objects¿  s"  è ø€ ð
 ˆØ"&ˆØó ?	ˆDØÑð ×$Ñ$ TÓ*ò IÜ˜DŸK™K¨¯©Ó5¸×8MÑ8MÑMØ—m‘m DÓ)ñ*òIð Ÿ™ tÓ,Ü˜$Ÿ*™* d§j¡jÓ1°H×4HÑ4HÑHñIð	 ð. ×,Ñ,ò KØ×(Ñ(¨Ó.òKä˜DŸJ™J¨¯
©
Ó3°h×6KÑ6KÑKØ—m‘m DÓ)ñ*òKð Ÿ™ tÓ,Ü˜$Ÿ+™+ t§{¡{Ó3°h×6JÑ6JÑJñKð ñ œz¨$Ô0DÔEÙœz¨$Ô0BÔCà—H‘H˜T•NØÐ%Ø’JØ‘DÙ¡FÜ-¨h×.BÑ.BÓC�DØ—H‘H˜T”NØ—H‘H˜T•NÙ¡FÜ/°×0DÑ0DÓE�DØ—H‘H˜T”NØ—H‘H˜T•Nä/°×0DÑ0DÓE�DØ—H‘H˜T”NØ’JØ�DØŠDð?	ð@ ˆ<Ü'¨×(<Ñ(<Ó=ˆDØÐ#Ð#Ð#Ø�H‰H�TŒNØ‹
ùs   ‚IIÚlinesc              #   óD  K  — t        | j                  «      }|j                  |«       i }|D ]©  }|j                  ||j                  «      }|g}|D ]8  }|j                  |«       ||v sŒ|j                  |j                  |«      «       Œ: t        |t        «      rt        «       }	n
t        «       }	t        |«      D ]  }
|	j                  |
«       |	||
<   Œ Œ« t        «       }|D ]7  }||vrŒ||   }	|	|v rŒ|j                  |	«       |	j                  «       rŒ4|	–— Œ9 y­w)z$Group neighboring lines to textboxesN)r   rc   r  r  r=   r   Úpopr,   r"  rQ  rb  r   r  Úsetr}   )r%   rR   r�  r  Úboxesr|  Ú	neighborsÚmembersr}  Úboxr0   Údones               r&   Úgroup_textlinesz!LTLayoutContainer.group_textlines  s  è ø€ ô $)¨¯©Ó#3ˆØ�‰�UÔØ-/ˆØò 	!ˆDØ×+Ñ+¨E°8×3GÑ3GÓHˆIØ�fˆGØ!ò 4�Ø—‘˜tÔ$Ø˜5’=Ø—N‘N 5§9¡9¨T£?Õ3ð4ô ˜$Ô 4Ô5Ü!4Ó!6‘ä'Ó)�Ü˜G“}ò !�Ø—‘˜”Ø ��c’
ñ!ð	!ô ‹uˆØò 	ˆDØ˜5Ñ ØØ˜‘+ˆCØ�d‰{ØØ�H‰H�SŒMØ—<‘<•>Ø“	ñ	ùs   ‚A'D Á*B.D ÄD r…  c           
      ó˜  ‡— t         t        t        f   }t        | j                  «      Šdt
        dt
        dt        fd„}d|d|dt        |   fˆfd„}g }t        t        |«      «      D ]Y  }||   }t        |dz   t        |«      «      D ]7  }	||	   }
|j                  d |||
«      t        |«      t        |
«      ||
f«       Œ9 Œ[ t        j                  |«       ‰j                  |«       t        «       }t        |«      dkD  �r%t        j                  |«      \  }}}}}}||vrõ||vrñ|s& |||«      rt        j                   |d	|||||f«       Œ[t#        |t$        t&        f«      st#        |t$        t&        f«      rt'        ||g«      }nt)        ||g«      }‰j+                  |«       ‰j+                  |«       |j-                  ||g«       ‰D ]7  }t        j                   |d |||«      t        |«      t        |«      ||f«       Œ9 ‰j/                  |«       t        |«      dkD  r�Œ%‰D �cg c]  }t1        t        |«      ‘Œ c}S c c}w )
ax  Group textboxes hierarchically.

        Get pair-wise distances, via dist func defined below, and then merge
        from the closest textbox pair. Once obj1 and obj2 are merged /
        grouped, the resulting group is considered as a new object, and its
        distances to other objects & groups are added to the process queue.

        For performance reason, pair-wise distances and object pair info are
        maintained in a heap of (idx, dist, id(obj1), id(obj2), obj1, obj2)
        tuples. It ensures quick access to the smallest element. Note that
        since comparison operators, e.g., __lt__, are disabled for
        LTComponent, id(obj) has to appear before obj in element tuples.

        :param laparams: LAParams object.
        :param boxes: All textbox objects to be grouped.
        :return: a list that has only one element, the final top level group.
        r}  Úobj2r!   c                 ó€  — t        | j                  |j                  «      }t        | j                  |j                  «      }t        | j                  |j                  «      }t        | j
                  |j
                  «      }||z
  ||z
  z  | j                  | j                  z  z
  |j                  |j                  z  z
  S )aÄ  A distance function between two TextBoxes.

            Consider the bounding rectangle for obj1 and obj2.
            Return its area less the areas of obj1 and obj2,
            shown as 'www' below. This value may be negative.
                    +------+..........+ (x1, y1)
                    | obj1 |wwwwwwwwww:
                    +------+www+------+
                    :wwwwwwwwww| obj2 |
            (x0, y0) +..........+------+
            )r…   ru   rv   r  rw   rx   ry   rz   )r}  rŒ  ru   rv   rw   rx   s         r&   Údistz/LTLayoutContainer.group_textboxes.<locals>.distG  s“   € ô �T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBà�b‘˜R "™WÑ%Ø—*‘*˜tŸ{™{Ñ*ñ+à—*‘*˜tŸ{™{Ñ*ñ+ðr(   c                 óf  •— t        | j                  |j                  «      }t        | j                  |j                  «      }t        | j                  |j                  «      }t        | j
                  |j
                  «      }t        ‰j                  ||||f«      «      }|j                  | |f«      S )z8Check if there's any other object between obj1 and obj2.)	r…   ru   rv   r  rw   rx   r„  r.  Ú
difference)r}  rŒ  ru   rv   rw   rx   r  r  s          €r&   Úisanyz0LTLayoutContainer.group_textboxes.<locals>.isany]  s‚   ø€ ä�T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBÜ�T—W‘W˜dŸg™gÓ&ˆBÜ�u—z‘z 2 r¨2¨rÐ"2Ó3Ó4ˆDØ—?‘? D¨$ <Ó0Ð0r(   r+   Fr   T)r   r-   r.   r   rc   rb   rF   r„  Úrangerý   r   ÚidÚheapqÚheapifyr  ÚheappopÚheappushr,   rb  rs  rj  ÚremoveÚupdater  r	   )r%   rR   r…  ÚElementTrŽ  r‘  ÚdistsÚiÚbox1ÚjÚbox2r‰  Ú
skip_isanyrí   Úid1Úid2r}  rŒ  Úgroupr5  Úgr  s                        @r&   Úgroup_textboxesz!LTLayoutContainer.group_textboxes.  s5  ø€ ô, œ¤KÐ/Ñ0ˆÜ!& t§y¡yÓ!1ˆð	”{ð 	¬+ð 	¼%ó 	ð,	1˜ð 	1¨ð 	1´S¸±]õ 	1ð IKˆÜ”s˜5“zÓ"ò 	XˆAØ˜‘8ˆDÜ˜1˜q™5¤# e£*Ó-ò X�Ø˜Q‘x�Ø—‘˜e¡T¨$°Ó%5´r¸$³xÄÀDÃÈ4ÐQUÐVÕWñXð	Xô
 	�‰�eÔà�‰�UÔÜ‹uˆÜ�%‹j˜1‹nÜ49·M±MÀ%Ó4HÑ1ˆZ˜˜C  d¨Dà˜4‘ c°¡oÙ!¡e¨D°$Ô&7Ü—N‘N 5¨4°°C¸¸dÀDÐ*IÔJØÜ˜dÔ%6¼Ð$HÔIÌZØÜ&¬Ð8ôNô *9¸$À¸Ó)F‘Eä+¨T°4¨LÓ9�EØ—‘˜TÔ"Ø—‘˜TÔ"Ø—‘˜S #˜JÔ'à"ò �EÜ—N‘NØØ¡ U¨EÓ 2´B°u³I¼rÀ%»yÈ%ÐQVÐWõðð
 —	‘	˜%Ô ô/ �%‹j˜1Œnð2 /4Ö4¨””[ !Õ$Ò4Ð4ùÒ4s   È-Ic                 ó  — t        d„ | «      \  }}|D ]  }|j                  |«       Œ |sy t        | j                  ||«      «      }t        d„ |«      \  }}|D ]  }|j                  |«       Œ t        | j	                  ||«      «      }|j
                  €M|D ]  }|j                  |«       Œ dt        dt        t        t        t        f   fd„}	|j                  |	¬«       ng| j                  ||«      | _        t        «       }
| j                  D ]$  }|j                  |«       |
j                  |«       Œ& |j                  d„ ¬«       t        t        t            |«      |z   t        t        t            |«      z   | _        y )Nc                 ó"   — t        | t        «      S r#   )r,   rÖ   rT  s    r&   rU  z+LTLayoutContainer.analyze.<locals>.<lambda>Ž  s   € ´:¸cÄ6Ó3J€ r(   c                 ó"   — | j                  «       S r#   )r}   rT  s    r&   rU  z+LTLayoutContainer.analyze.<locals>.<lambda>”  s   € °#·,±,³.€ r(   rˆ  r!   c                 óŒ   — t        | t        «      rd| j                   | j                   fS d| j                   | j                  fS )Nr   r+   )r,   rb  rw   rv   ru   ©rˆ  s    r&   Úgetkeyz)LTLayoutContainer.analyze.<locals>.getkeyœ  s=   € Ü˜cÔ#4Ô5Ø §¡˜w¨¯©¨Ð0Ð0à §¡˜w¨¯©Ð/Ð/r(   rW  c                 ó   — | j                   S r#   r$   rª  s    r&   rU  z+LTLayoutContainer.analyze.<locals>.<lambda>©  s
   € ¨3¯9©9€ r(   )r   rU   rª   r€  rŠ  r?   r-   r«   r7   rF   rZ  r¥  ry  r   r/   r	   rb   rø   )r%   rR   ÚtextobjsÚ	otherobjsr0   Ú	textlinesÚemptiesÚ	textboxesÚtextboxr«  Úassignerr£  s               r&   rU   zLTLayoutContainer.analyze‹  sq  € ô !'Ñ'JÈDÓ QÑˆ�9Øò 	"ˆCØ�K‰K˜Õ!ð	"áØÜ˜×+Ñ+¨H°hÓ?Ó@ˆ	Ü%Ñ&@À)ÓLÑˆ�)Øò 	"ˆCØ�K‰K˜Õ!ð	"ä˜×-Ñ-¨h¸	ÓBÓCˆ	Ø×ÑÐ&Ø$ò *�Ø—‘ Õ)ð*ð0œIð 0¬%´´U¼EÐ0AÑ*Bó 0ð �N‰N˜vˆNÕ&à×.Ñ.¨x¸ÓCˆDŒKÜ$“ˆHØŸ™ò $�Ø—‘˜hÔ'Ø—‘˜UÕ#ð$ð �N‰NÑ4ˆNÔ5ä””kÑ" IÓ.Øñä”4œÑ$ gÓ.ñ/ð 	�
r(   )r4   r5   r6   r   r'   r:   r   rb   r   r  r€  r-   rŠ  r   rª   r.   r¥  rU   r8   r(   r&   rw  rw  ¹  s´   „ ð5˜Tð 5 dó 5ð
KàðKð �{Ñ#ðKð 
�*Ñ	ó	KðZ àð ð ˜
Ñ#ð ð 
�)Ñ	ó	 ðD[5àð[5ð ˜	Ñ"ð[5ð 
ˆkÑ	ó	[5ðz#
 ð #
¨Tô #
r(   rw  c                   óD   — e Zd ZdZdedededdfd„Zdefd„Zd	e	ddfd
„Z
y)ÚLTFigurezÛRepresents an area used by PDF Form objects.

    PDF Forms can be used to present figures or pictures by embedding yet
    another PDF document within a page. Note that LTFigure objects can appear
    recursively.
    r·   rc   r×   r!   Nc                 óŠ   — || _         || _        |\  }}}}||||z   ||z   f}t        ||«      }t        j	                  | |«       y r#   )r·   r×   r   rw  r'   )	r%   r·   rc   r×   r1   ÚyÚwÚhÚrects	            r&   r'   zLTFigure.__init__¹  sO   € ØˆŒ	ØˆŒØ‰ˆˆAˆq�!Ø�1�a˜!‘e˜Q ™UÐ#ˆÜ  ¨Ó.ˆÜ×"Ñ" 4¨Õ.r(   c           
      ó¨   — d| j                   j                  › d| j                  › dt        | j                  «      › dt        | j                  «      › d�	S )NrZ   rË   rÌ   rñ   rI   )r\   r4   r·   r   rc   r   r×   rJ   s    r&   rK   zLTFigure.__repr__Á  sO   € à�—‘×'Ñ'Ð(¨¨$¯)©)¨°BÜ˜Ÿ	™	Ó"Ð#ð $Ü  §¡Ó-Ð.¨að1ð	
r(   rR   c                 óJ   — |j                   sy t        j                  | |«       y r#   )rA   rw  rU   rT   s     r&   rU   zLTFigure.analyzeÈ  s   € Ø×!Ò!ØÜ×!Ñ! $¨Õ1r(   )r4   r5   r6   rN   rP   r   r   r'   rK   r:   rU   r8   r(   r&   rµ  rµ  ±  sG   „ ñð/˜Sð /¨ð /°fð /Àó /ð
˜#ó 
ð2 ð 2¨Tô 2r(   rµ  c            	       ó6   — e Zd ZdZd	dedededdfd„Zdefd„Z	y)
ÚLTPagez»Represents an entire page.

    Like any other LTLayoutContainer, an LTPage can be iterated to obtain child
    objects like LTTextBox, LTFigure, LTImage, LTRect, LTCurve and LTLine.
    Úpageidrc   Úrotater!   Nc                 óL   — t         j                  | |«       || _        || _        y r#   )rw  r'   r¿  rÀ  )r%   r¿  rc   rÀ  s       r&   r'   zLTPage.__init__Õ  s    € Ü×"Ñ" 4¨Ô.ØˆŒØˆ�r(   c           	      ó–   — d| j                   j                  › d| j                  ›dt        | j                  «      › d| j
                  ›d�	S )NrZ   rË   rÌ   z rotate=rI   )r\   r4   r¿  r   rc   rÀ  rJ   s    r&   rK   zLTPage.__repr__Ú  sI   € à�—‘×'Ñ'Ð(¨¨$¯+©+¨¸Ü˜Ÿ	™	Ó"Ð#ð $Ø—k‘k�_ Að'ð	
r(   r2   )
r4   r5   r6   rN   r7   r   rF   r'   rP   rK   r8   r(   r&   r¾  r¾  Î  s4   „ ññ˜sð ¨$ð ¸ð Àdó ð

˜#ô 
r(   r¾  )Er”  ÚloggingÚcollections.abcr   r   r   Útypingr   r   r   r	   Úpdfminer.pdfcolorr
   Úpdfminer.pdfexceptionsr   r   Úpdfminer.pdffontr   Úpdfminer.pdfinterpr   r   Úpdfminer.pdftypesr   Úpdfminer.utilsr   r   r   r   r   r   r   r   r   r   r   r   r   Ú	getLoggerr4   Úloggerr   r:   r3   rW   rb   r•   r­   r³   r¶   rÎ   rÖ   ró   rö   r  r  ÚTextLineElementr  r"  r?  r-   rQ  rb  rh  r.   rj  rs  rw  rµ  r¾  r8   r(   r&   ú<module>rÏ     sô  ðÛ Û ß 8Ñ 8÷ó õ ,ß >Ý $ß 5Ý '÷÷ ÷ õ ð  
ˆ×	Ñ	˜8Ó	$€÷
ñ 
÷@
ñ @
÷F+ñ +÷"ñ "ôF�&ô FôR!Fˆkô !FôH
ˆWô 
ôB
ˆWô 
ôB
ˆkô 
ô0ˆV�Vô ô:ˆ[˜&ô :ñz �) 6Ô
*€ô"�+˜w wÑ/ô "ô2
˜K¨Ñ0ô 
ô$
Ð+¨GÑ4°fô 
ð ˜ ˜Ñ'€ô?� Ñ1ô ?ô<<<˜:ô <<ô~<:˜ô <:ô~"� 
Ñ+ô "ô,˜)ô ô˜	ô ð ˜ MÐ1Ñ2Ð ô�/Ð"2Ñ3ô ô	
�kô 	
ô	
�kô 	
ôu
˜ KÑ0ô u
ôp2Ð ô 2ô:
Ðõ 
r(   