Ë
    úmxiÑ$  ã                  óð   — d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ erd dlmZ 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 dd„Z ed	«      Z G d
„ dee   «      Z G d„ d«      Z G d„ de«      Z G d„ de«      Zy)é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚGenericÚTypeVar)Úutil)ÚElement)Úget_script_run_ctx)ÚIteratorc                óP   — | g}|j                  |«       |j                  |«       |S ©N)ÚextendÚappend)Úroot_containerÚparent_pathÚindexÚ
delta_paths       úG/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/cursor.pyÚmake_delta_pathr      s.   € ð !Ð!€JØ×Ñ�kÔ"Ø×Ñ�eÔØÐó    c                ó–   — | €yt        «       }|€y| |j                  v r|j                  |    S t        | ¬«      }||j                  | <   |S )zñReturn the top-level RunningCursor for the given container.
    This is the cursor that is used when user code calls something like
    `st.foo` (which uses the main container) or `st.sidebar.foo` (which uses
    the sidebar container).
    N)r   )r
   ÚcursorsÚRunningCursor)r   ÚctxÚcursors      r   Úget_container_cursorr   $   sU   € ð ÐØä
Ó
€Cà
€{Øà˜Ÿ™Ñ$Ø�{‰{˜>Ñ*Ð*ä¨.Ô9€FØ"(€C‡K�K�ÑØ€Mr   ÚTc                  óX   — e Zd Z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dd
„Zy)Ú
SparseListz<A list-like data structure that only stores non-empty items.c                ó   — i | _         y r   ©Ú_data©Úselfs    r   Ú__init__zSparseList.__init__B   s	   € Ø#%ˆ�
r   c                ób   — t        |t        «      r|dk  rt        d«      ‚|| j                  |<   y )Nr   z0SparseList indices must be non-negative integers)Ú
isinstanceÚintÚ
IndexErrorr"   )r$   r   Úvalues      r   Ú__setitem__zSparseList.__setitem__E   s,   € Ü˜%¤Ô%¨°ªÜÐOÓPÐPà!ˆ�
‰
�5Òr   c                óZ   — || j                   vrt        d|› d�«      ‚| j                   |   S ©NzIndex z	 is empty©r"   ÚKeyError©r$   r   s     r   Ú__getitem__zSparseList.__getitem__K   s1   € Ø˜Ÿ
™
Ñ"Ü˜V E 7¨)Ð4Ó5Ð5à�z‰z˜%Ñ Ð r   c                óX   — || j                   v r| j                   |= y t        d|› d�«      ‚r-   r.   r0   s     r   Ú__delitem__zSparseList.__delitem__Q   s.   € Ø�D—J‘JÑØ—
‘
˜5Ñ!ä˜V E 7¨)Ð4Ó5Ð5r   c              #  ób   K  — t        | j                  «      D ]  }| j                  |   –— Œ y ­wr   ©Úsortedr"   r0   s     r   Ú__iter__zSparseList.__iter__W   s-   è ø€ ä˜DŸJ™JÓ'ò 	$ˆEØ—*‘*˜UÑ#Ó#ñ	$ùs   ‚-/c                ó,   — t        | j                  «      S r   )Úlenr"   r#   s    r   Ú__len__zSparseList.__len__\   s   € ä�4—:‘:‹Ðr   c              #  óf   K  — t        | j                  «      D ]  }|| j                  |   f–— Œ y­w)z2Iterate through (index, value) for filled entries.Nr5   r0   s     r   ÚitemszSparseList.items`   s2   è ø€ ä˜DŸJ™JÓ'ò 	+ˆEØ˜Ÿ™ EÑ*Ð*Ó*ñ	+ùs   ‚/1c                ó   — || j                   v S r   r!   r0   s     r   Ú__contains__zSparseList.__contains__e   s   € Ø˜Ÿ
™
Ð"Ð"r   c                óZ   — dj                  d„ | j                  «       D «       «      }d|› d�S )Nz, c              3  ó0   K  — | ]  \  }}|› d |› �–— Œ y­w)z: N© )Ú.0ÚiÚvs      r   ú	<genexpr>z&SparseList.__repr__.<locals>.<genexpr>i   s   è ø€ Ò?©$¨!¨Q˜Q˜C˜r ! œ+Ñ?ùs   ‚zSparseList({z}))Újoinr<   )r$   r<   s     r   Ú__repr__zSparseList.__repr__h   s+   € Ø—	‘	Ñ?°$·*±*³,Ô?Ó?ˆØ˜u˜g SÐ)Ð)r   N)ÚreturnÚNone)r   r(   r*   r   rH   rI   )r   r(   rH   r   )r   r(   rH   rI   )rH   zIterator[T]©rH   r(   )rH   zIterator[tuple[int, T]])r   r(   rH   Úbool©rH   Ústr)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r+   r1   r3   r7   r:   r<   r>   rG   rA   r   r   r   r   ?   s2   „ ÙFó&ó"ó!ó6ó$ó
ó+ó
#ô*r   r   c                  óÐ   — e Zd ZdZ	 	 d	 	 	 	 	 dd„Zdd„Zedd„«       Zedd„«       Zedd„«       Z	edd„«       Z
edd	„«       Zedd
„«       Zedd„«       Zdd„Zdd„Zedd„«       Zy)ÚCursora|  A pointer to a delta location in the app.

    When adding an element to the app, you should always call
    get_locked_cursor() on that element's respective Cursor.

    Parameters
    ----------
    transient_index: int | None
      The running index of the transient elements.
    transient_elements: SparseList[Element] | None
      The list of active transient elements.
    Nc                óF   — || _         |xs t        t           «       | _        y r   )Ú_transient_indexr   r	   Ú_transient_elements)r$   Útransient_indexÚtransient_elementss      r   r%   zCursor.__init__{   s!   € ð
 -<ˆÔØ#5Ò#N¼ÄGÑ9LÓ9NˆÕ r   c                ó,   — t        j                  | «      S r   )r   Úrepr_r#   s    r   rG   zCursor.__repr__ƒ   s   € Ü�z‰z˜$ÓÐr   c                ó   — t        «       ‚)zwThe top-level container this cursor lives within - either
        RootContainer.MAIN or RootContainer.SIDEBAR.
        ©ÚNotImplementedErrorr#   s    r   r   zCursor.root_container†   s   € ô
 "Ó#Ð#r   c                ó   — t        «       ‚)z0The cursor's parent's path within its container.r\   r#   s    r   r   zCursor.parent_path�   ó   € ô "Ó#Ð#r   c                ó   — t        «       ‚)z/The index of the Delta within its parent block.r\   r#   s    r   r   zCursor.index’   r_   r   c                óX   — t        | j                  | j                  | j                  «      S )zrThe complete path of the delta pointed to by this cursor - its
        container, parent path, and index.
        )r   r   r   r   r#   s    r   r   zCursor.delta_path—   s#   € ô
 ˜t×2Ñ2°D×4DÑ4DÀdÇjÁjÓQÐQr   c                ó   — t        «       ‚r   r\   r#   s    r   Ú	is_lockedzCursor.is_lockedž   s   € ä!Ó#Ð#r   c                ó   — | j                   S r   )rV   r#   s    r   rX   zCursor.transient_elements¢   s   € à×'Ñ'Ð'r   c                ó6   — | j                   €dS | j                   S )Nr   ©rU   r#   s    r   rW   zCursor.transient_index¦   s   € à×)Ñ)Ð1ˆqÐL°t×7LÑ7LÐLr   c                ó   — t        «       ‚r   r\   ©r$   Úpropss     r   Úget_locked_cursorzCursor.get_locked_cursorª   s   € Ü!Ó#Ð#r   c                óZ   — | j                   €	d| _         | S | xj                   dz  c_         | S )Nr   é   rf   r#   s    r   Úget_transient_cursorzCursor.get_transient_cursor­   s5   € Ø× Ñ Ð(Ø$%ˆDÔ!ð ˆð ×!Ò! QÑ&Õ!àˆr   c                ó   — t        «       ‚)zÃOther data in this cursor. This is a temporary measure that will go
        away when we implement improved return values for elements.

        This is only implemented in LockedCursor.
        r\   r#   s    r   ri   zCursor.propsµ   s   € ô "Ó#Ð#r   )NN)rW   ú
int | NonerX   úSparseList[Element] | NonerH   rI   rL   rJ   ©rH   útuple[int, ...])rH   ú	list[int]©rH   rK   )rH   zSparseList[Element]©ri   r   rH   ÚLockedCursor)rH   rS   ©rH   r   )rN   rO   rP   rQ   r%   rG   Úpropertyr   r   r   r   rc   rX   rW   rj   rm   ri   rA   r   r   rS   rS   m   sç   „ ñð '+Ø9=ðOà#ðOð 7ðOð 
ó	Oó ð ò$ó ð$ð ò$ó ð$ð ò$ó ð$ð òRó ðRð ò$ó ð$ð ò(ó ð(ð òMó ðMó$óð ò$ó ñ$r   rS   c                  óŠ   ‡ — e Zd Z	 	 	 d	 	 	 	 	 	 	 	 	 dˆ fd„Zed	d„«       Zed
d„«       Zed	d„«       Zedd„«       Zdd„Z	ˆ xZ
S )r   c                óP   •— t         ‰| �  ||«       || _        || _        d| _        y)aŠ  A moving pointer to a delta location in the app.

        RunningCursors auto-increment to the next available location when you
        call get_locked_cursor() on them.

        Parameters
        ----------
        root_container: int
            The root container this cursor lives in.
        parent_path: tuple of ints
          The full path of this cursor, consisting of the IDs of all ancestors.
          The 0th item is the topmost ancestor.
        transient_index: int | None
          The running index of the transient elements.
        transient_elements: SparseList[Element]
          The list of active transient elements.

        r   N)Úsuperr%   Ú_root_containerÚ_parent_pathÚ_index)r$   r   r   rW   rX   Ú	__class__s        €r   r%   zRunningCursor.__init__À   s,   ø€ ô2 	‰Ñ˜Ð*<Ô=Ø-ˆÔØ'ˆÔØˆ�r   c                ó   — | j                   S r   ©r|   r#   s    r   r   zRunningCursor.root_containerÞ   ó   € à×#Ñ#Ð#r   c                ó   — | j                   S r   ©r}   r#   s    r   r   zRunningCursor.parent_pathâ   ó   € à× Ñ Ð r   c                ó   — | j                   S r   ©r~   r#   s    r   r   zRunningCursor.indexæ   ó   € à�{‰{Ðr   c                 ó   — y)NFrA   r#   s    r   rc   zRunningCursor.is_lockedê   s   € àr   c                óÄ   — t        d| j                  | j                  | j                  dœ|¤Ž}| xj                  dz  c_        d | _        t        t           «       | _        |S )N)r   r   r   rl   rA   )rv   r|   r}   r~   rU   r   r	   rV   )r$   ri   Úlocked_cursors      r   rj   zRunningCursor.get_locked_cursorî   sb   € Ü$ð 
Ø×/Ñ/Ø×)Ñ)Ø—+‘+ñ
ð ñ	
ˆð 	�Š�qÑ�Ø $ˆÔÜ#-¬gÑ#6Ó#8ˆÔ àÐr   )rA   NN)
r   r(   r   rr   rW   ro   rX   rp   rH   rI   rJ   rq   rt   ru   )rN   rO   rP   r%   rx   r   r   r   rc   rj   Ú__classcell__©r   s   @r   r   r   ¿   s˜   ø„ ð (*Ø&*Ø9=ðàðð %ðð $ð	ð
 7ðð 
õð< ò$ó ð$ð ò!ó ð!ð òó ðð òó ð÷r   r   c                  ó¦   ‡ — e Zd Z	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d	ˆ fd„Zed
d„«       Zedd„«       Zed
d„«       Zedd„«       Zedd„«       Z	dd„Z
ˆ xZS )rv   c                ó^   •— t         ‰| �  ||«       || _        || _        || _        || _        y)aX  A locked pointer to a location in the app.

        LockedCursors always point to the same location, even when you call
        get_locked_cursor() on them.

        Parameters
        ----------
        root_container: int
            The root container this cursor lives in.
        parent_path: tuple of ints
          The full path of this cursor, consisting of the IDs of all ancestors. The
          0th item is the topmost ancestor.
        index: int
        transient_index: int | None
          The running index of the transient elements.
        transient_elements: SparseList[Element]
          The list of active transient elements.
        **props: any
          Anything else you want to store in this cursor. This is a temporary
          measure that will go away when we implement improved return values
          for elements.

        N)r{   r%   r|   r~   r}   Ú_props)r$   r   r   r   rW   rX   ri   r   s          €r   r%   zLockedCursor.__init__þ   s4   ø€ ô@ 	‰Ñ˜Ð*<Ô=Ø-ˆÔØˆŒØ'ˆÔØˆ�r   c                ó   — | j                   S r   r�   r#   s    r   r   zLockedCursor.root_container$  r‚   r   c                ó   — | j                   S r   r„   r#   s    r   r   zLockedCursor.parent_path(  r…   r   c                ó   — | j                   S r   r‡   r#   s    r   r   zLockedCursor.index,  rˆ   r   c                 ó   — y)NTrA   r#   s    r   rc   zLockedCursor.is_locked0  s   € àr   c                ó   — | j                   S r   ©r�   r#   s    r   ri   zLockedCursor.props4  rˆ   r   c                ó   — || _         | S r   r–   rh   s     r   rj   zLockedCursor.get_locked_cursor8  s   € ØˆŒØˆr   )rA   r   NN)r   r(   r   rr   r   r(   rW   ro   rX   rp   ri   r   rH   rI   rJ   rq   rt   rw   ru   )rN   rO   rP   r%   rx   r   r   r   rc   ri   rj   rŒ   r�   s   @r   rv   rv   ý   sÄ   ø„ ð (*ØØ&*Ø9=ð$àð$ð %ð$ð ð	$ð
 $ð$ð 7ð$ð ð$ð 
õ$ðL ò$ó ð$ð ò!ó ð!ð òó ðð òó ðð òó ð÷r   rv   N)r   r(   r   rr   r   r(   rH   rs   )r   ro   rH   zRunningCursor | None)Ú
__future__r   Útypingr   r   r   r   Ú	streamlitr   Ústreamlit.proto.Element_pb2r	   Ú7streamlit.runtime.scriptrunner_utils.script_run_contextr
   Úcollections.abcr   r   r   r   r   rS   r   rv   rA   r   r   ú<module>rž      s›   ðõ #ç 7Ó 7å Ý /Ý VáÝ(ðØðØ&5ðØ>AðàóðØðàóñ0 ˆCƒL€ô+*�˜‘ô +*÷\O$ñ O$ôd;�Fô ;ô|=�6õ =r   