
    6Dh                         S SK Jr  S SKrS SKJrJrJrJr  S SKJ	r	  SSK
JrJr  SSKJrJrJrJr  SSKJr  S SKr " S	 S
\\R*                  5      rg)    )deepcopyN)ListDictobserveInteger) display_jupyter_version_warnings   )
BaseFigureBasePlotlyType)BoxSelectorLassoSelectorInputDeviceStatePoints)custom_serializersc                     ^  \ rS rSrSr\R                  " \5      R                  S-  S-  r	\
" 5       R                  " S'SS0\D6r\" 5       R                  " S'SS0\D6r\
" 5       R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\
" SS9R                  " S'SS0\D6r\ " S5      R                  SS	9r!\ " S5      R                  SS	9r"Sr#S
r$ S+U 4S jjr%S r&S,S jr'S-S jr(S r)S r* S-S jr+S r,S r-\." S5      S 5       r/\." S5      S 5       r0\." S5      S 5       r1\." S5      S 5       r2\." S5      S 5       r3\." S5      S 5       r4S  r5S.S! jr6S" r7S# r8\9S$ 5       r:\:Rv                  S% 5       r:\<S& 5       r=\<S/S( j5       r>\<S0S) j5       r?S*r@U =rA$ )1BaseFigureWidget   zU
Base class for FigureWidget. The FigureWidget class is code-generated as a
subclass
package_datazwidgetbundle.jssyncT)
allow_noner   )r   Fc                 R  > [         [        U ]
  " SUUUUS.UD6  U R                  (       a  [        R	                  5         SU l        SU l        / U l        SU l        SU l	        SU l
        [        U R                  R                  5      U l        [        U R                  5      U l        g )N)datalayout_plotlyframesskip_invalidr   F )superr   __init___frame_objs_display_frames_error_last_layout_edit_id_layout_edit_in_process_waiting_edit_callbacks_last_trace_edit_id_trace_edit_in_process_view_countr   _layout_obj_props_widget_layout_data_widget_data)selfr   layoutr   r   kwargs	__class__s         C/var/www/html/env/lib/python3.13/site-packages/plotly/basewidget.pyr   BaseFigureWidget.__init__Z   s     	. 	
 %		

 	
 224 %&!
 (-$
 (*$ $% 
 ',#  't'7'7'>'>?$TZZ0    c                     U $ Nr   )r,   argsr.   s      r0   showBaseFigureWidget.show   s    r2   c                 b    U R                   S-   nX0l         SU l        UUUS.nX@l        SU l        g)a:  
Send Plotly.relayout message to the frontend

Parameters
----------
layout_data : dict
    Plotly.relayout layout data
source_view_id : str
    UID of view that triggered this relayout operation
    (e.g. By the user clicking 'zoom' in the toolbar). None if the
    operation was not triggered by a frontend view
r	   T)relayout_datalayout_edit_idsource_view_idN)r!   r"   _py2js_relayout)r,   layout_datar;   r:   msg_datas        r0   _send_relayout_msg#BaseFigureWidget._send_relayout_msg   sD     22Q6$2!'+$
 ),,
  (#r2   c                     U R                  U5      nU R                  S-   nX@l        SU l        U R                  S-   nXPl        SU l        UUUUUS.nX`l        SU l        g)a  
Send Plotly.restyle message to the frontend

Parameters
----------
restyle_data : dict
    Plotly.restyle restyle data
trace_indexes : list[int]
    List of trace indexes that the restyle operation
    applies to
source_view_id : str
    UID of view that triggered this restyle operation
    (e.g. By the user clicking the legend to hide a trace).
    None if the operation was not triggered by a frontend view
r	   T)restyle_datarestyle_tracestrace_edit_idr:   r;   N)_normalize_trace_indexesr!   r"   r$   r%   _py2js_restyle)r,   rB   trace_indexesr;   r:   rD   restyle_msgs          r0   _send_restyle_msg"BaseFigureWidget._send_restyle_msg   sz    & 55mD 22Q6$2!'+$0014#0 &*#
 )+*,,
 *"r2   c                     U R                   S-   nX l         SU l        U R                  S-   nX0l        SU l        UUUS.nX@l        SU l        g)z
Send Plotly.addTraces message to the frontend

Parameters
----------
new_traces_data : list[dict]
    List of trace data for new traces as accepted by Plotly.addTraces
r	   T)
trace_datarD   r:   N)r!   r"   r$   r%   _py2js_addTraces)r,   new_traces_datar:   rD   add_traces_msgs        r0   _send_addTraces_msg$BaseFigureWidget._send_addTraces_msg   sb     22Q6$2!'+$0014#0 &*#
 **,
 !/ $r2   c                 &    XS.nX0l         SU l         g)z
Send Plotly.moveTraces message to the frontend

Parameters
----------
current_inds : list[int]
    List of current trace indexes
new_inds : list[int]
    List of new trace indexes
)current_trace_indsnew_trace_indsN)_py2js_moveTraces)r,   current_indsnew_indsmove_msgs       r0   _send_moveTraces_msg%BaseFigureWidget._send_moveTraces_msg
  s     +7S "*!%r2   c                     U R                  U5      nU R                  S-   nXPl        SU l        U R                  S-   nX`l        SU l        UUUUUUS.nXpl        SU l        g)a  
Send Plotly.update message to the frontend

Parameters
----------
restyle_data : dict
    Plotly.update restyle data
relayout_data : dict
    Plotly.update relayout data
trace_indexes : list[int]
    List of trace indexes that the update operation applies to
source_view_id : str
    UID of view that triggered this update operation
    (e.g. By the user clicking a button).
    None if the operation was not triggered by a frontend view
r	   T)
style_datar=   style_tracesrD   r:   r;   N)rE   r$   r%   r!   r"   _py2js_update)r,   rB   r9   rG   r;   rD   r:   
update_msgs           r0   _send_update_msg!BaseFigureWidget._send_update_msg  s}    , 55mD 0014#0 &*#22Q6$2!'+$
 '()*,,

 (!r2   c                     U R                  U5      nU R                  S-   nXPl        SU l        U R                  S-   nX`l        SU l        UUUUUUSS.nXpl        SU l        g)a  
Send Plotly.update message to the frontend

Note: there is no source_view_id parameter because animations
triggered by the fontend are not currently supported

Parameters
----------
styles_data : list[dict]
    Plotly.animate styles data
relayout_data : dict
    Plotly.animate relayout data
trace_indexes : list[int]
    List of trace indexes that the animate operation applies to
r	   TN)r\   r=   r]   animation_optsrD   r:   r;   )rE   r$   r%   r!   r"   _py2js_animate)r,   styles_datar9   rG   rc   rD   r:   animate_msgs           r0   _send_animate_msg"BaseFigureWidget._send_animate_msgQ  s    * 55mD 0014#0 &*#22Q6$2!'+$
 &(),*,"
 *"r2   c                     U R                   S-   nX l         SU l        U R                  S-   nX0l        SU l        UUUS.nX@l        SU l        g)z
Send Plotly.deleteTraces message to the frontend

Parameters
----------
delete_inds : list[int]
    List of trace indexes of traces to delete
r	   T)delete_indsr:   rD   N)r$   r%   r!   r"   _py2js_deleteTraces)r,   rj   rD   r:   
delete_msgs        r0   _send_deleteTraces_msg'BaseFigureWidget._send_deleteTraces_msg  sb     0014#0 &*#22Q6$2!'+$
 ',*

 $. #' r2   _js2py_traceDeltasc                    US   nU(       d  SU l         gUS   nUS   nX@R                  :X  Ga  U H  nUS   nU R                   Vs/ s H  owR                  PM     nnUR	                  U5      n	U R                  U	   n
[
        R                  U
R                  U5      nU R                  U
R                  U
R                  5      nU(       a  U	US.nXl
        SU l
        U R                  X/5        M     SU l        U R                  (       dC  U R                  (       a2  U R                  R                  5       " 5         U R                  (       a  M2  SU l         gs  snf )z0
Process trace deltas message from the frontend
newNtrace_deltasrD   uid)remove_traceremove_propsF)ro   r$   r   rs   indexr   _transform_data_prop_defaults_remove_overlapping_propsr(   _py2js_removeTraceProps _dispatch_trace_change_callbacksr%   r"   r#   pop)r,   changer>   rr   rD   delta	trace_uidtrace
trace_uidstrace_index	uid_tracedelta_transformru   remove_trace_props_msgs                 r0   _handler_js2py_traceDeltas+BaseFigureWidget._handler_js2py_traceDeltas  sU    %=&*D#/ 1 444 & "%L	59YY?YEiiY
?(..y9 IIk2	 #3"B"B,,e#  $==$$i&>&> 
  (3(4.* 4J037D0 55o}U= &B +0D' //22004468 222 #'I @s   E_js2py_layoutDeltac                    US   nU(       d  SU l         gUS   nUS   nX@R                  :X  Ga  [        R                  U R                  U5      nU R                  U R                  U R                  5      nU(       a  SU0nXpl        SU l        U HL  nUS   n	U R                  R                  U	5      n
U
(       d  M,  XR                  ;  d  M=  0 U R                  U	'   MN     U R                  U5        SU l        U R                  (       dC  U R                  (       a2  U R                  R                  5       " 5         U R                  (       a  M2  SU l         g)z0
Process layout delta message from the frontend
rq   Nlayout_deltar:   ru   r   F)r   r!   r   rw   _layout_defaultsry   r)   _py2js_removeLayoutPropsr-   _subplot_re_match!_dispatch_layout_change_callbacksr"   r%   r#   r|   )r,   r}   r>   r   r:   r   removed_propsremove_props_msgproppathpropmatchs              r0   _handler_js2py_layoutDelta+BaseFigureWidget._handler_js2py_layoutDelta  s<    %=&*D#/!"23 666 />>%%|O !::##T%:%:M
 $2M#B 0@-04-
 ,{55d;5T4(*DKK% , 22?C ,1D( ..22004468 222 #'r2   _js2py_restylec                 z    US   nU(       d  SU l         gUS   nUS   nUS   nU R                  UUUS9  SU l         g)z2
Process Plotly.restyle message from the frontend
rq   Nr\   r]   r;   )rB   rG   r;   )r   plotly_restyle)r,   r}   rH   r\   r]   r;   s         r0   _handler_js2py_restyle'BaseFigureWidget._handler_js2py_restyle'  sb     Um"&D .
">2$%56 	#&) 	 	
 #r2   _js2py_updatec                     US   nU(       d  SU l         gUS   nUS   nUS   nUS   nU R                  UUUUS9  SU l         g)z1
Process Plotly.update message from the frontend
rq   Nr\   r]   r=   r;   )rB   r9   rG   r;   )r   plotly_update)r,   r}   r_   stylerG   r-   r;   s          r0   _handler_js2py_update&BaseFigureWidget._handler_js2py_updateC  so     E]
!%D<(">2M*#$45 	 ')	 	 	
 "r2   _js2py_relayoutc                     US   nU(       d  SU l         gUS   nUS   nSU;   a  UR                  S5        U R                  X4S9  SU l         g)z3
Process Plotly.relayout message from the frontend
rq   Nr9   r;   lastInputTime)r9   r;   )r   r|   plotly_relayout)r,   r}   relayout_msgr9   r;   s        r0   _handler_js2py_relayout(BaseFigureWidget._handler_js2py_relayouta  sc     e}#'D $_5%&67m+ o. 	=X#r2   _js2py_pointsCallbackc           
      *   US   nU(       d  SU l         gUS   nUR                  SS5      (       aA  US   nUS   nUS   nUS:X  a  [        S0 UD6nO"US:X  a  [        S0 UD6nO[	        S	U-  5      eSnUR                  S
S5      (       a  US
   n[        S0 UD6n	OSn	US   n
[        [        U R                  5      5       Vs0 s H#  nU/ / / U R                  U   R                  US._M%     nn[        U
S   U
S   U
S   U
S   5       HF  u  ppX   nUS   R                  U5        US   R                  U5        US   R                  U5        MH     UR                  5        H  u  nn[        S0 UD6nU R                  U   nUS:X  a  UR                  UU	5        M:  US:X  a  UR!                  UU	5        MT  US:X  a  UR#                  UU	5        Mn  US:X  a  UR%                  UU5        M  US:X  d  M  UR'                  U5        M     SU l         gs  snf )z3
Process points callback message from the frontend
rq   N
event_typeselectortypeselector_stateboxlassozUnsupported selector type: %sdevice_statepoints)
point_indsxsys
trace_namer   r   r   point_indexesrG   r   plotly_clickplotly_hoverplotly_unhoverplotly_selectedplotly_deselectr   )r   getr   r   
ValueErrorr   rangelen
_data_objsnamezipappenditemsr   r   _dispatch_on_click_dispatch_on_hover_dispatch_on_unhover_dispatch_on_selection_dispatch_on_deselect)r,   r}   callback_datar   selector_dataselector_typer   r   device_state_datastatepoints_data	trace_indtrace_pointsxy	point_ind
trace_dicttrace_points_datar   r   s                       r0   _handler_js2py_pointsCallback.BaseFigureWidget._handler_js2py_pointsCallback~  sp    u)-D& #<0
 Z..)*5M)&1M*+;<N%&88')(:>: !@=!PQQH ^T22 -n =$9'89EE $H- #3t#78	
 9	  "ooi8==(  9 	 	
 +.((	+
&A) &0Jt##A&t##A&|$++I6+
 -9,>,>,@(I(0/0FIIi(E^+((7~-((7//**65900,,VX>00++F3 -A &*"Q	
s   *Hc                     [         e)z
Customize html representation
NotImplementedErrorr,   s    r0   _repr_html_BaseFigureWidget._repr_html_  
     "!r2   c                     [        5         [        U R                  R                  5      U l        [        U R
                  5      U l        SSSU R                  S.0$ )z6
Return mimebundle corresponding to default renderer.
z(application/vnd.jupyter.widget-view+json   r   )version_majorversion_minormodel_id)r   r   r'   r(   r)   r*   r+   	_model_id)r,   includeexcludevalidater.   s        r0   _repr_mimebundle_"BaseFigureWidget._repr_mimebundle_  sU     	)*
 't'7'7'>'>?$TZZ06!"!" NN9
 	
r2   c                     [         e)z4
Handle rich display of figures in ipython contexts
r   r   s    r0   _ipython_display_"BaseFigureWidget._ipython_display_  r   r2   c                     U R                   (       d  U R                  (       a  U R                  R                  U5        gU" 5         g)a6  
Register a function to be called after all pending trace and layout
edit operations have completed

If there are no pending edit operations then function is called
immediately

Parameters
----------
fn : callable
    Function of zero arguments to be called when all pending edit
    operations have completed
N)r"   r%   r#   r   )r,   fns     r0   on_edits_completed#BaseFigureWidget.on_edits_completed  s.     ''4+F+F((//3Dr2   c                     U R                   $ r4   )r   r   s    r0   r   BaseFigureWidget.frames  s    
 r2   c                 <    U(       a  [         R                  5         g g r4   )r   r    )r,   
new_framess     r0   r   r     s    224 r2   c                      Sn [        U 5      e)zv
Display an informative error when user attempts to set frames on a
FigureWidget

Raises
------
ValueError
    always
z
Frames are not supported by the plotly.graph_objs.FigureWidget class.
Note: Frames are supported by the plotly.graph_objs.Figure class)r   )msgs    r0   r    &BaseFigureWidget._display_frames_error  s    D or2   r   c                    / n[        U [        5      (       a  [        U[        5      (       d   eUR                  5        H  u  pE[        U[        5      (       d  [        R                  " U5      (       ad  X@;   a]  X   nX$4-   n[
        R                  XeU5      nUR                  U5        U(       d$  U R                  U5        UR                  U5        M  M  M  X@;   d  M  US:w  d  M  U R                  U5        UR                  X$4-   5        M     U$ [        U [        5      (       a  [        U[        5      (       d   e[        U5       H|  u  pU	[        U 5      :  a    U$ X	   nUb  [        U[        5      (       d  [        R                  " U5      (       d  MP  X)4-   n[
        R                  XeU5      nUR                  U5        M~     U$ )a?  
Remove properties in input_data that are also in delta_data, and do so
recursively.

Exception: Never remove 'uid' from input_data, this property is used
to align traces

Parameters
----------
input_data : dict|list
delta_data : dict|list

Returns
-------
list[tuple[str|int]]
    List of removed property path tuples
rs   )
isinstancedictr   r
   _is_dict_listr   ry   extendr|   r   list	enumerater   )

input_data
delta_data	prop_pathremovedp	delta_val	input_valrecur_prop_pathrecur_removedis
             r0   ry   *BaseFigureWidget._remove_overlapping_props*  s   0  j$''j$//// * 0 0 2i..*2J2J92U2U$.M	*3d*:(8(R(R%/)  }5  )&NN1-#NN?;  ) ' _eNN1%NN9t#34) !3\ - 
D))j$//// )* 5J'"  'M	)"9d33!//	:: '0$&6O$4$N$N!o%M NN=1# !6& r2   c           
         0 n[        U [        5      (       GaV  [        U[        5      (       d  [        SR                  XS95      eUR	                  5        H  u  pV[        U[        5      (       d  [
        R                  " U5      (       aN  XP;  a  [        U[        5      (       a  0 O/ X'   X   nUR                  [        R                  UUUX54-   S95        M  XP;  d   [        R                  " X   U5      (       a  M  X`U'   X54-   nXdU'   M     U(       aW  [        U R                  5       5      R                  [        UR                  5       5      5       H  n	U R                  U	5        M     U$ [        U [         5      (       a  [        U[         5      (       d  [        SR                  XS95      e[#        U5       H  u  pU
[%        U 5      :  a  U R'                  S5        X
   nUbZ  [        U[        5      (       d  [
        R                  " U5      (       a*  UR                  [        R                  UUUX:4-   S95        M  [        R                  " X
   U5      (       a  M  X`U
'   XdX:4-   '   M     U$ )z
Transform to_data into from_data and return relayout-style
description of the transformation

Parameters
----------
to_data : dict|list
from_data : dict|list

Returns
-------
dict
    relayout-style description of the transformation
z,Mismatched data types: {to_dict} {from_data})to_dict	from_data)should_removerelayout_pathz5Mismatched data types: to_data: {to_data} {from_data})to_datar  N)r   r   r   formatr   r
   r   updater   rw   r   _vals_equalsetkeys
differencer|   r   r   r   r   )r  r  r  r  r9   	from_propfrom_valr  relayout_path_propremove_propr	  s              r0   rw    BaseFigureWidget._transform_datay  si   &  gt$$ i.. BII ' J   (1'8#	 h--1I1I(1S1S !/3=h3M3MRSU* !( 2I!(((88%$*7*7,*F	 9  !/~7Q7Q*H8 8 .6	*-:\-I*<D&899 (9> #&w||~#6#A#A	()$K KK,$\ O && i.. KRR ' S    )3 G$NN4(#J	 (x..*2J2J82T2T "(((88%$*7*7$*>	 9  *55gj(KK%-
>Fmd&:;3  46 r2   )r   r   r   r   ro   r   r!   r$   r"   rM   rd   rk   rU   r<   r   rz   rF   r^   r%   r&   r#   r+   r)   )NNNFr4   )NN)NNT)r   )Tr   )B__name__
__module____qualname____firstlineno____doc__pathlibPath__file__parent_esmr   tagr   r)   r   r+   _configrM   rF   r<   r^   rd   rk   rU   r   rz   ro   r   r   r   r   r   r   r!   r$   _set_trace_uid_allow_disable_validationr   r6   r?   rI   rP   rY   r`   rg   rm   r   r   r   r   r   r   r   r   r   r   r   propertyr   setterstaticmethodr    ry   rw   __static_attributes____classcell__)r/   s   @r0   r   r      s   
 <<!((>9<MMD VZZ@T@-?@N6::>4>+=>Lfjj9d9&89G t,00QdQ>PQT*..ODO<NONd+//PTP=OPOD)--N4N;MNMT*..ODO<NON$/33TTAST-11RtR?QR#t488   '  #d377XTXEWX .22SS@RS.22SS@RST*..ODO<NONd+//PTP=OPOD)--N4N;MNM D155V4VCUV #1:>>t>4!!*..d.3N %
 AF:1x
$@,#\%B&, OS0"d0#d(F !">' #>'@ !"=' #='~ # #6 _" ": $  $8 $%S* &S*n"
&"*     ]]5 5  " L L\ p pr2   r   )copyr   r!  	traitletsr   r   r   r   plotly.io._renderersr   basedatatypesr
   r   	callbacksr   r   r   r   serializersr   	anywidget	AnyWidgetr   r   r2   r0   <module>r7     s9      2 2 A 5 K K + ^z9#6#6 ^r2   