
    %er              	           d dl mZmZmZmZ d dlmZ d dlmZ de	dee	df         de	dee	         fd	Z
dee	         ded
         fdZ G d d          Z G d d
e          Z G d de          ZdS )    )AnyListOptionalTuple)util)get_script_run_ctxroot_containerparent_path.indexreturnc                 `    | g}|                     |           |                    |           |S N)extendappend)r	   r
   r   
delta_paths       0lib/python3.11/site-packages/streamlit/cursor.pymake_delta_pathr      s:     !!Jk"""e    RunningCursorc                     | dS t                      }|dS | |j        v r|j        |          S t          |           }||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   cursorsr   )r	   ctxcursors      r   get_container_cursorr      s_     t


C
{t$${>**.999F"(CKMr   c                       e Zd ZdZdefdZedefd            Zede	edf         fd            Z
edefd            Zedee         fd            Zedefd	            ZddZedef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   c                 *    t          j        |           S r   )r   repr_selfs    r   __repr__zCursor.__repr__=   s    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_pathG        "###r   c                     t                      )z/The index of the Delta within its parent block.r#   r   s    r   r   zCursor.indexL   r&   r   c                 B    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_pathQ   s    
 t2D4DdjQQQr   c                     t                      r   r#   r   s    r   	is_lockedzCursor.is_lockedX   s    !###r   LockedCursorc                     t                      r   r#   r    propss     r   get_locked_cursorzCursor.get_locked_cursor\   s    !###r   c                     t                      )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   s    r   r.   zCursor.props_   s     "###r   Nr   r+   )__name__
__module____qualname____doc__strr!   propertyintr	   r   r
   r   r   r   boolr*   r/   r   r.    r   r   r   r   6   sH         #         $ $ $ $ X$ $U38_ $ $ $ X$ $s $ $ $ X$ RDI R R R XR $4 $ $ $ X$$ $ $ $ $s $ $ $ X$ $ $r   r   c                       e Zd Zddedeedf         fdZedefd            Zedeedf         fd            Zedefd	            Z	ede
fd
            ZddZdS )r   r:   r	   r
   .c                 0    || _         || _        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
   s      r   __init__zRunningCursor.__init__j   s      .'r   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                     dS )NFr:   r   s    r   r*   zRunningCursor.is_locked   s    ur   r+   c                 d    t          d| j        | j        | j        d|}| xj        dz  c_        |S )N)r	   r
   r      r:   )r+   r=   r>   r?   )r    r.   locked_cursors      r   r/   zRunningCursor.get_locked_cursor   sN    $ 
/)+
 
 	
 
 	qr   N)r:   r1   )r2   r3   r4   r8   r   r@   r7   r	   r
   r   r9   r*   r/   r:   r   r   r   r   i   s         s sCx    & $ $ $ $ X$ !U38_ ! ! ! X! s    X 4    X
 
 
 
 
 
r   c                       e Zd Z	 	 ddedeedf         defdZedefd	            Zedeedf         fd
            Zedefd            Z	ede
fd            ZddZedefd            ZdS )r+   r:   r   r	   r
   .r   c                 >    || _         || _        || _        || _        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)r=   r?   r>   _props)r    r	   r
   r   r.   s        r   r@   zLockedCursor.__init__   s&    4  .'r   r   c                     | j         S r   rB   r   s    r   r	   zLockedCursor.root_container   rC   r   c                     | j         S r   rE   r   s    r   r
   zLockedCursor.parent_path   rF   r   c                     | j         S r   rH   r   s    r   r   zLockedCursor.index   rI   r   c                     dS )NTr:   r   s    r   r*   zLockedCursor.is_locked   s    tr   c                     || _         | S r   rP   r-   s     r   r/   zLockedCursor.get_locked_cursor   s    r   c                     | j         S r   rV   r   s    r   r.   zLockedCursor.props   rI   r   N)r:   r   r1   )r2   r3   r4   r8   r   r@   r7   r	   r
   r   r9   r*   r/   r   r.   r:   r   r   r+   r+      s8        (*	  38_ 	   > $ $ $ $ X$ !U38_ ! ! ! X! s    X 4    X    s    X  r   r+   N)typingr   r   r   r   	streamlitr   streamlit.runtime.scriptrunnerr   r8   r   r   r   r   r+   r:   r   r   <module>r[      sD   . - - - - - - - - - - -       = = = = = =&+CHo>A	#Y   SMo   00$ 0$ 0$ 0$ 0$ 0$ 0$ 0$f. . . . .F . . .b6 6 6 6 66 6 6 6 6 6r   