
    dh                        S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
  \(       a  S SKJr  S SKJr   " S S\5      r " S S	\	5      r " S
 S5      rg)    )annotations)Enum)TYPE_CHECKINGAnyDictList
NamedTupleOptional)DeltaGenerator)SupportsStrc                       \ rS rSrSrSrSrSrg)	ChildType   zEnumerator of the child type.MARKDOWN	EXCEPTION N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r       p/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/callbacks/streamlit/mutable_expander.pyr   r      s    'HIr   r   c                  8    \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)ChildRecord   zChild record as a NamedTuple.r   typeDict[str, Any]kwargsr   dgr   N)r   r   r   r   r   __annotations__r   r   r   r   r   r      s    '
Or   r   c                      \ rS rSrSrSS jr\SS j5       r\SS j5       rSS jr	SS jr
SSS	.     SS
 jjr SSSS.         SS jjjrSS.     SS jjrSS jrSS jrSS jrSrg)MutableExpander   zJStreamlit expander that can be renamed and dynamically expanded/collapsed.c                    X l         X0l        UR                  5       U l        U R                  R	                  X#5      U l        / U l        g)a  Create a new MutableExpander.

Parameters
----------
parent_container
    The `st.container` that the expander will be created inside.

    The expander transparently deletes and recreates its underlying
    `st.expander` instance when its label changes, and it uses
    `parent_container` to ensure it recreates this underlying expander in the
    same location onscreen.
label
    The expander's initial label.
expanded
    The expander's initial `expanded` value.
N)_label	_expandedempty_parent_cursorexpander
_container_child_records)selfparent_containerlabelexpandeds       r   __init__MutableExpander.__init__   s?    " !.446--66uG13r   c                    U R                   $ )zExpander's label string.)r'   r.   s    r   r0   MutableExpander.label4   s     {{r   c                    U R                   $ )z6True if the expander was created with `expanded=True`.)r(   r5   s    r   r1   MutableExpander.expanded9   s     ~~r   c                v    U R                   R                  5       U l        U R                  R	                  5         g)zURemove the container and its contents entirely. A cleared container can't
be reused.
N)r*   r)   r,   r-   clearr5   s    r   r:   MutableExpander.clear>   s,     --335!!#r   c                    UR                   R                  5       nU H)  nU R                  UR                  UR                  5        M+     g)zMAppend a copy of another MutableExpander's children to this
MutableExpander.
N)r-   copy_create_childr   r    )r.   otherother_recordsrecords       r   append_copyMutableExpander.append_copyE   s:     ,,113#Fv{{FMM: $r   N)	new_labelnew_expandedc               ^   Uc  U R                   nUc  U R                  nU R                   U:X  a  U R                  U:X  a  gXl         X l        U R                  R                  X5      U l        U R
                  n/ U l        U H)  nU R                  UR                  UR                  5        M+     g)z.Change the expander's label and expanded stateN)	r'   r(   r*   r+   r,   r-   r>   r   r    )r.   rD   rE   prev_recordsrA   s        r   updateMutableExpander.updateM   s     I>>L;;)#,(F%--66yO**  #Fv{{FMM: #r   )helpindexc                   XUS.nU R                  U5      R                  " S0 UD6n[        [        R                  XV5      nU R                  Xt5      $ )z=Add a Markdown element to the container and return its index.)bodyunsafe_allow_htmlrJ   r   )_get_dgmarkdownr   r   r   _add_record)r.   rM   rN   rJ   rK   r    new_dgrA   s           r   rP   MutableExpander.markdowne   sN     PTUe$--77Y//@..r   )rK   c                   SU0nU R                  U5      R                  " S0 UD6n[        [        R                  X45      nU R                  XR5      $ )z?Add an Exception element to the container and return its index.	exceptionr   )rO   rU   r   r   r   rQ   )r.   rU   rK   r    rR   rA   s         r   rU   MutableExpander.exceptions   sM     y)e$..88Y00&A..r   c                    U[         R                  :X  a  U R                  " S0 UD6  gU[         R                  :X  a  U R                  " S0 UD6  g[        SU 35      e)z(Create a new child with the given paramszUnexpected child type Nr   )r   r   rP   r   rU   RuntimeError)r.   r   r    s      r   r>   MutableExpander._create_child|   sO    9%%%MM#F#Y(((NN$V$!7v>??r   c                    Ub  XR                   U'   U$ U R                   R                  U5        [        U R                   5      S-
  $ )zAdd a ChildRecord to self._children. If `index` is specified, replace
the existing record at that index. Otherwise, append the record to the
end of the list.

Return the index of the added record.
   )r-   appendlen)r.   rA   rK   s      r   rQ   MutableExpander._add_record   sI     )/&L 	""6*4&&'!++r   c                    UbE  SUs=::  a  [        U R                  5      :  d  O   SU 35       eU R                  U   R                  $ U R                  $ )Nr   zBad index: )r]   r-   r!   r,   )r.   rK   s     r   rO   MutableExpander._get_dg   sU    8D$7$7 88OKw:OO8&&u-000 r   )r-   r,   r(   r'   r*   )r/   r   r0   strr1   bool)returnra   )rc   rb   )rc   None)r?   r$   rc   rd   )rD   Optional[str]rE   zOptional[bool]rc   rd   )F)
rM   r   rN   rb   rJ   re   rK   Optional[int]rc   int)rU   BaseExceptionrK   rf   rc   rg   )r   r   r    r   rc   rd   )rA   r   rK   rf   rc   rg   )rK   rf   rc   r   )r   r   r   r   r   r2   propertyr0   r1   r:   rB   rH   rP   rU   r>   rQ   rO   r   r   r   r   r$   r$      s    T4.    $; -1QU;);@N;	;6 #(/
 ##//  /
 / / 
/ CG/&/2?/	/@, r   r$   N)
__future__r   enumr   typingr   r   r   r   r	   r
   streamlit.delta_generatorr   streamlit.type_utilr   r   r   r$   r   r   r   <module>ro      s>    "  G G8/ * B Br   