
    dhL                         d dl mZ d dl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mZmZmZmZ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             Z G d de      Z G d de      Z G d de      Zy)    )Lock)defaultdict)asynccontextmanager)copy)	dataclassfield)AnyAsyncGeneratorDefaultDictDictHashableMappingOptionaloverload)DataNotDictLikeError)State)BaseEventIsolationBaseStorage	StateType
StorageKeyc                   H    e Zd ZU  ee      Zeeef   e	d<   dZ
ee   e	d<   y)MemoryStorageRecord)default_factorydataNstate)__name__
__module____qualname__r   dictr   r   strr	   __annotations__r   r        T/var/www/netwell/bot/venv/lib/python3.12/site-packages/aiogram/fsm/storage/memory.pyr   r      s'     6D$sCx.6E8C=r#   r   c            
           e Zd ZdZddZddZddededdfdZdede	e
   fd	Zded
ee
ef   ddfdZdedee
ef   fdZedede
de	e   fd       Zedede
dedefd       Z	 ddede
de	e   de	e   fdZy)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                 ,    t        t              | _        y N)r   r   storageselfs    r$   __init__zMemoryStorage.__init__+   s    EPF
r#   c                    K   y wr)   r"   r+   s    r$   closezMemoryStorage.close0   	        keyr   c                 l   K   t        |t              r|j                  n|| j                  |   _        y wr)   )
isinstancer   r   r*   )r,   r2   r   s      r$   	set_statezMemoryStorage.set_state3   s&     1;E51I%++uSs   24c                 <   K   | j                   |   j                  S wr)   )r*   r   r,   r2   s     r$   	get_statezMemoryStorage.get_state6   s     ||C &&&s   r   c                    K   t        |t              s!t        dt        |      j                         |j                         | j                  |   _        y w)Nz-Data must be a dict or dict-like object, got )r4   r   r   typer   r   r*   r   )r,   r2   r   s      r$   set_datazMemoryStorage.set_data9   sK     $%&?T
@S@S?TU  "&Ss   AAc                 X   K   | j                   |   j                  j                         S wr)   )r*   r   r   r7   s     r$   get_datazMemoryStorage.get_data@   s$     ||C %%**,,s   (*storage_keydict_keyc                    K   y wr)   r"   )r,   r>   r?   s      r$   	get_valuezMemoryStorage.get_valueC   s	     X[r1   defaultc                    K   y wr)   r"   )r,   r>   r?   rB   s       r$   rA   zMemoryStorage.get_valueF   s	     \_r1   c                 r   K   | j                   |   j                  }t        |j                  ||            S wr)   )r*   r   r   get)r,   r>   r?   rB   r   s        r$   rA   zMemoryStorage.get_valueI   s2      ||K(--DHHXw/00s   57r'   Nr)   )r   r   r   __doc__r-   r/   r   r   r5   r   r    r8   r   r	   r;   r   r=   r   rA   r"   r#   r$   r&   r&   !   s    

U: Ui U4 U': '(3- '-* -GCH4E -$ --* -c3h - [:[[RU[ [_:__s_WZ_ _ PT1%1141?G}1	#1r#   r&   c                   4    e Zd Zededed   fd       ZddZy)DisabledEventIsolationr2   r'   NNc                   K   d  y wr)   r"   r7   s     r$   lockzDisabledEventIsolation.lockQ   s	     s   	Nc                    K   y wr)   r"   r+   s    r$   r/   zDisabledEventIsolation.closeU   r0   r1   rF   )r   r   r   r   r   r
   rL   r/   r"   r#   r$   rI   rI   P   s,    j ^J-G  r#   rI   c                   <    e Zd ZddZededed   fd       ZddZy)	SimpleEventIsolationr'   Nc                 ,    t        t              | _        y r)   )r   r   _locksr+   s    r$   r-   zSimpleEventIsolation.__init__Z   s    3>t3Dr#   r2   rJ   c                   K   | j                   |   }|4 d {    d  d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr)   )rQ   )r,   r2   rL   s      r$   rL   zSimpleEventIsolation.lock^   sI     {{3 	 		 	 	 	 	 	 	s:   A3A7A5AAA	A A	Ac                 @   K   | j                   j                          y wr)   )rQ   clearr+   s    r$   r/   zSimpleEventIsolation.closed   s     s   rF   )	r   r   r   r-   r   r   r
   rL   r/   r"   r#   r$   rO   rO   Y   s4    E j ^J-G  
r#   rO   N) asyncior   collectionsr   
contextlibr   r   dataclassesr   r   typingr	   r
   r   r   r   r   r   r   aiogram.exceptionsr   aiogram.fsm.stater   aiogram.fsm.storage.baser   r   r   r   r   r&   rI   rO   r"   r#   r$   <module>r]      su     # *  (	 	 	 4 #       
,1K ,1^/ - r#   