ó
    ‰*£hø'  ã                  óº   • S r SSKJr  SSKJr  SSKJr  \(       a  SSKJr   " S S\	5      r
 " S S	\5      r " S
 S\5      r " S S\	5      r " S S\5      rS rg)z?Objects related to layout of rendered text, such as TextFitter.é    )Úannotations)ÚTYPE_CHECKING)Ú	ImageFont)ÚLengthc                  ó®   • \ rS rSrSrS r\          SS j5       rS rS r	S r
\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       rS rSrg)Ú
TextFitteré   zGValue object that knows how to fit text into given rectangular extents.c                ó:   • Uu  pE[         R                  XXEU45      $ ©N©ÚtupleÚ__new__)ÚclsÚline_sourceÚextentsÚ	font_fileÚwidthÚheights         ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pptx/text/layout.pyr   ÚTextFitter.__new__   s   € Ø‰ˆÜ�}‰}˜S°¸yÐ"IÓJÐJó    c                óL   • [        U5      nU " XRU5      nUR                  U5      $ )a  Return whole-number best fit point size less than or equal to `max_size`.

The return value is the largest whole-number point size less than or equal to
`max_size` that allows `text` to fit completely within `extents` when rendered
using font defined in `font_file`.
)Ú_LineSourceÚ_best_fit_font_size)r   Útextr   Úmax_sizer   r   Útext_fitters          r   Úbest_fit_font_sizeÚTextFitter.best_fit_font_size   s+   € ô " $Ó'ˆÙ˜+°	Ó:ˆØ×.Ñ.¨xÓ8Ð8r   c                ó’   • U R                   n[        R                  [        S[	        U5      S-   5      5      nUR                  U5      $ )zg
Return the largest whole-number point size less than or equal to
*max_size* that this fitter can fit.
é   )Ú_fits_inside_predicateÚ_BinarySearchTreeÚfrom_ordered_sequenceÚrangeÚintÚfind_max)Úselfr   Ú	predicateÚsizess       r   r   ÚTextFitter._best_fit_font_size"   s?   € ð
 ×/Ñ/ˆ	Ü!×7Ñ7¼¸aÄÀXÃÐQRÑARÓ8SÓTˆØ�~‰~˜iÓ(Ð(r   c                óp   • [         R                  U5      nU R                  U5      nUR                  U5      $ )zÑ
Return a (line, remainder) pair where *line* is the longest line in
*line_source* that will fit in this fitter's width and *remainder* is
a |_LineSource| object containing the text following the break point.
)r#   r$   Ú_fits_in_width_predicater'   )r(   r   Ú
point_sizeÚlinesr)   s        r   Ú_break_lineÚTextFitter._break_line+   s3   € ô "×7Ñ7¸ÓDˆØ×1Ñ1°*Ó=ˆ	Ø�~‰~˜iÓ(Ð(r   c                ó   ^ ^• UU 4S jnU$ )z¥
Return a function taking a text string value and returns |True| if
that text fits in this fitter when rendered at *point_size*. Used as
predicate for _break_line()
c                ój   >• [        U R                  TTR                  5      S   nUTR                  :*  $ )zL
Return |True| if *line* fits in this fitter when rendered at
*point_size*.
r   )Ú_rendered_sizer   Ú
_font_fileÚ_width)ÚlineÚcxr.   r(   s     €€r   r)   Ú6TextFitter._fits_in_width_predicate.<locals>.predicate<   s/   ø€ ô
   §	¡	¨:°t·±ÓGÈÑJˆBØ˜Ÿ™Ñ$Ð$r   © )r(   r.   r)   s   `` r   r-   Ú#TextFitter._fits_in_width_predicate5   s   ù€ ö	%ð Ðr   c                ó   ^ • U 4S jnU$ )zÄReturn  function taking an integer point size argument.

The function returns |True| if the text in this fitter can be wrapped to fit
entirely within its extents when rendered at that point size.
c                ó¦   >• TR                  TR                  U 5      n[        SU TR                  5      S   nU[	        U5      -  TR
                  :*  $ )zÑReturn |True| when text in `line_source` can be wrapped to fit.

Fit means text can be broken into lines that fit entirely within `extents`
when rendered at `point_size` using the font defined in `font_file`.
ÚTyr!   )Ú_wrap_linesÚ_line_sourcer4   r5   ÚlenÚ_height)r.   Ú
text_linesÚcyr(   s      €r   r)   Ú4TextFitter._fits_inside_predicate.<locals>.predicateN   sL   ø€ ð ×)Ñ)¨$×*;Ñ*;¸ZÓHˆJÜ  j°$·/±/ÓBÀ1ÑEˆBØœ˜Z›Ñ(¨T¯\©\Ñ9Ð9r   r:   )r(   r)   s   ` r   r"   Ú!TextFitter._fits_inside_predicateF   s   ø€ õ	:ð Ðr   c                ó   • U S   $ )Né   r:   ©r(   s    r   r5   ÚTextFitter._font_fileZ   ó   € à�A‰wˆr   c                ó   • U S   $ )Né   r:   rI   s    r   rB   ÚTextFitter._height^   rK   r   c                ó   • U S   $ ©Nr   r:   rI   s    r   r@   ÚTextFitter._line_sourceb   rK   r   c                ó   • U S   $ ©Nr!   r:   rI   s    r   r6   ÚTextFitter._widthf   rK   r   c                ó€   • U R                  X5      u  p4U/nU(       a   UR                  U R                  XB5      5        U$ )z‚
Return a sequence of str values representing the text in
*line_source* wrapped within this fitter when rendered at
*point_size*.
)r0   Úextendr?   )r(   r   r.   r   Ú	remainderr/   s         r   r?   ÚTextFitter._wrap_linesj   s<   € ð ×*Ñ*¨;ÓC‰ˆØ�ˆÞØ�L‰L˜×)Ñ)¨)Ó@ÔAØˆr   r:   N)
r   Ústrr   ztuple[Length, Length]r   r&   r   rY   Úreturnr&   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úclassmethodr   r   r0   r-   Úpropertyr"   r5   rB   r@   r6   r?   Ú__static_attributes__r:   r   r   r   r      s¿   † ÙQòKð ð9Øð9Ø!6ð9ØBEð9ØRUð9à	ó9ó ð9ò)ò)òð" ñó ðð& ñó ðð ñó ðð ñó ðð ñó ðõ
r   r   c                  ón   • \ rS rSrSrS rSS jr\S 5       rS r	SS jr
\S	 5       r\S
 5       rS rSrg)r#   éw   zQ
A node in a binary search tree. Uniform for root, subtree root, and leaf
nodes.
c                ó,   • Xl         S U l        S U l        g r   )Ú_valueÚ_lesserÚ_greater)r(   Úvalues     r   Ú__init__Ú_BinarySearchTree.__init__}   s   € ØŒØˆŒØˆ�r   Nc                ó¦   • U" U R                   5      (       a  U R                   nU R                  nOU R                  nUc  U$ UR                  X5      $ )zK
Return the largest item in or under this node that satisfies
*predicate*.
)ri   rh   rg   r'   )r(   r)   Úmax_Ú	next_nodes       r   r'   Ú_BinarySearchTree.find_max‚   sJ   € ñ
 �T—Z‘Z× Ñ Ø—:‘:ˆDØŸ™‰IàŸ™ˆIØÑØˆKØ×!Ñ! )Ó2Ð2r   c                ój   • [        U5      nU " UR                  5       5      nUR                  U5        U$ )z`
Return the root of a balanced binary search tree populated with the
values in iterable *iseq*.
)ÚlistÚpopÚ_insert_from_ordered_sequence)r   ÚiseqÚseqÚbsts       r   r$   Ú'_BinarySearchTree.from_ordered_sequence�   s/   € ô �4‹jˆá�#—'‘'“)‹nˆØ×)Ñ)¨#Ô.Øˆ
r   c                ó”   • XR                   :  a  SOSn[        X5      nUc  [        X[        U5      5        gUR	                  U5        g)zs
Insert a new node containing *value* into this tree such that its
structure as a binary search tree is preserved.
rg   rh   N)ri   ÚgetattrÚsetattrr#   Úinsert)r(   ri   ÚsideÚchilds       r   r{   Ú_BinarySearchTree.insertœ   s?   € ð
 "§J¡JÓ.‰y°JˆÜ˜Ó#ˆØ‰=Ü�DÔ 1°%Ó 8Õ9à�L‰L˜Õr   c                ó  • U< U R                   R                  < S3nSSU-  -  nU R                  (       a!  X0R                  R                  US-   U5      -  nU R                  (       a!  X0R                  R                  US-   U5      -  nU$ )zY
A string representation of the tree rooted in this node, useful for
debugging purposes.
Ú
u   %sâ””â”€â”€ z    r!   )ri   r   rg   Útreerh   )r(   ÚlevelÚprefixr   s       r   r�   Ú_BinarySearchTree.tree¨   sq   € ò
 " 4§:¡:§?¤?Ð3ˆØ 6¨E¡>Ñ2ˆØ�<�<Ø—L‘L×%Ñ% e¨a¡i°Ó8Ñ8ˆDØ�=�=Ø—M‘M×&Ñ& u¨q¡y°&Ó9Ñ9ˆDØˆr   c                ó   • U R                   $ )z*
The value object contained in this node.
)rf   rI   s    r   ri   Ú_BinarySearchTree.valueµ   s   € ð
 �{‰{Ðr   c                ó€   • [        U 5      S:X  a  / S/ 4$ [        [        U 5      S-  5      nX   nXS-   S nU SU nX#U4$ )zf
Return a (medial_value, greater_values, lesser_values) 3-tuple
obtained by bisecting sequence *seq*.
r   NrM   r!   )rA   r&   )ru   Úmid_idxÚmidÚgreaterÚlessers        r   Ú_bisectÚ_BinarySearchTree._bisect¼   sX   € ô ˆs‹8�q‹=Ø�t˜R�<ÐÜ”c˜#“h ‘lÓ#ˆØ‰lˆØ ‘k�mÐ$ˆØ�X�g�ˆØ˜VÐ#Ð#r   c                ó²   • [        U5      S:X  a  gU R                  U5      u  p#nU R                  U5        U R                  U5        U R                  U5        g)z`
Insert the new values contained in *seq* into this tree such that
a balanced tree is produced.
r   N)rA   rŒ   r{   rs   )r(   ru   r‰   rŠ   r‹   s        r   rs   Ú/_BinarySearchTree._insert_from_ordered_sequenceÊ   sM   € ô
 ˆs‹8�q‹=ØØ#Ÿ|™|¨CÓ0Ñˆ�fØ�‰�CÔØ×*Ñ*¨7Ô3Ø×*Ñ*¨6Õ2r   )rh   rg   rf   r   )r   Ú )r[   r\   r]   r^   r_   rj   r'   r`   r$   r{   r�   ra   ri   ÚstaticmethodrŒ   rs   rb   r:   r   r   r#   r#   w   s\   † ñò
ô
3ð ñ	ó ð	ò
 ôð ñó ðð ñ$ó ð$õ
3r   r#   c                  ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)r   é×   aR  
Generates all the possible even-word line breaks in a string of text,
each in the form of a (line, remainder) 2-tuple where *line* contains the
text before the break and *remainder* the text after as a |_LineSource|
object. Its boolean value is |True| when it contains text, |False| when
its text is the empty string or whitespace only.
c                ó   • Xl         g r   ©Ú_text)r(   r   s     r   rj   Ú_LineSource.__init__à   s   € Ø�
r   c                ó<   • U R                   R                  5       S:g  $ )zƒ
Gives this object boolean behaviors (in Python 3). bool(line_source)
is False if it contains the empty string or whitespace only.
r�   ©r–   ÚstriprI   s    r   Ú__bool__Ú_LineSource.__bool__ã   ó   € ð
 �z‰z×ÑÓ! RÑ'Ð'r   c                ó4   • U R                   UR                   :H  $ r   r•   ©r(   Úothers     r   Ú__eq__Ú_LineSource.__eq__ê   s   € Ø�z‰z˜UŸ[™[Ñ(Ð(r   c              #  óü   #   • U R                   R                  5       n[        S[        U5      S-   5       HB  nSR	                  USU 5      nSR	                  XS 5      n[        U5      n[        X55      v •  MD     g7f)z£
Generate a (text, remainder) pair for each possible even-word line
break in this line source, where *text* is a str value and remainder
is a |_LineSource| value.
r!   Ú N)r–   Úsplitr%   rA   Újoinr   Ú_Line)r(   ÚwordsÚidxÚ	line_textÚremainder_textrW   s         r   Ú__iter__Ú_LineSource.__iter__í   sm   é € ð —
‘
× Ñ Ó"ˆÜ˜œC ›J¨™NÖ+ˆCØŸ™  t¨ Ó-ˆIØ ŸX™X e¨D kÓ2ˆNÜ# NÓ3ˆIÜ˜	Ó-Ô-ò	 ,ùs   ‚A:A<c                ó<   • U R                   R                  5       S:g  $ )zƒ
Gives this object boolean behaviors (in Python 2). bool(line_source)
is False if it contains the empty string or whitespace only.
r�   r™   rI   s    r   Ú__nonzero__Ú_LineSource.__nonzero__ú   r�   r   c                ó    • SU R                   -  $ )Nz<_LineSource('%s')>r•   rI   s    r   Ú__repr__Ú_LineSource.__repr__  s   € Ø$ t§z¡zÑ1Ð1r   r•   N)r[   r\   r]   r^   r_   rj   r›   r¡   r¬   r¯   r²   rb   r:   r   r   r   r   ×   s%   † ñòò(ò)ò.ò(õ2r   r   c                  óV   • \ rS rSrSrS rS rS rS rS r	\
S 5       r\
S	 5       rS
rg)r§   i  z«
A candidate line broken at an even word boundary from a string of text,
and a |_LineSource| value containing the text that remains after the line
is broken at this spot.
c                ó0   • [         R                  XU45      $ r   r   )r   r   rW   s      r   r   Ú_Line.__new__  s   € Ü�}‰}˜S¨Ð"3Ó4Ð4r   c                óX   • [        U R                  5      [        UR                  5      :„  $ r   ©rA   r   rŸ   s     r   Ú__gt__Ú_Line.__gt__  s   € Ü�4—9‘9‹~¤ E§J¡J£Ñ/Ð/r   c                ó.   • U R                  U5      (       + $ r   )r¹   rŸ   s     r   Ú__lt__Ú_Line.__lt__  s   € Ø—;‘;˜uÓ%Ô%Ð%r   c                ó,   • [        U R                  5      $ r   r¸   rI   s    r   Ú__len__Ú_Line.__len__  s   € Ü�4—9‘9‹~Ðr   c                ó@   • SU R                   < SU R                  < S3$ )NÚ'z' => ')r   rW   rI   s    r   r²   Ú_Line.__repr__  s   � Ø!%§¤¨D¯N¬NÐ;Ð;r   c                ó   • U S   $ rS   r:   rI   s    r   rW   Ú_Line.remainder  rK   r   c                ó   • U S   $ rP   r:   rI   s    r   r   Ú
_Line.text  rK   r   r:   N)r[   r\   r]   r^   r_   r   r¹   r¼   r¿   r²   ra   rW   r   rb   r:   r   r   r§   r§     sH   † ñò5ò0ò&òò<ð ñó ðð ñó ór   r§   c                  ó,   • \ rS rSrSr0 r\S 5       rSrg)Ú_Fontsi$  z*
A memoizing cache for ImageFont objects.
c                óŒ   • X4U R                   ;  a$  [        R                  " X5      U R                   X4'   U R                   X4   $ r   )Úfontsr   Útruetype)r   Ú	font_pathr.   s      r   ÚfontÚ_Fonts.font+  s?   € àÐ"¨#¯)©)Ó3Ü1:×1CÒ1CÀIÓ1ZˆC�I‰I�yÐ-Ñ.Ø�y‰y˜)Ð0Ñ1Ð1r   r:   N)	r[   r\   r]   r^   r_   rË   r`   rÎ   rb   r:   r   r   rÉ   rÉ   $  s    † ñð €Eàñ2ó ó2r   rÉ   c                óø   • SnSn[         R                  X!5      n UR                  U 5      u  pg[        Xd-  U-  5      n[        Xt-  U-  5      nXÍ4$ ! [         a    UR	                  U 5      u  p‰p«X¨-
  X¹-
  pv NJf = f)zŸ
Return a (width, height) pair representing the size of *text* in English
Metric Units (EMU) when rendered at *point_size* in the font defined in
*font_file*.
iàó g      R@)rÉ   rÎ   ÚgetsizeÚAttributeErrorÚgetbboxr&   )r   r.   r   Úemu_per_inchÚpx_per_inchrÎ   Úpx_widthÚ	px_heightÚleftÚtopÚrightÚbottomÚ	emu_widthÚ
emu_heights                 r   r4   r4   2  s�   € ð €LØ€Kä�;‰;�yÓ-€Dð9Ø"Ÿl™l¨4Ó0Ñˆô
 �HÑ*¨\Ñ9Ó:€IÜ�YÑ,¨|Ñ;Ó<€JàÐ Ð øô ó 9Ø#'§<¡<°Ó#5Ñ ˆ�5Ø#™l¨F©L’)ð9ús   ›A Á%A9Á8A9N)r_   Ú
__future__r   Útypingr   ÚPILr   Ú	pptx.utilr   r   r   Úobjectr#   r   r§   rÉ   r4   r:   r   r   Ú<module>rã      s_   ðÙ Eå "å  å æÝ ôg�ô gôT]3˜ô ]3ô@+2�&ô +2ô\ˆEô ô>2ˆVô 2ó!r   