
    Bep                       d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZ ddlmZ ddl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#m$Z$m%Z% dd
l&m'Z'm(Z( ddl)Z)ddl*Z)ddl+Z+ddl,Z,ddl-m.Z/ ddl0m1Z1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZI ddlJmKZK ddlLmMZN ddlOmPZPmQZQ ddlRmSZT ddlUmVZW ddlXmYZZ ddl[m\Z\ ddl]m^Z^ ddl_m`Z`maZambZb dd lcmdZd dd!lemfZfmgZgmhZhmiZi dd"ljmkZk d#d$llmlZl d#d%lmmnZnmoZo d#d&lpmqZq d'd(lrmsZsmtZtmuZu d'd)lvmwZw d'd*lxmyZy d'd+l
mzZzm{Z{m|Z| d'd,l}m~Z~ d'd-lmZ d'd.lmZ d'd/lmZmZmZmZmZmZmZmZmZmZ d'd0lmZmZ  e
j        e          Zer^dd1lmZ dd2lmZ dd3lmZmZ dd4lmZ dd5lmZ dd6lmZ d#d7lmZ d#d8lmZmZ d'd9lmZ e%eeef         Ze%ee!g ef         ej        ef         Zej                            ej                            e          d:d;d<          Zd=ZddAZddDZddOZddSZee+j        _        ddVZej                            e           di fddaZdedfddjZddlZdm Z G dn doeN          ZMeMe)j        j        _M         G dp dqe/          Z.e.e)j        jm        _.         G dr ds          Z G dt du          Z G dv dweeWe          ZVdxeVfePd<    G dy dzeTe          ZSd{eSfePd|<    G d} d~eeZ          ZYdxeYfeQd<   eYe)j        j,        _Y         G d deh          ZddZee1_        d Zee)j        j,        _        ej        dk    ruej        dd|         dk    rbe,j        dk    rW e ej                              ej        u r8dej        vr	dej        vs	dej        v r ej         ej                               	 	 	 	 	 	 	 	 	 	 	 dddZ G d deg          Zd Zdddddkdkddkddki dddddi dddddddddddddkfddZ G d dej                  ZdS )z0
Utilities for creating bokeh Server instances.
    )annotationsN)OrderedDict)contextmanager)partialwraps)escape)FunctionType
MethodType)TYPE_CHECKINGAnyCallableDictMappingOptionalUnion)urljoinurlparse)Application)CodeHandler_monkeypatch_iopatch_curdoc)FunctionHandler)serialize_json)AUTOLOAD_JSFILEMACROS)silence)EMPTY_LAYOUT)Script)script_for_render_items)
RenderItem)wrap_in_script_tag)curdoc)CustomJS)Server)per_app_patternstoplevel_patterns)AutoloadJsHandler)
DocHandler)RootHandler)StaticHandler)make_id)generate_jwt_tokengenerate_session_idget_token_payload)IOLoop)	HTTPErrorRequestHandlerStaticFileHandlerauthenticated)WSGIContainer   config)edit_readonlyfullpath)warn   )init_docunlocked	with_lock)LivenessHandler)LOADING_INDICATOR_CSS_CLASS)LOG_SESSION_CREATEDLOG_SESSION_DESTROYEDLOG_SESSION_LAUNCHING) build_single_handler_application)profile_ctx)autoreload_watcher)
BASE_TEMPLATECDN_DISTCOMPONENT_PATHERROR_TEMPLATE
LOCAL_DIST	Resources_envbundle_resourcespatch_model_cssresolve_custom_path)
set_curdocstate)Bundle)ID)DocJsonDocument)BokehSessionContext)ServerSession)TemplateBaseTemplate)ViewableViewer)Location..
_templatesz
index.htmlzPanel Applicationurlstrreturnc                f    |                      d          r|                     d          d         } | S )Nhttpz//r<   )
startswithsplit)rb   s    /lib/python3.11/site-packages/panel/io/server.py_origin_urlrj   s   s/    
~~f !iiooa J    portintc                    |                      d          r"d|                     dd          d         |dfz  S d|                     d          d         |dfz  S )Nrf   z%s:%d%s:r<   r   /zhttp://%s:%d%s)rg   rsplitrh   )rb   rl   s     ri   _server_urlrr   x   s]    
~~f ACJJsA..q14===399S>>!#4dC"@@@rk   panelTViewableFuncOrPath	server_idtitlelocationbool | LocationadminbooldocrW   c           
     l   ddl m} ddlm} t          j        r:                    dt          dt          dt          j	        d                     t                              t          t                               fd	}                    |           t                    5  t!          | t"          t$          f          r
 |             } t!          | |          r|                     |||          n! ||                               |||          cd d d            S # 1 swxY w Y   d S )
Nr6   )rs   r[   document_readyze
            const body = document.getElementsByTagName('body')[0]
            body.classList.remove(z, z)
            )codec                b    t                               t          t                               d S NloggerinforC   idsession_contextr{   s    ri   _log_session_destroyedz+_eval_panel.<locals>._log_session_destroyed   s$    )2c7733333rk   )paners   templater\   r8   global_loading_spinnerjs_on_eventr$   rA   loading_spinnerr   r   rD   r   on_session_destroyedrR   
isinstancer	   r
   _modify_doc)	rs   ru   rv   rw   ry   r{   as_panelr\   r   s	        `   ri   _eval_panelr   ~   s    )(((((''''''$ 
h -#>- -DJDZ- - -   	
 	
 	
 KK%r#ww///4 4 4 4 43444	C  elJ788 	EGGEe\** 	O##Iuc8DDCC(5//--iXNNC                 s   *A2D))D-0D-funcCallable[..., None]Nonec                d    t           j        rt           j        j        swt          j                    }|j        }t          j                   }|                                r|                    |           n|	                     |                       dS t           t                    r#t           j        d          r j        j         }nt           dd           }t           j        t!                      fd            }|rd|_        t           j                            |           dS )z
    Wrap async event loop scheduling to ensure that with_lock flag
    is propagated from function to partial wrapping it.
    NlockFc                    K   t                    5  	  | i | d {V 	 cd d d            S # t          $ r}t          j        |           Y d }~nd }~ww xY w	 d d d            d S # 1 swxY w Y   d S r   )rR   	ExceptionrS   _handle_exception)argskwer#   r   s      ri   wrapperzasync_execute.<locals>.wrapper   s      	+ 	++!T4.2.........	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+  + + +'********+*		+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s1   A)0
AAA)AA))A-0A-T)rS   r#   r   r0   currentasyncio_loop_handle_exception_wrapper
is_runningadd_callbackrun_until_completer   r   hasattrr   r   getattrr   nolockadd_next_tick_callback)r   ioloop
event_loopr   unlockr#   s   `    @ri   async_executer      s4   
 < u|; !!(
1$77  "" 	5(((())''))444$   2WTY%?%? 2Y^#T65111\F
4[[+ + + + + [+  	L''00000rk   r   'BokehSessionContext'c                p   ddl m } | j        }t          j        d         }|j        rdn|j        }|j        s|dk    s||v rd S t          j        dxx         dz  cc<   |dk    r^t          |          |k    rKt          |                                          }t          ||dz
   d                    }|t          j        d<   t          j                                                                        d d d | j        j                            d          d	||<   t          j                            d
           d S )Nr6   r7   sessionsr   totalr<   z
User-Agent)launchedstartedrenderedended
user_agentsession_info)r8   r   rS   r   _adminsession_historylenlistitemsr   dtdatetimenow	timestamprequestheadersgetparamtrigger)r   r8   
session_idr   historyold_historys         ri   _initialize_session_infor      s?    #J!*-HM=bbv'=G= glljH.D.D	w1${{s8}}//8>>++,,{WQY<==9::)1:&KOO%%//11%-599,GG HZ 
K'''''rk   bundleBundle | tuple[str, str]	docs_jsondict[ID, DocJson]render_itemslist[RenderItem]r   Template | str | Nonetemplate_variablesdict[str, Any]c                h   |t           }| \  }}t                      }t          t          |          d          }	t	          |	d|          }	t	          t          ||                    }
|                                }|                    t          ||||	|
z   |t          t                               t          |          dk    r!|d         d         |d	<   |d	         j        |d
<   |t          }n,t          |t                    rt          j        d|z             }|                    |          }|S )a  
    Render an HTML page from a template and Bokeh render items.

    Arguments
    ---------
    bundle (tuple):
        A tuple containing (bokehjs, bokehcss)
    docs_json (JSON-like):
        Serialized Bokeh Document
    render_items (RenderItems)
        Specific items to render from the document and where
    title (str or None)
        A title for the HTML page. If None, DEFAULT_TITLE is used
    template (str or Template or None, optional) :
        A Template to be used for the HTML page. If None, FILE is used.
    template_variables (dict, optional):
        Any Additional variables to pass to the template

    Returns
    -------
    str
    NF)quotezapplication/json)rv   bokeh_js	bokeh_cssplot_scriptdocsbasemacrosr<   r   r   r{   rootsz{% extends base %}
)DEFAULT_TITLEr,   r   r   r"   r    copyupdatedictrH   r   r   r   r   rc   rN   from_stringrender)r   r   r   rv   r   r   r   r   json_idjsonscriptcontexthtmls                ri   html_page_for_render_itemsr      s:   6 } HiiiG.++5999Dd$6@@D 7 N NOOF %%''GNN4Vm      <A +"5>/ 	Hc	"	" G#$:X$EFF??7##DKrk   session'ServerSession'	resources'Resources'token
str | Nonestr | TemplateOptional[Dict[str, Any]]c           	     l   |j         dk    r*t          j        rt          j         dt           nt          }nt          }| j        }t          j        |j        d<   ||j        d<   |j	        D ]}t          ||           t          |p| j        |j	        d          }	|i }|t          u rt          }t          |          5  t!          |j	        |          }
t#          |
i |	g|||          }t          j        r' |j        d	d
t(           dt          j         d          }d d d            n# 1 swxY w Y   |S )Nserverrp   
theme_namedist_url)r   F)r   r   use_for_title)r   r   z<body>z<body class="z pn-z">)moderS   rel_pathrL   rI   documentr8   theme_template_variablesr   rP   r!   r   r   rH   rR   rO   r   r   replacerA   r   )r   r   rv   r   r   r   r   r{   rootrender_itemr   r   s               ri   server_html_page_for_sessionr     s    ~!!7<~Uen33z333:

C,2LCL)*2CJ'	 1 1x00000&	  K !4 	C 	 	!#)Y77)Bux1
 
 
 ( 	4<e*Eee6Kaeee D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 Ks   >AD))D-0D-Fc           
        t          j        ||          }t          | j        |          }t	          ||d          g}|                    t          t          i |||                               t          j	        ||          S )NabsoluteF)r   	elementidr   )app_pathabsolute_url)r   r   )
rM   
from_bokehrO   r   r!   addr   r    r   r   )	r{   r   r   
element_idr  r  r   r   r   s	            ri   autoload_js_scriptr  F  s    $YBBBIci33FUjPUVVVWL
JJv-b,`lmmmnnoooVzBBBBrk   c                   ||                      |           | `| `| `d| _        | j                                         | j                                         | j                                         t          j
                            | g           D ]}|                                 t          t                    D ]T}|                    d          r|dk    rt          t          |          }t!          |t"          j                  r| |v r|| = Ut&          j                                        t'          j        d          z   }t          j        dt0          j        |           | `dS )a  
    Override for Document.destroy() without calling gc.collect directly.
    The gc.collect() call is scheduled as a task, ensuring that when
    multiple documents are destroyed in quick succession we do not
    schedule excessive garbage collection.
    N__param_watchers   )secondsz
gc.collect)at)remove_on_change_roots_theme	_template_session_context	callbacksdestroymodelsmodulesrS   	_periodicr   stopdirrg   r   r   weakrefWeakKeyDictionaryr   r   r   	timedeltaschedule_taskgccollect)selfr   cbattr	state_objr  s         ri   destroy_documentr#  O  sZ    g&&& DNKL o!!$++  
				 E

    s## 	t/@'@'@E4((	i!:;; 	 	@Q@Q$ 
		R\!444	4B	bjR8888rk   c                  8     e Zd Z fdZd	 fdZd
d fdZ xZS )r%   c                     t                      j        |i | t          j        r| j        t          j        _        d S d S r   )super__init__rS   _admin_context_loopr  r   kwargs	__class__s      ri   r'  zServer.__init__x  sG    $)&))) 	4)-E &&&	4 	4rk   rd   r   c                    t                                                       t          j        r+| j                            t          j        j                   d S d S r   )r&  startrS   r(  r)  r   run_load_hook)r  r,  s    ri   r.  zServer.start}  sN     	HJ##E$8$FGGGGG	H 	Hrk   Twaitrz   c                    t                                          |           t          j        r t          j                                         d S d S )N)r0  )r&  r  rS   r(  run_unload_hook)r  r0  r,  s     ri   r  zServer.stop  sK    $ 	3 0022222	3 	3rk   rd   r   )T)r0  rz   rd   r   )__name__
__module____qualname__r'  r.  r  __classcell__r,  s   @ri   r%   r%   v  s        4 4 4 4 4
H H H H H H
3 3 3 3 3 3 3 3 3 3 3rk   r%   c                  2     e Zd Z fdZ fdZ fdZ xZS )r   c                p    |                     dd           | _         t                      j        |i | d S )Nry   )popr   r&  r'  r*  s      ri   r'  zApplication.__init__  s:    jj$//$)&)))))rk   c                2  K   t          |j                  5  | j        | j        t          _        t          j        t          j        z   D ]} ||           	 d d d            n# 1 swxY w Y   t                                          |           d {V  d S r   )	rR   	_documentr   r8   rS   _on_session_created_internal_on_session_createdr&  on_session_created)r  r   r   r,  s      ri   r@  zApplication.on_session_created  s      122 	$ 	${& $89RR $ $?####$	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$
 gg((99999999999s   A A%%A),A)c                N   t                                          |           |t          j        v rr|t          j        |         j        vr[t          j        |         }t          |          5  |                    |j        d|           d d d            d S # 1 swxY w Y   d S d S d S )NT)rv   rw   r{   )r&  initialize_documentrS   ra   
_documentsrR   
server_docrv   )r  r{   r   r,  s      ri   rB  zApplication.initialize_document  s    ##C(((%"""s%2B32G2R'R'R',HC R R##(.4S#QQQR R R R R R R R R R R R R R R R R R #"'R'Rs   +BBB)r4  r5  r6  r'  r@  rB  r7  r8  s   @ri   r   r     ss        * * * * *: : : : :R R R R R R R R Rrk   r   c                  $    e Zd Zed             ZdS )SessionPrefixHandlerc              #    K   | j         j                            | j        j        d          }|                    d          s|dz  }t          d|          }d                    dg| j        j                            d          	                    d          z            }t          j        t          j        }}|                     dd           }| |                    | j        j        d          }t          t                    5  |t          _        |t          _        d d d            n# 1 swxY w Y   	 d V  t          t                    5  |t          _        |t          _        d d d            d S # 1 swxY w Y   d S # t          t                    5  |t          _        |t          _        d d d            w # 1 swxY w Y   w xY w)N rp   r`   bokeh-absolute-urldefault)r   urir   application_context_urlendswithr   joinstripcountrS   base_urlr   get_argumentr9   )r  prefixrS  r   old_urlold_relabs_urls          ri   _session_prefixz$SessionPrefixHandler._session_prefix  sL     !))$*B*GLLs## 	cMF3''88TFT%=%B%H%H%M%M%S%STW%X%XXYY >5> ##$8$#GGt'?'DbIIH5!! 	& 	&%EN%EN	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&	)EEEu%% ) )!(!() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )u%% ) )!(!() ) ) ) ) ) ) ) ) ) ) ) ) ) ) )sT   D**D.1D.6F E44E8;E8GF;/G;F??GF?GN)r4  r5  r6  r   rY   rk   ri   rF  rF    s-        ) ) ^) ) )rk   rF  c                      e Zd ZdZd ZdS )LoginUrlMixinzi
    Overrides the AuthRequestHandler.get_login_url implementation to
    correctly handle prefixes.
    c                    | j         j        j        "d| j         j                            |           z   S | j         j        j        d| j         j        j        z   S t	          d          )zm Delegates to``get_login_url`` method of the auth provider, or the
        ``login_url`` attribute.

        N.zSlogin_url or get_login_url() must be supplied when authentication hooks are enabled)applicationauth_providerget_login_url	login_urlRuntimeErrorr  s    ri   ra  zLoginUrlMixin.get_login_url  sd    
 )7C)7EEdKKKK)3?)7AAApqqqrk   N)r4  r5  r6  __doc__ra  rZ  rk   ri   r\  r\    s2         
	r 	r 	r 	r 	rrk   r\  c                  J     e Zd Ze fd            Zd Zed             Z xZS )r)   c                (  K   ddl m } | j        j        }d }|j        rL|t          j        v r>t	          j        |         | j                  }t          j                            |          }|t                      	                                 d {V }t          |j                  5  |j        rL|j        pd }|t          j        |<    || j                  }|t          j        |<   |                                 d d d            n# 1 swxY w Y   |S )Nr6   r7   c                z    | j         | j                            ddg          d                             d          fS )Nr   s   defaultr   zutf-8)path	argumentsr   decoders    ri   <lambda>z(DocHandler.get_session.<locals>.<lambda>  sG    afakoo^ehrgsNtNtuvNwN~N~  @G  OH  OH  FI rk   )r8   r   ri  reuse_sessionsrS   _session_key_funcs	_sessionsr   r&  get_sessionrR   r   session_key_funcblock_expiration)r  r8   ri  r   keykey_funcr,  s         ri   rr  zDocHandler.get_session  sf     ######|   	/TU-E%E%E*40>>Co))#..G?!GG//11111111GG,-- / /( /%6   J  <I  <IH5=E,T2"(4<00C+2EOC(,,.../ / / / / / / / / / / / / / / s   'ADDDc                Z  	 | j         }|j        "|j        pg 		fd| j        j        D             n|j        fd| j        j                                        D             }|j        "|j        pg fd| j        j        D             n|j        fd| j        j                                        D             }|rd|v rd|j        pg vr|d= | j        j	        i n| j        j	        }|||d}|
                    | j        j                             | j                             |S )Nc                    g | ]}|v|	S rZ  rZ  ).0headerexcluded_headerss     ri   
<listcomp>z-DocHandler._token_payload.<locals>.<listcomp>  1     B B B&"(0@"@"@  &"@"@"@rk   c                $    i | ]\  }}|v 	||S rZ  rZ  )ry  kvallowed_headerss      ri   
<dictcomp>z-DocHandler._token_payload.<locals>.<dictcomp>  s3     , , ,DAq?** a***rk   c                    g | ]}|v|	S rZ  rZ  )ry  cookieexcluded_cookiess     ri   r|  z-DocHandler._token_payload.<locals>.<listcomp>  r}  rk   c                .    i | ]\  }}|v 	||j         S rZ  )value)ry  r  r  allowed_cookiess      ri   r  z-DocHandler._token_payload.<locals>.<dictcomp>  s5     , , ,$!Q?** ag***rk   Cookie)r   cookiesrj  )r_  include_headersexclude_headersr   r   r   include_cookiesexclude_cookiesr  rj  r   rM  process_request)
r  appr   r  rj  payloadr  r  r  r{  s
         @@@@ri   _token_payloadzDocHandler._token_payload  s   & # 3 9rB B B BDL4H B B BOO "1O, , , ,DL$8$>$>$@$@ , , , & # 3 9rB B B BDL4H B B BOO "1O, , , ,$,*>*D*D*F*F , , ,  	"x7**x@S@YWY/Z/Z!,08BBdl>T	%'	RRt/;KKDLYYZZZrk   c           
       K   | j         }|                                 5  t          j                            | j        j        d           } || j                  t          j        v }|                                  d {V }|rt          j                             || j                            |u rt          | j         j
        | j         j                  }t          |j                  }|                    |                                            |d= t!          ||j
        |j        |j        |          }	n|j        }	t$                              t(          t+          |j                             t/          |j                  5  t1          j        | j                                                   }
t6          j        }d}|rt6          j        }t;          j        |          j        }tA          |          dk    rt          j!        f}n;tA          |          dk    rt          j!        | j        j        f}ntE          d          t          j#         d	}	  || }tI          |tJ                    r.| &                    |           	 d d d            d d d            d S |sd
t          j#         d| j        j         d}|rd }n"# tN          $ r dt          j#         d}Y nw xY wd}|r4tQ          ||
|j        j)        |	|j        j*        |j        j+                  }nt6          j,        rXt[          t6          j,                  5 }t]          j/        |0                                          }d d d            n# 1 swxY w Y   ntb          }|2                    t6          j3        ddd|          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | 4                    dd           | 5                    |           d S )Nc                    | j         S r   )ri  rl  s    ri   rn  z DocHandler.get.<locals>.<lambda>  s
    QRQW rk   )
secret_keysignedsession_expiry)r  r  
expirationextra_payloadFr<   r6   zAuthorization callback must accept either 1) a single argument which is the user name or 2) two arguments which includes the user name and the url path the user is trying to access.z. is not authorized to access this application.z>Authorization callback errored. Could not validate user name "z" for the given app "z".z8Authorization callback errored. Could not validate user r^  T)r   rv   r   r   r   zPanel: Authorization ErrorzAuthorization ErrorzUser is not authorized.)npm_cdnrv   
error_typeerror	error_msgContent-Typez	text/html)6r_  rY  rS   rp  r   r   ri  rq  rr  r.   r  sign_sessionsr/   r   r   r  r-   session_token_expirationr   r   rB   r   r   rR   rM   r  r   r8   authorize_callbackinspect	signature
parametersr   	user_inforc  userr   rc   redirectr   r   rv   r   r   auth_templateopenrN   r   readrK   r   r  
set_headerwrite)r  r   r+  r  rv  old_requestr   r   r  r   r   auth_cb
authorizedauth_params	auth_args
auth_errorpagefr   s                      ri   r   zDocHandler.get  s7     !!## K	 K	/33DL4EGWGWXXH"(4<00EOCK ,,........G &u2288DL3I3IJJgUU0#/:+9  
 ,GM::t2244555,-*"~,";")    KK+R0@-A-ABBBG,-- 5 5%01A1K1K1M1MNN	 3"
 &$7G")"3G"<"<"GK;''1,,%*_$6		[))Q..%*_dl6G$I		*W  
 %*J!^!^!^Jn%,Wi%8
%j#66  MM*555"-5 5 5 5 5 5-K	 K	 K	 K	 K	 K	 K	 K	Z ", !Lafak !L !L6:l6G!L !L !L ' & .)-J$ n n n%m`e`j%m%m%m


n "&J 79G<L<R#g.>.G+2+;+N  DD + 2!&"677 B1'+'7'A'AHB B B B B B B B B B B B B B B $2#?? &:#87", +  D_5 5 5 5 5 5 5 5 5 5 5 5 5 5 5-K	 K	 K	 K	 K	 K	 K	 K	 K	 K	 K	 K	 K	 K	 K	X 	444

4s   E'O	CN2/J?O	#J?>N2?KN2KA N2<'M/#N2/M33N26M37/N2&O	2N6	6O	9N6	:O		OO)r4  r5  r6  r4   rr  r  r   r7  r8  s   @ri   r)   r)     ss            ]$  : O O ]O O O O Ork   r)   z/?c                      e Zd ZdZddZdS )r(   zD Implements a custom Tornado handler for the autoload JS chunk

    rd   r   c                  K   |                      dd           }|s|                     dd           d S |                      dd          }|                      dd           }|r$d	                    t          |          
          }nd }|                                 5  |                                  d {V }t          |j                  5  t          j	        | j
                            |          d          }t          |j        ||j        |||d          }	d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     dd           |                     |	           d S )Nzbokeh-autoload-elementrJ    z)No bokeh-autoload-element query parameter)status_codereasonzbokeh-app-pathrp   rI  z{uri.scheme}://{uri.netloc})rL  Tr   r  zapplication/javascript)rT  
send_errorformatr   rY  rr  rR   r   rM   r  r_  r   r  r   r  r  )
r  r   r+  r  r  r  
server_urlr   r   jss
             ri   r   zAutoloadJsHandler.get[  s     &&'?&NN
 	OO4_O```F$$%5s$CC(()=t(LL 	6==(<BXBX=YYJJJ!!## 		 		 ,,........GG,--  %0$..z::T  	 ($i
lT  	              		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 	(@AAA

2s7   /E AD)E )D-	-E 0D-	1E  EENr3  )r4  r5  r6  re  r   rZ  rk   ri   r(   r(   V  s2              rk   r(   z/autoload.js   c                  "     e Zd ZdZ fdZ xZS )r*   z]
    Custom RootHandler that provides the CDN_DIST directory as a
    template variable.
    c                J    t           |d<    t                      j        |i |S )N	PANEL_CDN)rI   r&  r   r*  s      ri   r   zRootHandler.render  s(    &{uww~t.v...rk   )r4  r5  r6  re  r   r7  r8  s   @ri   r*   r*   y  sB         
/ / / / / / / / /rk   r*   c                  L    e Zd ZdZg dZdddZdd
Zedd            ZddZ	dS )ComponentResourceHandlera=  
    A handler that serves local resources relative to a Python module.
    The handler resolves a specific Panel component by module reference
    and name, then resolves an attribute on that component to check
    if it contains the requested resource path.

    /<endpoint>/<module>/<class>/<attribute>/<path>
    )__css____javascript____js_module____javascript_modules__
_resources_css_jsbase_csscss_stylesheets	modifiersNri  Optional[str]default_filenamec                "    || _         || _        d S r   )r   r  )r  ri  r  s      ri   
initializez#ComponentResourceHandler.initialize  s    	 0rk   rc   rd   c                D  
 |                     d          }t          |          dk     rt          dd          |^}}}}	 t          j        |          }n# t
          $ r t          dd          w xY w	 t          ||          
n# t          $ r t          dd          w xY w|| j        vrt          dd	          	 t          
|          }n# t          $ r t          dd
          w xY w|dk    r4|d         }|dd         }||vrt          dd
          ||         }d| }n$|dk    rd |	                                D             }t          |t                    r"t          |	                                          }n$t          |t          t          j        f          r|g}
fd|D             }d                    |          }	|	|vrt          dd          |j        st          dd          t          t          j        |j                  j        |	z            S )zB
        Resolves the resource the URL pattern refers to.
        rp      r  zMalformed URL  zModule not foundzComponent not found  z"Requested resource type not valid.zResource type not foundr  r   r<   Nz_resources/r  c                n    g | ]2}|                     d g           D ]}t          |t                    |3S )stylesheets)r   r   rc   )ry  rssts      ri   r|  z;ComponentResourceHandler.parse_url_path.<locals>.<listcomp>  s[       "&&PR:S:S 46b#&&   rk   c           	         g | ]D}t          t          |d                                         t          j        j        d          ES )T)relativerp   )rc   rQ   r   osri  sep)ry  resource	components     ri   r|  z;ComponentResourceHandler.parse_url_path.<locals>.<listcomp>  sY     
 
 
 #Ix$GGGHHPPQSQXQ\^abb
 
 
rk   z"Requested resource was not listed.z+Requested module does not reference a file.)rh   r   r1   	importlibimport_moduleModuleNotFoundErrorr   AttributeError_resource_attrsvaluesr   r   r   rc   pathlibPurePathrP  __file__Pathparent)r  ri  partsmodclsrtypesubpathmoduler   r   r  s             @ri   parse_url_pathz'ComponentResourceHandler.parse_url_path  s    

3u::>>C111$)!S%'	5,S11FF" 	5 	5 	5C!3444	5	8,,II 	8 	8 	8C!6777	8 ,,,C!EFFF	<	511II 	< 	< 	<C!:;;;	< L  AJEabbkGI%%%>???!%(I)%))EEk!! &--//  I
 i&& 	$Y--//00II	C)9#:;; 	$"I
 
 
 
%
 
 
	
 88G$$ 9$$C!EFFF 	PC!NOOO7<007(BCCCs$   A A15B B!>C C*r   c                    |S r   rZ  )r  r   ri  s      ri   get_absolute_pathz*ComponentResourceHandler.get_absolute_path  s    rk   absolute_pathc                    t           j                            |          st          d          t           j                            |          st          dd| j                  |S )Nr  r  z%s is not a file)r  ri  existsr1   isfile)r  r   r  s      ri   validate_absolute_pathz/ComponentResourceHandler.validate_absolute_path  sV    w~~m,, 	!C.. w~~m,, 	@C!3TY???rk   )NN)ri  r  r  r  )ri  rc   rd   rc   )r   rc   ri  rc   rd   rc   )r   rc   r  rc   rd   rc   )
r4  r5  r6  re  r  r  r  classmethodr  r  rZ  rk   ri   r  r    s           O
1 1 1 1 1;D ;D ;D ;Dz    [     rk   r  
'Document'c                    ddl m} ddlm t                              t
          t                               j        r> j        j	        } j        j
        } t                     ||          }|j         _         j                                        d S t          j        j        <   j        j                                       	 t%                      }n# t&          $ r d }Y nw xY w |           j        r(t                     t)          j        t,                     g }	  fd}fd}	j        r|	t.          j        j        j        _        t(          j                                       t;           j                  5  t?                    5  tA          j!                  5 } j        "                    |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   fd}
#                    |
           tI          tJ                    _&        t(          j        '                               j!        rc	 j(        j)        j	        }t(          j*        |j!        fxx         |z  cc<   t(          j+        ,                    d	           n# tZ          $ r Y nw xY w| ||           d S d S # t(          j        '                               j!        rc	 j(        j)        j	        }t(          j*        |j!        fxx         |z  cc<   t(          j+        ,                    d	           n# tZ          $ r Y nw xY w| ||           w w xY w)
Nr   )rR   r6   r7   )filenameargvc                     t                      } j        rg | j        _        | ur$t	          j        dj        j        d          d S )Nz at 'z' replaced the output document)r#   
autoreloadr  _modulesrc  _origin_runnerri  )newdocr8   r{   r  s    ri   
post_checkz#modify_document.<locals>.post_check  sb    XXF   -*,' S  "PTP\P\P\^b^j^o^o^o#pqqq ! rk   c           	        ddl m} ddlm} t          j        j        = t          d          r j        j        	                               nj        	                               |t          j        j        j        _        t          j        t!          j                                                  dd                              dd	          }t'          |                              dd                              dd	          } |dt)          |          j         d
| d| dddd                                           d S )Nr   )handle_exceptionr6   )Alertr  z[1mz<b>z[0mz</b>z</b>: z
<pre style="overflow-y: auto">z</pre>dangerr
  stretch_width)
alert_typemarginsizing_mode)"bokeh.application.handlers.handlerr  r   r  sysr  r4  r   r  removebokehr_  handlerscode_runnerr   r   	traceback
format_excr   rc   typeservable)handlerr   r  r  tbe_msgr{   r  s         ri   r  z)modify_document.<locals>.handle_exception  sC   KKKKKK$$$$$$ FO,sI&& ,$++F3333##F+++FVE&2CY13344<<YNNVVW`bhiiB FFNN9e44<<YOOEE_d1gg&__e__UW___#A?   hjjjjjrk   c                b    t                               t          t                               d S r   r   r   s    ri   r   z/modify_document.<locals>._log_session_destroyed7  s$    KK-r#ww77777rk   	_profiles).bokeh.io.docrR   r8   r   r   rD   r   r   r  ri  _argvr  
new_moduler  r  r4  r  appendr#   rc  rS   onloadrG   r  r_  r  r  r  
_launchingr   _loggersr   rF   profilerrunr   r   r#  r  r  r   r   r  r   r   r   )r  r{   bk_set_curdocri  r  r  old_docr   r  r  r   r8   r  s   ``         @@ri   modify_documentr(    s   888888
KK%r#ww/// '| |!$t**d666\$$&&F ~ $*CK K'''((   M# )3'(((H;#
	r 
	r 
	r 
	r 
	r 
	r 
	r	 	 	 	 	 	,  	WFVE&2C$$$T]++ 	9 	9c"" 9 9 11 9XL$$VZ8889 9 9 9 9 9 9 9 9 9 9 9 9 9 99 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9
	8 	8 	8 	8 	8 	  !7888.44$$$? 	*27v 7888HD888##K0000   M'"""""  	$$$? 	*27v 7888HD888##K0000   M'"""" s   C# #C21C22A"K( H$G89G!G8!G%%G8(G%)G8,H8G<	<H?G<	 HK( HK( H7K( 5AK 
KK('NAM"!N"
M/,N.M//Nc                ~    |dk    rdn|}| }||dk    rdn|dz   z  }|j         |t          d|j         ifS |t          i fS )Nrp   z/__patchedrootz/static/(.*)ri  )static_pathr3   r+   )rU  ru  r  routes       ri   create_static_handlerr,  K  s_    !Sjj

cCE	sczz^^s^/CCE
"(6CO*DEE="%%rk   win32)r     r   )   r<   jupyter_serverjupyter_clientpytestTpanels7TViewableFuncOrPath | Mapping[str, TViewableFuncOrPath]addressr  websocket_originOptional[str | list[str]]loopOptional[IOLoop]showr.  verbosethreadedStoppableThread | Serverc                   t          t          d           t          |fi t          |||||||||	|
  
        }|
r|t          d          n|x|d<   }t	          t
          || f|          }|                    dt          j                    j	                  }|t          j        |<   |                                 nt          | fi |S |S )	a  
    Allows serving one or more panel objects on a single server.
    The panels argument should be either a Panel object or a function
    returning a Panel object or a dictionary of these two. If a
    dictionary is supplied the keys represent the slugs at which
    each app is served, e.g. `serve({'app': panel1, 'app2': panel2})`
    will serve apps at /app and /app2 on the server.

    Reference: https://panel.holoviz.org/user_guide/Server_Configuration.html#serving-multiple-apps

    Arguments
    ---------
    panel: Viewable, function or {str: Viewable or function}
      A Panel object, a function returning a Panel object or a
      dictionary mapping from the URL slug to either.
    port: int (optional, default=0)
      Allows specifying a specific port
    address : str
      The address the server should listen on for HTTP requests.
    websocket_origin: str or list(str) (optional)
      A list of hosts that can connect to the websocket.

      This is typically required when embedding a server app in
      an external web site.

      If None, "localhost" is used.
    loop : tornado.ioloop.IOLoop (optional, default=IOLoop.current())
      The tornado IOLoop to run the Server on
    show : boolean (optional, default=True)
      Whether to open the server in a new browser tab on start
    start : boolean(optional, default=True)
      Whether to start the Server
    title: str or {str: str} (optional, default=None)
      An HTML title for the application or a dictionary mapping
      from the URL slug to a customized title
    verbose: boolean (optional, default=True)
      Whether to print the address and port
    location : boolean or panel.io.location.Location
      Whether to create a Location component to observe and
      set the URL location.
    threaded: boolean (default=False)
      Whether to start the server on a new Thread
    admin: boolean (default=False)
      Whether to enable the admin panel
    kwargs: dict
      Additional keyword arguments to pass to Server instance
    T)
rl   r5  r6  r8  r:  r.  rv   r;  rw   ry   NF)make_currentr8  )targetio_loopr   r+  ru   )r   r   r   r0   StoppableThread
get_serverr   uuiduuid4hexrS   _threadsr.  )r3  rl   r5  r6  r8  r:  r.  rv   r;  rw   r<  ry   r+  r   ru   s                  ri   serverH  m  s    @ L$&  D75EE    F
  	,>BlE : : : :PTTv t6)F
 
 
 JJ{DJLL,<==	$*y!&++F+++Mrk   c                       e Zd ZdZddZd ZdS )ProxyFallbackHandlerz\A `RequestHandler` that wraps another HTTP server callback and
    proxies the subpath.
    Nc                "    || _         || _        d S r   fallbackproxy)r  rM  rN  s      ri   r  zProxyFallbackHandler.initialize  s     


rk   c                    | j         r/| j        j                            | j         d          | j        _        |                     | j                   d| _        |                                  d S )NrH  T)rN  r   ri  r   rM  	_finished	on_finishrd  s    ri   preparezProxyFallbackHandler.prepare  s_    : 	J $ 1 9 9$*b I IDLdl###rk   r   )r4  r5  r6  re  r  rR  rZ  rk   ri   rJ  rJ    sA                rk   rJ  c                   g }|                                  D ]\  }}|                    d          sd|z   }|dk    rt          d          t          |          }t          j                            |          st          d|z            |                    d|z  t          d|if           |                    dt           dt          i f           |S )zy
    Returns a list of tornado routes of StaticFileHandlers given a
    dictionary of slugs and file paths to serve.
    rp   z/staticzHStatic file route may not use /static this is reserved for internal use.z!Cannot serve non-existent path %sz%s/(.*)ri  z(.*))r   rg   
ValueErrorr:   r  ri  isdirr   r3   rJ   r  )static_dirspatternsslugri  s       ri   get_static_routesrY    s   
 H!'')) 
 

ds## 	:D9 B C C C~~w}}T"" 	I@4GHHH$ 1FD>B	
 	
 	
 	
 OO N   ":B    Ork   rV  Mapping[str, str]
basic_authoauth_provider	oauth_keyoauth_secretoauth_redirect_urioauth_extra_paramsoauth_error_templatecookie_secretoauth_encryption_keyoauth_jwt_useroauth_refresh_tokensOptional[bool]oauth_guest_endpointsoauth_optionallogin_endpointlogout_endpointlogin_templatelogout_templater   Optional[int]liveness
bool | strc                  678 ddl m 6 ddlm}  |                    dt	          j                    j                  }!|                    dg           x|d<   }"t          | t                    rPi }#| 
                                D ]7\  }$}%|$                    d          r|$dk    st          d|$d	          t          |t                    r+	 ||$         }&n## t          $ r t          d
|$ d          w xY w|}&|$                    d          r|$nd|$z   }$dt          j        v rddlm}' t          |%|'          rrt'          |%          }(|$dk    rt          d          |$                    d          s|$dz  }$|"                    d|$z   dz   t*          t          |(|$          f           (t          |%t,          j                  rt1          |%          }%t          |%t0                    r{|%                    d          s*|%                    d          s|%                    d          r<t2          j                            |%          rt9          |%          x|#|$<   }%|
|%_        t          |%t<                    r|%|#|$<   t?          tA          tB          |%|!|&|	|
                    })tE          |)|
          |#|$<   9nt          | t,          j                  rt1          |           } t          | t0                    rp|                     d          s*|                     d          s|                     d          r1t2          j                            |           rdt9          |           i}#n9t?          tA          tB          | |!||	|
                    })dtE          |)|
          i}#|
r:d|#v rt          d          ddl#m$}* t?          |*          }+tE          |+          |#d<   |"tK          |          z  }"||6_&        6j&        dk    rC | d         g d          },|"'                    |,           tQ          j)        dtP          dg           |r8t          |tT                    rdn|}-|"d|-z  tV          t          |#           fgz  }"t          |          }.|rtY          j-        |j.                   ||.d!<   n0|.                    d"d          dk    rt_          j0                    |.d!<   d#|.vr
tb          |.d#<   |||.d$<   |rt          |td                    s|g}||.d%<   ddl m 6 i }/|                    d&|          }s|r.dd'l3m4}0m5}1 r|/d(<   |0}2n	|6_6        |1}2 |2||||)          |.d*<   |r|6_7        |r|6_8        |r|6_9        |r|6_:        |r|6_;        ||6_<        ||6_=        ||6_>        ||6_?        6j:        |.d+<   t          |#fd,|i|.8|r/8jA        pd-}d.| d/8jB         8jC         }3t          d0|3            8| g ftP          jE        |!<   |/tP          jF        8jG        <   |r&pd168fd2}48jH        I                    |4           78fd3}58fd47	 t          jJ        t          jK        |5           n# t          $ r Y nw xY w|rY8L                                 	 8jH        L                                 n*# t          $ r Y nt          $ r t          d5           Y nw xY w8S )6a  
    Returns a Server instance with this panel attached as the root
    app.

    Arguments
    ---------
    panel: Viewable, function or {str: Viewable}
      A Panel object, a function returning a Panel object or a
      dictionary mapping from the URL slug to either.
    port: int (optional, default=0)
      Allows specifying a specific port
    address : str
      The address the server should listen on for HTTP requests.
    websocket_origin: str or list(str) (optional)
      A list of hosts that can connect to the websocket.

      This is typically required when embedding a server app in
      an external web site.

      If None, "localhost" is used.
    loop : tornado.ioloop.IOLoop (optional, default=IOLoop.current())
      The tornado IOLoop to run the Server on.
    show : boolean (optional, default=False)
      Whether to open the server in a new browser tab on start.
    start : boolean(optional, default=False)
      Whether to start the Server.
    title : str or {str: str} (optional, default=None)
      An HTML title for the application or a dictionary mapping
      from the URL slug to a customized title.
    verbose: boolean (optional, default=False)
      Whether to report the address and port.
    location : boolean or panel.io.location.Location
      Whether to create a Location component to observe and
      set the URL location.
    admin: boolean (default=False)
      Whether to enable the admin panel
    static_dirs: dict (optional, default={})
      A dictionary of routes and local paths to serve as static file
      directories on those routes.
    basic_auth: str (optional, default=None)
      Password or filepath to use with basic auth provider.
    oauth_provider: str
      One of the available OAuth providers
    oauth_key: str (optional, default=None)
      The public OAuth identifier
    oauth_secret: str (optional, default=None)
      The client secret for the OAuth provider
    oauth_redirect_uri: Optional[str] = None,
      Overrides the default OAuth redirect URI
    oauth_jwt_user: Optional[str] = None,
      Key that identifies the user in the JWT id_token.
    oauth_extra_params: dict (optional, default={})
      Additional information for the OAuth provider
    oauth_error_template: str (optional, default=None)
      Jinja2 template used when displaying authentication errors.
    cookie_secret: str (optional, default=None)
      A random secret string to sign cookies (required for OAuth)
    oauth_encryption_key: str (optional, default=None)
      A random encryption key used for encrypting OAuth user
      information and access tokens.
    oauth_guest_endpoints: list (optional, default=None)
      List of endpoints that can be accessed as a guest without authenticating.
    oauth_optional: bool (optional, default=None)
      Whether the user will be forced to go through login flow or if
      they can access all applications as a guest.
    oauth_refresh_tokens: bool (optional, default=None)
      Whether to automatically refresh OAuth access tokens when they expire.
    login_endpoint: str (optional, default=None)
      Overrides the default login endpoint `/login`
    logout_endpoint: str (optional, default=None)
      Overrides the default logout endpoint `/logout`
    logout_template: str (optional, default=None)
      Jinja2 template served when viewing the login endpoint when
      authentication is enabled.
    logout_template: str (optional, default=None)
      Jinja2 template served when viewing the logout endpoint when
      authentication is enabled.
    session_history: int (optional, default=None)
      The amount of session history to accumulate. If set to non-zero
      and non-None value will launch a REST endpoint at
      /rest/session_info, which returns information about the session
      history.
    liveness: bool | str (optional, default=False)
      Whether to add a liveness endpoint. If a string is provided
      then this will be used as the endpoint, otherwise the endpoint
      will be hosted at /liveness.
    kwargs: dict
      Additional keyword arguments to pass to Server instance.

    Returns
    -------
    server : panel.io.server.Server
      Bokeh Server instance running this panel
    r6   r7   r<   )REST_PROVIDERSru   extra_patternsrp   z)Invalid URL: trailing slash '/' used for z not supported.zGKeys of the title dictionary and of the apps dictionary must match. No z# key found in the title dictionary.flaskr   )Flaskz'Flask apps must be served on a subpath.^z.*rL  z.pyz.ipynbz.md)ry   z/adminzTCannot enable admin panel because another app is being served on the /admin endpoint)admin_panelNr   restr   rn  z/%s)applicationsrA  	num_procsindexr5  allow_websocket_originbasic_login_template)BasicAuthProviderOAuthProviderr[  )ri  rj  rk  rl  error_templater`  rb  rl   	localhostzhttp://ro   zLaunching server at z/loginc                 H                         j        s rnd           d S )Nrp   )r:  r\  )r[  r8   ri  r   s   ri   show_callbackz!get_server.<locals>.show_callback  s-    KK&*?V:VSVWWWWWrk   c                 <    j                                        d S r   )rA  add_callback_from_signal)r   r+  do_stopr   s     ri   sig_exitzget_server.<locals>.sig_exit  s    //88888rk   c                 :    j                                          d S r   )rA  r  )r   r+  r   s     ri   r  zget_server.<locals>.do_stop  s    rk   z_IOLoop couldn't be started. Ensure it is started by process invoking the panel.io.server.serve.)Pr8   rw  rq  r;  rD  rE  rF  r   r   r   r   rO  rT  KeyErrorrg   r  r  rs  rt  r5   r   rJ  r  r  rc   r  ri  r  rE   r   BkApplicationr   r   r   r   ry   rv  rY  r   extendrS   publishrz   r@   asyncioset_event_loopr   r0   r   
INDEX_HTMLr   authr}  r~  r\  r]  r^  r`  rb  r_  re  rh  rg  rd  r%   r5  rl   rU  print_servers_server_config_tornadorA  r   signalSIGINTr.  rc  	TypeErrorr;   )9rs   rl   r5  r6  r8  r:  r.  rv   r;  rw   ry   rV  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rg  rh  ri  rj  rk  rl  r   rn  r+  rq  ru   rr  appsrX  r  title_rt  wsgir  rv  admin_handlerpatternliveness_endpointoptsserver_configr}  r~  providerrb   r  r  r8   r  r   s9               `            `                            @@@ri   rC  rC    s   @  $$$$$$

;
(899I06

;KR0P0PPF~% .< #	? #	?ID#}}S!! f$#++ !dT!d!d!deee%&& 	-"4[FF - - -",59, , ,- - -- ??3//=44SXD#+%%''''''c5)) (--Ds{{()RSSS==-- $"))3t8D=:N+/T+J+J+J+L M M M#w|,, #hh3$$ ?#,,u*=*= ?hAWAW ?[^[g[ghm[n[n ?GNN3''?#CC#H#HHT
S"

C// ? T

)'+sIvW_af*g*ghh(>>>T

G#	?J eW\** 	JJEuc"" 	<u(=(= 	<PXAYAY 	<]b]k]klq]r]r 	<u%%	<9%@@ADD%gk5)UT\^c&d&deeGWE:::;D 4t)   	'&&&&&'44$]33X'444N"!0"").)"f55g&&&nen-=>>> c*4Xt*D*DRJJ(F%66[_I`I`I`abb<<D +t0111Y	+q	!	!Q	&	& .**Yd"W!Y :*D11 	2 01)9%&  MZZ 6GGN 
^ 
;;;;;;;; 	%*4M,'(HH$2F!$H ()+)+/!
 !
 !
_  %$ +* 7$6! -, 7$6!'&:#! .('<$! ."0DD,,t,t,,F ,./K>>>&+>v}>>*S**+++!' 3EN9,9E) 3'38	X 	X 	X 	X 	X 	X 	X 	X##M2229 9 9 9 9 9    fmX....     
	N  """" 	 	 	D 	 	 	>    	
 Ms6   CC6Y> >
Z
Z%Z? ?
[&[&%[&c                  4     e Zd ZdZd	 fdZd
dZd
dZ xZS )rB  z"Thread class with a stop() method.rA  r0   c                H     t                      j        di | || _        d S )NrZ  )r&  r'  rA  )r  rA  r+  r,  s      ri   r'  zStoppableThread.__init__  s+    ""6"""rk   rd   r   c                   t          | d          r| j        | j        | j        }}}n| j        | j        | j        }}}|sd S d }	  ||i |}t          |t                    r&	 |	                                 n# t          $ r Y nw xY wt          | d          r| `| `| `d S | `| `| `d S # t          |t                    r&	 |	                                 n# t          $ r Y nw xY wt          | d          r| `| `| `n| `| `| `w xY w)N_target)r   r  _args_kwargs_Thread__target_Thread__args_Thread__kwargsr   r%   r  r   )r  r@  r   r+  bokeh_servers        ri   r%  zStoppableThread.run  s   4## 	b#'<T\&DFF#'#79KTMa&DF 	F	S!642622L,//  %%''''    DtY'' SL$*dlll($*<d>R>R>R ,//  %%''''    DtY'' SL$*dll($*<d>RRRRRsB   B& !A6 6
BB&D =CD 
CD C!D c                N    | j                             | j         j                   d S r   )rA  r   r  rd  s    ri   r  zStoppableThread.stop1  s#    !!$,"344444rk   )rA  r0   r3  )r4  r5  r6  re  r'  r%  r  r7  r8  s   @ri   rB  rB    so        ,,     S S S S*5 5 5 5 5 5 5 5rk   rB  )rb   rc   rd   rc   )rb   rc   rl   rm   rd   rc   )rs   rt   ru   rc   rv   rc   rw   rx   ry   rz   r{   rW   )r   r   rd   r   )r   r   )r   r   r   r   r   r   rv   rc   r   r   r   r   rd   rc   )r   r   r   r   rv   rc   r   r   r   r   r   r   rd   rc   )F)r{   r  )r   NNNTTNTTFF)r3  r4  rl   rm   r5  r  r6  r7  r8  r9  r:  rz   r.  rz   rv   r  r;  rz   rw   rz   r<  rz   ry   rz   rd   r=  )@rs   r4  rl   rm   r5  r  r6  r7  r8  r9  r:  rz   r.  rz   rv   rz   r;  rz   rw   rx   ry   rz   rV  rZ  r[  rc   r\  r  r]  r  r^  r  r_  r  r`  rZ  ra  r  rb  r  rc  r  rd  r  re  rf  rg  rf  rh  rf  ri  r  rj  r  rk  r  rl  r  r   rm  rn  ro  rd   r%   )re  
__future__r   r  r   r   r  r   r  r  loggingr  r  r  r  	threadingr  rD  r  collectionsr   
contextlibr   	functoolsr   r   r   typesr	   r
   typingr   r   r   r   r   r   r   urllib.parser   r   r  bokeh.command.utilr   tornadobokeh.applicationr   r  bokeh.application.handlers.coder   r   r   #bokeh.application.handlers.functionr   bokeh.core.json_encoderr   bokeh.core.templatesr   r   r   bokeh.core.validationr   bokeh.core.validation.warningsr   bokeh.embed.bundler   bokeh.embed.elementsr    bokeh.embed.utilr!   bokeh.embed.wrappersr"   bokeh.ior#   bokeh.modelsr$   bokeh.server.serverr%   BokehServerbokeh.server.urlsr&   r'   &bokeh.server.views.autoload_js_handlerr(   BkAutoloadJsHandlerbokeh.server.views.doc_handlerr)   BkDocHandlerbokeh.server.views.root_handlerr*   BkRootHandler!bokeh.server.views.static_handlerr+   bokeh.util.serializationr,   bokeh.util.tokenr-   r.   r/   tornado.ioloopr0   tornado.webr1   r2   r3   r4   tornado.wsgir5   r8   utilr9   r:   util.warningsr;   r   r=   r>   r?   rn  r@   loadingrA   rB   rC   rD   markdownrE   profilerF   reloadrG   r   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rS   rR   	getLoggerr4  r   bokeh.bundlerT   bokeh.core.typesrU   bokeh.document.documentrV   rW   bokeh.server.contextsrX   bokeh.server.sessionrY   jinja2rZ   template.baser\   viewabler]   r^   rw   r_   	TViewablePathLikerc   rt   ri  rP  dirnamer  r  r   rj   rr   r   r   parameterizedasync_executorr   r>  r   r   r   r  r#  r   commandrF  r\  r  r(  r,  platformversion_infor  get_event_loop_policyWindowsSelectorEventLoopPolicyr  set_event_loop_policyWindowsProactorEventLoopPolicyrH  rJ  rY  rC  ThreadrB  rZ  rk   ri   <module>r     s    # " " " " "      				        				   



           # # # # # # % % % % % % $ $ $ $ $ $ $ $       * * * * * * * *                  + * * * * * * *        ; : : : : :          @ ? ? ? ? ? 2 2 2 2 2 2 : : : : : : : : : : ) ) ) ) ) ) 7 7 7 7 7 7 % % % % % % 8 8 8 8 8 8 ' ' ' ' ' ' 3 3 3 3 3 3       ! ! ! ! ! ! 5 5 5 5 5 5 A A A A A A A A      F E E E E E H H H H H H ; ; ; ; ; ; , , , , , ,          " ! ! ! ! !            ' & & & & &       * * * * * * * *             3 3 3 3 3 3 3 3 3 3 % % % % % % 0 0 0 0 0 0          7 6 6 6 6 6             & & & & & &                        % $ $ $ $ $ $ $		8	$	$ V############99999999999999222222,,,,,,++++++++""""""h45I	8B	M+BBKQT TU W\\"'//(33T<VV
#   
A A A A   <1 1 1 1> &3  "( ( ( (,  " ) )*B C C C SW)+< < < < <D ,37+ + + + +\C C C C$ $ $N3 3 3 3 3[ 3 3 3" $  R R R R R- R R R* "-  ) ) ) ) ) ) ) )4r r r r r r r r&B B B B B.B B B BH j)      +-A   B '(9:  / / / / /- / / / {+ ! #.   Y Y Y Y Y0 Y Y Yxc# c# c# c#J . & & & .C  * LGRaRI%%F""D	&	&	(	())W-SSSck))ck))!G!"H'"H"J"JKKK !26!P P P P Pf    >   "  2 !26! $%'$(#"&(,,.*.#'*.$(+/,0%)$(%)$(%)%) ?j j j j jZ	5 5 5 5 5i& 5 5 5 5 5rk   