
    -e                     *   U d Z ddlmZ ddlZ ej        e          ZddlZddlm	Z	 ddl
mZmZ ddlmZ ddlmZ dd	lmZmZ erdd
lmZ ddlmZ ddlmZmZ dZ G d d          ZddZ e	d           G d d                      Zdaded<   dS )a   Encapsulate implicit state that is useful for Bokeh plotting APIs.

.. note::
    While ``State`` objects can also be manipulated explicitly, they are
    automatically configured when the output functions like |output_file|
    from :ref:`bokeh.io` are used. Therefore, manipulating ``State`` objects is
    usually not necessary.

Generating output for Bokeh plots requires coordinating several things:

|Document|
    Groups together Bokeh models that may be shared between plots (e.g.,
    range or data source objects) into one common structure.

:class:`~bokeh.resources.Resources`
    Control how JavaScript and CSS for the client library BokehJS are
    included and used in the generated output.

It is possible to handle the configuration of these things manually, and some
examples of doing this can be found in ``examples/models`` directory. When
developing sophisticated applications, it may be necessary or desirable to work
at this level. However, for general use this would quickly become burdensome.
This module provides a ``State`` class that encapsulates these objects and
ensures their proper configuration in many common usage scenarios.

    )annotationsN)	dataclass)TYPE_CHECKINGcast   )PathLike)Document)	ResourcesResourcesMode)ID)Server   )CommsHandleNotebookType)curstateStatec                  "   e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   d)dZed*d            Zej        d+d            Zed,d            Z	ed-d            Z
ed.d            Zej        d/d            Z	 	 d0d1d#Zd2d/d%Zd)d&Zd)d'Zd+d(ZdS )3r   z8 Manage state related to controlling Bokeh output.

    FileConfig | None_filebool	_notebookNotebookType | None_notebook_typezCommsHandle | Nonelast_comms_handlezdict[ID, Server]uuid_to_serverreturnNonec                J    d | _         i | _        |                                  d S N)r   r   resetselfs    .lib/python3.11/site-packages/bokeh/io/state.py__init__zState.__init__V   s#    !% 

    r	   c                    | j         S )zA A default |Document| to use for all output operations.

        	_documentr!   s    r#   documentzState.document]       
 ~r%   docc                    || _         d S r   r'   r"   r+   s     r#   r)   zState.documentd   s    r%   c                    | j         S )z A structure with the default configuration for file output (READ ONLY)

            See :class:`~bokeh.io.state.FileConfig`.

        )r   r!   s    r#   filez
State.fileh   s     zr%   c                    | j         S )zN Whether to generate notebook output on show operations. (READ ONLY)

        )r   r!   s    r#   notebookzState.notebookq   r*   r%   c                    | j         S )z Notebook type

        )r   r!   s    r#   notebook_typezState.notebook_typex   s    
 ""r%   r3   r   c                    |t          |t                    st          d          t          d|                                          | _        dS )z Notebook type, acceptable values are 'jupyter' as well as any names
        defined by external notebook hooks that have been installed.

        NzNotebook type must be a stringr   )
isinstancestr
ValueErrorr   lowerr   r"   r3   s     r#   r3   zState.notebook_type   sL      
=#(F(F =>>>">=3F3F3H3HIIr%   
Bokeh PlotNfilenamer   titler6   modeResourcesMode | Noneroot_dirPathLike | Nonec                    t          |t          ||          |          | _        t          j                            |          r t                              d| d           dS dS )aT   Configure output to a standalone HTML file.

        Calling ``output_file`` does not clear the effects of any other calls to
        |output_notebook|, etc. It adds an additional output destination
        (publishing to HTML files). Any other active output modes continue
        to be active.

        Args:
            filename (PathLike, e.g. str, Path) : a filename for saving the HTML document

            title (str, optional) : a title for the HTML document

            mode (str, optional) : how to include BokehJS (default: ``'cdn'``)

                One of: ``'inline'``, ``'cdn'``, ``'relative(-dev)'`` or
                ``'absolute(-dev)'``. See :class:`~bokeh.resources.Resources`
                for more details.

            root_dir (str, optional) : root dir to use for absolute resources
                (default: None)

                This value is ignored for other resource types, e.g. ``INLINE`` or ``CDN``.

        .. warning::
            The specified output file will be overwritten on every save, e.g.,
            every time ``show()`` or ``save()`` is called.

        )r=   r?   )r;   	resourcesr<   zSession output file 'z&' already exists, will be overwritten.N)
FileConfigr
   r   ospathisfileloginfo)r"   r;   r<   r=   r?   s        r#   output_filezState.output_file   sy    <  TH===
 
 

 7>>(## 	_HH]X]]]^^^^^	_ 	_r%   jupyterc                "    d| _         || _        dS )aW   Generate output in notebook cells.

        Calling ``output_notebook`` does not clear the effects of any other
        calls to |output_file|, etc. It adds an additional output destination
        (publishing to notebook output cells). Any other active output modes
        continue to be active.

        Returns:
            None

        TN)r   r3   r9   s     r#   output_notebookzState.output_notebook   s     *r%   c                H    |                      t                                 dS )z Deactivate all currently active output modes and set ``curdoc()``
        to a fresh empty ``Document``.

        Subsequent calls to ``show()`` will not render until a new output mode
        is activated.

        Returns:
            None

        N)_reset_with_docr	   r!   s    r#   r    zState.reset   s"     	XZZ(((((r%   c                0    d| _         d| _        d| _        dS )zE Reset output modes but DO NOT replace the default Document

        NF)r   r   r   r!   s    r#   _reset_keeping_doczState._reset_keeping_doc   s      
"r%   c                <    || _         |                                  dS )zA Reset output modes but DO replace the default Document

        N)r(   rP   r-   s     r#   rN   zState._reset_with_doc   s#     !!!!!r%   )r   r   )r   r	   )r+   r	   r   r   )r   r   )r   r   )r   r   )r3   r   r   r   )r:   NN)
r;   r   r<   r6   r=   r>   r?   r@   r   r   )rJ   )__name__
__module____qualname____doc____annotations__r$   propertyr)   setterr/   r1   r3   rI   rL   r    rP   rN    r%   r#   r   r   J   s          OOO''''))))$$$$       X _   _    X    X # # # X# J J J J <HKO%_ %_ %_ %_ %_N+ + + + +) ) ) )# # # #" " " " " "r%   r   r   c                 :    t           t                      a t           S )zc Return the current State object

    Returns:
      State : the current default State object

    )_STATEr   rY   r%   r#   r   r      s     ~Mr%   T)frozenc                  .    e Zd ZU ded<   ded<   ded<   dS )rC   r   r;   r
   rB   r6   r<   N)rR   rS   rT   rV   rY   r%   r#   rC   rC      s1         JJJJJr%   rC   zState | Noner[   )r   r   ) rU   
__future__r   logging	getLoggerrR   rG   rD   dataclassesr   typingr   r   
core.typesr   r)   r	   rB   r
   r   r   server.serverr   r1   r   r   __all__r   r   rC   r[   rV   rY   r%   r#   <module>rf      s    < # " " " " " g!! 
			 ! ! ! ! ! ! & & & & & & & & " ! ! ! ! !       0 0 0 0 0 0 0 0 4&&&&&&33333333S" S" S" S" S" S" S" S"j
 
 
 
  $              r%   