Ë
    úmxiX   ã                  ó  — U 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 d dlmZ d dlmZ d dlmZ d d	lmZmZ d d
lmZ d dlmZ erd dlmZ d dlmZ d dlmZ ed   Z de!d<   	 	 	 	 dd„Z"dd„Z# G d„ de
«      Z$y)é    )Úannotations)ÚTYPE_CHECKINGÚLiteralÚ	TypeAliasÚcast)ÚSelf)ÚDeltaGenerator)Úcompute_and_register_element_id)ÚStreamlitAPIException)ÚBlock)Ú
ForwardMsg)Úenqueue_messageÚget_script_run_ctx)Úregister_widget)Úvalidate_icon_or_emoji)ÚTracebackType)ÚCursor)ÚWidgetCallback)ÚsmallÚlargeÚmediumr   ÚDialogWidthc                óî   — | dk(  r$t         j                  j                  j                  S | dk(  r$t         j                  j                  j                  S t         j                  j                  j
                  S )z¦Maps the user-provided literal to a value of the DialogWidth proto enum.

    Returns the mapped enum field for "small" by default and otherwise the mapped type.
    r   r   )Ú
BlockProtoÚDialogr   ÚLARGEÚMEDIUMÚSMALL)Úwidths    úT/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/elements/lib/dialog.pyÚ_process_dialog_width_inputr!   *   s\   € ð �ÒÜ× Ñ ×,Ñ,×2Ñ2Ð2Ø�ÒÜ× Ñ ×,Ñ,×3Ñ3Ð3ä×Ñ×(Ñ(×.Ñ.Ð.ó    c                ó`   — t        «       }| r"|r|j                  rt        d«      ‚d|_        yyy)a«  Check whether a dialog has already been opened in the same script run.

    Only one dialog is supposed to be opened. The check is implemented in a way
    that for a script run, the open function can only be called once.
    One dialog at a time is a product decision and not a technical one.

    Raises
    ------
    StreamlitAPIException
        Raised when a dialog has already been opened in the current script run.
    z’Only one dialog is allowed to be opened at the same time. Please make sure to not call a dialog-decorated function more than once in a script run.TN)r   Úhas_dialog_openedr   )Úshould_openÚscript_run_ctxs     r    Ú!_assert_first_dialog_to_be_openedr'   9   s@   € ô (Ó)€Nñ ‘~Ø×+Ò+Ü'ðkóð ð ,0ˆÕ(ð &€{r"   c                  ó¬   ‡ — e Zd Zedddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Z	 	 	 	 	 	 	 	 	 	 dˆ fd„Zdd„Zdd	„Zdd
„Zdˆ fd„Z		 	 	 	 	 	 	 	 dˆ fd„Z
ˆ xZS )r   Tr   NÚignore)Údismissibler   ÚiconÚ
on_dismissc               ó¶  — |dvrt        |«      st        d|› d�«      ‚t        «       }||j                  _        ||j                  _        t        |«      |j                  _        t        |«      |j                  _	        t        dd d| ||||t        |«      st        |«      nd¬«	      }||_        |dk7  }|r;t        «       }	||j                  _        t        |t        |«      r|nd d	„ d
„ |	d¬«       | j                  j                   r | j                  j                   j"                  ng }
t%        d| j'                  |t(        ¬«      «      }|
|_        ||_        |S )N)r)   ÚrerunzYou have passed zI to `on_dismiss`. But only 'ignore', 'rerun', or a callable is supported.ÚdialogFÚcallback)Úuser_keyÚkey_as_main_identityÚdgÚtitler*   r   r+   r,   r)   c                ó   — | S ©N© ©Úxs    r    ú<lambda>z Dialog._create.<locals>.<lambda>�   s   €  q€ r"   c                ó   — | S r6   r7   r8   s    r    r:   z Dialog._create.<locals>.<lambda>‘   s   €  Q€ r"   Útrigger_value)Úon_change_handlerÚdeserializerÚ
serializerÚctxÚ
value_typer   )Úblock_protoÚdg_type)Úcallabler   r   r/   r4   r*   r!   r   r   r+   r
   ÚstrÚidr   r   Ú
_active_dgÚ_cursorÚ
delta_pathr   Ú_blockr   Ú_delta_pathÚ_current_proto)Úparentr4   r*   r   r+   r,   rB   Ú
element_idÚis_dismiss_activatedr@   rI   r/   s               r    Ú_createzDialog._createS   sd  € ð Ð0Ñ0¼À*Ô9MÜ'Ø" : ,ð /7ð 7óð ô
 !“lˆØ#(ˆ×ÑÔ Ø)4ˆ×ÑÔ&Ü#>¸uÓ#Eˆ×ÑÔ Ü"8¸Ó">ˆ×ÑÔô 5ØØØ!&ØØØ#ØØÜ.6°zÔ.B”s˜:”È
ô

ˆ
ð $ˆŒð  *¨XÑ5Ðáô %Ó&ˆCð %/ˆK×ÑÔ!äØÜ08¸Ô0D¡*È$Ù(Ù&ØØ*õð 5;×4EÑ4E×4MÒ4MˆF×Ñ×%Ñ%×0Ò0ÐSUð 	ô �h §¡¸+Ìv Ó VÓWˆà'ˆÔØ +ˆÔàˆr"   c                óF   •— t         ‰| �  ||||«       d | _        d | _        y r6   )ÚsuperÚ__init__rL   rK   )ÚselfÚroot_containerÚcursorrM   Ú
block_typeÚ	__class__s        €r    rS   zDialog.__init__£   s*   ø€ ô 	‰Ñ˜¨°¸ÔDð 26ˆÔØ-1ˆÕr"   c                ó®  — | j                   �| j                  €t        d«      ‚t        |«       t	        «       }| j                  |j
                  j                  dd |j                  j                  j                  | j                   «       ||j                  j                  j                  _        |j                  j                  | _         t        |«       y)zISend an updated proto message to indicate the open-status for the dialog.Nz;Dialog not correctly initialized. This should never happen.)rL   rK   ÚRuntimeErrorr'   r   ÚmetadatarI   ÚdeltaÚ	add_blockÚCopyFromr/   Úis_openr   )rT   r%   Úmsgs      r    Ú_updatezDialog._update°   s¦   € ð ×ÑÐ&¨$×*:Ñ*:Ð*BÜØMóð ô 	*¨+Ô6Ü‹lˆØ%)×%5Ñ%5ˆ�‰×Ñ¡Ð"Ø�	‰	×Ñ×$Ñ$ T×%8Ñ%8Ô9Ø-8ˆ�	‰	×Ñ×"Ñ"Ô*Ø!Ÿi™i×1Ñ1ˆÔä˜Õr"   c                ó&   — | j                  d«       y )NT©ra   ©rT   s    r    ÚopenzDialog.openÁ   s   € Ø�‰�TÕr"   c                ó&   — | j                  d«       y )NFrc   rd   s    r    ÚclosezDialog.closeÄ   s   € Ø�‰�UÕr"   c                ó$   •— t         ‰| �  «        | S r6   )rR   Ú	__enter__)rT   rX   s    €r    ri   zDialog.__enter__Ç   s   ø€ ô 	‰ÑÔØˆr"   c                ó&   •— t         ‰| �  |||«      S r6   )rR   Ú__exit__)rT   Úexc_typeÚexc_valÚexc_tbrX   s       €r    rk   zDialog.__exit__Î   s   ø€ ô ‰wÑ ¨'°6Ó:Ð:r"   )rM   r	   r4   rE   r*   Úboolr   r   r+   ú
str | Noner,   z+Literal['ignore', 'rerun'] | WidgetCallbackÚreturnr   )
rU   z
int | NonerV   zCursor | NonerM   zDeltaGenerator | NonerW   rp   rq   ÚNone©r%   ro   rq   rr   )rq   rr   )rq   r   )rl   ztype[BaseException] | Nonerm   zBaseException | Nonern   zTracebackType | Nonerq   zLiteral[False])Ú__name__Ú
__module__Ú__qualname__ÚstaticmethodrP   rS   ra   re   rg   ri   rk   Ú__classcell__)rX   s   @r    r   r   R   sé   ø„ Øð
 !Ø$ØØBJñMØðMàðMð ð	Mð
 ðMð ðMð @ðMð 
òMó ðMð^2à"ð2ð ð2ð &ð	2ð
 ð2ð 
õ2óó"óõð;à,ð;ð &ð;ð %ð	;ð
 
÷;ñ ;r"   r   N)r   r   rq   z'BlockProto.Dialog.DialogWidth.ValueTypers   )%Ú
__future__r   Útypingr   r   r   r   Útyping_extensionsr   Ústreamlit.delta_generatorr	   Ústreamlit.elements.lib.utilsr
   Ústreamlit.errorsr   Ústreamlit.proto.Block_pb2r   r   Ústreamlit.proto.ForwardMsg_pb2r   Ú7streamlit.runtime.scriptrunner_utils.script_run_contextr   r   Ústreamlit.runtime.stater   Ústreamlit.string_utilr   Útypesr   Ústreamlit.cursorr   r   r   Ú__annotations__r!   r'   r   r7   r"   r    ú<module>r‡      ss   ðö #ç :Ó :å "å 4Ý HÝ 2Ý 9Ý 5÷õ 4Ý 8áÝ#å'Ý6à Ð!;Ñ<€ˆYÓ <ð/Øð/à,ó/ó0ô2B;ˆ^õ B;r"   