U
    õÕ/e@  ã                   @  sº   U d Z ddlmZ ddlZe e¡ZddlZddlm	Z	 ddl
mZmZmZ ddlmZ ertdd	lmZ dd
lmZ dZg aded< ddœdd„Ze	dddœdd„ƒZdddœdd„ZdS )z

é    )ÚannotationsN)Úcontextmanager)ÚTYPE_CHECKINGÚIteratorÚListé   )Úcurstateé   )ÚDocument)ÚUnlockedDocumentProxy)ÚcurdocÚpatch_curdocÚ
set_curdocz=List[weakref.ReferenceType[Document | UnlockedDocumentProxy]]Ú_PATCHED_CURDOCSz Document | UnlockedDocumentProxy)Úreturnc                  C  s2   t tƒdkr*td ƒ } | dkr&tdƒ‚| S tƒ jS )z Return the document for the current default state.

    Returns:
        Document : the current default document object.

    r   éÿÿÿÿNz,Patched curdoc has been previously destroyed)Úlenr   ÚRuntimeErrorr   Údocument©Údoc© r   ú0/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/io/doc.pyr   4   s    
r   zIterator[None])r   r   c                 c  s$   t  t | ¡¡ ~ dV  t  ¡  dS )a2   Temporarily override the value of ``curdoc()`` and then return it to
    its original state.

    This context manager is useful for controlling the value of ``curdoc()``
    while invoking functions (e.g. callbacks). The cont

    Args:
        doc (Document) : new Document to use for ``curdoc()``

    N)r   ÚappendÚweakrefÚrefÚpopr   r   r   r   r   F   s    r   r
   ÚNonec                 C  s   | t ƒ _dS )zñ Configure the current document (returned by curdoc()).

    Args:
        doc (Document) : new Document to use for curdoc()

    Returns:
        None

    .. warning::
        Calling this function will replace any existing document.

    N)r   r   r   r   r   r   r   X   s    r   )Ú__doc__Ú
__future__r   ÚloggingÚ	getLoggerÚ__name__Úlogr   Ú
contextlibr   Útypingr   r   r   Ústater   r   r
   Zdocument.lockingr   Ú__all__r   Ú__annotations__r   r   r   r   r   r   r   Ú<module>   s    
