Ë
    Ûvžj@4  ã                  óÎ  — d dl mZ 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m	Z	 ddl
mZ ddlmZ ddlmZ g d¢Z d	j"                  ej$                  Ž Zej(                  j+                  d
de› de› �«      Zej(                  j+                  dde› de› �«      Z eej(                  j+                  dd«      «      Z eej(                  j+                  dd«      «      Z eej(                  j+                  dd«      «      Zdd„Z ej:                  d«      Z ej:                  d«      Zej@                   G d„ d«      «       Z!ej@                   G d„ d«      «       Z"	 	 	 	 dd„Z#	 	 	 	 dd„Z$y) é    )ÚannotationsN)ÚCallableÚ	Generatoré   )ÚHeaders)ÚSecurityError)Úversion)ÚSERVERÚ
USER_AGENTÚRequestÚResponsez{}.{}ÚWEBSOCKETS_USER_AGENTzPython/z websockets/ÚWEBSOCKETS_SERVERÚWEBSOCKETS_MAX_NUM_HEADERSÚ128ÚWEBSOCKETS_MAX_LINE_LENGTHÚ8192ÚWEBSOCKETS_MAX_BODY_SIZEÚ	1_048_576c                ó&   — | j                  d¬«      S )zG
    Decode a bytestring for interpolating into an error message.

    Úbackslashreplace)Úerrors)Údecode)Úvalues    úb/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/websockets/http11.pyÚdr   ,   s   € ð
 �<‰<Ð1ˆ<Ó2Ð2ó    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*c                  óh   — e Zd ZU dZded<   ded<   dZded<   edd	„«       Ze	 	 	 	 dd
„«       Z	dd„Z
y)r   z�
    WebSocket handshake request.

    Attributes:
        path: Request path, including optional query.
        headers: Request headers.
    ÚstrÚpathr   ÚheadersNúException | NoneÚ
_exceptionc                óN   — t        j                  dt        «       | j                  S )NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc instead©ÚwarningsÚwarnÚDeprecationWarningr#   ©Úselfs    r   Ú	exceptionzRequest.exceptionX   ó"   € ä�‰ð7äô	
ð
 �‰Ðr   c              #  óô  K  — 	 t        |«      E d{  –—† }	 |j                  dd«      \  }}}|dk7  rt        dt	        |«      › �«      ‚|dk7  rt        d	t	        |«      › �«      ‚|j                  d
d«      }t        |«      E d{  –—† }d|v rt        d«      ‚d|v rt        d«      ‚ | ||«      S 7 ŒŸ# t        $ r}t        d«      |‚d}~ww xY w# t        $ r t        dt	        |«      › �«      d‚w xY w7 Œo­w)a©  
        Parse a WebSocket handshake request.

        This is a generator-based coroutine.

        The request path isn't URL-decoded or validated in any way.

        The request path and headers are expected to contain only ASCII
        characters. Other characters are represented with surrogate escapes.

        :meth:`parse` doesn't attempt to read the request body because
        WebSocket handshake requests don't have one. If the request contains a
        body, it may be read from the data stream after :meth:`parse` returns.

        Args:
            read_line: Generator-based coroutine that reads a LF-terminated
                line or raises an exception if there isn't enough data

        Raises:
            EOFError: If the connection is closed without a full HTTP request.
            SecurityError: If the request exceeds a security limit.
            ValueError: If the request isn't well formatted.

        Nz1connection closed while reading HTTP request lineó    é   zinvalid HTTP request line: ó   HTTP/1.1ú)unsupported protocol; expected HTTP/1.1: s   GETz+unsupported HTTP method; expected GET; got ÚasciiÚsurrogateescapeúTransfer-Encodingú!transfer codings aren't supportedúContent-Lengthzunsupported request body)Ú
parse_lineÚEOFErrorÚsplitÚ
ValueErrorr   r   Úparse_headersÚNotImplementedError)	ÚclsÚ	read_lineÚrequest_lineÚexcÚmethodÚraw_pathÚprotocolr    r!   s	            r   ÚparsezRequest.parsea   s-  è ø€ ðF	YÜ&0°Ó&;×;ˆLð	XØ)5×);Ñ);¸DÀ!Ó)DÑ&ˆF�H˜hð �{Ò"ÜØ;¼A¸l»OÐ;LÐMóð ð �VÒÜÐJÌ1ÈVË9È+ÐVÓWÐWØ�‰˜wÐ(9Ó:ˆä*¨9Ó5×5ˆð  'Ñ)Ü%Ð&IÓJÐJà˜wÑ&ÜÐ7Ó8Ð8á�4˜Ó!Ð!ð5 <ùÜò 	YÜÐNÓOÐUXÐXûð	Yûô
 ò 	XÜÐ:¼1¸\»?Ð:KÐLÓMÐSWÐWð	Xúð 6úsU   ‚C8„B4 ’B2“B4 ˜C ®AC8ÂC6Â+C8Â2B4 Â4	CÂ=C	Ã	CÃC8Ã"C3Ã3C8c                ó|   — d| j                   › d�j                  «       }|| j                  j                  «       z  }|S )z;
        Serialize a WebSocket handshake request.

        zGET z HTTP/1.1
)r    Úencoder!   Ú	serialize)r*   Úrequests     r   rG   zRequest.serialize¡   s;   € ð ˜Ÿ™˜ =Ð1×8Ñ8Ó:ˆØ�4—<‘<×)Ñ)Ó+Ñ+ˆØˆr   ©Úreturnr"   )r>   ú-Callable[[int], Generator[None, None, bytes]]rJ   zGenerator[None, None, Request]©rJ   Úbytes)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r#   Úpropertyr+   ÚclassmethodrD   rG   © r   r   r   r   H   s_   … ñð ƒIØÓð $(€JÐ Ó'àòó ðð ð="à@ð="ð 
(ò="ó ð="ô~	r   r   c                  óˆ   — e Zd ZU dZded<   ded<   ded<   dZd	ed
<   dZded<   edd„«       Ze		 	 	 	 	 	 	 	 dd„«       Z
dd„Zy)r   zÍ
    WebSocket handshake response.

    Attributes:
        status_code: Response code.
        reason_phrase: Response reason.
        headers: Response headers.
        body: Response body, if any.

    ÚintÚstatus_coder   Úreason_phraser   r!   Nzbytes | NoneÚbodyr"   r#   c                óN   — t        j                  dt        «       | j                  S )NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr%   r)   s    r   r+   zResponse.exceptionÁ   r,   r   c              #  óæ  K  — 	 t        |«      E d{  –—† }	 |j                  dd«      \  }}}|dk7  rt        dt	        |«      › �«      ‚	 t        |«      }	d	|	cxk  rd
k  sn t        dt	        |«      › �«      ‚t        j                  |«      st        dt	        |«      › �«      ‚|j                  dd«      }
t        |«      E d{  –—† }d|v rt        d«      ‚d	|	cxk  rdk  sn |	dk(  s|	dk(  rd}nQ	 |d   }t        |«      }|€	  |t        «      E d{  –—† }n(|t        kD  rt        d|› d�«      ‚ ||«      E d{  –—† } | |	|
||«      S 7 �Œ># t        $ r}t        d«      |‚d}~ww xY w# t        $ r t        dt	        |«      › �«      d‚w xY w# t        $ r t        dt	        |«      › �«      d‚w xY w7 Œó# t        $ r d}Y ŒÄw xY w7 Œµ# t        $ r t        dt        › d�«      ‚w xY w7 Œ®­w)aÂ  
        Parse a WebSocket handshake response.

        This is a generator-based coroutine.

        The reason phrase and headers are expected to contain only ASCII
        characters. Other characters are represented with surrogate escapes.

        Args:
            read_line: Generator-based coroutine that reads a LF-terminated
                line or raises an exception if there isn't enough data.
            read_exact: Generator-based coroutine that reads the requested
                bytes or raises an exception if there isn't enough data.
            read_to_eof: Generator-based coroutine that reads until the end
                of the stream.

        Raises:
            EOFError: If the connection is closed without a full HTTP response.
            SecurityError: If the response exceeds a security limit.
            LookupError: If the response isn't well formatted.
            ValueError: If the response isn't well formatted.

        Nz0connection closed while reading HTTP status liner.   r/   zinvalid HTTP status line: r0   r1   z+invalid status code; expected integer; got éd   iX  u-   invalid status code; expected 100â€“599; got zinvalid HTTP reason phrase: r2   r3   r4   r5   éÈ   éÌ   i0  r6   zbody too large: over z byteszbody too large: )r7   r8   r9   r:   r   rW   Ú	_value_reÚ	fullmatchr   r;   r<   ÚKeyErrorÚMAX_BODY_SIZEÚRuntimeErrorr   )r=   r>   Ú
read_exactÚread_to_eofÚstatus_liner@   rC   Úraw_status_codeÚ
raw_reasonrX   Úreasonr!   rZ   Úraw_content_lengthÚcontent_lengths                  r   rD   zResponse.parseÊ   s`  è ø€ ð@	XÜ%/°	Ó%:×:ˆKð	VØ4?×4EÑ4EÀdÈAÓ4NÑ1ˆH�o zð �{Ò"ÜØ;¼A¸k»NÐ;KÐLóð ð	Ü˜oÓ.ˆKð
 �kÔ' CÔ'ÜØ?ÄÀ/Ó@RÐ?SÐTóð ô ×"Ñ" :Ô.ÜÐ;¼A¸j»M¸?ÐKÓLÐLØ×"Ñ" 7Ð,=Ó>ˆä*¨9Ó5×5ˆð  'Ñ)Ü%Ð&IÓJÐJð �+Ô# Ô# {°cÒ'9¸[ÈCÒ=OØ‰Dð9ð &-Ð-=Ñ%>Ð"ô "%Ð%7Ó!8�àÐ%ðWÙ&1´-Ó&@×@‘Dð  ¤-Ò/Ü#Ð&6°~Ð6FÀfÐ$MÓNÐNá",¨^Ó"<×<�á�; ¨°Ó6Ð6ðw ;úÜò 	XÜÐMÓNÐTWÐWûð	Xûô
 ò 	VÜÐ9¼!¸K».Ð9IÐJÓKÐQUÐUð	Vûô ò 	ÜØ=¼aÀÓ>PÐ=QÐRóàðð	úð 6ùô$ ò &Ø!%’ð&úð AùÜ#ò WÜ'Ð*?Ä¸ÈfÐ(UÓVÐVðWúð
 =úsÇ   ‚G1„E ’E“E ˜E0 ®G1ÁF ÁA0G1ÃF:Ã-G1Ã5F< Ã:G1ÄG ÄGÄG Ä$G1Å G/ÅG1ÅE Å	E-ÅE(Å(E-Å-G1Å0"FÆG1Æ"F7Æ7G1Æ<G
ÇG1Ç	G
Ç
G1ÇG ÇG,Ç,G1c                óÌ   — d| j                   › d| j                  › d�j                  «       }|| j                  j	                  «       z  }| j
                  �|| j
                  z  }|S )z<
        Serialize a WebSocket handshake response.

        z	HTTP/1.1 Ú z
)rX   rY   rF   r!   rG   rZ   )r*   Úresponses     r   rG   zResponse.serialize(  sc   € ð ˜t×/Ñ/Ð0°°$×2DÑ2DÐ1EÀTÐJ×QÑQÓSˆØ�D—L‘L×*Ñ*Ó,Ñ,ˆØ�9‰9Ð Ø˜Ÿ	™	Ñ!ˆHØˆr   rI   )r>   rK   re   rK   rf   rK   rJ   zGenerator[None, None, Response]rL   )rN   rO   rP   rQ   rR   rZ   r#   rS   r+   rT   rD   rG   rU   r   r   r   r   ­   sŠ   … ñ	ð ÓØÓØÓØ€Dˆ,Óà#'€JÐ Ó'àòó ðð ð[7à@ð[7ð Bð[7ð Cð	[7ð
 
)ò[7ó ð[7ôzr   r   c              #  óp  K  — t        «       }t        t        dz   «      D ]Å  }	 t        | «      E d{  –—† }|dk(  r |S 	 |j                  dd«      \  }}t        j                  |«      st        dt        |«      › �«      ‚|j                  d«      }t        j                  |«      st        d	t        |«      › �«      ‚|j                  d
«      }|j                  d
d«      }|||<   ŒÇ t        d«      ‚7 ŒÀ# t        $ r}t	        d«      |‚d}~ww xY w# t        $ r t        dt        |«      › �«      d‚w xY w­w)aÅ  
    Parse HTTP headers.

    Non-ASCII characters are represented with surrogate escapes.

    Args:
        read_line: Generator-based coroutine that reads a LF-terminated line
            or raises an exception if there isn't enough data.

    Raises:
        EOFError: If the connection is closed without complete headers.
        SecurityError: If the request exceeds a security limit.
        ValueError: If the request isn't well formatted.

    r   Nz,connection closed while reading HTTP headersr   ó   :zinvalid HTTP header line: zinvalid HTTP header name: s    	zinvalid HTTP header value: r2   r3   ztoo many HTTP headers)r   ÚrangeÚMAX_NUM_HEADERSr7   r8   r9   r:   r   Ú	_token_rera   Ústripr`   r   r   )	r>   r!   Ú_Úliner@   Úraw_nameÚ	raw_valueÚnamer   s	            r   r;   r;   6  sF  è ø€ ô, ‹i€GÜ”? QÑ&Ö'ˆð	TÜ(¨Ó3×3ˆDð �3Š;Øð& €Nð#	OØ"&§*¡*¨T°1Ó"5ÑˆH�iô ×"Ñ" 8Ô,ÜÐ9¼!¸H»+¸ÐGÓHÐHØ—O‘O FÓ+ˆ	Ü×"Ñ" 9Ô-ÜÐ:¼1¸Y»<¸.ÐIÓJÐJà�‰˜wÓ'ˆØ× Ñ  Ð*;Ó<ˆØˆ�Šð) (ô. Ð3Ó4Ð4ð+ 4ùÜò 	TÜÐIÓJÐPSÐSûð	Tûô ò 	OÜÐ9¼!¸D»'¸ÐCÓDÈ$ÐNð	OüsO   ‚ D6£C4±C2²C4¶D6¿DÁBD6Ã2C4Ã4	DÃ=D	Ä	DÄD6Ä"D3Ä3D6c              #  óª   K  — 	  | t         «      E d{  –—† }|j                  d«      st	        d«      ‚|dd S 7 Œ%# t        $ r t        d«      ‚w xY w­w)ao  
    Parse a single line.

    CRLF is stripped from the return value.

    Args:
        read_line: Generator-based coroutine that reads a LF-terminated line
            or raises an exception if there isn't enough data.

    Raises:
        EOFError: If the connection is closed without a CRLF.
        SecurityError: If the response exceeds a security limit.

    Nzline too longs   
zline without CRLFéþÿÿÿ)ÚMAX_LINE_LENGTHrd   r   Úendswithr8   )r>   rw   s     r   r7   r7   i  s\   è ø€ ð"-Ù#¤OÓ4×4ˆð �=‰=˜Ô!ÜÐ*Ó+Ð+Ø��ˆ9Ðð 5ùÜò -Ü˜OÓ,Ð,ð-üs%   ‚A„; “9”; ˜!A¹; »AÁA)r   rM   rJ   r   )r>   rK   rJ   zGenerator[None, None, Headers])r>   rK   rJ   zGenerator[None, None, bytes])%Ú
__future__r   ÚdataclassesÚosÚreÚsysr&   Útypingr   r   Údatastructuresr   Ú
exceptionsr   r	   Úwebsockets_versionÚ__all__ÚformatÚversion_infoÚPYTHON_VERSIONÚenvironÚgetr   r
   rW   rs   r}   rc   r   Úcompilert   r`   Ú	dataclassr   r   r;   r7   rU   r   r   Ú<module>r�      s†  ðÝ "ã Û 	Û 	Û 
Û ß &å #Ý %Ý 2ò :€ð  �—‘ ×!1Ñ!1Ð2€ð �Z‰Z�^‰^ØØˆnÐ˜\Ð*<Ð)=Ð>ó€
ð 
�‰�‰ØØˆnÐ˜\Ð*<Ð)=Ð>ó
€ñ �b—j‘j—n‘nÐ%AÀ5ÓIÓJ€ñ �b—j‘j—n‘nÐ%AÀ6ÓJÓK€ñ �B—J‘J—N‘NÐ#=¸{ÓKÓL€ó3ð ˆB�J‰JÐ7Ó8€	ð ˆB�J‰JÐ4Ó5€	ð ×Ñ÷að aó ðaðH ×Ñ÷Eð Eó ðEðP0Ø<ð0à#ó0ðfØ<ðà!ôr   