o
    沪g                     @  sv   d dl mZ d dlmZ d dlmZ d dlmZ dddZdddZ	G dd dZ
G dd de
ZG dd de
ZdS )    )annotations)Any)util)get_script_run_ctxroot_containerintparent_pathtuple[int, ...]indexreturn	list[int]c                 C  s   | g}| | || |S N)extendappend)r   r   r
   
delta_path r   L/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/cursor.pymake_delta_path   s   

r   
int | NoneRunningCursor | Nonec                 C  sJ   | du rdS t  }|du rdS | |jv r|j|  S t| d}||j| < |S )zReturn 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cursorr   r   r   get_container_cursor    s   



r   c                   @  sx   e Zd ZdZdddZedddZedd
dZedddZedddZ	edddZ
d ddZed!ddZdS )"CursorzA 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.
    r   strc                 C  s
   t | S r   )r   repr_selfr   r   r   __repr__?   s   
zCursor.__repr__r   c                 C     t  )zwThe top-level container this cursor lives within - either
        RootContainer.MAIN or RootContainer.SIDEBAR.
        NotImplementedErrorr   r   r   r   r   B   s   zCursor.root_containerr	   c                 C  r!   )z0The cursor's parent's path within its container.r"   r   r   r   r   r   I      zCursor.parent_pathc                 C  r!   )z/The index of the Delta within its parent block.r"   r   r   r   r   r
   N   r$   zCursor.indexr   c                 C  s   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   r   r   r   r   S   s   zCursor.delta_pathboolc                 C  r!   r   r"   r   r   r   r   	is_lockedZ      zCursor.is_lockedLockedCursorc                 K  r!   r   r"   r   propsr   r   r   get_locked_cursor^   s   zCursor.get_locked_cursorr   c                 C  r!   )zOther 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   r   r   r   r*   a   s   zCursor.propsN)r   r   r   r   r   r	   )r   r   r   r%   r   r(   r   r   )__name__
__module____qualname____doc__r    propertyr   r   r
   r   r&   r+   r*   r   r   r   r   r   8   s     

r   c                   @  sZ   e Zd ZddddZedd	d
ZedddZedddZedddZdddZ	dS )r   r   r   r   r   r	   c                 C  s   || _ || _d| _dS )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.

        r   N)_root_container_parent_path_index)r   r   r   r   r   r   __init__l   s   
zRunningCursor.__init__r   c                 C     | j S r   r6   r   r   r   r   r      r'   zRunningCursor.root_containerc                 C  r:   r   r7   r   r   r   r   r      r'   zRunningCursor.parent_pathc                 C  r:   r   r8   r   r   r   r   r
      r'   zRunningCursor.indexr%   c                 C     dS )NFr   r   r   r   r   r&         zRunningCursor.is_lockedr(   c                 K  s.   t d| j| j| jd|}|  jd7  _|S )N)r   r   r
      r   )r(   r6   r7   r8   )r   r*   locked_cursorr   r   r   r+      s   zRunningCursor.get_locked_cursorN)r   )r   r   r   r	   r,   r-   r.   r/   )
r1   r2   r3   r9   r5   r   r   r
   r&   r+   r   r   r   r   r   k   s    r   c                   @  sl   e Zd Z		dddd	ZedddZedddZedddZedddZdddZ	ed ddZ
dS )!r(   r   r   r   r   r   r	   r
   c                 K  s   || _ || _|| _|| _dS )a  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
        **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)r6   r8   r7   _props)r   r   r   r
   r*   r   r   r   r9      s   
zLockedCursor.__init__r   c                 C  r:   r   r;   r   r   r   r   r      r'   zLockedCursor.root_containerc                 C  r:   r   r<   r   r   r   r   r      r'   zLockedCursor.parent_pathc                 C  r:   r   r=   r   r   r   r   r
      r'   zLockedCursor.indexr%   c                 C  r>   )NTr   r   r   r   r   r&      r?   zLockedCursor.is_lockedc                 K  s
   || _ | S r   rB   r)   r   r   r   r+      s   zLockedCursor.get_locked_cursorr   c                 C  r:   r   rC   r   r   r   r   r*      r'   zLockedCursor.propsN)r   r   )r   r   r   r	   r
   r   r,   r-   r.   r/   r0   )r1   r2   r3   r9   r5   r   r   r
   r&   r+   r*   r   r   r   r   r(      s    
r(   N)r   r   r   r	   r
   r   r   r   )r   r   r   r   )
__future__r   typingr   	streamlitr   7streamlit.runtime.scriptrunner_utils.script_run_contextr   r   r   r   r   r(   r   r   r   r   <module>   s   

	31