Ë
    £cgjý  ã                  ó  — 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
mZmZmZ g d¢Z ede¬«      Z ed	«      Z G d
„ deeef   «      Z edeedf   ¬«      Z ed«      Z G d„ deeef   «      Z ededef   ¬«      Zddd„Zy)é    )Úannotations)Údeque)ÚCallableÚHashable)Úwraps)ÚAnyÚGenericÚTypeVarÚcast)ÚSimpleCacheÚFastDictCacheÚmemoizedÚ_T)ÚboundÚ_Uc                  ó*   — e Zd ZdZddd„Zdd„Zd	d„Zy)
r   z§
    Very simple cache that discards the oldest item when the cache size is
    exceeded.

    :param maxsize: Maximum size of the cache. (Don't make it too big.)
    c                óL   — |dkD  sJ ‚i | _         t        «       | _        || _        y ©Nr   )Ú_datar   Ú_keysÚmaxsize)Úselfr   s     úe/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/prompt_toolkit/cache.pyÚ__init__zSimpleCache.__init__   s%   € Ø˜Š{Ðˆ{à#%ˆŒ
Ü %£ˆŒ
Ø#ˆ�ó    c                óT  — 	 | j                   |   S # t        $ r�  |«       }|| j                   |<   | j                  j                  |«       t	        | j                   «      | j
                  kD  r5| j                  j                  «       }|| j                   v r| j                   |= |cY S w xY w)zš
        Get object from the cache.
        If not found, call `getter_func` to resolve it, and put that on the top
        of the cache instead.
        )r   ÚKeyErrorr   ÚappendÚlenr   Úpopleft)r   ÚkeyÚgetter_funcÚvalueÚkey_to_removes        r   ÚgetzSimpleCache.get!   s�   € ð	Ø—:‘:˜c‘?Ð"øÜò 	á“MˆEØ#ˆD�J‰J�s‰OØ�J‰J×Ñ˜cÔ"ô �4—:‘:‹ §¡Ò-Ø $§
¡
× 2Ñ 2Ó 4�Ø  D§J¡JÑ.ØŸ
™
 =Ð1àŠLð	ús   ‚ ‘BB'Â&B'c                ó0   — i | _         t        «       | _        y)zClear cache.N)r   r   r   )r   s    r   ÚclearzSimpleCache.clear8   s   € àˆŒ
Ü“Wˆ�
r   N)é   )r   ÚintÚreturnÚNone)r!   r   r"   zCallable[[], _U]r*   r   )r*   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r%   r'   © r   r   r   r      s   „ ñô$óô.r   r   Ú_K.Ú_Vc                  ó"   — e Zd ZdZddd„Zdd„Zy)r   a¿  
    Fast, lightweight cache which keeps at most `size` items.
    It will discard the oldest items in the cache first.

    The cache is a dictionary, which doesn't keep track of access counts.
    It is perfect to cache little immutable objects which are not expensive to
    create, but where a dictionary lookup is still much faster than an object
    instantiation.

    :param get_value: Callable that's called in case of a missing key.
    c                óL   — |dkD  sJ ‚t        «       | _        || _        || _        y r   )r   r   Ú	get_valueÚsize)r   r5   r6   s      r   r   zFastDictCache.__init__W   s$   € Ø�aŠxˆˆxä %£ˆŒ
Ø"ˆŒØˆ�	r   c                óÖ   — t        | «      | j                  kD  r!| j                  j                  «       }|| v r| |=  | j                  |Ž }|| |<   | j                  j                  |«       |S ©N)r   r6   r   r    r5   r   )r   r!   r$   Úresults       r   Ú__missing__zFastDictCache.__missing__^   sd   € äˆt‹9�t—y‘yÒ Ø ŸJ™J×.Ñ.Ó0ˆMØ Ñ$Ø˜Ð'à�—‘ Ð%ˆØˆˆS‰	Ø�
‰
×Ñ˜#ÔØˆr   N)i@B )r5   zCallable[..., _V]r6   r)   r*   r+   )r!   r1   r*   r2   )r,   r-   r.   r/   r   r:   r0   r   r   r   r   B   s   „ ñ
ô(ô
r   r   Ú_Fc                ó   ‡ — dˆ fd„}|S )zI
    Memoization decorator for immutable classes and pure functions.
    c                ój   •‡ ‡— t        ‰¬«      Št        ‰ «      dˆˆ fd„«       }t        t        |«      S )N)r   c                 ó„   •‡ ‡— dˆ ˆˆfd„}‰ t        t        ‰j                  «       «      «      f}‰j                  ||«      S )Nc                 ó   •—  ‰‰ i ‰¤ŽS r8   r0   )ÚaÚkwÚobjs   €€€r   Ú
create_newzEmemoized.<locals>.decorator.<locals>.new_callable.<locals>.create_newx   s   ø€ Ù˜A�} ‘}Ð$r   )r*   r   )ÚtupleÚsortedÚitemsr%   )r@   rA   rC   r!   ÚcacherB   s   ``  €€r   Únew_callablez1memoized.<locals>.decorator.<locals>.new_callablev   s5   ú€ ÷%ð ”eœF 2§8¡8£:Ó.Ó/Ð0ˆCØ—9‘9˜S *Ó-Ð-r   )r@   r   rA   r   r*   r   )r   r   r   r;   )rB   rH   rG   r   s   ` @€r   Ú	decoratorzmemoized.<locals>.decorators   s2   ú€ Ü,7ÀÔ,Hˆä	ˆs‹õ	.ó 
ð	.ô ”B˜Ó%Ð%r   )rB   r;   r*   r;   r0   )r   rI   s   ` r   r   r   n   s   ø€ õ
&ð Ðr   N)i   )r   r)   r*   zCallable[[_F], _F])Ú
__future__r   Úcollectionsr   Úcollections.abcr   r   Ú	functoolsr   Útypingr   r	   r
   r   Ú__all__r   r   r   rD   r1   r2   Údictr   Úobjectr;   r   r0   r   r   Ú<module>rR      s›   ðÝ "å ß .Ý ß .Ó .ò€ñ ˆT˜Ô"€ÙˆTƒ]€ô)�'˜"˜b˜&‘/ô )ñX ˆT˜˜x¨˜}Ñ-Ô.€ÙˆTƒ]€ô&�D˜˜R˜‘Lô &ñR ˆT˜ # v +Ñ.Ô/€õr   