
    /_i                        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	            `/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/elements/graphviz_chart.pyr   zGraphvizMixin.graphviz_chart1   s    d *$,) N&+ !&
 "5I)E WW002
j//12
13%}jA 	uD1d3$5@ww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|j                  }|j                  }n,t	        |t
              r|}d}nt        dt        |             || _        || _        || _	        y)zXConstruct a GraphViz chart object.

    See DeltaGenerator.graphviz_chart for docs.
    dotz#Unhandled type for graphviz chart: N)
r   is_graphviz_chartsourceengine
isinstancestrr   typespecr-   )protor+   r-   r9   r<   s        r/   r(   r(      sq     ""=1""%%	M3	'#1$}2E1FG
 	
 EJEL!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>rP      s    - " 8 8   3 Q 9 #8(*;S@Y 
U, U,p""" " 
	"r0   