
    Be                    .   d 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mZmZmZmZ ddlZddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlm Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z' erddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/  eddg          Z0 eddg          Z1 G d de#          Z2 G d dej3                  Z4 G d dej3                  Z5 G d de4e2          Z6 G d de5e2          Z7 G d  d!e6          Z G d" d#e6          Z  G d$ d%e6          Z8dS )&zu
Defines Layout classes which may be used to arrange panes and widgets
in flexible ways to build complex dashboards.
    )annotations)defaultdict
namedtuple)TYPE_CHECKINGAnyClassVarDictIterableIteratorListMappingOptionalTupleTypeN)Row)iscoroutinefunctionresolve_ref   )hold)CDN_DISTstate)Column)Reactive)
param_nameparam_reprsparam_watchers)Document)Model)Comm)Viewablerowchildrencolc                       e Zd ZU dZdZded<   ded<   dZded	<   g Zd
ed<   ddiZded<   dZ	d2d3 fdZ
d4 fd%Z	 d5d6d(Z	 	 d7d8d+Zd, Z	 	 d9d: fd0Zd5 fd1	Z xZS );Panelz7
    Abstract baseclass for a layout of Viewables.
    FzClassVar[bool]_batch_updateClassVar[Type[Model]]_bokeh_modelNzClassVar[str | None]
_directionClassVar[List[str]]_preprocess_paramsobjectsr#   "ClassVar[Mapping[str, str | None]]_renameTr   
   depthint	max_depthreturnstrc                   |k    rdS dddz   z  z   }t          |           j        }t          | dg          }fdt          |           D             }|s&|s$t	                                          dz             S |sd}n|sd}nd	}|                    |d
                    |          d|z                      |          |          S )Nz...
z       r-   c                P    g | ]"\  }}d ||                     dz             fz  #S )z[%d] %sr8   )__repr__).0iobjr1   s      1lib/python3.11/site-packages/panel/layout/base.py
<listcomp>z"Panel.__repr__.<locals>.<listcomp>@   s7    UUU61c	QU1W 5 566UUU    z{cls}{spacer}{objs}z{cls}({params})z{cls}({params}){spacer}{objs}z, z%s)clsparamsobjsspacer)type__name__r   	enumeratesuperr:   formatjoin)	selfr1   r3   rD   rA   rB   rC   template	__class__s	    `      r>   r:   zPanel.__repr__:   s    9557+,4jj!TI;//UUUUYt__UUU 	7d 	777##E!G,,, 	7,HH 	7(HH6HDIIf---%%d++F  < < 	<r@   events$Dict[str, param.parameterized.Event]msgDict[str, Any]rootr   modeldocr   commOptional[Comm]Nonec                    t          |          }d  j                                        D             t           fd|D                       }d|v r||u rd|d         v r	|d         d=  j        d         }||v r|d         j        }	                     ||	|||          \  }
}|
||<   |                                         |
t          |                    d|j	                  |                    d|j
                  |                    d|j                  |                    d|j                  |                    d	|j                  
                               nd }t          |          5  t          j        }dt          _        	 |j                                        5  t'                                          ||||||           |r%	 d d d            |t          _        d d d            d S ddlm} |j        d         }||j        v r*|r(|j        |         d                             | |           d d d            n# 1 swxY w Y   |t          _        n# |t          _        w xY w	 d d d            d S # 1 swxY w Y   d S )Nc                    i | ]
\  }}|||S N )r;   kvs      r>   
<dictcomp>z'Panel._update_model.<locals>.<dictcomp>V   s    TTTDAqam1ammmr@   c              3  R   K   | ]!}                     ||          j        v V  "d S rZ   )getr,   )r;   r\   inverserK   s     r>   	<genexpr>z&Panel._update_model.<locals>.<genexpr>W   s9      SS!Q**d.EESSSSSSr@   styles
overflow-xr-   sizing_modewidth	min_widthmargin)re   rc   rf   rg   rh   Tr   r   idr   )dict_property_mappingitemsanyold_get_objectsupdate_compute_sizing_moder`   re   rc   rf   rg   rh   r   r&   r'   modelsfreezerH   _update_modelior   ref_views_preprocess)rK   rN   rP   rR   rS   rT   rU   
preprocessobj_keyrn   r#   old_childrenrp   r   rv   ra   rM   s   `              @r>   rt   zPanel._update_modelQ   sv    3iiTTD$:$@$@$B$BTTTSSSSSsSSSSS
 s??tu}}X1N1NHl+(3c>>#'C%)%6%6uc3d%S%S"Hl#CLJJt00 #u7H I I778U\::'''5;77!ggk5?CC778U\::  	 	 	 	 	 	  L#YY 	- 	-(F"&E
-Z&&(( S SGG))&#tUCNNN S S S S S S '-#	- 	- 	- 	- 	- 	- 	- 	- +*****(4.Cel**z*S)!,88t\RRRS S S S S S S S S S S S S S S '-##f#,,,,#	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-sa   6J I!)*I	I!J 7AI	=I!	I	I!I	I!J !I//J  JJold_objectsList[Viewable]c           	        ddl m}m} g g }	}t          | j                  D ]\  }
} ||          }|| j        |
<   |D ] }|| j        vr|                    |           !t          | j                  }|j        d         }t          | j                  D ]\  }
}||v r:||j        v r1|j        |j        d                  \  }}|		                    |           nh	 |
                    ||||          }nN# |$ rF}|j        |j        | ur|d|_        |                     ||d|
         |||          cY d}~c S d}~ww xY w|	                    |           ||	fS )z
        Returns new child models for the layout while reusing unchanged
        models and cleaning up any dropped objects.
        r   )RerenderErrorpanelri   N)	pane.baser   r   rG   r-   _cleanuplistrv   _modelsappend
_get_modellayoutro   )rK   rS   r|   rT   rR   rU   r   r   
new_models
old_modelsr<   paner=   current_objectsrv   child_es                     r>   ro   zPanel._get_objects   s    	54444444!#RJ
 .. 	# 	#GAt5;;D"DLOO 	# 	#C$,&&T"""t|,,htn .. 	% 	%GAt{""sdl':':<7q!!%((((Z OOCudCCEE$ Z Z Zx+0D0D#AH,,UOBQB4GdTXYYYYYYYYYY	Z
 e$$$$:%%s   C11D<69D7/D<7D<Optional[Model]parentc                   | j         $t          t          |           j         d          |                                  }|p|}||f| j        |j        d         <   |                     |g |||          \  }}|                     |          }||| j        d         <   |	                    | 
                    ||                      |j	        di | |                     || j        |||           |S )Nz did not define a _bokeh_model.ri   r-   r[   )r)   
ValueErrorrE   rF   r   rv   ro   _get_propertiesrk   rp   rq   _link_props_linked_properties)	rK   rT   rR   r   rU   rS   r-   r   propss	            r>   r   zPanel._get_model   s     $T

 3TTTUUU!!##}u(-vTXd^$&&ub#tTBB
$$S))3:d$Y/0T..w>>???u 7dDIIIr@   c                   |                     d| j                  }|                     d| j                  }|dk    ri S g g }}d\  }}}	}
|D ]6}|j        }|rd|v rd}
|dv }|dv }||z  }|	|z  }	|r|j        }n|j        }|j        s|j        }|rit          |t                    r7t          |          d	k    r||d
         d	z  z  }n||d
         |d         z   z  }n||d	z  z  }|                    |           |r|j	        }n|j
        }|rd}n|j	        }|rit          |t                    r7t          |          d	k    r||d         d	z  z  }n||d         |d	         z   z  }n||d	z  z  }|                    |           8|
rdnd}| j        dk    r|}nd}|r$|	r"| j        s| j
        s|sd|pdv r| d}n%| d}n|r| j        s| d}n|	r| j
        s|r| d}|d|                     d          iS d|i}|                    d          s|                    d          r^|r\d|vrX| j        dk    rt          nt          } ||          }|g}d|v r|                    |d                    t          |          |d<   |                    d          s|                    d          r^|r\d|vrX| j        dk    rt          nt          } ||          }|g}d|v r|                    |d                    t          |          |d<   |S )aK  
        Handles inference of correct layout sizing mode by inspecting
        the children and adapting to their layout properties. This
        aims to provide a layer of backward compatibility for the
        layout behavior before v1.0 and provide general usability
        improvements.

        The code iterates over the children and extracts their sizing_mode,
        width and height. Based on these values we infer a few overrides
        for the container sizing_mode, width and height:

        - If a child is responsive in width then the container should
          also be responsive in width (unless it has a fixed size).
        - If a container is vertical (e.g. a Column) and a child is
          responsive in height then the container should also be
          responsive.
        - If a container is horizontal (e.g. a Row) and all children
          are responsive in height then the container should also be
          responsive. This behavior is asymmetrical with height
          because there isn't always vertical space to expand into
          and it is better for the component to match the height of
          the other children.
        - Always compute the fixed sizes of the children (if available)
          and provide this as min_width and min_height settings to
          ensure sufficient space is available.
        rh   re   fixed)TFFFscaleT)stretch_widthstretch_bothscale_width
scale_both)stretch_heightr   scale_heightr   r   r8      Fr   stretch
horizontalboth _both_width_heightNrg   vertical	max_width
min_height
max_height)r`   rh   re   rg   rf   
isinstancetuplelenr   r   heightr*   endswithmaxsummin)rK   r#   r   rh   re   heightswidthsall_expand_heightexpand_widthexpand_heightr   r   smodewidth_expandedheight_expandedrf   r   modeallow_height_scale
propertieswidth_oprg   	op_widths	height_opr   
op_heightss                             r>   rq   zPanel._compute_sizing_mode   s'   6 8T[11iit/?@@'!!I b@Y=< )	' )	'E%E E))"&ddN#'ggON*L_,M ,{ ,!OE %fe,, &6{{a''1,VAY!66VAX%Ee$$$ .) .(-%%"-F 'fe,, '6{{a''&)A+-&)fQi"77fQh&Fv&&&  .wwY?l**!2!% 	+M 	+$* 	+T[ 	+! .V0Ar%B%B!%nnn!%ooo 	+$* 	+!///KK 	+4; 	+3E 	+!***K!599]#;#;<<#[1
!!(++ 	5{/C/CG/L/L 	5	5"*44"o;;ssH ((I"Ij((  K!8999&))nnJ{#!!),, 	70D0DW0M0M 	7	7$J66#,>>CI"7++J$Jz))!!*\":;;;'*:J|$r@   Optional[Document]ry   boolc                    t                                          |||          }t          |d          rd|j        v r|j        d= |S )Nrc   rd   )rH   get_roothasattrrc   )rK   rT   rU   ry   rR   rM   s        r>   r   zPanel.get_root/  sM     wwT:664"" 	*|t{'B'BL)r@   c                    t                                          |          }| D ]}||                    |          z  }|S )a  
        Iterates over the Viewable and any potential children in the
        applying the Selector.

        Arguments
        ---------
        selector: type or callable or None
          The selector allows selecting a subset of Viewables by
          declaring a type or callable function to filter by.

        Returns
        -------
        viewables: list(Viewable)
        )rH   select)rK   selectorr-   r=   rM   s       r>   r   zPanel.select9  sF     ''..** 	, 	,Cszz(+++GGr@   )r   r0   )r1   r2   r3   r2   r4   r5   )rN   rO   rP   rQ   rR   r   rS   r   rT   r   rU   rV   r4   rW   rZ   )
rS   r   r|   r}   rT   r   rR   r   rU   rV   )NNN)
rT   r   rR   r   r   r   rU   rV   r4   r   )NNT)rT   r   rU   rV   ry   r   r4   r   )rF   
__module____qualname____doc__r'   __annotations__r*   r,   r/   _Panel__abstractr:   rt   ro   r   rq   r   r   __classcell__rM   s   @r>   r&   r&   $   sp         
 %*M)))) (''' (,J++++ /10000 4=j2IGIIIIJ< < < < < < <.,- ,- ,- ,- ,- ,-h -1!& !& !& !& !&H 6:?C    "r r rr FJ               r@   r&   c                      e Zd ZU  ej        g d          ZdgZded<   d)d
Zd*dZ	d+dZ
d,dZd,dZd,dZd-dZd.dZd/dZd0dZd1d!Zd2d"Zd*d#Zd3d$Zd4d%Zd5d&Zd6d'Zd(S )7ListLike;
        The list of child objects that make up the layout.defaultrT   r-   r+   r,   indexint | slicer4   Viewable | List[Viewable]c                    | j         |         S rZ   r-   rK   r   s     r>   __getitem__zListLike.__getitem__U      |E""r@   r2   c                *    t          | j                  S rZ   r   r-   rK   s    r>   __len__zListLike.__len__X      4<   r@   Iterator[Viewable]c              #  &   K   | j         D ]}|V  d S rZ   r   rK   r=   s     r>   __iter__zListLike.__iter__[  ,      < 	 	CIIII	 	r@   otherIterable[Any]
'ListLike'c                0    |                      |           | S rZ   extendrK   r   s     r>   __iadd__zListLike.__iadd___      Er@   c                ~    t          |t                    r|j        }nt          |          } | j        | j        |z    S rZ   r   r   r-   r   cloner   s     r>   __add__zListLike.__add__c  s>    eX&& 	 MEEKKEtzDL.00r@   c                ~    t          |t                    r|j        }nt          |          } | j        || j        z    S rZ   r   r   s     r>   __radd__zListLike.__radd__j  s>    eX&& 	 MEEKKEtzE$,.00r@   r=   r!   r   c                    || j         v S rZ   r   r   s     r>   __contains__zListLike.__contains__q  s    dl""r@   panesrW   c                   ddl m} t          |           }t          |t                    s]||dz   }}|t          | j                  k    r9t          d|t          |           j	        t          | j                  fz            |g}n?|j
        pd}|j        t          |           n|j        }|j
        n|j        gt          |t                    s:t          dt          |           j	        dt          |          j	        d          t          |          }d g|z  }|}nV|t          | j                  k    r9t          d|t          |           j	        t          | j                  fz            ||z
  }t          |t                    rt          |          |k    r&t          d	|t          |           j	        fz            t          t          ||          |          D ]\  }}	 ||	          ||<   || _        d S )
Nr   r   r8   3Index %d out of bounds on %s containing %d objects.r   9Expected a list of objects to replace the objects in the , got a  type.KExpected a list of %d objects to set on the %s to match the supplied slice.)r   r   r   r   slicer   r-   
IndexErrorrE   rF   startstopziprange)
rK   r   r   r   new_objectsr  endexpectedr<   r   s
             r>   __setitem__zListLike.__setitem__t  s<         4jj%'' 	Ba3Es4<((((  ":"%tDzz':C<M<M!N"O P P P GEEK$1E$z1#d)))uzC{"uz'9!%.. R$* '+4jj&9&9&94;;;O;O;O&Q R R R u::#fXos4<((((  ":"%tDzz':C<M<M!N"O P P P u9eT** Bc%jjH.D.D  "J"*DJJ,?!@"A B B B 5,,e44 	) 	)GAt"U4[[KNN"r@   r   rB   c                   |s"d|v r|                     d          }n0| j        }n(d|v r$t          dt          |           j        z            t          | j                                        fi |}|d=  t          |           |i |S )a*  
        Makes a copy of the layout sharing the same parameters.

        Arguments
        ---------
        objects: Objects to add to the cloned layout.
        params: Keyword arguments override the parameters on the clone.

        Returns
        -------
        Cloned layout object
        r-   zPA %s's objects should be supplied either as arguments or as a keyword, not both.)popr-   r   rE   rF   rj   paramvalues)rK   r-   rB   ps       r>   r   zListLike.clone  s      	4F"" **Y//,&   G#Dzz23 4 4 4 ""$$////iLtDzz7(a(((r@   c                z    ddl m} t          |           }|                     ||                     || _        dS )z
        Appends an object to the layout.

        Arguments
        ---------
        obj (object): Panel component to add to the layout.
        r   r   N)r   r   r   r   r-   )rK   r=   r   r  s       r>   r   zListLike.append  sH     	!     4jj55::&&&"r@   r}   c                "    | j         }g | _         |S )z
        Clears the objects on this layout.

        Returns
        -------
        objects (list[Viewable]): List of cleared objects.
        r   )rK   r-   s     r>   clearzListLike.clear  s     ,r@   c                    ddl m} t          |           }|                    t          t	          ||                               || _        dS )z
        Extends the objects on this layout with a list.

        Arguments
        ---------
        objects (list): List of panel components to add to the layout.
        r   r   N)r   r   r   r   mapr-   )rK   r-   r   r  s       r>   r   zListLike.extend  sR     	!     4jj4E7 3 344555"r@   c                6    | j                             |          S )a   
        Returns the integer index of the supplied object in the list of objects.

        Arguments
        ---------
        obj (object): Panel component to look up the index for.

        Returns
        -------
        index (int): Integer index of the object in the layout.
        )r-   r   )rK   objects     r>   r   zListLike.index  s     |!!&)))r@   c                |    ddl m} t          |           }|                    | ||                     || _        dS )z
        Inserts an object in the layout at the specified index.

        Arguments
        ---------
        index (int): Index at which to insert the object.
        object (object): Panel components to insert in the layout.
        r   r   N)r   r   r   insertr-   )rK   r   r=   r   r  s        r>   r  zListLike.insert  sJ     	!     4jj5%%**---"r@   c                \    t          |           }|                    |          }|| _        |S )z
        Pops an item from the layout by index.

        Arguments
        ---------
        index (int): The index of the item to pop from the layout.
        )r   r  r-   rK   r   r  r=   s       r>   r  zListLike.pop  s,     4jjooe$$"
r@   c                \    t          |           }|                    |           || _        dS )z
        Removes an object from the layout.

        Arguments
        ---------
        obj (object): The object to remove from the layout.
        N)r   remover-   )rK   r=   r  s      r>   r  zListLike.remove  s.     4jj3"r@   c                Z    t          |           }|                                 || _        dS )z5
        Reverses the objects in the layout.
        N)r   reverser-   rK   r  s     r>   r  zListLike.reverse  s,     4jj"r@   N)r   r   r4   r   r4   r2   r4   r   )r   r   r4   r   )r=   r!   r4   r   r   r   r   r   r4   rW   )r-   r   rB   r   r4   r   )r=   r   r4   rW   )r4   r}   )r-   r   r4   rW   )r   r2   r=   r   r4   rW   r   r2   r4   r!   )r=   r!   r4   rW   r4   rW   )rF   r   r   r  r   r-   r,   r   r   r   r   r   r   r   r   r  r   r   r  r   r   r  r  r  r  r[   r@   r>   r   r   N  s        ej *> ? ? ?G 09k9999# # # #! ! ! !      1 1 1 11 1 1 1# # # ### ## ## ##J) ) ) )4# # # #
 
 
 
# # # #* * * *# # # #   
# 
# 
# 
## # # # # #r@   r   c                       e Zd ZU  ej        g d          ZdgZded<   d. fd
Zd Z	d Z
d/dZd0dZd1dZd2dZd3dZd4dZd4dZd4dZd5d#Zd6d$Zd7d&Zd8d'Zd9d(Zd:d)Zd;d+Zd<d,Zd8d-Z xZS )=NamedListLiker   r   r-   r+   r,   rl   List[Any | Tuple[str, Any]]rB   r   c                   d|v r;|r$t          dt          |           j        z            |                    d          }|                     |          \  |d<   | _         t                      j        di | t          t                    | _
        | j                            | j        d           t          |           d         d                                          d S )Nr-   zW%s objects should be supplied either as positional arguments or as a keyword, not both.valuer[   )r   rE   rF   r  _to_objects_and_names_namesrH   __init__r   rj   _panelsr  watch_update_namesr   r  )rK   rl   rB   rM   s      r>   r-  zNamedListLike.__init__  s     D  "-/3Dzz/B"C D D D JJy))E)-)C)CE)J)J&y4;""6""""4((
+Y777 	tY'088:::::r@   c                    ddl m} t          |t                    r|\  }}nt	          |dd           } |||          }|t          |j                  n|}||fS )Nr   r   name)r2  )r   r   r   r   getattrr   r2  )rK   itemr   r2  r   s        r>   _to_object_and_namez!NamedListLike._to_object_and_name-  sx          dE"" 	/JD$$4..DuT%%%(,z$)$$$$Tzr@   c                    g g }}|D ]D}|                      |          \  }}|                    |           |                    |           E||fS rZ   )r5  r   )rK   rl   r-   namesr4  r   r2  s          r>   r+  z#NamedListLike._to_objects_and_names7  sb    R 	 	D11$77JD$NN4   LL~r@   eventparam.parameterized.Eventr4   rW   c                   t          |j                  t          | j                  k    rd S g }|j        D ]O}||j        v r(|j                            |          }| j        |         }n|j        }|                    |           P|| _        d S rZ   )r   newr,  rn   r   r2  r   )rK   r8  r7  r=   r   r2  s         r>   r0  zNamedListLike._update_names?  s    uy>>S----F9 	 	Cei	,,{5)xLLr@   rN   c                    d S rZ   r[   )rK   rN   s     r>   _update_activezNamedListLike._update_activeL  s    r@   r   c                    | j         |         S rZ   r   r   s     r>   r   zNamedListLike.__getitem__S  r   r@   r2   c                *    t          | j                  S rZ   r   r   s    r>   r   zNamedListLike.__len__V  r   r@   r   c              #  &   K   | j         D ]}|V  d S rZ   r   r   s     r>   r   zNamedListLike.__iter__Y  r   r@   r   r   'NamedListLike'c                0    |                      |           | S rZ   r   r   s     r>   r   zNamedListLike.__iadd__]  r   r@   c                <   t          |t                    r(t          t          |j        |j                            }n,t          |t                    r|j        }nt          |          }t          t          | j        | j                            } | j        ||z    S rZ   r   r'  r   r  r,  r-   r   r   rK   r   addedr-   s       r>   r   zNamedListLike.__add__a  s    e]++ 	 U\5=99::EEx(( 	 MEEKKEs4;5566tzGEM++r@   c                <   t          |t                    r(t          t          |j        |j                            }n,t          |t                    r|j        }nt          |          }t          t          | j        | j                            } | j        ||z    S rZ   rD  rE  s       r>   r   zNamedListLike.__radd__k  s    e]++ 	 U\5=99::EEx(( 	 MEEKKEs4;5566tzE'M++r@   r   r   r   c                \   t          |           }t          |t                    s]|t          | j                  k    r9t          d|t          |           j        t          | j                  fz            ||dz   }}|g}n\|j        pd}|j	        t          | j                  n|j	        }|j        |j	        t          |t                     s:t          dt          |           j        dt          |          j        d          t          |          }d g|z  }d gt          |          z  | _
        |}nV||z
  }|t          | j                  k    r9t          d|t          |           j        t          | j                  fz            t          |t                     rt          |          |k    r&t          d|t          |           j        fz            t          t          ||          |          D ](\  }}|                     |          \  ||<   | j
        |<   )|| _        d S )Nr   r8   r   r   r   r   r  )r   r   r  r   r-   r  rE   rF   r  r  r,  r  r  r5  )	rK   r   r   r  r  r	  r
  r<   r   s	            r>   r  zNamedListLike.__setitem__u  sV   4jj%'' 	Bs4<((((  ":"'d)<c$,>O>O!P"Q R R R a3EGEEK$1E',z'9#dl###uzC{"uz'9!%.. R$* '+4jj&9&9&94;;;O;O;O&Q R R R u::#fXo#fSZZ/u9T\****$ &>&)4::+>DL@Q@Q%R&S T T T eT** Bc%jjH.D.D  "J"*DJJ,?!@"A B B B 5,,e44 	L 	LGAt-1-E-Ed-K-K*KNDKNN"r@   c                ,   |r|}nTd|v rt          d          d|v r|                    d          }n't          t          | j        | j                            }t          | j                                        fi |}|d=  t          |           |i |S )a+  
        Makes a copy of the Tabs sharing the same parameters.

        Arguments
        ---------
        objects: Objects to add to the cloned Tabs object.
        params: Keyword arguments override the parameters on the clone.

        Returns
        -------
        Cloned Tabs object
        r-   zYTabs objects should be supplied either as positional arguments or as a keyword, not both.)
r   r  r   r  r,  r-   rj   r  r  rE   )rK   r-   rB   	overridesr  s        r>   r   zNamedListLike.clone  s      		>II&   ) * * * &  

9--IIc$+t|<<==I""$$////iLtDzz9////r@   r   c                    |                      |          \  }}t          |           }|                    |           | j                            |           || _        dS )z
        Appends an object to the tabs.

        Arguments
        ---------
        obj (object): Panel component to add as a tab.
        N)r5  r   r   r,  r-   )rK   r   
new_objectnew_namer  s        r>   r   zNamedListLike.append  s\      $77==
H4jj:&&&8$$$"r@   c                "    g | _         g | _        dS )z"
        Clears the tabs.
        N)r,  r-   r   s    r>   r  zNamedListLike.clear  s     r@   c                    |                      |          \  }}t          |           }|                    |           | j                            |           || _        dS )z
        Extends the the tabs with a list.

        Arguments
        ---------
        objects (list): List of panel components to add as tabs.
        N)r+  r   r   r,  r-   )rK   r   r  	new_namesr-   s        r>   r   zNamedListLike.extend  sZ     "&!;!;E!B!BYt**{###9%%%r@   c                    |                      |          \  }}t          | j                  }|                    ||           | j                            ||           || _        dS )z
        Inserts an object in the tabs at the specified index.

        Arguments
        ---------
        index (int): Index at which to insert the object.
        object (object): Panel components to insert as tabs.
        N)r5  r   r-   r  r,  )rK   r   r   rL  rM  r  s         r>   r  zNamedListLike.insert  sd      $77==
H4<((5*---5(+++"r@   r!   c                    t          |           }|                    |          }| j                            |           || _        |S )z
        Pops an item from the tabs by index.

        Arguments
        ---------
        index (int): The index of the item to pop from the tabs.
        )r   r  r,  r-   r  s       r>   r  zNamedListLike.pop  s@     4jjooe$$"
r@   c                    t          |           }||v r|                    |          }|                    |           | j                            |           || _        dS )z
        Removes an object from the tabs.

        Arguments
        ---------
        obj (object): The object to remove from the tabs.
        N)r   r   r  r,  r  r-   )rK   r   r  r   s       r>   r  zNamedListLike.remove  s`     4jj;%%d++E4   "r@   c                    t          |           }|                                 | j                                         || _        dS )z$
        Reverses the tabs.
        N)r   r  r,  r-   r   s     r>   r  zNamedListLike.reverse  s@     4jj"r@   )rl   r(  rB   r   )r8  r9  r4   rW   )rN   r9  r4   rW   )r4   r   r!  r"  )r   r   r4   rA  r#  )r-   r   rB   r   r4   rA  )r   r   r4   rW   r%  )r   r   r4   rW   )r   r2   r   r   r4   rW   r$  )r   r!   r4   rW   )rF   r   r   r  r   r-   r,   r   r-  r5  r+  r0  r=  r   r   r   r   r   r   r  r   r   r  r   r  r  r  r  r   r   s   @r>   r'  r'    s        ej *> ? ? ?G 09k9999; ; ; ; ; ;          # # # #! ! ! !      , , , ,, , , ,"# "# "# "#H0 0 0 06# # # #      # # # #   # # # ## # # # # # # #r@   r'  c                       e Zd ZU dZ ej        dd          ZddiZded<   ddiZ	ded	<   d
Z
d fdZed             Zd fdZdd fdZ xZS )	ListPanelzJ
    An abstract baseclass for Panel objects with list-like children.
    F^
        Whether to add scrollbars if the content overflows the size
        of the container.r   scrollNr.   r/   _source_transformsTr-   r   rB   c                D   ddl m |r:d|v r$t          dt          |           j        z            fd|D             |d<   n;d|v r7|d         }t          |          rt          |          rfd|D             |d<    t          t          |           j	        di | d S )Nr   r   r-   z[A %s's objects should be supplied either as positional arguments or as a keyword, not both.c                &    g | ]} |          S r[   r[   r;   r   r   s     r>   r?   z&ListPanel.__init__.<locals>.<listcomp>#  s!     A A At A A Ar@   c                &    g | ]} |          S r[   r[   r\  s     r>   r?   z&ListPanel.__init__.<locals>.<listcomp>'  s!    $E$E$ETUU4[[$E$E$Er@   r[   )
r   r   r   rE   rF   r   r   rH   r&   r-  )rK   r-   rB   r   rM   s      @r>   r-  zListPanel.__init__  s           		FF""  "-/3Dzz/B"C D D D !B A A A A A AF9&  Y'Gw'' F+>w+G+G F$E$E$E$EW$E$E$Ey!#eT#--f-----r@   c                D     t           fd j        D                       S )Nc              3     K   | ]H}|t           j        vj                            ||          +j                            ||          V  Id S rZ   )rV  r  rk   r`   )r;   r  rK   s     r>   rb   z/ListPanel._linked_properties.<locals>.<genexpr>,  sg       
 
12	''D,B,F,Fq!,L,L,X "&&q!,,,X,X,X,X
 
r@   )r   r  r   s   `r>   r   zListPanel._linked_properties*  s=     
 
 
 
6:j
 
 
 
 
 	
r@   rQ   r4   c                    d|v rF|d         }|                     d| j                  }|r| j        |d| j         gz  }n|dgz  }||d<   t                                          |          S NrX  css_classeszscrollable-
scrollabler`   rb  r*   rH   _process_param_changerK   rB   rX  rb  rM   s       r>   re  zListPanel._process_param_change1      vH%F **]D4DEEK 2?.$C$/$C$C#DDKKL>1K$/F=!ww,,V444r@   rR   Model | NonerW   c                   |C|j         d         t          j        v r*t          j                            |j         d                    t	                                          |           | j        D ]}|                    |           d S Nri   rv   r   _fake_rootsr  rH   r   r-   rK   rR   r  rM   s      r>   r   zListPanel._cleanup=      %2C C C$$TXd^444 	 	AJJt	 	r@   r-   r   rB   r   rB   rQ   r4   rQ   rZ   rR   rh  r4   rW   )rF   r   r   r   r  BooleanrX  r/   r   rY  _ListPanel__abstractr-  propertyr   re  r   r   r   s   @r>   rV  rV    s           U]5 /   F 4<T2BGBBBB>F=MMMMMJ. . . . . . 
 
 X

5 
5 
5 
5 
5 
5          r@   rV  c                       e Zd ZU  ej        ddd          Z ej        dd          Zdd	iZd
e	d<   dd	iZ
d
e	d<   dZd fdZdd fdZ xZS )NamedListPanelr   r   Nz2
        Index of the currently displayed objects.)r   boundsrT   FrW  r   rX  Nr.   r/   rY  TrB   rQ   r4   c                    d|v rF|d         }|                     d| j                  }|r| j        |d| j         gz  }n|dgz  }||d<   t                                          |          S ra  rd  rf  s       r>   re  z$NamedListPanel._process_param_changeT  rg  r@   rR   rh  rW   c                   |C|j         d         t          j        v r*t          j                            |j         d                    t	                                          |           | j        D ]}|                    |           d S rj  rk  rm  s      r>   r   zNamedListPanel._cleanup`  rn  r@   rp  rZ   rq  )rF   r   r   r  Integeractiverr  rX  r/   r   rY  _NamedListPanel__abstractre  r   r   r   s   @r>   rv  rv  E  s         U]1Y =5 6 6 6F U]5 /   F 4<T2BGBBBB>F=MMMMMJ
5 
5 
5 
5 
5 
5          r@   rv  c                  <    e Zd ZU dZeZded<   dZe dgZ	ded<   dS )	r   a  
    The `Row` layout allows arranging multiple panel objects in a horizontal
    container.

    It has a list-like API with methods to `append`, `extend`, `clear`,
    `insert`, `pop`, `remove` and `__setitem__`, which makes it possible to
    interactively update and modify the layout.

    Reference: https://panel.holoviz.org/reference/layouts/Row.html

    :Example:

    >>> pn.Row(some_widget, some_pane, some_python_object)
    r(   r)   r   css/listpanel.cssClassVar[list[str]]_stylesheetsN)
rF   r   r   r   BkRowr)   r   r*   r   r  r[   r@   r>   r   r   h  sQ           +0L////J,4)G)G)G(HLHHHHHHr@   r   c                  
   e Zd ZU dZ ej        dd          Z ej        dd          Z ej        dd          Z ej	        d	d
          Z
eZded<   dZe dgZded<    ej        dddddd          d             ZdS )r   a  
    The `Column` layout allows arranging multiple panel objects in a vertical
    container.

    It has a list-like API with methods to `append`, `extend`, `clear`,
    `insert`, `pop`, `remove` and `__setitem__`, which makes it possible to
    interactively update and modify the layout.

    Reference: https://panel.holoviz.org/reference/layouts/Column.html

    :Example:

    >>> pn.Column(some_widget, some_pane, some_python_object)
    Nz
        Current scroll position of the Column. Setting this value
        will update the scroll position of the Column. Setting to
        0 will scroll to the top.r   rw  z
        Max pixel distance from the latest object in the Column to
        activate automatic scrolling upon update. Setting to 0
        disables auto-scrolling.)rx  rT   z
        Min pixel distance from the latest object in the Column to
        display the scroll button. Setting to 0
        disables the scroll button.Fzu
        Whether to scroll to the latest object on init. If not
        enabled the view will be on the first object.r(   r)   r   r  r  r  scroll_positionauto_scroll_limitscroll_button_thresholdview_latestT)r/  on_initc                    | j         pBt          | j                  p.t          | j                  pt          | j                  p| j        | _         d S rZ   )rX  r   r  r  r  r  r   s    r>   _set_scrollablezColumn._set_scrollable  s\     K %&&'(( -..  	r@   )rF   r   r   r   r  r{  r  r  r  rr  r  PnColumnr)   r   r*   r   r  dependsr  r[   r@   r>   r   r     s          $emD 7% & & &O
 &Y =$ % % %
 ,em9 C' ( ( (
  %- 49 : : :K +3L2222J,4)G)G)G(HLHHHHU]!  
 
 
 
 
r@   r   c                  D    e Zd ZU dZ ej        dgd          Z ej        dd          Z ej        dd          Z	ddd	Z
d
ed<   ddddZd
ed<   e de dgZded<   ed d            Zed             Z ej        ddd          d!d            Zd" fdZ xZS )#	WidgetBoxaU  
    The `WidgetBox` layout allows arranging multiple panel objects in a
    vertical (or horizontal) container.

    It is largely identical to the `Column` layout, but has some default
    styling that makes widgets be clearly grouped together visually.

    It has a list-like API with methods to `append`, `extend`, `clear`,
    `insert`, `pop`, `remove` and `__setitem__`, which make it possible to
    interactively update and modify the layout.

    Reference: https://panel.holoviz.org/reference/layouts/WidgetBox.html

    :Example:

    >>> pn.WidgetBox(some_widget, another_widget)
    zpanel-widget-boxz,
        CSS classes to apply to the layout.r   Fz(
        Whether the widget is disabled.z^
        Whether to lay out the widgets in a Row layout as opposed
        to a Column layout.N)disabledr   r.   rY  r#   )r  r-   r   r/   zcss/widgetbox.cssr  r  r  r4   Type[Model]c                ,    | j         rt          nt          S rZ   )r   r  r  r   s    r>   r)   zWidgetBox._bokeh_model  s    5uuX5r@   c                    | j         rdndS )Nr   )r   r   s    r>   r*   zWidgetBox._direction  s    !_<zz*<r@   r  r-   T)r/  rW   c                Z    ddl m} |                     |          D ]}| j        |_        d S )Nr   )Widget)widgetsr  r   r  )rK   r  r=   s      r>   _disable_widgetszWidgetBox._disable_widgets  sD    $$$$$$;;v&& 	) 	)C=CLL	) 	)r@   r   rB   c                t     t                      j        |i | | j        r|                                  d S d S rZ   )rH   r-  r  r  )rK   r-   rB   rM   s      r>   r-  zWidgetBox.__init__  sK    ',V,,,= 	$!!#####	$ 	$r@   )r4   r  r%  ro  )rF   r   r   r   r  r   rb  rr  r  r   rY  r   r/   r   r  rt  r)   r*   r  r  r-  r   r   s   @r>   r  r    s         $ %*&8%9 @/ 0 0 0K u}U 1+ , , ,H u 3      J
 > >    
 Zt3 3G    
 &&&8(F(F(F)L     6 6 6 X6 = = X= U]:y555) ) ) 65)
$ $ $ $ $ $ $ $ $ $r@   r  )9r   
__future__r   collectionsr   r   typingr   r   r   r	   r
   r   r   r   r   r   r   r  bokeh.modelsr   r  param.parameterizedr   r   io.modelr   io.resourcesr   io.stater   rr   r   r  reactiver   utilr   r   r   bokeh.documentr   bokeh.modelr   pyviz_commsr    viewabler!   _row_colr&   Parameterizedr   r'  rV  rv  r  r[   r@   r>   <module>r     sj    # " " " " " / / / / / / / /                         
  % % % % % % @ @ @ @ @ @ @ @       # # # # # #       ' ' ' ' ' '       : : : : : : : : : : $''''''!!!!!!      ######z%*&&z%*&&g g g g gH g g gT	F# F# F# F# F#u" F# F# F#Rs# s# s# s# s#E' s# s# s#l5 5 5 5 5% 5 5 5p         ]E      FI I I I I) I I I.8
 8
 8
 8
 8
Y 8
 8
 8
v:$ :$ :$ :$ :$	 :$ :$ :$ :$ :$r@   