
    -e0                       d Z ddlmZ ddlZ ej        e          ZddlmZm	Z	m
Z
 ddlmZmZ er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 ddlmZ ddlmZ ddlmZ erddlm Z  ddl!m"Z" ddlm#Z# ddl$m%Z% dZ&	 	 d;d<d!Z'dddddi fd=d'Z(edfd>d0Z)d?d1Z*d?d2Z+d@d3Z,dAd5Z-dBd6Z.dCd7Z/dDd:Z0 ee'j         e	          e'_          ee(j         e	          e(_         dS )Ez

    )annotationsN)TYPE_CHECKINGAnyLiteral)
quote_plusurlparse)Template   )AUTOLOAD_REQUEST_TAGFILE)DEFAULT_SERVER_HTTP_URL)make_id)format_docstring   )bundle_for_objs_and_resources)html_page_for_render_items)
RenderItem)ID)Model)	Resources)ServerSession)server_documentserver_sessionserver_html_page_for_sessiondefaultFurlstrrelative_urlsbool	resourcesLiteral['default'] | None	argumentsdict[str, str] | Noneheadersreturnc                H   t          |           } t          |           }t                      }t          | |          }|t	          |          z  }|t          ||           z  }|t          |          z  }|t          |          z  }|pi }t          j	        ||||          }|S )a>   Return a script tag that embeds content from a Bokeh server.

    Bokeh apps embedded using these methods will NOT set the browser window title.

    Args:
        url (str, optional) :
            A URL to a Bokeh application on a Bokeh server (default: "default")

            If ``"default"`` the default URL ``{DEFAULT_SERVER_HTTP_URL}`` will be used.

        relative_urls (bool, optional) :
            Whether to use relative URLs for resources.

            If ``True`` the links generated for resources such a BokehJS
            JavaScript and CSS will be relative links.

            This should normally be set to ``False``, but must be set to
            ``True`` in situations where only relative URLs will work. E.g.
            when running the Bokeh behind reverse-proxies under certain
            configurations

        resources (str) : A string specifying what resources need to be loaded
            along with the document.

            If ``default`` then the default JS/CSS bokeh files will be loaded.

            If None then none of the resource files will be loaded. This is
            useful if you prefer to serve those resource files via other means
            (e.g. from a caching server). Be careful, however, that the resource
            files you'll load separately are of the same version as that of the
            server's, otherwise the rendering may not work correctly.

       arguments (dict[str, str], optional) :
            A dictionary of key/values to be passed as HTTP request arguments
            to Bokeh application code (default: None)

       headers (dict[str, str], optional) :
            A dictionary of key/values to be passed as HTTP Headers
            to Bokeh application code (default: None)

    Returns:
        A ``<script>`` tag that will embed content from a Bokeh Server.

    )src_pathapp_path	elementidr$   )

_clean_url_get_app_pathr   	_src_path_process_app_path_process_relative_urls_process_resources_process_argumentsr   render)	r   r   r    r"   r$   r(   r)   r'   tags	            2lib/python3.11/site-packages/bokeh/embed/server.pyr   r   <   s    \ S//CS!!H		Ii((H!(+++H&}c:::H"9---H"9---HmG

%	  C J    modelModel | None
session_id	ID | Nonedict[str, str]c                   |t          d          t          |          }t          |          }t                      }| dn| j        }t          ||          }	|	t          |          z  }	|	t          ||          z  }	|	t          |          z  }	|rt          |          ni }||d<   t          j        |	||||          }
|
S )a	   Return a script tag that embeds content from a specific existing session on
    a Bokeh server.

    This function is typically only useful for serving from a a specific session
    that was previously created using the ``bokeh.client`` API.

    Bokeh apps embedded using these methods will NOT set the browser window title.

    .. note::
        Typically you will not want to save or re-use the output of this
        function for different or multiple page loads.

    Args:
        model (Model or None, optional) :
            The object to render from the session, or None. (default: None)

            If None, the entire document will be rendered.

        session_id (str) :
            A server session ID

        url (str, optional) :
            A URL to a Bokeh application on a Bokeh server (default: "default")

            If ``"default"`` the default URL ``{DEFAULT_SERVER_HTTP_URL}`` will be used.

        relative_urls (bool, optional) :
            Whether to use relative URLs for resources.

            If ``True`` the links generated for resources such a BokehJS
            JavaScript and CSS will be relative links.

            This should normally be set to ``False``, but must be set to
            ``True`` in situations where only relative URLs will work. E.g.
            when running the Bokeh behind reverse-proxies under certain
            configurations

        resources (str) : A string specifying what resources need to be loaded
            along with the document.

            If ``default`` then the default JS/CSS bokeh files will be loaded.

            If None then none of the resource files will be loaded. This is
            useful if you prefer to serve those resource files via other means
            (e.g. from a caching server). Be careful, however, that the resource
            files you'll load separately are of the same version as that of the
            server's, otherwise the rendering may not work correctly.

       headers (dict[str, str], optional) :
            A dictionary of key/values to be passed as HTTP Headers
            to Bokeh application code (default: None)

    Returns:
        A ``<script>`` tag that will embed content from a Bokeh Server.

        .. warning::
            It is typically a bad idea to re-use the same ``session_id`` for
            every page load. This is likely to create scalability and security
            problems, and will cause "shared Google doc" behavior, which is
            probably not desired.

    NzMust supply a session_id zBokeh-Session-Id)r'   r(   r)   modelidr$   )
ValueErrorr*   r+   r   idr,   r-   r.   r/   dictr   r1   )r5   r7   r   r   r    r$   r(   r)   r<   r'   r2   s              r3   r   r      s    @ 3444
S//CS!!H		IMbbuxGi((H!(+++H&}c:::H"9---H&.d7mmmBG",G

%  C Jr4   sessionr   r   titletemplater	   template_variablesdict[str, Any] | Nonec                    t          | j        | j        j        d          }|i }t	          d|          }t          |i |g|||          }|S )z

    Args:
        session (ServerSession) :

        resources (Resources) :

        title (str) :

        template (Template) :

        template_variables (dict) :

    Returns:
        str

    T)tokenrootsuse_for_titleN)rB   rC   )r   rF   documentrG   r   r   )r@   r    rA   rB   rC   render_itembundlehtmls           r3   r   r      sr    &  &  K !*4;;F%fb;-.@B B BDKr4   c                    | dk    rt           } |                     d          rt          d          |                     d          S )z Produce a canonical Bokeh server URL.

    Args:
        url (str)
            A URL to clean, or "defatul". If "default" then the
            ``BOKEH_SERVER_HTTP_URL`` will be returned.

    Returns:
        str

    r   wszIurl should be the http or https URL for the server, not the websocket URL/)r   
startswithr=   rstrip)r   s    r3   r*   r*     sH     i%
~~d fdeee::c??r4   c                    t          |           j                            d          }|                    d          sd|z   }|S )zl Extract the app path from a Bokeh server URL

    Args:
        url (str) :

    Returns:
        str

    rO   )r   pathrQ   rP   )r   r(   s     r3   r+   r+     sD     }}!((--Hs## ">Or4   c           
         | dS d}|                                  D ]Y\  }}|                    d          s?|dt          t          |                     dt          t          |                     z  }Z|S )z Return user-supplied HTML arguments to add to a Bokeh server URL.

    Args:
        arguments (dict[str, object]) :
            Key/value pairs to add to the URL

    Returns:
        str

    Nr;   zbokeh-&=)itemsrP   r   r   )r"   resultkeyvalues       r3   r0   r0   )  s     rFoo'' J J
U~~h'' 	JI*SXX..IICJJ1G1GIIIFMr4   r(   c                    | dk    rdS d| z   S )z Return an app path HTML argument to add to a Bokeh server URL.

    Args:
        app_path (str) :
            The app path to add. If the app path is ``/`` then it will be
            ignored and an empty string returned.

    rO   r;   z&bokeh-app-path= )r(   s    r3   r-   r-   <  s     3rr((r4   c                    | rdS d|z   S )a#   Return an absolute URL HTML argument to add to a Bokeh server URL, if
    requested.

    Args:
        relative_urls (book) :
            If false, generate an absolute URL to add.

        url (str) :
            The absolute URL to add as an HTML argument

    Returns:
        str

    r;   z&bokeh-absolute-url=r\   )r   r   s     r3   r.   r.   H  s     RR!C''r4   c                4    | dvrt          d          | dS dS )z Return an argument to suppress normal Bokeh server resources, if requested.

    Args:
        resources ("default" or None) :
            If None, return an HTML argument to suppress default resources.

    Returns:
        str

    )r   Nz-`resources` must be either 'default' or None.Nz&resources=noner;   )r=   )r    s    r3   r/   r/   Z  s0     )))HIII  2r4   r)   r   c                    | dz   |z   S )z Return a base autoload URL for a given element ID

    Args:
        url (str) :
            The base server URL

        elementid (str) :
            The div ID for autload to target

    Returns:
        str

    z$/autoload.js?bokeh-autoload-element=r\   )r   r)   s     r3   r,   r,   k  s     77)CCr4   )r   Fr   NN)r   r   r   r   r    r!   r"   r#   r$   r#   r%   r   )r5   r6   r7   r8   r   r   r   r   r    r!   r$   r9   r%   r   )
r@   r   r    r   rA   r   rB   r	   rC   rD   )r   r   r%   r   )r"   r#   r%   r   )r(   r   r%   r   )r   r   r   r   r%   r   )r    r!   r%   r   )r   r   r)   r   r%   r   )1__doc__
__future__r   logging	getLogger__name__logtypingr   r   r   urllib.parser   r   jinja2r	   core.templatesr   r   r    r   util.serializationr   util.stringsr   rK   r   elementsr   utilr   
core.typesr   r5   r   r   server.sessionr   __all__r   r   r   r*   r+   r0   r-   r.   r/   r,   r\   r4   r3   <module>rq      s    # " " " " " g!! / . . . . . . . . . - - - - - - - -    8 7 7 7 7 7 7 7 / / / / / / ( ( ( ( ( ( + + + + + + 1 1 1 1 1 1 0 0 0 0 0 0       /%%%%%%...... oxRVC C C C CJ *.tXa#IqsZ Z Z Z ZB "t    J   (      &
) 
) 
) 
)( ( ( ($   "D D D D( +*?+B\sttt )).*@Zqrrr   r4   