§
    )xÅjý  ã                  óV  — 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dS )é    )Ú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dS )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.)
    é   ÚmaxsizeÚintÚreturnÚNonec                óX   — |dk    sJ ‚i | _         t          ¦   «         | _        || _        d S ©Nr   )Ú_datar   Ú_keysr   )Úselfr   s     úEC:\Projects\Historical\venv\Lib\site-packages\prompt_toolkit/cache.pyÚ__init__zSimpleCache.__init__   s,   € Ø˜Š{ˆ{ˆ{ˆ{à#%ˆŒ
Ý %¡¤ˆŒ
Ø#ˆŒˆˆó    Úkeyr   Úgetter_funcúCallable[[], _U]r   c                ó,  — 	 | j         |         S # t          $ rz  |¦   «         }|| j         |<   | j                             |¦  «         t	          | j         ¦  «        | j        k    r*| 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   r    r!   ÚvalueÚkey_to_removes        r   ÚgetzSimpleCache.get!   s¤   € ð	Ø”:˜c”?Ð"øÝð 	ð 	ð 	à�K‘M”MˆEØ#ˆDŒJ�s‰OØŒJ×Ò˜cÑ"Ô"Ð"õ �4”:‰Œ ¤Ò-Ð-Ø $¤
× 2Ò 2Ñ 4Ô 4�Ø  D¤JÐ.Ð.Øœ
 =Ð1àˆLˆLˆLð	øøøs   ‚ �BBÂBc                ó:   — i | _         t          ¦   «         | _        dS )zClear cache.N)r   r   r   )r   s    r   ÚclearzSimpleCache.clear8   s   € àˆŒ
Ý‘W”WˆŒ
ˆ
ˆ
r   N)r   )r   r   r   r   )r    r   r!   r"   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dS )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.
    é@B Ú	get_valueúCallable[..., _V]Úsizer   r   r   c                óX   — |dk    sJ ‚t          ¦   «         | _        || _        || _        d S r   )r   r   r6   r8   )r   r6   r8   s      r   r   zFastDictCache.__init__W   s,   € Ø�aŠxˆxˆxˆxå %¡¤ˆŒ
Ø"ˆŒØˆŒ	ˆ	ˆ	r   r    r2   r3   c                óÈ   — t          | ¦  «        | j        k    r | j                             ¦   «         }|| v r| |=  | j        |Ž }|| |<   | j                             |¦  «         |S ©N)r&   r8   r   r'   r6   r%   )r   r    r)   Úresults       r   Ú__missing__zFastDictCache.__missing__^   sm   € åˆt‰9Œ9�t”yÒ Ð Ø œJ×.Ò.Ñ0Ô0ˆMØ Ð$Ð$Ø˜Ð'à�” Ð%ˆØˆˆS‰	ØŒ
×Ò˜#ÑÔÐØˆr   N)r5   )r6   r7   r8   r   r   r   )r    r2   r   r3   )r-   r.   r/   r0   r   r=   r1   r   r   r   r   B   sK   € € € € € ð
ð 
ð(ð ð ð ð ð
ð 
ð 
ð 
ð 
ð 
r   r   Ú_Fé   r   r   r   úCallable[[_F], _F]c                ó   ‡ — dˆ fd„}|S )zI
    Memoization decorator for immutable classes and pure functions.
    Úobjr>   r   c                óŠ   •‡ ‡— t          ‰¬¦  «        Št          ‰ ¦  «        dˆˆ fd„¦   «         }t          t          |¦  «        S )N)r   Úar   Úkwr   c                 ó¤   •‡ ‡— dˆ ˆˆfd„}‰ t          t          ‰                     ¦   «         ¦  «        ¦  «        f}‰                     ||¦  «        S )Nr   r   c                 ó   •—  ‰‰ i ‰¤ŽS r;   r1   )rD   rE   rB   s   €€€r   Ú
create_newzEmemoized.<locals>.decorator.<locals>.new_callable.<locals>.create_newx   s   ø€ Ø�s˜A�} �}�}Ð$r   )r   r   )ÚtupleÚsortedÚitemsr*   )rD   rE   rH   r    ÚcacherB   s   ``  €€r   Únew_callablez1memoized.<locals>.decorator.<locals>.new_callablev   se   øøø€ ð%ð %ð %ð %ð %ð %ð %ð %ð •e�F 2§8¢8¡:¤:Ñ.Ô.Ñ/Ô/Ð0ˆCØ—9’9˜S *Ñ-Ô-Ð-r   )rD   r   rE   r   r   r   )r   r   r   r>   )rB   rM   rL   r   s   ` @€r   Ú	decoratorzmemoized.<locals>.decorators   sZ   øøø€ Ý,7ÀÐ,HÑ,HÔ,Hˆå	ˆs‰Œð	.ð 	.ð 	.ð 	.ð 	.ð 	.ñ 
Œð	.õ •B˜Ñ%Ô%Ð%r   )rB   r>   r   r>   r1   )r   rN   s   ` r   r   r   n   s)   ø€ ð
&ð &ð &ð &ð &ð &ð Ðr   N)r?   )r   r   r   r@   )Ú
__future__r   Úcollectionsr   Úcollections.abcr   r   Ú	functoolsr   Útypingr   r	   r
   r   Ú__all__r   r   r   rI   r2   r3   Údictr   Úobjectr>   r   r1   r   r   ú<module>rW      s  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .ðð ð €ð €WˆT˜Ð"Ñ"Ô"€Ø€WˆT�]„]€ð)ð )ð )ð )ð )�'˜"˜b˜&”/ñ )ô )ð )ðX €WˆT˜˜x¨˜}Ô-Ð.Ñ.Ô.€Ø€WˆT�]„]€ð&ð &ð &ð &ð &�D˜˜R˜”Lñ &ô &ð &ðR €WˆT˜ # v +Ô.Ð/Ñ/Ô/€ðð ð ð ð ð ð r   