o
    Ci
                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ ej	dkr,d dlm
Z
 nd dlm
Z
 dZej	dk rMzd dlmZ W n eyL   d	ZY nw ed
Zejdeje f Zejdee de
ee  fddZejdejde
eej  fddZdejdejfddZejdddZG dd deje eje eje ZG dd dejZejded	dZG dd deje Zedej d fddZ!dede"fd d!Z#dS )"    N)contextmanager)Scope)   
   )	TypeGuardT)r      )BaseExceptionGroupFT.objreturnc                 C      d S N r
   r   r   h/var/www/html/fyndo/python/python_agents/rag_suite/venv/lib/python3.10/site-packages/starlette/_utils.pyis_async_callable      r   c                 C   r   r   r   r   r   r   r   r      r   c                 C   s<   t | tjr| j} t | tjst| pt| ot| jS r   )
isinstance	functoolspartialfuncasyncioiscoroutinefunctioncallable__call__r   r   r   r   r   $   s   
T_co)	covariantc                   @   s   e Zd ZdS )AwaitableOrContextManagerN)__name__
__module____qualname__r   r   r   r   r   0   s    r   c                   @   s   e Zd ZdddZdS )SupportsAsyncCloser   Nc                    s   d S r   r   selfr   r   r   close7   s   zSupportsAsyncClose.close)r   N)r   r   r    r$   r   r   r   r   r!   6   s    r!   SupportsAsyncCloseType)boundr   c                   @   sp   e Zd ZdZdeje ddfddZdejej	def fddZ
defd	d
Zdej	dejdef fddZdS ) AwaitableOrContextManagerWrapperawenteredr)   r   Nc                 C   s
   || _ d S r   )r)   )r#   r)   r   r   r   __init__C      
z)AwaitableOrContextManagerWrapper.__init__c                 C   s
   | j  S r   )r)   	__await__r"   r   r   r   r-   F   r,   z*AwaitableOrContextManagerWrapper.__await__c                    s   | j I d H | _| jS r   r(   r"   r   r   r   
__aenter__I   s   z+AwaitableOrContextManagerWrapper.__aenter__argsc                    s   | j  I d H  d S r   )r*   r$   )r#   r/   r   r   r   	__aexit__M   s   z*AwaitableOrContextManagerWrapper.__aexit__)r   r   r    	__slots__typing	Awaitabler%   r+   	GeneratorAnyr-   r.   Unionboolr0   r   r   r   r   r'   @   s    "r'   )NNNc               
   c   sj    zd V  W d S  t y4 }  z!tr.t| tr.t| jdkr.| jd } t| tr.t| jdks| d } ~ ww )N   r   )BaseExceptionhas_exceptiongroupsr   r   len
exceptions)excr   r   r   collapse_excgroupsR   s   
r>   scopec                 C   s&   |  dd}td| d| d }|S )N	root_path ^path)getresub)r?   r@   
route_pathr   r   r   get_route_path^   s   rH   )$r   r   rE   sysr2   
contextlibr   starlette.typesr   version_infor   typing_extensionsr:   exceptiongroupr   ImportErrorTypeVarr	   Callabler3   AwaitableCallableoverloadr   r5   r   AsyncContextManagerProtocolr   r!   r%   Genericr'   r4   r>   strrH   r   r   r   r   <module>   sH    


  	
