o
    ,&]i  ã                   @  s\   U d dl mZ d dlmZmZmZ d dlmZ eeƒZ	de
d< er'd dlmZ ddd„ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚFinal)Ú
get_loggerr   Ú_LOGGER)ÚSessionStateÚsession_stater   Ú	widget_idÚstrÚ
base_valuer   Úreturnc                 C  sŒ   z:|   |¡}|durt|ddƒnd}|du r|W S t|ƒs't d||¡ |W S z||| ƒW W S  ty:   | Y W S w  tyE   | Y S w )aÞ  Return the user-visible value for a widget if it has a ``presenter``.

    If the widget's metadata defines a ``presenter`` callable, it is used to
    transform the stored value into its presentation form. Any exception raised
    while resolving metadata or invoking the presenter is swallowed and
    ``base_value`` is returned, so presentation never interferes with core
    behavior.

    Notes
    -----
    Presentation is applied exclusively for user-facing access paths such as:
    - `st.session_state[... ]` via `SessionState.__getitem__`
    - `SessionState.filtered_state`

    Internal serialization paths (for example `WStates.as_widget_states()` and
    `SessionState.get_widget_states()`) must operate on base (unpresented)
    values to ensure stable and lossless serialization. Do not use
    `apply_presenter` in serialization code paths.

    Parameters
    ----------
    session_state : SessionState
        The current session state object that holds widget state and metadata.
    widget_id : str
        The identifier of the widget whose value is being presented.
    base_value : Any
        The raw value stored for the widget.

    Returns
    -------
    Any
        The value that should be shown to the user.
    NÚ	presenterzDWidget '%s' has a non-callable presenter (%r); returning base value.)Ú_get_widget_metadataÚgetattrÚcallabler   ÚwarningÚ	Exception)r	   r
   r   Úmetar   © r   úb/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/runtime/state/presentation.pyÚapply_presenter   s(   %
ý
ÿþr   N)r	   r   r
   r   r   r   r   r   )Ú
__future__r   Útypingr   r   r   Ústreamlit.loggerr   Ú__name__r   Ú__annotations__Ú%streamlit.runtime.state.session_stater   r   r   r   r   r   Ú<module>   s   