ó
    [hž#  ã                   óö   • S r SSKJr  SSKJr  SSKJrJr  SSKrSSK	J
r
  SSKJrJr  SSKrSSKJr  SSKr " S	 S
\R$                  \R&                  5      r " S S\5      rS rS rS rS rS rS rS rS rg)a   
Add a ``figure-mpl`` directive that is a responsive version of ``figure``.

This implementation is very similar to ``.. figure::``, except it also allows a
``srcset=`` argument to be passed to the image tag, hence allowing responsive
resolution images.

There is no particular reason this could not be used standalone, but is meant
to be used with :doc:`/api/sphinxext_plot_directive_api`.

Note that the directory organization is a bit different than ``.. figure::``.
See the *FigureMpl* documentation below.

é    )Únodes)Ú
directives)ÚFigureÚImageN)Úrelpath)ÚPurePathÚPath)ÚExtensionErrorc                   ó   • \ rS rSrSrg)Ú
figmplnodeé   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Út/home/gothic/public_html/Fooocus/fooocus_env/lib64/python3.13/site-packages/matplotlib/sphinxext/figmpl_directive.pyr   r      s   † Úr   r   c            	       óä   • \ rS rSrSrSrSrSrSr\	R                  \	R                  \	R                  \	R                  \R                  \	R                   \	R                  \	R                  S.rS rSrg	)
Ú	FigureMplé"   a&  
Implements a directive to allow an optional hidpi image.

Meant to be used with the *plot_srcset* configuration option in conf.py,
and gets set in the TEMPLATE of plot_directive.py

e.g.::

    .. figure-mpl:: plot_directive/some_plots-1.png
        :alt: bar
        :srcset: plot_directive/some_plots-1.png,
                 plot_directive/some_plots-1.2x.png 2.00x
        :class: plot-directive

The resulting html (at ``some_plots.html``) is::

    <img src="sphx_glr_bar_001_hidpi.png"
        srcset="_images/some_plot-1.png,
                _images/some_plots-1.2x.png 2.00x",
        alt="bar"
        class="plot_directive" />

Note that the handling of subdirectories is different than that used by the sphinx
figure directive::

    .. figure-mpl:: plot_directive/nestedpage/index-1.png
        :alt: bar
        :srcset: plot_directive/nestedpage/index-1.png
                 plot_directive/nestedpage/index-1.2x.png 2.00x
        :class: plot_directive

The resulting html (at ``nestedpage/index.html``)::

    <img src="../_images/nestedpage-index-1.png"
        srcset="../_images/nestedpage-index-1.png,
                ../_images/_images/nestedpage-index-1.2x.png 2.00x",
        alt="bar"
        class="sphx-glr-single-img" />

where the subdirectory is included in the image name for uniqueness.
Fé   é   )ÚaltÚheightÚwidthÚscaleÚalignÚclassÚcaptionÚsrcsetc                 ó2  • [        5       nU R                  S   nU R                  R                  SS5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  S	S 5      US	'   X!S
'   U R                  R                  SS 5      US'   U/$ )Nr   r   Ú r   r    r   r   r   r!   Úurir"   )r   Ú	argumentsÚoptionsÚget)ÚselfÚ
image_nodeÚimagenms      r   ÚrunÚFigureMpl.run\   s  € ä“\ˆ
à—.‘. Ñ#ˆØ ŸL™L×,Ñ,¨U°BÓ7ˆ
�5ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ#Ÿ|™|×/Ñ/°¸$Ó?ˆ
�8ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ $§¡× 0Ñ 0°¸DÓ Aˆ
�9Ñð $�5ÑØ#Ÿ|™|×/Ñ/°¸$Ó?ˆ
�8Ñàˆ|Ðr   r   N)r   r   r   r   Ú__doc__Úhas_contentÚrequired_argumentsÚoptional_argumentsÚfinal_argument_whitespacer   Ú	unchangedÚlength_or_unitlessÚ length_or_percentage_or_unitlessÚnonnegative_intr   r   Úclass_optionÚoption_specr,   r   r   r   r   r   r   "   ss   † ñ(ðT €KØÐØÐØ %Ðà×#Ñ#Ø×/Ñ/Ø×<Ñ<Ø×+Ñ+Ø—‘Ø×(Ñ(Ø×'Ñ'Ø×&Ñ&ñ	€Kõr   r   c                 ó  • U R                  S5      n0 nU Hr  nUR                  5       R                  S5      n[        U5      S:X  a
  US   US'   M;  [        U5      S:X  a  US   SS nUS   U[        U5      '   Me  [	        SU S	35      e   U$ )
z
parse srcset...
Ú,Ú r   r   r   Néÿÿÿÿzsrcset argument "z" is invalid.)ÚsplitÚstripÚlenÚfloatr
   )ÚstÚentriesr"   ÚentryÚsplÚmults         r   Ú_parse_srcsetNodesrF   s   s–   € ð �h‰h�s‹m€GØ€FÛˆØ�k‰k‹m×!Ñ! #Ó&ˆÜˆs‹8�q‹=Ø˜A™ˆF�1‹IÜ�‹X˜‹]Ø�q‘6˜#˜2�;ˆDØ"% a¡&ˆF”5˜“;Óä Ð#4°U°G¸=Ð!IÓJÐJñ ð €Mr   c                 óò  • US   (       a  [        US   5      nOS n[        U R                  S   5      R                  nU R                  R
                  n[        X45      R                  SS5      R                  [        R                  S5      n[        U5      (       a  US-  n[        U R                  R                  U R                  R                  5      n[        U5      R                  SSS9  U(       aJ  UR                  5        H5  n[        X75      nXXR                   -   n	["        R$                  " X†U	-  5        M7     O5[        X1S   5      nXXR                   -   n	["        R$                  " X†U	-  5        XbU4$ )	Nr"   ÚsourceÚ.r$   Ú-T)ÚparentsÚexist_okr%   )rF   r   ÚdocumentÚparentÚbuilderÚsrcdirr   ÚreplaceÚosÚsepr?   ÚoutdirÚimagedirr	   ÚmkdirÚvaluesÚnameÚshutilÚcopyfile)
r)   Únoder"   Ú	docsourceÚsrctopÚrelrU   ÚsrcÚabspathrX   s
             r   Ú_copy_images_figmplra   …   s1  € ð ˆH‡~Ü# D¨¡NÓ3‰àˆô ˜Ÿ™ xÑ0Ó1×8Ñ8€Ið �\‰\× Ñ €FÜ
�)Ó
$×
,Ñ
,¨S°"Ó
5×
=Ñ
=¼b¿f¹fÀcÓ
J€CÜ
ˆ3‡x�xØˆs‰
ˆô ˜Ÿ™×+Ñ+¨T¯\©\×-BÑ-BÓC€Hô 	ˆƒN×Ñ °ÐÑ5ö Ø—=‘=–?ˆCä˜yÓ.ˆGØŸ™Ñ%ˆDÜ�OŠO˜G°¡_Ö5ò	 #ô ˜9¨5¡kÓ2ˆØ—\‘\Ñ!ˆÜ�Š˜¨D¡Ô1à˜SÐ Ð r   c                 óL  • [        X5      u  p#n[        U R                  S   5      n[        U R                  R                  S5      n[        XV5      n[        U R                  R                  S5      nX‡-  n	[        [        X)R                  5      5      R                  5       n
U R                  R                  S:X  a  SU
 3n
[        US   SS  5      R                  nU
 SU U 3nUnSnU(       ai  SnUR                  5        HN  u  nn[        USS  5      R                  nU
 SU U 3nUU-  nUS	:X  a  US
-  nO
USUS S3-  nUU:”  d  MJ  UnUnMP     US S nUS   nUS   b  SR                  US   5      nSU S3nOSn/ SQnSnU H  nUU   (       d  M  UU SUU    S3-  nM     US   (       a  US   OSnSU SU SU SU SU S3nSU S3nUS U S3-  nUS!U S"3-  nUS#   (       a  US$-  nUS%US#    S&3-  nUS'-  nUS(-  nU R                  R                  U5        g ))NrH   r$   Údirhtmlz..r%   r   Ú/r<   r   z, r;   z1.2fzx, éþÿÿÿr   r    zclass="Ú")r   r   r   z: Ú;r   Úcenterz
<img src="z	" style="z
" srcset="z" alt="z" z/>z<figure class="align-z">
z6  <a class="reference internal image-reference" href="z    z
  </a>
r!   z  <figcaption>
z!   <p><span class="caption-text">z</span></p>
z  </figcaption>
z
</figure>
)ra   r   rM   rO   rP   r   rT   rN   Úas_posixrX   ÚitemsÚjoinÚbodyÚappend)r)   r[   rU   r"   r^   r\   r]   Ú	relsourceÚdesttopÚdestÚimagerelÚnmr%   ÚmaxsrcÚsrcsetstÚmaxmultrE   r_   Úpathr   ÚclassstÚstylersÚstylestÚstyleÚfigalignÚ	img_blockÚ
html_blocks                              r   Úvisit_figmpl_htmlr~   ¬   s­  € ä/°Ó;Ñ€H�cô ˜Ÿ™ xÑ0Ó1€Iô �d—l‘l×)Ñ)¨2Ó.€Fä˜	Ó*€Iä�t—|‘|×*Ñ*¨BÓ/€GàÑ€Dô œ ¯+©+Ó6Ó7×@Ñ@ÓB€HØ‡|�|×Ñ˜IÓ%Ø˜�z�?ˆô 
�$�u‘+˜a˜b�/Ó	"×	'Ñ	'€BØˆJ�a˜�u˜R˜DÐ
!€Cð €FØ€HÞØˆØŸ™ž‰IˆD�#Ü˜#˜a˜b˜'Ó"×'Ñ'ˆBà�Z˜q   b TÐ*ˆDØ˜ÑˆHØ�q‹yØ˜DÑ ‘à˜a  T˜{¨#Ð.Ñ.�à�g�~Ø�Ø’ñ (ð ˜C˜R�=ˆà
ˆu‰+€CØˆG�}Ñ Ø—(‘(˜4 ™=Ó)ˆØ˜G˜9 AÐ&‰ð ˆâ*€GØ€GÛˆØ��;‰;Ø˜%˜  4¨¡; -¨qÐ1Ñ1ŠGñ ð !% W§ˆt�GŠ}°8€Hð ˜c˜U )¨G¨9°J¸x¸jð IØ˜˜R ˜y¨ð,€Ià(¨¨
°$Ð7€JØÐJÈ6È(ÐRVÐWÑW€JØ�D˜˜ :Ð.Ñ.€JØˆI‡ØÐ(Ñ(ˆ
ØÐ9¸$¸y¹/Ð9JÈ-ÐXÑXˆ
ØÐ)Ñ)ˆ
Ø�-Ñ€JØ‡I�I×Ñ�ZÕ r   c                 ó˜   • US   b3  [        X5      u  p#Sn[        USS9n[        X4   5      R                  US'   U R	                  U5        g )Nr"   r<   )Údefaultr%   )ra   Úmaxr   rX   Úvisit_figure)r)   r[   rU   r"   ru   s        r   Úvisit_figmpl_latexrƒ     sN   € àˆH�~Ñ!Ü.¨tÓ:ÑˆØˆä�f bÑ)ˆÜ˜v™Ó/×4Ñ4ˆˆU‰à×Ñ�dÕr   c                 ó   • g ©Nr   ©r)   r[   s     r   Údepart_figmpl_htmlr‡     s   € Ør   c                 ó&   • U R                  U5        g r…   )Údepart_figurer†   s     r   Údepart_figmpl_latexrŠ     s   € Ø×Ñ�tÕr   c                 óV   • U R                  [        [        [        4[        [
        4S9  g )N)ÚhtmlÚlatex)Úadd_noder   r~   r‡   rƒ   rŠ   )Úapps    r   Úfigurempl_addnoder�     s(   € Ø‡L�L”Ü(Ô*<Ð=Ü*Ô,?Ð@ð ò Br   c                 óp   • U R                  S[        5        [        U 5        SS[        R                  S.nU$ )Nz
figure-mplT)Úparallel_read_safeÚparallel_write_safeÚversion)Úadd_directiver   r�   Ú
matplotlibÚ__version__)r�   Úmetadatas     r   Úsetupr™     s4   € Ø×Ñ�l¤IÔ.Ü�cÔØ&*À4Ü%×1Ñ1ñ3€Hà€Or   )r.   Údocutilsr   Údocutils.parsers.rstr   Ú&docutils.parsers.rst.directives.imagesr   r   rR   Úos.pathr   Úpathlibr   r	   rY   Úsphinx.errorsr
   r–   ÚGeneralÚElementr   r   rF   ra   r~   rƒ   r‡   rŠ   r�   r™   r   r   r   Ú<module>r¢      sx   ðñõ å +ß @ã 	Ý ß "Û å (ã ô	�—‘ §¡ô 	ôN�ô Nòbò$$!òNR!òj	ò	òòBór   