Ë
    úmxif  ã                  óö   — U d Z ddl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mZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ er
ddlZddlmZ edddef   Z de!d<    G d„ d«      Z"	 	 	 	 	 	 	 	 dd„Z#y)z&Streamlit support for GraphViz charts.é    )Úannotations)ÚTYPE_CHECKINGÚ	TypeAliasÚUnionÚcast)Ú	type_util)Úmake_deprecated_name_warningÚshow_deprecation_warning)ÚHeightÚLayoutConfigÚWidthÚvalidate_heightÚvalidate_width)ÚStreamlitAPIException)ÚGraphVizChart)Úgather_metrics)Úcalc_md5N)ÚDeltaGeneratorzgraphviz.Graphzgraphviz.Digraphzgraphviz.Sourcer   ÚFigureOrDotc                  óZ   — e Zd Z ed«      	 ddddœ	 	 	 	 	 	 	 	 	 dd„«       Zed	d„«       Zy)
ÚGraphvizMixinÚgraphviz_chartNÚcontent©ÚwidthÚheightc          	     óf  — |�!t        t        ddddd¬«      d¬«       |rdnd	}| j                  j                  «       }t	        |j                  «       «      }t        «       }t        |||«       t        |d
¬«       t        |d
¬«       t        ||¬«      }| j                  j                  d||¬«      S )ag  Display a graph using the dagre-d3 library.

        .. Important::
            You must install ``graphviz>=0.19.0`` to use this command. You can
            install all charting dependencies (except Bokeh) as an extra with
            Streamlit:

            .. code-block:: shell

               pip install streamlit[charts]

        Parameters
        ----------
        figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, graphviz.sources.Source, str
            The Graphlib graph object or dot string to display

        use_container_width : bool
            Whether to override the figure's native width with the width of
            the parent container. If ``use_container_width`` is ``False``
            (default), Streamlit sets the width of the chart to fit its contents
            according to the plotting library, up to the width of the parent
            container. If ``use_container_width`` is ``True``, Streamlit sets
            the width of the figure to match the width of the parent container.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        width : "content", "stretch", or int
            The width of the chart element. This can be one of the following:

            - ``"content"`` (default): The width of the element matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - ``"stretch"``: The width of the element matches the width of the
              parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        height : "content", "stretch", or int
            The height of the chart element. This can be one of the following:

            - ``"content"`` (default): The height of the element matches the
              height of its content.
            - ``"stretch"``: The height of the element matches the height of
              its content or the height of the parent container, whichever is
              larger. If the element is not in a parent container, the height
              of the element matches the height of its content.
            - An integer specifying the height in pixels: The element has a
              fixed height. If the content is larger than the specified
              height, scrolling is enabled.

        Example
        -------
        >>> import streamlit as st
        >>> import graphviz
        >>>
        >>> # Create a graphlib graph object
        >>> graph = graphviz.Digraph()
        >>> graph.edge("run", "intr")
        >>> graph.edge("intr", "runbl")
        >>> graph.edge("runbl", "run")
        >>> graph.edge("run", "kernel")
        >>> graph.edge("kernel", "zombie")
        >>> graph.edge("kernel", "sleep")
        >>> graph.edge("kernel", "runmem")
        >>> graph.edge("sleep", "swap")
        >>> graph.edge("swap", "runswap")
        >>> graph.edge("runswap", "new")
        >>> graph.edge("runswap", "runmem")
        >>> graph.edge("new", "runmem")
        >>> graph.edge("sleep", "runmem")
        >>>
        >>> st.graphviz_chart(graph)

        Or you can render the chart from the graph using GraphViz's Dot
        language:

        >>> st.graphviz_chart('''
            digraph {
                run -> intr
                intr -> runbl
                runbl -> run
                run -> kernel
                kernel -> zombie
                kernel -> sleep
                kernel -> runmem
                sleep -> swap
                swap -> runswap
                runswap -> new
                runswap -> runmem
                new -> runmem
                sleep -> runmem
            }
        ''')

        .. output::
           https://doc-graphviz-chart.streamlit.app/
           height: 600px

        Úuse_container_widthr   z
2025-12-31znFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'`.F)Úinclude_st_prefix)Úshow_in_browserÚstretchr   T)Úallow_contentr   r   )Úlayout_config)r
   r	   ÚdgÚ_get_delta_path_strr   ÚencodeÚGraphVizChartProtoÚmarshallr   r   r   Ú_enqueue)	ÚselfÚfigure_or_dotr   r   r   Ú
delta_pathÚ
element_idÚgraphviz_chart_protor#   s	            úX/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/elements/graphviz_chart.pyr   zGraphvizMixin.graphviz_chart1   sÀ   € ðd Ð*Ü$Ü,Ø)ØØ ðNà&+ôð !&õ
ñ "5‘I¸)ˆEð —W‘W×0Ñ0Ó2ˆ
Ü˜j×/Ñ/Ó1Ó2ˆ
ä1Ó3ÐäÐ% }°jÔAô 	�u¨DÕ1Ü˜¨dÕ3Ü$¨5¸Ô@ˆà�w‰w×ÑØÐ2À-ð  ó 
ð 	
ó    c                ó   — t        d| «      S )zGet our DeltaGenerator.r   )r   )r*   s    r/   r$   zGraphvizMixin.dgÂ   s   € ô Ð$ dÓ+Ð+r0   )N)
r+   r   r   zbool | Noner   r   r   r   Úreturnr   )r2   r   )Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr$   © r0   r/   r   r   0   sy   „ ÙÐ$Ó%ð ,0ðN
ð
 !Ø"ñN
à"ðN
ð )ðN
ð
 ðN
ð ðN
ð 
òN
ó &ðN
ð` ò,ó ñ,r0   r   c                óú   — t        j                  |«      r%t        d|«      }|j                  }|j                  }n,t        |t        «      r|}d}nt        dt        |«      › �«      ‚|| _	        || _        || _
        y)zXConstruct a GraphViz chart object.

    See DeltaGenerator.graphviz_chart for docs.
    z3graphviz.Graph | graphviz.Digraph | graphviz.SourceÚdotz#Unhandled type for graphviz chart: N)r   Úis_graphviz_chartr   ÚsourceÚengineÚ
isinstanceÚstrr   ÚtypeÚspecr-   )Úprotor+   r-   Úchartr9   r<   s         r/   r(   r(   È   s~   € ô ×"Ñ" =Ô1ÜØAÀ=ó
ˆð �l‰lˆØ—‘‰Ü	�M¤3Ô	'ØˆØ‰ä#Ø1´$°}Ó2EÐ1FÐGó
ð 	
ð €E„JØ€E„LØ!€EÕr0   )rA   r'   r+   r   r-   r>   r2   ÚNone)$Ú__doc__Ú
__future__r   Útypingr   r   r   r   Ú	streamlitr   Ústreamlit.deprecation_utilr	   r
   Ú#streamlit.elements.lib.layout_utilsr   r   r   r   r   Ústreamlit.errorsr   Ú!streamlit.proto.GraphVizChart_pb2r   r'   Ústreamlit.runtime.metrics_utilr   Ústreamlit.utilr   ÚgraphvizÚstreamlit.delta_generatorr   r>   r   Ú__annotations__r   r(   r7   r0   r/   ú<module>rQ      s‘   ðò -å "ç 8Ó 8å ÷÷õ õ 3Ý QÝ 9Ý #áÛå8àØÐ(Ð*;¸SÐ@ñ€ˆYó ÷
U,ñ U,ðp"Øð"àð"ð ð"ð 
ô	"r0   