Ë
    EêñiI  ã                  óÒ   — d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
 erddlmZ ddlmZ ddlmZ dd	„Zdd
„Zdd„Zdd„Z G d„ deeef   «      ZdZ G d„ de«      Zdd„Zy)zA bunch of useful utilities.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)ÚRootContainer)ÚCallable)Ú_Hash)ÚDeltaGeneratorc                óL   ‡ ‡— g Št        j                  ‰ «      dˆ ˆfd„«       }|S )z2Decorator to memoize the result of a no-args func.c                 ó>   •— ‰s‰j                   ‰ «       «       ‰d   S ©Nr   )Úappend)ÚfuncÚresults   €€úP/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/streamlit/util.pyÚwrapped_funczmemoize.<locals>.wrapped_func%   s   ø€ áØ�M‰M™$›&Ô!Ø�a‰yÐó    )Úreturnr   )Ú	functoolsÚwraps)r   r   r   s   ` @r   Úmemoizer   !   s+   ù€ à€Fä‡_�_�TÓõó ðð
 Ðr   c                óB  ‡ ‡— ‰ j                   j                  }dddg t        «       i gŠt        j                  ‰ «      r ˆˆ fd„t        j
                  ‰ «      D «       }n#ˆfd„‰ j                  j                  «       D «       }dj                  d„ |D «       «      }|› d|› d	�S )
z€A clean repr for a class, excluding both values that are likely defaults,
    and those explicitly default for dataclasses.
    NÚ Fc              3  óð   •K  — | ]m  }|j                   r_t        ‰|j                  «      |j                  k7  r<t        ‰|j                  «      ‰vr$|j                  t        ‰|j                  «      f–— Œo y ­w©N)ÚreprÚgetattrÚnameÚdefault)Ú.0ÚfÚdefaultsÚselfs     €€r   ú	<genexpr>zrepr_.<locals>.<genexpr>7   s^   øè ø€ ò 
àØ�vŠvÜ˜˜aŸf™fÓ%¨¯©Ò2Ü˜˜aŸf™fÓ%¨XÑ5ð	 �V‰V”W˜T 1§6¡6Ó*Ô+ñ
ùs   ƒA3A6c              3  ó6   •K  — | ]  \  }}|‰vsŒ||f–— Œ y ­wr   © )r   r    Úvr!   s      €r   r#   zrepr_.<locals>.<genexpr>?   s    øè ø€ ÒW¡& 1 aÀQÈhÒEV˜˜1”vÑWùs   ƒ�	z, c              3  ó0   K  — | ]  \  }}|› d |›�–— Œ y­w)ú=Nr%   )r   ÚfieldÚvalues      r   r#   zrepr_.<locals>.<genexpr>A   s   è ø€ ÒQ±\°U¸E˜u˜g Q u iÔ0ÑQùs   ‚ú(ú))	Ú	__class__Ú__name__ÚsetÚdataclassesÚis_dataclassÚfieldsÚ__dict__ÚitemsÚjoin)r"   Ú	classnameÚfields_valsÚfield_reprsr!   s   `   @r   Úrepr_r9   .   s“   ù€ ð —‘×'Ñ'€Ið    U¨B´³°rÐ:€HÜ×Ñ Ô%ô
ä ×'Ñ'¨Ó-ô
‰ó X¨D¯M©M×,?Ñ,?Ó,AÔWˆà—)‘)ÑQÀ[ÔQÓQ€KØˆ[˜˜+˜ aÐ(Ð(r   c                 ó.   — t        j                  d¬«      S )zxCreate a fast hasher for incremental hashing.

    Uses BLAKE2b which produces 32-character hex digests (16 bytes).
    é   )Údigest_size)ÚhashlibÚblake2br%   r   r   Úcreate_fast_hasherr?   E   s   € ô
 �?‰? rÔ*Ð*r   c                óž   — t        | t        «      r| j                  d«      n| }t        «       }|j	                  |«       |j                  «       S )z¸Return a fast hash of the given string.

    Uses BLAKE2b (~2.4x faster than MD5) and produces 32-character hex digests.
    This should not be used for security-related purposes.
    zutf-8)Ú
isinstanceÚstrÚencoder?   ÚupdateÚ	hexdigest)ÚsÚbÚhs      r   Ú	calc_hashrI   M   s<   € ô (¨¬3Ô/ˆ�‰�Ô°Q€AÜÓ€AØ‡H�HˆQ„KØ�;‰;‹=Ðr   c                  ó    — e Zd ZdZdd„Zdd„Zy)ÚAttributeDictionarya®  
    A dictionary subclass that supports attribute-style access.

    This class extends the functionality of a standard dictionary to allow items
    to be accessed via attribute-style dot notation in addition to the traditional
    key-based access. If a dictionary item is accessed and is itself a dictionary,
    it is automatically wrapped in another `AttributeDictionary`, enabling recursive
    attribute-style access.
    c                óÎ   — 	 | j                  |«      }t        |t        «      rt        |«      S |S # t        $ r+}t        dt        | «      j                  › d|› d�«      |‚d }~ww xY w©Nú'z' object has no attribute ')Ú__getitem__rA   ÚdictrK   ÚKeyErrorÚAttributeErrorÚtyper.   )r"   ÚkeyÚitemÚerrs       r   Ú__getattr__zAttributeDictionary.__getattr__d   so   € ð	Ø×#Ñ# CÓ(ˆDÜ0:¸4ÄÔ0FÔ& tÓ,ÐPÈDÐPøÜò 	Ü Ø”D˜“J×'Ñ'Ð(Ð(CÀCÀ5ÈÐJóàðûð	ús   ‚+0 ®0 °	A$¹&AÁA$c                ó   — || |<   y r   r%   ©r"   r   r*   s      r   Ú__setattr__zAttributeDictionary.__setattr__m   s   € ØˆˆTŠ
r   N©rT   rB   r   r   ©r   rB   r*   r   r   ÚNone)r.   Ú
__module__Ú__qualname__Ú__doc__rW   rZ   r%   r   r   rK   rK   Y   s   „ ñóôr   rK   a*  Widget state is read-only. To programmatically update widget state, assign a new dictionary to the session state key instead of modifying nested values. For example, use:
    st.session_state['my_key'] = {'selection': {'rows': [0]}}
Instead of:
    st.session_state.my_key.selection = {'rows': [0]}c                  ó†   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zddd„Zdd„Zdd„Zdd„Zˆ xZS )ÚReadOnlyAttributeDictionaryaÓ  Read-only dictionary subclass with attribute-style access.

    Similar to AttributeDictionary, but raises TypeError on any mutation attempt.
    Used for widget state return values (e.g., dataframe selections) to prevent
    users from modifying values in ways that don't trigger proper state updates.

    Modifications should be done by assigning a new dictionary to the session
    state key, e.g., ``st.session_state['key'] = {'selection': {'rows': [0]}}``.
    c                ó\   •— t         ‰| �  |«      }t        |t        «      rt	        |«      S |S r   )ÚsuperrO   rA   rP   rb   )r"   rT   rU   r-   s      €r   rO   z'ReadOnlyAttributeDictionary.__getitem__†   s-   ø€ Ü‰wÑ" 3Ó'ˆä4>¸tÄTÔ4JÔ*¨4Ó0ÐTÐPTÐTr   c                ó|   — 	 | |   S # t         $ r+}t        dt        | «      j                  › d|› d�«      |‚d }~ww xY wrM   )rQ   rR   rS   r.   )r"   rT   rV   s      r   rW   z'ReadOnlyAttributeDictionary.__getattr__‹   sO   € ð	Ø˜‘9ÐøÜò 	Ü Ø”D˜“J×'Ñ'Ð(Ð(CÀCÀ5ÈÐJóàðûð	ús   ‚ ‡	;�&6¶;c                ó    — t        t        «      ‚r   ©Ú	TypeErrorÚ_READ_ONLY_ERROR_MSGrY   s      r   rZ   z'ReadOnlyAttributeDictionary.__setattr__”   ó   € ÜÔ,Ó-Ð-r   c                ó    — t        t        «      ‚r   rg   )r"   rT   r*   s      r   Ú__setitem__z'ReadOnlyAttributeDictionary.__setitem__—   rj   r   c                ó    — t        t        «      ‚r   rg   )r"   rT   s     r   Ú__delitem__z'ReadOnlyAttributeDictionary.__delitem__š   rj   r   c                ó    — t        t        «      ‚r   rg   )r"   Úothers     r   Ú__ior__z#ReadOnlyAttributeDictionary.__ior__�   rj   r   c                ó    — t        t        «      ‚r   rg   ©r"   s    r   Úclearz!ReadOnlyAttributeDictionary.clear    rj   r   c                ó    — t        t        «      ‚r   rg   )r"   Úargss     r   ÚpopzReadOnlyAttributeDictionary.pop£   rj   r   c                ó    — t        t        «      ‚r   rg   rs   s    r   Úpopitemz#ReadOnlyAttributeDictionary.popitem¦   rj   r   c                ó    — t        t        «      ‚r   rg   )r"   rT   r   s      r   Ú
setdefaultz&ReadOnlyAttributeDictionary.setdefault©   rj   r   c                ó    — t        t        «      ‚r   rg   )r"   rv   Úkwargss      r   rD   z"ReadOnlyAttributeDictionary.update¬   rj   r   c                ó>   — t        t        j                  | «      «      S r   )rb   rP   Úcopyrs   s    r   Ú__copy__z$ReadOnlyAttributeDictionary.__copy__¯   s   € Ü*¬4¯9©9°T«?Ó;Ð;r   c                ó°   — dd l }t        | j                  «       D ��ci c](  \  }}|j                  ||«      |j                  ||«      “Œ* c}}«      S c c}}w r   )r   rb   r4   Údeepcopy)r"   Úmemor   Úkr&   s        r   Ú__deepcopy__z(ReadOnlyAttributeDictionary.__deepcopy__²   sH   € Ûä*ØHLÏ
É
Ë×UÁÀÀ1ˆT�]‰]˜1˜dÓ# T§]¡]°1°dÓ%;Ñ;ÓUó
ð 	
ùÛUs   �-A
)rT   r   r   r   r[   r\   )rT   r   r*   r   r   r]   )rT   r   r   r]   )rp   r   r   rb   )r   r]   )rv   r   r   r   )r   ztuple[Any, Any]r   )rT   r   r   r   r   r   )rv   r   r}   r   r   r]   )r   rb   )rƒ   zdict[Any, Any]r   rb   )r.   r^   r_   r`   rO   rW   rZ   rl   rn   rq   rt   rw   ry   r{   rD   r€   r…   Ú__classcell__)r-   s   @r   rb   rb   {   sJ   ø„ ñõUó
ó.ó.ó.ó.ó.ó.ó.ô.ó.ó<÷
r   rb   c                óP   — | j                   j                  t        j                  k(  S )z.Check if the DeltaGenerator is in the sidebar.)Ú
_active_dgÚ_root_containerr   ÚSIDEBAR)Údgs    r   Ú
in_sidebarrŒ   º   s   € à�=‰=×(Ñ(¬M×,AÑ,AÑAÐAr   )r   úCallable[..., Any]r   r�   )r"   r   r   rB   )r   r   )rF   zbytes | strr   rB   )r‹   r	   r   Úbool)r`   Ú
__future__r   r0   r   r=   Útypingr   r   Ú!streamlit.proto.RootContainer_pb2r   Úcollections.abcr   r   Ústreamlit.delta_generatorr	   r   r9   r?   rI   rP   rK   ri   rb   rŒ   r%   r   r   ú<module>r”      sn   ðñ #å "ã Û Û ß %å ;áÝ(Ýå8ó
ó)ó.+ó	ô˜$˜s C˜x™.ô ð2<ð ô<
Ð"5ô <
ô~Br   