§
    §	Êjˆ  ã                   ó  — d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlmZ e G d„ d¦  «        ¦   «         Z G d„ d¦  «        Z e¦   «         Zd	ed
eegef         fd„Zdeded
efd„Z e
de	¬¦  «        Zded
efd„ZdS )é    )Ú	dataclass)Úwraps)ÚAnyÚCallableÚIteratorÚListÚTypeÚTypeVar)ÚEventEmitterc                   ó$   — e Zd ZU eed<   eed<   dS )ÚHandlerÚeventÚmethodN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r   © ó    ú8C:\Projects\Muse2API\.venv\Lib\site-packages\pyee/cls.pyr   r      s'   € € € € € € à€J€J�JØÐÐÑÐÐr   r   c                   ó<   — e Zd Zdd„Zdd„Zdee         fd„Zd„ ZdS )ÚHandlersÚreturnNc                 ó   — g | _         d S ©N©Ú	_handlers©Úselfs    r   Ú__init__zHandlers.__init__   s   € Ø(*ˆŒˆˆr   c                 ó:   — | j                              |¦  «         d S r   )r   Úappend)r    Úhandlers     r   r#   zHandlers.append   s   € ØŒ×Ò˜gÑ&Ô&Ð&Ð&Ð&r   c                 ó*   — t          | j        ¦  «        S r   )Úiterr   r   s    r   Ú__iter__zHandlers.__iter__   s   € Ý�D”NÑ#Ô#Ð#r   c                 ó   — g | _         d S r   r   r   s    r   ÚresetzHandlers.reset   s   € ØˆŒˆˆr   )r   N)	r   r   r   r!   r#   r   r   r'   r)   r   r   r   r   r      sk   € € € € € ð+ð +ð +ð +ð'ð 'ð 'ð 'ð$˜( 7Ô+ð $ð $ð $ð $ðð ð ð ð r   r   r   r   c                 ó0   ‡ — dt           dt           fˆ fd„}|S )zr
    Register an event handler on an evented class. See the `evented` class
    decorator for a full example.
    r   r   c                 óZ   •— t                                t          ‰| ¬¦  «        ¦  «         | S )N)r   r   )r   r#   r   )r   r   s    €r   Ú	decoratorzon.<locals>.decorator%   s)   ø€ Ý×Ò� u°VÐ<Ñ<Ô<Ñ=Ô=Ð=Øˆr   )r   )r   r,   s   ` r   Úonr-      s7   ø€ ð�(ð ¥xð ð ð ð ð ð ð Ðr   r    r   c                 óP   ‡ ‡— t          ‰¦  «        dt          fˆˆ fd„¦   «         }|S )Nr   c                  ó   •—  ‰‰g| ¢R i |¤ŽS r   r   )ÚargsÚkwargsr   r    s     €€r   Úboundz_bind.<locals>.bound-   s#   ø€ àˆv�dÐ,˜TÐ,Ð,Ð, VÐ,Ð,Ð,r   )r   r   )r    r   r2   s   `` r   Ú_bindr3   ,   sE   øø€ Ý
ˆ6�]„]ð-¥#ð -ð -ð -ð -ð -ð -ñ „]ð-ð €Lr   ÚCls)r2   Úclsc           	      óð   ‡‡— t          t          ¦  «        Št                               ¦   «          | j        Št	          | j        ¦  «        dt
          dt
          dt
          ddfˆˆfd„¦   «         }|| _        | S )aQ  
    Configure an evented class.

    Evented classes are classes which use an EventEmitter to call instance
    methods during runtime. To achieve this without this helper, you would
    instantiate an `EventEmitter` in the `__init__` method and then call
    `event_emitter.on` for every method on `self`.

    This decorator and the `on` function help make things look a little nicer
    by defining the event handler on the method in the class and then adding
    the `__init__` hook in a wrapper:

    ```py
    from pyee.cls import evented, on

    @evented
    class Evented:
        @on("event")
        def event_handler(self, *args, **kwargs):
            print(self, args, kwargs)

    evented_obj = Evented()

    evented_obj.event_emitter.emit(
        "event", "hello world", numbers=[1, 2, 3]
    )
    ```

    The `__init__` wrapper will create a `self.event_emitter: EventEmitter`
    automatically but you can also define your own event_emitter inside your
    class's unwrapped `__init__` method. For example, to use this
    decorator with a `TwistedEventEmitter`::

    ```py
    @evented
    class Evented:
        def __init__(self):
            self.event_emitter = TwistedEventEmitter()

        @on("event")
        async def event_handler(self, *args, **kwargs):
            await self.some_async_action(*args, **kwargs)
    ```
    r    r0   r1   r   Nc                 óÖ   •—  ‰| g|¢R i |¤Ž t          | d¦  «        st          ¦   «         | _        ‰D ]5}| j                             |j        t          | |j        ¦  «        ¦  «         Œ6d S )NÚevent_emitter)Úhasattrr   r8   r-   r   r3   r   )r    r0   r1   ÚhÚhandlersÚog_inits       €€r   Úinitzevented.<locals>.initi   sˆ   ø€ àˆ�Ð&�tÐ&Ð&Ð&˜vÐ&Ð&Ð&Ý�t˜_Ñ-Ô-ð 	0Ý!-¡¤ˆDÔàð 	Bð 	BˆAØÔ×!Ò! !¤'­5°°q´xÑ+@Ô+@ÑAÔAÐAÐAð	Bð 	Br   )Úlistr   r)   r!   r   r   )r5   r=   r;   r<   s     @@r   Úeventedr?   7   s–   øø€ õZ #¥9™oœo€HÝ‡O‚OÑÔÐàœ€Gå
ˆ3Œ<ÑÔðB•3ð B�sð B­cð B°dð Bð Bð Bð Bð Bð Bñ ÔðBð €C„Là€Jr   N)Údataclassesr   Ú	functoolsr   Útypingr   r   r   r   r	   r
   Úpyeer   r   r   r   r   r-   r3   r4   r?   r   r   r   ú<module>rD      sm  ðØ !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?à Ð Ð Ð Ð Ð ð ðð ð ð ð ñ ô ñ „ðð
ð ð ð ð ñ ô ð ð ˆH‰JŒJ€	ð
ˆcð 
�h ˜z¨8Ð3Ô4ð 
ð 
ð 
ð 
ð�ð ˜Sð  Sð ð ð ð ð €gˆe˜4Ð Ñ Ô €ð=�ð =˜ð =ð =ð =ð =ð =ð =r   