
    -PhL                         d dl Z d dlmZ d dlZd dlmZ d dlmZmZ d dl	m
Z
mZ  ed          ZdZdZ	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZdS )    N)Path)
get_module)validate_coerce_fig_to_dictplotly_cdn_url)_get_jconfigget_plotlyjsjsonzW<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>z<script type="text/javascript">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}</script>TF100%c           	         ddl m} t          | |
          }|pt          t	          j                              } ||                    dg                     } ||                    di                     }|                    dd          r  ||                    dg                     }nd}t          |          }|                    dd           |                    di           }|                    di                               d	i                               di           }|                    d
|                    d
|                    }|                    d|                    d|	                    }	 t          |           t          |          dz   }n# t          t          f$ r Y nw xY w	 t          |           t          |          dz   }n# t          t          f$ r Y nw xY w|                    dd          s|                    dd          r+d                    |                    dd                    }nD|                    dd           |                    dd           |                    dd           d}d}|rQt          |t          t           f          s|g}|D ]/}|d                    |                    d|                    z  }0d}d}|rRd                    ||          }|r9|rdt$                              |          z   }nd}d                    ||          }t$                              |          }d                    |||||||          }|}t          |t                    r|                                }d}|d k    r)d!                    t*          t-                      "          }n|d#k    rd$                    t*          %          }nqt          |t                    r2|                    d&          rd'                    t*          |(          }n*|r(d)                    t*          t1                      *          }|} t          |t                    r|                                }d+}!|d k    r|!                    d,-          t2          z   }"nt          |t                    r4|                    d&          r|!                    | -          t2          z   }"nC|sd}"n>t          d.                    t5          |          t7          |          /                    d0                    |"||||||1                                          }#|rd2                    |#3          S |#S )4a	  
    Convert a figure to an HTML string representation.

    Parameters
    ----------
    fig:
        Figure object or dict representing a figure
    config: dict or None (default None)
        Plotly.js figure config options
    auto_play: bool (default=True)
        Whether to automatically start the animation sequence on page load
        if the figure contains frames. Has no effect if the figure does not
        contain frames.
    include_plotlyjs: bool or string (default True)
        Specifies how the plotly.js library is included/loaded in the output
        div string.

        If True, a script tag containing the plotly.js source code (~3MB)
        is included in the output.  HTML files generated with this option are
        fully self-contained and can be used offline.

        If 'cdn', a script tag that references the plotly.js CDN is included
        in the output. The url used is versioned to match the bundled plotly.js.
        HTML files generated with this option are about 3MB smaller than those
        generated with include_plotlyjs=True, but they require an active
        internet connection in order to load the plotly.js library.

        If 'directory', a script tag is included that references an external
        plotly.min.js bundle that is assumed to reside in the same
        directory as the HTML file.

        If a string that ends in '.js', a script tag is included that
        references the specified path. This approach can be used to point
        the resulting HTML file to an alternative CDN or local bundle.

        If False, no script tag referencing plotly.js is included. This is
        useful when the resulting div string will be placed inside an HTML
        document that already loads plotly.js. This option is not advised
        when full_html=True as it will result in a non-functional html file.
    include_mathjax: bool or string (default False)
        Specifies how the MathJax.js library is included in the output html
        div string.  MathJax is required in order to display labels
        with LaTeX typesetting.

        If False, no script tag referencing MathJax.js will be included in the
        output.

        If 'cdn', a script tag that references a MathJax CDN location will be
        included in the output.  HTML div strings generated with this option
        will be able to display LaTeX typesetting as long as internet access
        is available.

        If a string that ends in '.js', a script tag is included that
        references the specified path. This approach can be used to point the
        resulting HTML div string to an alternative CDN.
    post_script: str or list or None (default None)
        JavaScript snippet(s) to be included in the resulting div just after
        plot creation.  The string(s) may include '{plot_id}' placeholders
        that will then be replaced by the `id` of the div element that the
        plotly.js figure is associated with.  One application for this script
        is to install custom plotly.js event handlers.
    full_html: bool (default True)
        If True, produce a string containing a complete HTML document
        starting with an <html> tag.  If False, produce a string containing
        a single <div> element.
    animation_opts: dict or None (default None)
        dict of custom animation parameters to be passed to the function
        Plotly.animate in Plotly.js. See
        https://github.com/plotly/plotly.js/blob/master/src/plots/animation_attributes.js
        for available options. Has no effect if the figure does not contain
        frames, or auto_play is False.
    default_width, default_height: number or str (default '100%')
        The default figure width/height to use if the provided figure does not
        specify its own layout.width/layout.height property.  May be
        specified in pixels as an integer (e.g. 500), or as a css width style
        string (e.g. '500px', '100%').
    validate: bool (default True)
        True if the figure should be validated before being converted to
        JSON, False otherwise.
    div_id: str (default None)
        If provided, this is the value of the id attribute of the div tag. If None, the
        id attribute is a UUID.

    Returns
    -------
    str
        Representation of figure as an HTML div string
    r   )to_json_plotlydatalayoutframesN
responsiveTtemplatewidthheightpxshowLinkFshowSendToCloudzG
                    window.PLOTLYENV.BASE_URL='{plotly_platform_url}';plotlyServerURLzhttps://plot.ly)plotly_platform_urllinkText zX.then(function(){{
                            {post_script}
                        }})z	{plot_id})post_scriptzn.then(function(){{
                            Plotly.addFrames('{id}', {frames});
                        }}))idr   z, zx.then(function(){{
                            Plotly.animate('{id}', null{animation_opts});
                        }}))r   animation_optsa0                  if (document.getElementById("{id}")) {{                    Plotly.newPlot(                        "{id}",                        {data},                        {layout},                        {config}                    ){then_addframes}{then_animate}{then_post_script}                }})r   r   r   configthen_addframesthen_animatethen_post_scriptcdnzR        {win_config}
        <script charset="utf-8" src="{cdn_url}"></script>    )
win_configcdn_url	directoryzV        {win_config}
        <script charset="utf-8" src="plotly.min.js"></script>    )r#   z.jszN        {win_config}
        <script charset="utf-8" src="{url}"></script>    )r#   urlzS        {win_config}
        <script type="text/javascript">{plotlyjs}</script>    )r#   plotlyjsz8    <script src="{url}?config=TeX-AMS-MML_SVG"></script>z?https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js)r&   zInvalid value of type {typ} received as the include_mathjax argument
    Received value: {val}

include_mathjax may be specified as False, 'cdn', or a string ending with '.js'
    )typvalaF  <div>        {mathjax_script}        {load_plotlyjs}            <div id="{id}" class="plotly-graph-div" style="height:{height}; width:{width};"></div>            <script type="text/javascript">                window.PLOTLYENV=window.PLOTLYENV || {{}};{base_url_line}                {script};            </script>        </div>)mathjax_scriptload_plotlyjsr   r   r   base_url_linescriptzM<html>
<head><meta charset="utf-8" /></head>
<body>
    {div}
</body>
</html>)div)plotly.io.jsonr   r   struuiduuid4getr   
setdefaultfloat
ValueError	TypeErrorformatpop
isinstancelisttuplereplace_jsondumpslower_window_plotly_configr   endswithr   _mathjax_configtypereprstrip)$figr   	auto_playinclude_plotlyjsinclude_mathjaxr   	full_htmlr   default_widthdefault_heightvalidatediv_idr   fig_dict	plotdividjdatajlayoutjframeslayout_dicttemplate_dict	div_width
div_heightr,   r!   psr   r    animation_opts_argjconfigr-   include_plotlyjs_origr+   include_mathjax_origmathjax_templater*   plotly_html_divs$                                       O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/plotly/io/_html.pyto_htmlra      s   L .----- +399H +#djll++I N8<<3344EnX\\(B7788G||Hd##  .h!;!;<< &!!F lD))) ,,x,,KLL2..22:rBBFFxQSTTM):):7M)R)RSSI=+<+<X~+V+VWWJ*i 	NNT)		 	"   
,j __t+

 	"    zz*e$$ 

3De(L(L 
F &

+<>O P P  
 
 	 	

$d+++

:t$$$

:t$$$  +e}55 	(&-K 	 	B !%vJJ{I>>  &     NL %v  &  
  
 	  		 (%)EKK,G,G%G""%'"%v-?  &      kk&!!G f%!)    & -"C(( 4+1133 M5   	,n6F6F 	 	
 	
 	 
[	(	( 	, 	 	
 	
 	 
$c	*	* 
/?/H/H/O/O 
 	,2G 	 	
 	
 	 
 
 	,|~~ 	 	
 	
 	 +/3'' 2)//11< %##X $  
  	 
OS	)	) 
o.F.Fu.M.M 
 ##(<#==O 	  

 	))tO/D/D 	 	 		
 	
 		

 &%##    egg% (   6  
 
	
 s$   =F F32F37G G-,G-c                 8   t          | ||||||||
||	|          }t          |t                    rt          |          }nt          |t                    r|}nd}||                    |d           n|                    |           |I|rG|dk    rA|j        dz  }|                                s#|                    t                      d           |@|r@|r@|	                                
                                }t          j        |           dS dS dS dS )a  
    Write a figure to an HTML file representation

    Parameters
    ----------
    fig:
        Figure object or dict representing a figure
    file: str or writeable
        A string representing a local file path or a writeable object
        (e.g. a pathlib.Path object or an open file descriptor)
    config: dict or None (default None)
        Plotly.js figure config options
    auto_play: bool (default=True)
        Whether to automatically start the animation sequence on page load
        if the figure contains frames. Has no effect if the figure does not
        contain frames.
    include_plotlyjs: bool or string (default True)
        Specifies how the plotly.js library is included/loaded in the output
        div string.

        If True, a script tag containing the plotly.js source code (~3MB)
        is included in the output.  HTML files generated with this option are
        fully self-contained and can be used offline.

        If 'cdn', a script tag that references the plotly.js CDN is included
        in the output. The url used is versioned to match the bundled plotly.js.
        HTML files generated with this option are about 3MB smaller than those
        generated with include_plotlyjs=True, but they require an active
        internet connection in order to load the plotly.js library.

        If 'directory', a script tag is included that references an external
        plotly.min.js bundle that is assumed to reside in the same
        directory as the HTML file.  If `file` is a string to a local file
        path and `full_html` is True, then the plotly.min.js bundle is copied
        into the directory of the resulting HTML file. If a file named
        plotly.min.js already exists in the output directory then this file
        is left unmodified and no copy is performed. HTML files generated
        with this option can be used offline, but they require a copy of
        the plotly.min.js bundle in the same directory. This option is
        useful when many figures will be saved as HTML files in the same
        directory because the plotly.js source code will be included only
        once per output directory, rather than once per output file.

        If a string that ends in '.js', a script tag is included that
        references the specified path. This approach can be used to point
        the resulting HTML file to an alternative CDN or local bundle.

        If False, no script tag referencing plotly.js is included. This is
        useful when the resulting div string will be placed inside an HTML
        document that already loads plotly.js.  This option is not advised
        when full_html=True as it will result in a non-functional html file.

    include_mathjax: bool or string (default False)
        Specifies how the MathJax.js library is included in the output html
        div string.  MathJax is required in order to display labels
        with LaTeX typesetting.

        If False, no script tag referencing MathJax.js will be included in the
        output.

        If 'cdn', a script tag that references a MathJax CDN location will be
        included in the output.  HTML div strings generated with this option
        will be able to display LaTeX typesetting as long as internet access
        is available.

        If a string that ends in '.js', a script tag is included that
        references the specified path. This approach can be used to point the
        resulting HTML div string to an alternative CDN.
    post_script: str or list or None (default None)
        JavaScript snippet(s) to be included in the resulting div just after
        plot creation.  The string(s) may include '{plot_id}' placeholders
        that will then be replaced by the `id` of the div element that the
        plotly.js figure is associated with.  One application for this script
        is to install custom plotly.js event handlers.
    full_html: bool (default True)
        If True, produce a string containing a complete HTML document
        starting with an <html> tag.  If False, produce a string containing
        a single <div> element.
    animation_opts: dict or None (default None)
        dict of custom animation parameters to be passed to the function
        Plotly.animate in Plotly.js. See
        https://github.com/plotly/plotly.js/blob/master/src/plots/animation_attributes.js
        for available options. Has no effect if the figure does not contain
        frames, or auto_play is False.
    default_width, default_height: number or str (default '100%')
        The default figure width/height to use if the provided figure does not
        specify its own layout.width/layout.height property.  May be
        specified in pixels as an integer (e.g. 500), or as a css width style
        string (e.g. '500px', '100%').
    validate: bool (default True)
        True if the figure should be validated before being converted to
        JSON, False otherwise.
    auto_open: bool (default True)
        If True, open the saved file in a web browser after saving.
        This argument only applies if `full_html` is True.
    div_id: str (default None)
        If provided, this is the value of the id attribute of the div tag. If None, the
        id attribute is a UUID.

    Returns
    -------
    None
    )r   rH   rI   rJ   r   rK   r   rL   rM   rN   rO   Nzutf-8r%   zplotly.min.js)encoding)ra   r:   r0   r   
write_textwriteparentexistsr   absoluteas_uri
webbrowseropen)rG   filer   rH   rI   rJ   r   rK   r   rN   rL   rM   	auto_openrO   html_strpathbundle_pathr&   s                     r`   
write_htmlrq   e  sZ   r )'%#%  H  $ 	Dzz	D$		   '****

8 I*:k*I*IkO3!!## 	E""<>>G"DDD I)mmoo$$&&     )NTTFNTNr
   r
   TN)NTTFNTNTr
   r
   FN)r1   pathlibr   rj   _plotly_utils.optional_importsr   plotly.io._utilsr   r   plotly.offline.offliner   r   r>   rA   rC   ra   rq    rr   r`   <module>rx      s              5 5 5 5 5 5 H H H H H H H H = = = = = = = =
6
 
 I I I I^
 e e e e e err   