
    DhA                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
Jr  S SKJr  S SKJr   S SKJr  S SKJrJrJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKrS SKr\" SS9r Sr!\S   r#S\$4S jr%\&S S S 4S jr'0 r(0 r)S r*S r+SS jr, " S S5      r-\-" 5       r.g! \" a
    Sr!Sr S r NHf = f)    N)Optional)Literal)make_server)get_ipython)IFramedisplay
Javascript)HTML)FormattedTB)retry)Commdash)target_nameTFc                      g N r       `C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\dash/_jupyter.py<lambda>r   #   s    $r   )inlineexternal
jupyterlabtab_noneerrorc                     SSK Jn  U R                  nSnUR                  bE  US-  nUR                  nUR                  R
                  UR                  L a  U$ UR                  b  ME  U$ )Nr   )_invoke_callback   )dash._callbackr   __traceback__tb_nexttb_framef_code__code__)r   r   tbskips       r   	_get_skipr'   (   sf     
		BD
**
 	ZZ;;!1!:!::K	 **
  Kr   c                     SU -   $ )N*r   names    r   r   r   >   s    sTzr   c                     SU -   $ )Nz**r   r*   s    r   r   r   ?   s    TD[r   c                     S[        U 5      -   $ )N=)repr)values    r   r   r   @   s    cDK/r   c                    X4U4S jn/ n	[        [        U 5      5       H  n
U	R                  U" X
   5      5        M     U(       a"  U	R                  U" U5      U" X1   5      -   5        U(       a"  U	R                  U" U5      U" X2   5      -   5        SSR                  U	5      -   S-   n[        U5      S:  a  U$ SSR                  U	5      -   S-   $ )	z[Copied from inspect.formatargvalues, modified to place function
arguments on separate linesc                 (    U" U 5      U" X   5      -   $ r   r   )r+   locals	formatargformatvalues       r   convert(_custom_formatargvalues.<locals>.convertG   s    V\!:::r   (z, )(   z(
    z,
    z
))rangelenappendjoin)argsvarargsvarkwr3   r4   formatvarargsformatvarkwr5   r6   specsiresults               r   _custom_formatargvaluesrG   8   s     $k ; E 3t9WTW%& ]7+k&/.JJK['+fm*DDE499U##c)F
6{Ry~~e,,u44r   c                      [        5       bO  [        R                  b=  [        R                  R                  5       [        S'   [        R                  SS05        g g g )Nparenttypebase_url_request)r   
_dash_commkernel
get_parent_callersendr   r   r   !_send_jupyter_config_comm_requestrQ   a   sM     } ( * 1 1 < < >GHOOV%789 ) !r   c                       [        [        5      $ r   )bool_jupyter_configr   r   r   _jupyter_comm_response_receivedrU   j   s      r   c                 f  ^	 [         R                  c  g [        5         [        5       nUR                  n/ m	U	4S jnX2R                  S'   U=R
                  S-  sl        [        R                  " 5       n [        R                  " 5       U-
  U :  a  [        S5      e[        5       (       a  O[        R                  " UR                  5      (       aK  [        R                  " 5       n[        R                  " U5        UR                  UR                  5       5        OUR                  5         M  UR                   UR                  S'   ["        R$                  R'                  5         ["        R(                  R'                  5         T	 H)  u  pgnUR+                  Xx5        UR!                  XgU5        M+     g )Nc                 ,   > TR                  XU45        g r   )r=   )streamidentrI   captured_eventss      r   capture_event._request_jupyter_config.<locals>.capture_event}   s    v67r   execute_requestr   zvUnable to communicate with the jupyter_dash notebook or JupyterLab 
extension required to infer Jupyter configuration.)rL   rM   rQ   r   shell_handlersexecution_counttimeEnvironmentErrorrU   asyncioiscoroutinefunctiondo_one_iterationget_event_loopnest_asyncioapplyrun_until_completer]   sysstdoutflushstderr
set_parent)
timeoutshellrM   r[   t0looprX   rY   rI   rZ   s
            @r   _request_jupyter_configrr   n   sc    %' ME\\F O8 0=+, 
Q 
B
IIK"'"E  +,,&&v'>'>??))+Dt$##F$;$;$=>##% & 06/E/EF+,
 JJJJ!0v 	%(vf5	 "1r   c                       \ rS rSr% SrSr\\S'   \" \	R                  " 5       5      rSr\\S'   0 rS rS r      SS
\\   4S jjr\S 5       r\S 5       r\S 5       rS r\S 5       rSrg	)JupyterDash   z3
Interact with dash apps inside jupyter notebooks.
r   default_modeTinline_exceptionsc                 ^    U R                   (       a  U R                  (       a  g[        5         g)a  
Infer the current Jupyter server configuration. This will detect
the proper request_pathname_prefix and server_url values to use when
displaying Dash apps.Dash requests will be routed through the proxy.

Requirements:

In the classic notebook, this method requires the `dash` nbextension
which should be installed automatically with the installation of the
jupyter-dash Python package. You can see what notebook extensions are installed
by running the following command:
    $ jupyter nbextension list

In JupyterLab, this method requires the `@plotly/dash-jupyterlab` labextension. This
extension should be installed automatically with the installation of the
jupyter-dash Python package, but JupyterLab must be allowed to rebuild before
the extension is activated (JupyterLab should automatically detect the
extension and produce a popup dialog asking for permission to rebuild). You can
see what JupyterLab extensions are installed by running the following command:
    $ jupyter labextension list
N)
in_ipythonin_colabrr   )selfs    r   infer_jupyter_proxy_config&JupyterDash.infer_jupyter_proxy_config   s    , $--!r   c                     [        5       S LU l        S[        R                  ;   U l        [
        (       a5  U R                  (       a#  [        (       a  [        R                  S 5       ng g g g )Nzgoogle.colabc                 x   [         R                  S5      nU(       aP  U[        R                  R	                  5       :w  a.  [        R                  R                  US   S   /U5        [         S	 U R                  S5      R                  S5      nUR                  SS 5      nUS:X  a  [        R                  U5        g g )NrI   headersessioncontentdatarJ   base_url_response)rO   getrL   rM   rN   rm   rT   update)msgprev_parentmsg_datamsg_types       r   _receive_message.JupyterDash.__init__.<locals>._receive_message   s    %kk(3;*2C2C2N2N2P#P%%00$X.y9:K  )779-11&9#<<522#**84 3r   )r   ry   ri   modulesrz   _dep_installedrL   on_msg)r{   r   s     r   __init__JupyterDash.__init__   sP    %-t3&#++5>doo**5 5 3=o>r   Nmodec                   ^^^^^^ U R                   (       a  SS/nO/ SQnUc  U R                  nO^[        U[        5      (       d#  [	        S[        U5       S[        U5       35      eUR                  5       nX(;  a  [	        SU SU 35      eU R                  R                  TT45      n	U	(       a  U	R                  5         U R                  TT4	 S	[        ;   a  [        S	   R                  S
5      S-   n
OUR                  R                  SS5      n
U
b  U
R                  TS9n
OS
n
UR                  R                  SS
5      n[        R!                  UR                  SU
5        UcY  S[        ;   a  [        S   R                  S
5      nOG["        R$                  R                  SS5      nU(       a  SU-   nOST ST 3nOUR                  S
5      nU U
 3n SSKn[*        R,                  " 5       m[/        TTUR0                  SSS9m[2        R4                  " S5      R7                  [2        R8                  5        [;        SSSS9UU4S j5       n[<        R>                  " US9nSUl         URC                  5         TU R                  TT4'   ST ST U S[D        RF                   3mU4S jm[;        SS SS9UUUU4S! j5       n U" 5         U R                   (       a  [D        RI                  UTX#U5        g[D        RK                  UTX#U5        g! [(         a     GN@f = f! [L         aA  n[        U5      nURO                  S"5      (       a  [Q        [S        U5      5         SnAgUeSnAff = f)#a  
:type app: dash.Dash
:param mode: How to display the app on the notebook. One Of:
    ``"external"``: The URL of the app will be displayed in the notebook
        output cell. Clicking this URL will open the app in the default
        web browser.
    ``"inline"``: The app will be displayed inline in the notebook output cell
        in an iframe.
    ``"jupyterlab"``: The app will be displayed in a dedicate tab in the
        JupyterLab interface. Requires JupyterLab and the `jupyterlab-dash`
        extension.
:param width: Width of app when displayed using mode="inline"
:param height: Height of app when displayed using mode="inline"
:param host: Host of the server
:param port: Port used by the server
:param server_url: Use if a custom url is required to display the app.
r   r   )r   r   r   r   r   Nz>The mode argument must be a string
    Received value of type z: zInvalid display argument z
    Valid arguments: base_subpath/z/proxy/{port}/requests_pathname_prefix)portroutes_pathname_prefix
server_urlDASH_DOMAIN_BASEzhttps://http://:r   T)threaded	processeswerkzeug   d   i  )stop_max_attempt_numberwait_exponential_multiplierwait_exponential_maxc                     >  TR                  5         g ! [         a     g [         a  n TR                  U 5        U eS n A ff = fr   )serve_forever
SystemExit	Exceptionput)r   err_qservers    r   run JupyterDash.run_app.<locals>.runS  s@    $$&  		% s    
A	A<A)target_alive_c                  n   >  TR                  5       n U (       a  U eg ! [        R                   a     g f = fr   )
get_nowaitqueueEmpty)errr   s    r   
_get_error'JupyterDash.run_app.<locals>._get_errorj  s9    &&(I ;; s    44
   c                  0  > T" 5          [         R                  " T5      n U R                  R                  5       nU R                  S:w  a  [        U5      eUS:w  a  ST ST 3n[        SU S35      eg ! [         R                   a  nT" 5         UeS nAff = f)N   Aliver   r   z	Address 'z:' already in use.
    Try passing a different port to run.)requestsr   r   decodestatus_coder   OSErrorConnectionError)reqresurlr   r   	alive_urlhostr   s       r   wait_for_app)JupyterDash.run_app.<locals>.wait_for_apps  s     Lll9-kk((*??c)#C.('>#D64&1C!#C5 )C C  " ++ 	s   A(A3 3B	BBz<!)*rz   rv   
isinstancestr
ValueErrorrJ   r/   lower_serversr   shutdownrT   rstripconfigformatdict__setitem__osenvironorjsonImportErrorr   Queuer   r   logging	getLoggersetLevelERRORr   	threadingThreaddaemonstartrt   alive_token_display_in_colab_display_in_jupyterr   
startswithr   r
   )r{   appr   widthheightr   r   r   valid_display_values
old_serverr   r   domain_basedashboard_urlr   r   threadr   final_errorr   r   r   r   r   s        ``             @@@@r   run_appJupyterDash.run_app   sa   8 ==$,j#9 #W <$$DD#&&..24j\DJ<I 
 ::<D/ /v 6,,@+AC  ]]&&d|4
!tTl+ _,/66s;>NN % (+zz~~6PRV'W$#/'?'F'FD'F'Q$'*$!$0H#!N 	JJ24L	

 .,\:AA#F
 jjnn-?F!+k!9J#*4&$!8J#**3/J &,'?&@A
	 T4daP*%..w}}=	$&(+!%


	


	 !!-&,tTl# dV1TF+A*B'+JaJaIbc		 
$&(*!%


	


	$	"N}}--mT4PVW//!4fK  		P  	"k"C~~d##S	""!!	"s6   L 0L" 8L" 
LL"
M-,5M(&M((M-c                     SSK Jn  US:X  a  UR                  XUS9  g US:X  a  [        S5        UR	                  XS9  g g )Nr   )outputr   )r   r   r   zDash app running on:)anchor_text)google.colabr   serve_kernel_port_as_iframeprintserve_kernel_port_as_window)r   r   r   r   r   r   s         r   r   JupyterDash._display_in_colab  sK     	(8..t.PZ ()..t.O	  r   c                     US:X  a  [        [        XU5      5        g US;   a.  [        SU  35        US:X  a  [        [        SU  S35      5        g g US:X  a  [        R                  SUU S	.5        g g )
Nr   )r   r   zDash app running on r   zwindow.open('z')r   show)rJ   r   r   )r   r   r   r	   rL   rP   )r   r   r   r   r   s        r   r   JupyterDash._display_in_jupyter  s}    8F=89(((89u}
]=/#DEF \! OO" ( "r   c                      g)Nr   r   r   r   r   serve_aliveJupyterDash.serve_alive  s    r   c                 Z   ^ ^ UR                   R                  [        5      UU 4S j5       ng)z(Install traceback handling for callbacksc                 T  > T(       a  [        U 5      OSn[        R                  n[        [        l         [        R
                  " 5       n[        USSSUS9nU" 5         U[        l        UR                  5       nTR                  (       a  [        U5        US4$ ! U[        l        f = f)Nr   VerboseNoColorT)	tb_offsetr   color_schemeinclude_varsostreami  )
r'   inspectformatargvaluesrG   ioStringIOr   getvaluerw   r   )r   r&   original_formatargvaluesr  ipytb
stacktracedev_tools_prune_errorsr{   s         r   _wrap_errorsGJupyterDash.configure_callback_exception_handling.<locals>._wrap_errors  s     (>9U#1D (/'>'>$&=G#C++-#""!*!%#  +C' ))+J%%j!s?" +C's   )B B'N)r   errorhandlerr   )r{   r   r  r  s   ` ` r   %configure_callback_exception_handling1JupyterDash.configure_callback_exception_handling  s&     
	 	 	+	# 
,	#r   c                     S[         R                  ;   n[        =(       a-    U(       + =(       a    U R                  =(       d    U R                  $ )NDATABRICKS_RUNTIME_VERSION)r   r   r   ry   rz   )r{   _inside_dbxs     r   activeJupyterDash.active  s/    2bjj@Xk/Xt7W$--Xr   )rz   ry   )Nz100%i  z	127.0.0.1ir  N)__name__
__module____qualname____firstlineno____doc__rv   JupyterDisplayMode__annotations__r   uuiduuid4r   rw   rS   r   r|   r   r   r   staticmethodr   r   r   r  propertyr  __static_attributes__r   r   r   rt   rt      s     (0L$/djjl#K"t"H"850 .2r" )*r"h 
P 
P  &   #D Y Yr   rt   )   )/rb   r  r  r   r   r   r  ri   r   r`   typingr   typing_extensionsr   werkzeug.servingr   IPythonr   IPython.displayr   r   r	   IPython.core.displayr
   IPython.core.ultratbr   retryingr   ipykernel.commr   rf   r   rL   r   r   r  r   r'   r   rG   rT   rO   rQ   rU   rr   rt   jupyter_dashr   r   r   <module>r.     s     	   	   
    % (#;;)0#&)JN OP Y * )(/!5H 
:!96xzY zYz	 }O  NJKs   8B- -B=<B=