o
    LDi(                     @   s   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
m
Z
 d dlmZmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZmZmZmZ eG dd dZG dd deZG dd deZG dd deZdS )    )Lock)defaultdict)AsyncGeneratorHashableMapping)asynccontextmanager)copy)	dataclassfield)Anyoverload)DataNotDictLikeError)State)BaseEventIsolationBaseStorage	StateType
StorageKeyc                   @   s8   e Zd ZU eedZeeef ed< dZ	edB ed< dS )MemoryStorageRecord)default_factorydataNstate)
__name__
__module____qualname__r
   dictr   strr   __annotations__r    r   r   f/var/www/www-root/data/www/77.83.87.30/venv/lib/python3.10/site-packages/aiogram/fsm/storage/memory.pyr      s   
 r   c                
   @   s   e Zd ZdZdddZdddZdded	eddfd
dZdede	dB fddZ
dedee	ef ddfddZdedee	ef fddZedede	dedB fddZedede	dedefddZ	ddede	dedB dedB fddZdS )MemoryStoragez
    Default FSM storage, stores all data in :class:`dict` and loss everything on shutdown

    .. warning::

        Is not recommended using in production in due to you will lose all data
        when your bot restarts
    returnNc                 C      t t| _d S N)r   r   storageselfr   r   r   __init__#   s   
zMemoryStorage.__init__c                       d S r"   r   r$   r   r   r   close(      zMemoryStorage.closekeyr   c                    s"   t |tr	|jn|| j| _d S r"   )
isinstancer   r   r#   )r%   r*   r   r   r   r   	set_state+   s    zMemoryStorage.set_statec                    s   | j | jS r"   )r#   r   r%   r*   r   r   r   	get_state.   s   zMemoryStorage.get_stater   c                    s8   t |tsdt|j }t|| | j| _d S )Nz-Data must be a dict or dict-like object, got )r+   r   typer   r   r   r#   r   )r%   r*   r   msgr   r   r   set_data1   s
   
zMemoryStorage.set_datac                    s   | j | j S r"   )r#   r   r   r-   r   r   r   get_data7   s   zMemoryStorage.get_datastorage_keydict_keyc                    r'   r"   r   )r%   r3   r4   r   r   r   	get_value:   r)   zMemoryStorage.get_valuedefaultc                    r'   r"   r   )r%   r3   r4   r6   r   r   r   r5   =   r)   c                    s   | j | j}t|||S r"   )r#   r   r   get)r%   r3   r4   r6   r   r   r   r   r5   @   s   r    Nr"   )r   r   r   __doc__r&   r(   r   r   r,   r   r.   r   r   r1   r   r2   r   r5   r   r   r   r   r      s,    
	
r   c                   @   s0   e Zd Zededed fddZd	ddZdS )
DisabledEventIsolationr*   r    NNc                 C  s   d V  d S r"   r   r-   r   r   r   lockK   s   
zDisabledEventIsolation.lockNc                    r'   r"   r   r$   r   r   r   r(   O   r)   zDisabledEventIsolation.closer8   )r   r   r   r   r   r   r<   r(   r   r   r   r   r:   J   s    r:   c                   @   s:   e Zd ZdddZededed fddZdd	d
ZdS )SimpleEventIsolationr    Nc                 C   r!   r"   )r   r   _locksr$   r   r   r   r&   T   s   zSimpleEventIsolation.__init__r*   r;   c              	   C  sP   | j | }|4 I d H  d V  W d   I d H  d S 1 I d H s!w   Y  d S r"   )r>   )r%   r*   r<   r   r   r   r<   X   s
   
.zSimpleEventIsolation.lockc                    s   | j   d S r"   )r>   clearr$   r   r   r   r(   ^   s   zSimpleEventIsolation.closer8   )	r   r   r   r&   r   r   r   r<   r(   r   r   r   r   r=   S   s
    
r=   N)asyncior   collectionsr   collections.abcr   r   r   
contextlibr   r   dataclassesr	   r
   typingr   r   aiogram.exceptionsr   aiogram.fsm.stater   aiogram.fsm.storage.baser   r   r   r   r   r   r:   r=   r   r   r   r   <module>   s    1	