ó
    X=Œjˆ  ã                   óÜ   • S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
  S SKJr  \ " S S5      5       r " S S5      r\" 5       rS	\S
\\/\4   4S jrS\S\S
\4S jr\
" S\	S9rS\S
\4S jrg)é    )Ú	dataclass)Úwraps)ÚAnyÚCallableÚIteratorÚListÚTypeÚTypeVar)ÚEventEmitterc                   ó*   • \ rS rSr% \\S'   \\S'   Srg)ÚHandleré   ÚeventÚmethod© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚstrÚ__annotations__r   Ú__static_attributes__r   ó    ÚL/Users/stevendouglas/BidBrain/.venv/lib/python3.13/site-packages/pyee/cls.pyr   r      s   ‡ àƒJØÖr   r   c                   óB   • \ rS rSrS	S jrS	S jrS\\   4S jrS r	Sr
g)
ÚHandlersé   ÚreturnNc                 ó   • / U l         g ©N©Ú	_handlers©Úselfs    r   Ú__init__ÚHandlers.__init__   s	   € Ø(*ˆ�r   c                 ó:   • U R                   R                  U5        g r    )r"   Úappend)r$   Úhandlers     r   r(   ÚHandlers.append   s   € Ø�‰×Ñ˜gÕ&r   c                 ó,   • [        U R                  5      $ r    )Úiterr"   r#   s    r   Ú__iter__ÚHandlers.__iter__   s   € Ü�D—N‘NÓ#Ð#r   c                 ó   • / U l         g r    r!   r#   s    r   ÚresetÚHandlers.reset   s	   € Øˆ�r   r!   )r   N)r   r   r   r   r%   r(   r   r   r-   r0   r   r   r   r   r   r      s"   † ô+ô'ð$˜( 7Ñ+ô $õr   r   r   r   c                 ó0   ^ • S[         S[         4U 4S jjnU$ )zf
Register an event handler on an evented class. See the `evented` class
decorator for a full example.
r   r   c                 óB   >• [         R                  [        TU S95        U $ )N)r   r   )r"   r(   r   )r   r   s    €r   Ú	decoratorÚon.<locals>.decorator%   s   ø€ Ü×Ñœ u°VÑ<Ô=Øˆr   )r   )r   r4   s   ` r   Úonr6      s   ø€ ðœ(ð ¤x÷ ð Ðr   r$   r   c                 óD   ^ ^• [        T5      S[        4UU 4S jj5       nU$ )Nr   c                  ó   >• T" T/U Q70 UD6$ r    r   )ÚargsÚkwargsr   r$   s     €€r   ÚboundÚ_bind.<locals>.bound-   s   ø€ á�dÐ,˜TÒ, VÑ,Ð,r   )r   r   )r$   r   r;   s   `` r   Ú_bindr=   ,   s'   ù€ Ü
ˆ6ƒ]ð-¤#÷ -ó ð-ð €Lr   ÚCls)r;   Úclsc           	      óÞ   ^^• [        [        5      m[        R                  5         U R                  m[	        U R                  5      S[
        S[
        S[
        SS4UU4S jj5       nXl        U $ )aÉ  
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$   r9   r:   r   Nc                 óâ   >• T" U /UQ70 UD6  [        U S5      (       d  [        5       U l        T H<  nU R                  R                  UR                  [        XR                  5      5        M>     g )NÚevent_emitter)Úhasattrr   rB   r6   r   r=   r   )r$   r9   r:   ÚhÚhandlersÚog_inits       €€r   ÚinitÚevented.<locals>.initi   sY   ø€ á�Ð&�tÒ&˜vÒ&Ü�t˜_×-Ñ-Ü!-£ˆDÔãˆAØ×Ñ×!Ñ! !§'¡'¬5°·x±xÓ+@ÖAò r   )Úlistr"   r0   r%   r   r   )r?   rG   rE   rF   s     @@r   ÚeventedrJ   7   sk   ù€ ôZ #¤9›o€HÜ‡O�OÔàŸ™€Gä
ˆ3�<‰<ÓðB”3ð Bœsð B¬cð B°d÷ Bó ðBð „Là€Jr   N)Údataclassesr   Ú	functoolsr   Útypingr   r   r   r   r	   r
   Úpyeer   r   r   r"   r   r6   r=   r>   rJ   r   r   r   Ú<module>rO      sš   ðÝ !Ý ß ?× ?å ð ÷ð ó ð÷
ñ ñ ‹J€	ð
ˆcð 
�h ˜z¨8Ð3Ñ4ô 
ð�ð ˜Sð  Sô ñ ˆe˜4Ñ €ð=�ð =˜õ =r   