o
    %h                     @   s   d dl Z 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mZ d dlmZmZ e ZedZeddd	ZG d
d dee ZG dd dee eZG dd deZG dd deZdS )    N)AbstractAsyncContextManager)TracebackType)AnyCallableGenericOptionalTypeTypeVarUnion)ImplToApiMappingImplWrapperTSelfAsyncContextManager)boundc                   @   s@   e Zd ZdddZedefddZdd	d
ZdefddZ	dS )AsyncEventInfofutureasyncio.Future[T]returnNc                 C   s
   || _ d S N)_futureselfr    r   P/var/www/html/myenv/lib/python3.10/site-packages/playwright/_impl/_async_base.py__init__      
zAsyncEventInfo.__init__c                    s   t | jI d H S r   )mappingfrom_maybe_implr   r   r   r   r   value!   s   zAsyncEventInfo.valuec                 C   s   | j   d S r   )r   cancelr   r   r   r   _cancel%   s   zAsyncEventInfo._cancelc                 C   
   | j  S r   )r   doner   r   r   r   is_done(   r   zAsyncEventInfo.is_doner   r   r   Nr   N)
__name__
__module____qualname__r   propertyr   r    r"   boolr%   r   r   r   r   r      s    

r   c                   @   sR   e Zd ZdddZdee fddZd	eee	  d
ee	 dee
 ddfddZdS )AsyncEventContextManagerr   r   r   Nc                 C   s   t t || _d S r   )r   r   _eventr   r   r   r   r   -   s   z!AsyncEventContextManager.__init__c                    s   | j S r   )r.   r   r   r   r   
__aenter__0   s   z#AsyncEventContextManager.__aenter__exc_typeexc_valexc_tbc                    s&   |r
| j   d S | j jI d H  d S r   )r.   r"   r    )r   r0   r1   r2   r   r   r   	__aexit__3   s   z"AsyncEventContextManager.__aexit__r&   )r(   r)   r*   r   r   r   r/   r   r   BaseExceptionr   r3   r   r   r   r   r-   ,   s    

r-   c                       s   e Zd Zdeddf fddZdefddZdeed	ef ef ded
 fddZ	dededdfddZ
dededdfddZdededdfddZ  ZS )	AsyncBaseimpl_objr   Nc                    s   t  | |j| _d S r   )superr   _loop)r   r6   	__class__r   r   r   @   s   zAsyncBase.__init__c                 C   r#   r   )	_impl_obj__str__r   r   r   r   r<   D   r   zAsyncBase.__str__handler.).Nc                 C   s   t |r	t|S |S r   )callabler   wrap_handler)r   r=   r   r   r   _wrap_handlerG   s   
zAsyncBase._wrap_handlereventfc                 C      | j || | dS )z9Registers the function ``f`` to the event name ``event``.N)r;   onr@   r   rA   rB   r   r   r   rD   N      zAsyncBase.onc                 C   rC   )zoThe same as ``self.on``, except that the listener is automatically
        removed after being called.
        N)r;   oncer@   rE   r   r   r   rG   R   s   zAsyncBase.oncec                 C   rC   )z*Removes the function ``f`` from ``event``.N)r;   remove_listenerr@   rE   r   r   r   rH   X   rF   zAsyncBase.remove_listener)r(   r)   r*   r   r   strr<   r
   r   r@   rD   rG   rH   __classcell__r   r   r9   r   r5   ?   s    
r5   c                   @   sR   e Zd ZdedefddZdeee  dee dee ddfd	d
Z	dddZ
dS )r   r   r   c                    s   | S r   r   r   r   r   r   r/   ^   s   zAsyncContextManager.__aenter__r0   r1   	tracebackNc                    s   |   I d H  d S r   )close)r   r0   r1   rK   r   r   r   r3   a   s   zAsyncContextManager.__aexit__c                    s   d S r   r   r   r   r   r   rL   i   s    zAsyncContextManager.closer'   )r(   r)   r*   r   r/   r   r   r4   r   r3   rL   r   r   r   r   r   ]   s    

)asyncio
contextlibr   typesr   typingr   r   r   r   r   r	   r
   %playwright._impl._impl_to_api_mappingr   r   r   r   r   r   r-   r5   r   r   r   r   r   <module>   s   $