+
     ]i\$  c                   s    R t ^ RIt^ RIHt ^ RIHtHt ^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIt ! R R	]	P$                  ]	P&                  4      t ! R
 R]4      tR tR tR tR tR tR tR tR tR# )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.

N)relpath)PurePathPath)nodes)
directives)FigureImage)ExtensionErrorc                   s    ] tR t^tRtR# )
figmplnode N)__name__
__module____qualname____firstlineno____static_attributes__r	       L/usr/lib64/python3.14/site-packages/matplotlib/sphinxext/figmpl_directive.pyr   r      s    r   r   c                   s   a  ] tR t^ t o RtRt^t^tRtR]	P                  R]	P                  R]	P                  R]	P                  R]P                  R]	P                   R	]	P                  R
]	P                  /tR tRtV tR# )	FigureMpla&  
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                s:   \        4       pV P                  ^ ,          pV P                  P                  RR4      VR&   V P                  P                  RR4      VR&   V P                  P                  RR4      VR&   V P                  P                  RR4      VR&   V P                  P                  RR4      VR&   V P                  P                  RR4      VR&   V P                  P                  R	R4      VR	&   W!R
&   V P                  P                  RR4      VR&   V.# )i    r    r   Nr   r   r   r   r   urir   )r   Z	argumentsZoptionsZget)selfZ
image_nodeZimagenms   &  r   runZFigureMpl.runZ   s   \
..# LL,,UB7
5"ll..w=
7"ll..w=
7"ll..w=
7#||//$?
8"ll..w=
7 $ 0 0D A
9 $5#||//$?
8|r   r	   N)r
   r   r   r   __doc__Zhas_contentZrequired_argumentsZoptional_argumentsZfinal_argument_whitespacer   Z	unchangedZlength_or_unitlessZ length_or_percentage_or_unitlessZnonnegative_intr   r   Zclass_optionZoption_specr   r   Z__classdictcell__)Z__classdict__s   @r   r   r       s     (T K %z##*//<<++((:''*&&	K r   r   c                s8   V P                  R4      p/ pV F  pVP                  4       P                  R4      p\        V4      ^8X  d   V^ ,          V^ &   K@  \        V4      ^8X  d$   V^,          RR pV^ ,          V\        V4      &   Ks  \	        RV R24      h	  V# )z
parse srcset...
Z, Nzsrcset argument "z" is invalid.)ZsplitZstriplenZfloatr   )ZstZentriesr   ZentryZsplmults   &     r   _parse_srcsetNodesr#   q   s     hhsmGFkkm!!#&s8q=AF1IX]q6#2;D"%a&F5; #4UG=!IJJ  Mr   c                 sF   VR ,          '       d   \        VR ,          4      pMRp\        V P                  R,          4      P                  pV P                  P
                  p\        W44      P                  RR4      P                  \        P                  R4      p\        V4      '       d
   VR,          p\        V P                  P                  V P                  P                  4      p\        V4      P                  RRR7       V'       dS   VP                  4        F=  p\        W74      pWXP                   ,           p	\"        P$                  ! WV	,          4       K?  	  MA\        W1R,          4      pWXP                   ,           p	\"        P$                  ! WV	,          4       WbV3# )	r   NsourceZ.r   Z-T)ZparentsZexist_okr   )r#   r   documentparentbuildersrcdirr    ZreplaceosZsepr!   outdirimagedirr   ZmkdirZvaluesnameshutilZcopyfile)
r   noder   	docsourcesrctoprelr+   srcZabspathr,   s
   &&        r   _copy_images_figmplr3      s3    H~~#DN3 x0188I \\  F
)
$
,
,S"
5
=
=bffc
JC
3xxs
 ++T\\-B-BCH 	N5 ==?Cy.G%DOOG_5	 # 95k2\\!D1S  r   c           	      s   \        W4      w  r#p\        V P                  R ,          4      p\        V P                  P                  R4      p\        WV4      p\        V P                  P                  R4      pW,          p	\        \        W)P                  4      4      P                  4       p
V P                  P                  R8X  d   RV
 2p
\        VR,          R,          4      P                  pV
 RV V 2pRVRVR,          /pTpV'       d   R$pRpVP                  4        F`  w  pp\        VR,          4      P                  pV
 RV V 2pVV,          pV^ 8X  d   VR	,          pMVR
VR R2,          pVV8  g   K\  TpTpKb  	  VRR% VR&   VR,          e   R
P                  VR,          4      VR&   R& FQ  pVV,          '       g   K  RV9  d   V RVV,           R2VR&   K/  VR;;,          V RVV,           R2,          uu&   KS  	  V P                  P                  T P                  TRVR,          '       d   RVR,           2MRR7      4       V P                  P                  V P                  VRRVR7      V P                  ! VR3/ VB ,           R,           4       VR,          '       d   V P                  P                  V P                  VR4      4       V P                  P                  V P                  VR4      4       V P                  P                  V P                  VR R!R7      4       V P                  P                  VR,          4       V P                  P                  R"4       V P                  P                  R#4       R# )'r$   r   Zdirhtmlz..r   :i   NNZ/r2   r   z, r   z1.2fzx, Nr   r   stylez: Z;Zfigurer   zalign-zalign-center)CLASSZaz"reference internal image-reference)r5   ZhrefZimgz</a>
r   Z
figcaptionZpZspanzcaption-textz</span></p></figcaption>
z
</figure>
r    i)r   r   r   )r3   r   r%   r'   r(   r    r*   r&   Zas_posixr,   ZitemsZjoinZbodyZappendZstarttagZemptytag)r   r.   r+   r   r1   r/   r0   Z	relsourceZdesttopZdestZimagerelZnmr   Z	img_attrsZmaxsrcmaxmultZsrcsetstr"   r2   Zpathr4   s   &&                   r   visit_figmpl_htmlr7      s2   /;Hc x01I dll))2.F	*It||**B/GD ++67@@BH||I%z? 
$u+b/	"	'	'BJauRD
!CUDK0I FID##b'"''BZqbT*DHqyD aT{#..g~ ( 'sm	(G}  XXd7m4	'-;;i'(-wbeQ%?	'"'"r$u+a&@@" ." 	II(.27mmF4=/* 	 	QR 	IIdC'K! 	 	#dE/Y/	0 		
 I		t\:;		tS12		tV>JK		i)		56II]#r   c                 s    VR ,          e;   \        W4      w  r#Rp\        VRR7      p\        W4,          4      P                  VR&   V P	                  V4       R# )r   N)Zdefaultr   r    )r3   Zmaxr   r,   Zvisit_figure)r   r.   r+   r   r6   s   &&   r   visit_figmpl_latexr8      sN    H~!.t:fb)v/44Udr   c                 s    R # Nr	   r   r.      &&r   depart_figmpl_htmlr<     s    r   c                 s(    V P                  V4       R # r9   )Zdepart_figurer:   r;   r   depart_figmpl_latexr=     s    tr   c                 s^    V P                  \        \        \        3\        \
        3R 7       R# ))ZhtmlZlatexN)Zadd_noder   r7   r<   r8   r=   )apps   &r   figurempl_addnoder?     s(    LL(*<=*,?@  Br   c                 st    V P                  R \        4       \        V 4       RRRRR\        P                  /pV# )z
figure-mplZparallel_read_safeTZparallel_write_safeZversion)Zadd_directiver   r?   
matplotlibZ__version__)r>   Zmetadatas   & r   setuprA     s;    lI.c$d,A4:113HOr   )r   r)   Zos.pathr    Zpathlibr   r   r-   Zdocutilsr   Zdocutils.parsers.rstr   Z&docutils.parsers.rst.directives.imagesr   r   Zsphinx.errorsr   r@   ZGeneralZElementr   r   r#   r3   r7   r8   r<   r=   r?   rA   r	   r   r   <module>rB      sx    
  "   + @ ( 	 	N Nb$$!NR$j		Br   