Ë
    Eü´jPó  ã                  ó  — 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Zd dl	Z	d dl
Z
d dlZd dlmZ e	j                  dk\  rd dlmZ nd dlm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mZmZmZ ddl m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z* ddl+m,Z, ejZ                  r(d dl.m/Z/m0Z0 ddlm1Z1m2Z2m3Z3 ddl m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ejx                  d   Z= ej                  d«      Z> ej                  d«      Z? eddd¬«      Z@ eddd¬«      ZA G d„ deB«      ZC G d„ deB«      ZD G d „ d«      ZE G d!„ dejŒ                  «      ZG	 	 	 	 d*d"„ZH G d#„ d$ej’                  e@   «      ZJej–                  	 d+eeeeddddeeedd%œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d&„«       ZL G d'„ d(ej’                  eA   «      ZMejœ                  	 d+eeeeddddeeedd%œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-d)„«       ZOy).é    )ÚannotationsN)ÚTracebackType)é   é   )ÚTypeVar)ÚMemoryObjectReceiveStreamÚMemoryObjectSendStream)ÚCloseReasoné   )ÚUSE_CLIENT_DEFAULT)Ú'DEFAULT_KEEPALIVE_PING_INTERVAL_SECONDSÚ&DEFAULT_KEEPALIVE_PING_TIMEOUT_SECONDSÚDEFAULT_MAX_MESSAGE_SIZE_BYTESÚDEFAULT_QUEUE_SIZE)ÚHeadersé   )ÚHTTPXWSExceptionÚWebSocketDisconnectÚWebSocketInvalidTypeReceivedÚWebSocketNetworkErrorÚWebSocketUpgradeError)ÚAsyncPingManagerÚPingManager)ÚASGIWebSocketAsyncNetworkStream)ÚAsyncNetworkStreamÚNetworkStream)ÚAsyncClientÚClientÚUseClientDefault)ÚResponse)Ú	AuthTypesÚCookieTypesÚHeaderTypesÚQueryParamTypesÚRequestExtensionsÚTimeoutTypes©ÚtextÚbinaryÚTaskFunctionÚ
TaskResultÚSyncSessionÚWebSocketSession)ÚboundÚdefaultÚAsyncSessionÚAsyncWebSocketSessionc                  ó   — e Zd Zy)ÚShouldCloseN©Ú__name__Ú
__module__Ú__qualname__© ó    úT/root/workspace/ytshorts/venv/lib/python3.12/site-packages/httpx2/websockets/_api.pyr3   r3   @   ó   „ Ør9   r3   c                  ó   — e Zd Zy)ÚEndOfStreamNr4   r8   r9   r:   r=   r=   D   r;   r9   r=   c                  ó  — e Zd ZU dZded<   ded<   eeeeddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z		 	 dd	„Z
dd
„Z	 	 	 	 	 	 	 	 dd„Zddd„Zd d„Zd!d„Zd"d„Zd#d$d„Zd%d&d„Zd%d'd„Zd%d(d„Zd)d*d„Zd+d,d„Zd-d„Zd%d.d„Z	 	 	 	 	 	 	 	 d/d„Zd0d„Zy)1r-   a  
    Sync context manager representing an opened WebSocket session.

    Attributes:
        subprotocol (typing.Optional[str]):
            Optional protocol that has been accepted by the server.
        response (Response | None):
            The webSocket handshake response.
    ú
str | NoneÚsubprotocolúResponse | NoneÚresponseN©Úmax_message_size_bytesÚ
queue_sizeÚkeepalive_ping_interval_secondsÚkeepalive_ping_timeout_secondsrB   c               ó  — || _         t        j                  j                  t        j                  j
                  «      | _        || _        | j                  �+| j                  j                  j                  d«      | _	        nd | _	        t        j                  |«      | _        t        «       | _        t        j                   «       | _        t        j$                  «       | _        d | _        d | _        || _        || _        || _        || _        y ©Núsec-websocket-protocol)ÚstreamÚwsprotoÚ
connectionÚ
ConnectionÚConnectionTypeÚCLIENTrB   ÚheadersÚgetr@   ÚqueueÚQueueÚ_eventsr   Ú_ping_managerÚ	threadingÚEventÚ_should_closeÚLockÚ_write_lockÚ_should_close_taskÚ	_executorÚ_max_message_size_bytesÚ_queue_sizeÚ _keepalive_ping_interval_secondsÚ_keepalive_ping_timeout_seconds©ÚselfrK   rD   rE   rF   rG   rB   s          r:   Ú__init__zWebSocketSession.__init__V   sÎ   € ð ˆŒÜ!×,Ñ,×7Ñ7¼×8NÑ8N×8UÑ8UÓVˆŒØ ˆŒØ�=‰=Ð$Ø#Ÿ}™}×4Ñ4×8Ñ8Ð9QÓRˆDÕà#ˆDÔäMRÏ[É[ÐYcÓMdˆŒä(›]ˆÔÜ&Ÿ_™_Ó.ˆÔÜ$Ÿ>™>Ó+ˆÔØJNˆÔØGKˆŒà'=ˆÔ$Ø%ˆÔØ0OˆÔ-Ø/MˆÕ,r9   c                ó  — | j                   €Wt        j                  j                  «       | _        | j                  j                  | j                  j                  «      | _         | j                  €J ‚| j                  | j                   fS ©N)r\   Ú
concurrentÚfuturesÚThreadPoolExecutorr]   ÚsubmitrY   Úwait©rc   s    r:   Ú_get_executor_should_close_taskz0WebSocketSession._get_executor_should_close_tasku   sn   € ð ×"Ñ"Ð*Ü'×/Ñ/×BÑBÓDˆDŒNØ&*§n¡n×&;Ñ&;¸D×<NÑ<N×<SÑ<SÓ&TˆDÔ#Ø�~‰~Ð)Ð)Ð)Ø�~‰~˜t×6Ñ6Ð6Ð6r9   c                ón  — t        j                  | j                  | j                  f¬«      | _        | j                  j                  «        d | _        | j                  �Vt        j                  | j                  | j                  | j                  f¬«      | _        | j                  j                  «        | S )N)ÚtargetÚargs)
rW   ÚThreadÚ_background_receiver^   Ú_background_receive_taskÚstartÚ_background_keepalive_ping_taskr`   Ú_background_keepalive_pingra   rl   s    r:   Ú	__enter__zWebSocketSession.__enter__~   s�   € Ü(1×(8Ñ(8Ø×+Ñ+°4×3OÑ3OÐ2Qô)
ˆÔ%ð 	×%Ñ%×+Ñ+Ô-àHLˆÔ,Ø×0Ñ0Ð<Ü3<×3CÑ3CØ×6Ñ6à×9Ñ9Ø×8Ñ8ðô4ˆDÔ0ð ×0Ñ0×6Ñ6Ô8àˆr9   c                ó¦   — | j                  «        | j                  j                  «        | j                  �| j                  j                  «        y y rf   )Úclosers   Újoinru   )rc   Úexc_typeÚexcÚtbs       r:   Ú__exit__zWebSocketSession.__exit__‘   sB   € ð 	�
‰
ŒØ×%Ñ%×*Ñ*Ô,Ø×/Ñ/Ð;Ø×0Ñ0×5Ñ5Õ7ð <r9   c                ó¢   — | j                   j                  |«      \  }}t        j                  j	                  |«      }| j                  |«       |S )a?  
        Send a Ping message.

        Args:
            payload:
                Payload to attach to the Ping event.
                Internally, it's used to track this specific event.
                If left empty, a random one will be generated.

        Returns:
            An event that can be used to wait for the corresponding Pong response.

        Examples:
            Send a Ping and wait for the Pong

                pong_callback = ws.ping()
                # Will block until the corresponding Pong is received.
                pong_callback.wait()
        ©rV   ÚcreaterL   ÚeventsÚPingÚsend©rc   ÚpayloadÚping_idÚcallbackÚevents        r:   ÚpingzWebSocketSession.pingœ   sD   € ð( !×.Ñ.×5Ñ5°gÓ>Ñˆ�Ü—‘×#Ñ# GÓ,ˆØ�	‰	�%ÔØˆr9   c                ó@  — ddl }	 | j                  j                  |«      }| j                  5  | j                  j                  |«       ddd«       y# 1 sw Y   yxY w# |j                  $ r0}| j                  t        j                  d«       t        «       |‚d}~ww xY w)aŠ  
        Send an Event message.

        Mainly useful to send events that are not supported by the library.
        Most of the time, [ping()][httpx_ws.WebSocketSession.ping],
        [send_text()][httpx_ws.WebSocketSession.send_text],
        [send_bytes()][httpx_ws.WebSocketSession.send_bytes]
        and [send_json()][httpx_ws.WebSocketSession.send_json] are preferred.

        Args:
            event: The event to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Examples:
            Send an event.

                event = wsproto.events.Message(b"Hello!")
                ws.send(event)
        r   NúStream write error©Ú	httpcore2rM   r„   r[   rK   ÚwriteÚ
WriteErrorry   r
   ÚINTERNAL_ERRORr   ©rc   r‰   rŽ   ÚdataÚes        r:   r„   zWebSocketSession.sendµ   s…   € ó, 	ð	1Ø—?‘?×'Ñ'¨Ó.ˆDØ×!Ñ!ñ (Ø—‘×!Ñ! $Ô'÷(÷ (ñ (ûà×#Ñ#ò 	1Ø�J‰J”{×1Ñ1Ð3GÔHÜ'Ó)¨qÐ0ûð	1ús4   †'A ­AÁ	A ÁAÁA ÁA ÁBÁ-+BÂBc                óf   — t         j                  j                  |¬«      }| j                  |«       y)a  
        Send a text message.

        Args:
            data: The text to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Examples:
            Send a text message.

                ws.send_text("Hello!")
        ©r“   N©rL   r‚   ÚTextMessager„   ©rc   r“   r‰   s      r:   Ú	send_textzWebSocketSession.send_textÕ   s'   € ô —‘×*Ñ*°Ð*Ó5ˆØ�	‰	�%Õr9   c                óf   — t         j                  j                  |¬«      }| j                  |«       y)a  
        Send a bytes message.

        Args:
            data: The data to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Examples:
            Send a bytes message.

                ws.send_bytes(b"Hello!")
        r–   N©rL   r‚   ÚBytesMessager„   r™   s      r:   Ú
send_byteszWebSocketSession.send_bytesç   s'   € ô —‘×+Ñ+°Ð+Ó6ˆØ�	‰	�%Õr9   c                ó¨   — |dv sJ ‚t        j                  |«      }|dk(  r| j                  |«       y| j                  |j	                  d«      «       y)a¿  
        Send JSON data.

        Args:
            data:
                The data to send. Must be serializable by [json.dumps][json.dumps].
            mode:
                The sending mode. Should either be `'text'` or `'bytes'`.

        Raises:
            WebSocketNetworkError: A network error occured.

        Examples:
            Send JSON data.

                data = {"message": "Hello!"}
                ws.send_json(data)
        r'   r(   úutf-8N©ÚjsonÚdumpsrš   rž   Úencode©rc   r“   ÚmodeÚserialized_datas       r:   Ú	send_jsonzWebSocketSession.send_jsonù   sK   € ð& Ð)Ñ)Ð)Ð)ÜŸ*™* TÓ*ˆØ�6Š>Ø�N‰N˜?Õ+à�O‰O˜O×2Ñ2°7Ó;Õ<r9   c                ó2  — 	 | j                   j                  d|¬«      }t        |t        «      r|‚t        |t        j                  j                  «      r t        |j                  |j                  «      ‚|S # t        j                  $ r}t        |‚d}~ww xY w)aG  
        Receive an event from the server.

        Mainly useful to receive raw [wsproto.events.Event][wsproto.events.Event].
        Most of the time, [receive_text()][httpx_ws.WebSocketSession.receive_text],
        [receive_bytes()][httpx_ws.WebSocketSession.receive_bytes],
        and [receive_json()][httpx_ws.WebSocketSession.receive_json] are preferred.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            A raw [wsproto.events.Event][wsproto.events.Event].

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.

        Examples:
            Wait for an event until one is available.

                try:
                    event = ws.receive()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for an event for 2 seconds.

                try:
                    event = ws.receive(timeout=2.)
                except TimeoutError:
                    print("No event received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        T)ÚblockÚtimeoutN)rU   rR   rS   ÚEmptyÚTimeoutErrorÚ
isinstancer   rL   r‚   ÚCloseConnectionr   ÚcodeÚreason)rc   r«   r‰   r”   s       r:   ÚreceivezWebSocketSession.receive  s   € ðN	&Ø—L‘L×$Ñ$¨4¸Ð$ÓAˆEô �eÔ-Ô.ØˆKÜ�eœWŸ^™^×;Ñ;Ô<Ü% e§j¡j°%·,±,Ó?Ð?Øˆøô �{‰{ò 	&Ü AÐ%ûð	&ús   ‚A7 Á7BÂ
BÂBc                óš   — | j                  |«      }t        |t        j                  j                  «      r|j
                  S t        |«      ‚)a(  
        Receive text from the server.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            Text data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event was not a text message.

        Examples:
            Wait for text until available.

                try:
                    text = ws.receive_text()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for text for 2 seconds.

                try:
                    event = ws.receive_text(timeout=2.)
                except TimeoutError:
                    print("No text received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        ©r²   r®   rL   r‚   r˜   r“   r   ©rc   r«   r‰   s      r:   Úreceive_textzWebSocketSession.receive_textD  s<   € ðF —‘˜WÓ%ˆÜ�eœWŸ^™^×7Ñ7Ô8Ø—:‘:ÐÜ*¨5Ó1Ð1r9   c                ó¬   — | j                  |«      }t        |t        j                  j                  «      rt        |j                  «      S t        |«      ‚)a.  
        Receive bytes from the server.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            Bytes data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event was not a bytes message.

        Examples:
            Wait for bytes until available.

                try:
                    data = ws.receive_bytes()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for bytes for 2 seconds.

                try:
                    data = ws.receive_bytes(timeout=2.)
                except TimeoutError:
                    print("No data received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        ©r²   r®   rL   r‚   r�   Úbytesr“   r   rµ   s      r:   Úreceive_byteszWebSocketSession.receive_bytesl  sA   € ðF —‘˜WÓ%ˆÜ�eœWŸ^™^×8Ñ8Ô9Ü˜Ÿ™Ó$Ð$Ü*¨5Ó1Ð1r9   c                ó’   — |dv sJ ‚|dk(  r| j                  |«      }n|dk(  r| j                  |«      }t        j                  «      S )aø  
        Receive JSON data from the server.

        The received data should be parseable by [json.loads][json.loads].

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.
            mode:
                Receive mode. Should either be `'text'` or `'bytes'`.

        Returns:
            Parsed JSON data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event
                didn't correspond to the specified mode.

        Examples:
            Wait for data until available.

                try:
                    data = ws.receive_json()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for data for 2 seconds.

                try:
                    data = ws.receive_json(timeout=2.)
                except TimeoutError:
                    print("No data received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        r'   r(   r)   ©r¶   rº   r¢   Úloads©rc   r«   r¦   r“   s       r:   Úreceive_jsonzWebSocketSession.receive_json”  sR   € ðP Ð)Ñ)Ð)Ð)à�6Š>Ø×$Ñ$ WÓ-‰DØ�XÒØ×%Ñ% gÓ.ˆDÜ�z‰z˜$ÓÐr9   c                ó˜  — ddl }| j                  j                  «        | j                  �| j                  j	                  d«       | j
                  j                  t        j
                  j                  j                  t        j
                  j                  j                  hvrlt        j                  j                  ||«      }| j
                  j                  |«      }	 | j                  5  | j                  j!                  |«       ddd«       | j                  j%                  «        y# 1 sw Y   Œ$xY w# |j"                  $ r Y Œ8w xY w)a  
        Close the WebSocket session.

        Internally, it'll send the
        [CloseConnection][wsproto.events.CloseConnection] event.

        *This method is automatically called when exiting the context manager.*

        Args:
            code:
                The integer close code to indicate why the connection has closed.
            reason:
                Additional reasoning for why the connection has closed.

        Examples:
            Close the WebSocket session.

                ws.close()
        r   NF)rŽ   rY   Úsetr]   ÚshutdownrM   ÚstaterL   ÚConnectionStateÚLOCAL_CLOSINGÚCLOSEDr‚   r¯   r„   r[   rK   r�   r�   ry   ©rc   r°   r±   rŽ   r‰   r“   s         r:   ry   zWebSocketSession.closeÄ  s   € ó( 	à×Ñ×ÑÔ Ø�>‰>Ð%Ø�N‰N×#Ñ# EÔ*Ø�?‰?× Ñ Ü×Ñ×.Ñ.×<Ñ<Ü×Ñ×.Ñ.×5Ñ5ð)
ñ 
ô —N‘N×2Ñ2°4¸Ó@ˆEØ—?‘?×'Ñ'¨Ó.ˆDðØ×%Ñ%ñ ,Ø—K‘K×%Ñ% dÔ+÷,ð 	�‰×ÑÕ÷	,ð ,ûà×'Ñ'ò Ùðús*   Ã D7 Ã,D+ÄD7 Ä+D4Ä0D7 Ä7E	ÅE	c                ó&  — ddl }d}d}	 | j                  j                  «       �sí| j                  | j                  |«      }| j
                  j                  |«       | j
                  j                  «       D �]{  }t        |t        j                  j                  «      rZ| j
                  j                  |j                  «       «      }| j                  5  | j                  j                  |«       ddd«       Œ‚t        |t        j                  j                   «      r&| j"                  j%                  |j&                  «       ŒÌt        |t        j                  j(                  «      r| j                  j+                  «        t        |t        j                  j,                  «      �r2|t/        t        |j0                  t2        «      r|j0                  j5                  «       n|j0                  «      z  }||kD  rU| j7                  t8        j:                  d«       | j<                  j?                  tA        t8        j:                  d«      «        nª|jB                  s|€|j0                  }no||j0                  z  }n_|€d}| j<                  j?                  |«       n?tE        |«      } |||j0                  z   «      }d}d}| j<                  j?                  |«       �Œa| j<                  j?                  |«       �Œ~ | j                  j                  «       s�Œìyy# 1 sw Y   �Œ&xY w# |jF                  |jH                  tJ        f$ rF | j7                  t8        jL                  d«       | j<                  j?                  tO        «       «       Y ytP        $ r Y yw xY w)ao  
        Background thread listening for data from the server.

        Internally, it'll:

        * Answer to Ping events.
        * Acknowledge Pong events.
        * Put other events in the [_events][_events]
        queue that'll eventually be consumed by the user.

        Args:
            max_bytes: The maximum chunk size to read at each iteration.
        r   NúMessage too bigúStream error))rŽ   rY   Úis_setÚ_wait_until_closedÚ_read_streamrM   Úreceive_datar‚   r®   rL   rƒ   r„   rB   r[   rK   r�   ÚPongrV   Úackr†   r¯   rÁ   ÚMessageÚlenr“   Ústrr¤   ry   r
   ÚMESSAGE_TOO_BIGrU   Úputr   Úmessage_finishedÚtypeÚ	ReadErrorr�   r=   r‘   r   r3   ©	rc   Ú	max_bytesrŽ   Úpartial_message_bufferÚpartial_message_sizer“   r‰   Ú
event_typeÚfull_message_events	            r:   rr   z$WebSocketSession._background_receiveê  sÁ  € ó 	à59ÐØ Ðð,	Ø×(Ñ(×/Ñ/Õ1Ø×.Ñ.¨t×/@Ñ/@À)ÓL�Ø—‘×,Ñ,¨TÔ2Ø!Ÿ_™_×3Ñ3Ó5ó #,�EÜ! %¬¯©×)<Ñ)<Ô=Ø#Ÿ™×3Ñ3°E·N±NÓ4DÓE˜Ø!×-Ñ-ñ 4Ø ŸK™K×-Ñ-¨dÔ3÷4à Ü! %¬¯©×)<Ñ)<Ô=Ø×*Ñ*×.Ñ.¨u¯}©}Ô=Ø Ü! %¬¯©×)GÑ)GÔHØ×*Ñ*×.Ñ.Ô0Ü! %¬¯©×)?Ñ)?Õ@Ø,´Ì:ÐV[×V`ÑV`ÔbeÔKf°E·J±J×4EÑ4EÔ4GÐlq×lvÑlvÓ0wÑwÐ,Ø/°)Ò;Ø ŸJ™J¤{×'BÑ'BÐDUÔVØ ŸL™L×,Ñ,Ô-@Ä×A\ÑA\Ð^oÓ-pÔqÙ!à$×5Ò5Ø5Ð=Ø9>¿¹Ñ 6à 6¸%¿*¹*Ñ DÑ 6à3Ð;Ø34Ð0Ø ŸL™L×,Ñ,¨UÕ3ô *.¨e«˜JÙ1;Ð<RÐUZ×U_ÑU_Ñ<_Ó1`Ð.Ø59Ð2Ø34Ð0Ø ŸL™L×,Ñ,Ð-?Ô@Ù Ø—L‘L×$Ñ$ UÖ+ðG#,ð ×(Ñ(×/Ñ/×1Ð1÷4ñ 4ûðB ×#Ñ# Y×%9Ñ%9¼;ÐGò 	6Ø�J‰J”{×1Ñ1°>ÔBØ�L‰L×ÑÔ2Ó4Ö5Üò 	Ùð	ús2   ŠC	L  ÃLÃ/H L  ÌL	ÌL  Ì A#NÎNÎNc                ó"  — 	 | j                   j                  «       sÂ| j                  | j                   j                  |«      }|r
t	        «       ‚	 | j                  «       }|�a| j                  |j                  |«      }|sC| j                  t        j                  d«       | j                  j                  t        «       «       | j                   j                  «       sŒÁy y # t        j                  j                  $ r Y y w xY w# t        $ r Y y w xY w©NzKeepalive ping timeout)rY   rË   rÌ   rk   r3   rŠ   rL   Ú	utilitiesÚLocalProtocolErrorry   r
   r‘   rU   rÕ   r   )rc   Úinterval_secondsÚtimeout_secondsÚshould_closeÚpong_callbackÚacknowledgeds         r:   rv   z+WebSocketSession._background_keepalive_ping*  sè   € ð	Ø×(Ñ(×/Ñ/Ô1Ø#×6Ñ6°t×7IÑ7I×7NÑ7NÐP`Óa�ÙÜ%›-Ð'ðØ$(§I¡I£K�Mð #Ð.Ø#'×#:Ñ#:¸=×;MÑ;MÈÓ#_�LÙ'ØŸ
™
¤;×#=Ñ#=Ð?WÔXØŸ™×(Ñ(Ô)>Ó)@ÔAð ×(Ñ(×/Ñ/×1øô ×(Ñ(×;Ñ;ò Ùðûô ò 	Ùð	ús7   ‚AD ÁC ÁA=D ÃC?Ã<D Ã>C?Ã?D Ä	DÄDc                óV  — 	 | j                  «       \  }} |j                  |g|¢­i |¤Ž}t        j                  j	                  ||ft        j                  j
                  ¬«      \  }}||v r
t        «       ‚||v sJ ‚|j                  «       }	|	S # t        $ r}
t        «       |
‚d }
~
ww xY w)N)Úreturn_when)	rm   rj   rg   rh   rk   ÚFIRST_COMPLETEDr3   ÚresultÚRuntimeError)rc   Úcallablerp   ÚkwargsÚexecutorÚshould_close_taskÚ	todo_taskÚdoneÚ_rë   r”   s              r:   rÌ   z#WebSocketSession._wait_until_closed<  s½   € ð	(Ø*.×*NÑ*NÓ*PÑ'ˆHÐ'Ø'˜Ÿ™¨ÐB°4ÒB¸6ÑBˆIô !×(Ñ(×-Ñ-ØÐ-Ð.Ü&×.Ñ.×>Ñ>ð .ó ‰GˆD�!ð ! DÑ(Ü!“mÐ#Ø Ñ$Ð$Ð$Ø×%Ñ%Ó'ˆFØˆøô ò 	'Ü“- QÐ&ûð	'ús   ‚)B Â	B(ÂB#Â#B(c                óZ   — | j                   j                  |«      }|dk(  r
t        «       ‚|S ©Nr9   ©rK   Úreadr=   ©rc   rÚ   r“   s      r:   rÍ   zWebSocketSession._read_streamO  s*   € Ø�{‰{×Ñ 	Ó*ˆØ�3Š;Ü“-ÐØˆr9   )rK   r   rD   ÚintrE   rù   rF   úfloat | NonerG   rú   rB   rA   ÚreturnÚNone)rû   zMtuple[concurrent.futures.ThreadPoolExecutor, concurrent.futures.Future[bool]])rû   r-   )r{   ztype[BaseException] | Noner|   zBaseException | Noner}   zTracebackType | Nonerû   rü   ©r9   )r†   r¹   rû   zthreading.Event©r‰   úwsproto.events.Eventrû   rü   ©r“   rÓ   rû   rü   ©r“   r¹   rû   rü   ©r(   ©r“   ú
typing.Anyr¦   ÚJSONModerû   rü   rf   ©r«   rú   rû   rÿ   ©r«   rú   rû   rÓ   ©r«   rú   rû   r¹   ©Nr(   ©r«   rú   r¦   r  rû   r  ©iè  N©r°   rù   r±   r?   rû   rü   ©rÚ   rù   rû   rü   ©rã   Úfloaträ   rú   rû   rü   )rí   z typing.Callable[..., TaskResult]rp   r  rî   r  rû   r+   ©rÚ   rù   rû   r¹   )r5   r6   r7   Ú__doc__Ú__annotations__r   r   r   r   rd   rm   rw   r~   rŠ   r„   rš   rž   r¨   r²   r¶   rº   r¿   ry   rr   rv   rÌ   rÍ   r8   r9   r:   r-   r-   H   s"  … ñð ÓØÓð 'EØ,Ø8_Ø7]Ø$(ñNàðNð !$ð	Nð
 ðNð *6ðNð )5ðNð "ðNð 
óNð>7à	Vó7óð&	8à,ð	8ð "ð	8ð !ð		8ð
 
ó	8ôó21ó@ó$ô$=ô4/ôb&2ôP&2ôP. ô`$óL>ô@ð$Ø8ðØAKðØWaðà	óô&r9   c                  ó  — e Zd ZU dZded<   ded<   ded<   ded	<   eeeed
dœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	e
j                  dd„«       Zddd„Zdd„Zd d„Zd!d„Zd"d#d„Zd$d%d„Zd$d&d„Zd$d'd„Zd(d)d„Zd*d+d„Zd,d„Zd$d-d„Zd.d„Zy
)/r1   aœ  
    Async context manager representing an opened WebSocket session.

    Internally, this session uses an anyio task group to manage background tasks.
    As a result, exceptions that are not caught inside the context manager
    and propagate out of the `async with` block will be wrapped
    in an [ExceptionGroup][ExceptionGroup].

    To handle them, use the `except*` syntax:

        async with AsyncWebSocketSession(stream) as ws:
            try:
                data = await ws.receive_text()
            except WebSocketDisconnect:
                # Caught inside the context manager: plain exception.
                print("Connection closed")

        # If not caught inside:
        try:
            async with AsyncWebSocketSession(stream) as ws:
                data = await ws.receive_text()
        except* WebSocketDisconnect:
            # Propagated out of the context manager: wrapped in ExceptionGroup.
            print("Connection closed")

    Attributes:
        subprotocol (typing.Optional[str]):
            Optional protocol that has been accepted by the server.
        response (Response | None):
            The webSocket handshake response.
    r?   r@   rA   rB   z?MemoryObjectSendStream[wsproto.events.Event | HTTPXWSException]Ú_send_eventzBMemoryObjectReceiveStream[wsproto.events.Event | HTTPXWSException]Ú_receive_eventNrC   c               ó  — || _         t        j                  j                  t        j                  j
                  «      | _        || _        | j                  �+| j                  j                  j                  d«      | _	        nd | _	        t        «       | _        t        j                  «       | _        t        j                  «       | _        || _        || _        t'        |t(        «      rd | _        d | _        y || _        || _        y rI   )rK   rL   rM   rN   rO   rP   rB   rQ   rR   r@   r   rV   ÚanyiorX   rY   rZ   r[   r^   r_   r®   r   r`   ra   rb   s          r:   rd   zAsyncWebSocketSession.__init__|  sÊ   € ð ˆŒÜ!×,Ñ,×7Ñ7¼×8NÑ8N×8UÑ8UÓVˆŒØ ˆŒØ�=‰=Ð$Ø#Ÿ}™}×4Ñ4×8Ñ8Ð9QÓRˆDÕà#ˆDÔä-Ó/ˆÔÜ"Ÿ[™[›]ˆÔÜ Ÿ:™:›<ˆÔà'=ˆÔ$Ø%ˆÔô �fÔ=Ô>Ø48ˆDÔ1Ø37ˆDÕ0à4SˆDÔ1Ø3QˆDÕ0r9   c               óä  K  — t        j                  t        j                  j                  t
        z     «       \  | _        | _        t        j                  «       | _	        | j                  4 ƒd {  –—†  | j                  4 ƒd {  –—†  | j                  4 ƒd {  –—†  | j                  j                  | j                  | j                  «       | j                  �;| j                  j                  | j                  | j                  | j                  «       	 | ­–— | j                  j                   j#                  «        t        j$                  d¬«      5  | j'                  «       ƒ d {  –—†  d d d «       d d d «      ƒd {  –—†  d d d «      ƒd {  –—†  d d d «      ƒd {  –—†  y 7 �Œ87 �Œ&7 �Œ7 ŒF# 1 sw Y   ŒExY w# | j                  j                   j#                  «        t        j$                  d¬«      5  | j'                  «       ƒ d {  –—†7   d d d «       w # 1 sw Y   w xY wxY w7 Œ©# 1 ƒd {  –—†7  sw Y   Œ¹xY w7 Œ°# 1 ƒd {  –—†7  sw Y   ŒÀxY w7 Œ·# 1 ƒd {  –—†7  sw Y   y xY w­w)NT)Úshield)r  Úcreate_memory_object_streamrL   r‚   rX   r   r  r  Úcreate_task_groupÚ_background_task_groupÚ
start_soonrr   r^   r`   rv   ra   Úcancel_scopeÚcancelÚCancelScopery   rl   s    r:   Ú__asynccontextmanager__z-AsyncWebSocketSession.__asynccontextmanager__�  s÷  è ø€ ä05×0QÑ0QÜ�N‰N× Ñ Ô#3Ñ3ñ1
ó 1Ñ-ˆÔ˜$Ô-ô ',×&=Ñ&=Ó&?ˆÔ#à×#Ñ#÷ 	'ñ 	' T×%8Ñ%8÷ 	'ñ 	'¸$×:UÑ:U÷ 	'ñ 	'Ø×'Ñ'×2Ñ2°4×3KÑ3KÈT×MiÑMiÔjØ×4Ñ4Ð@Ø×+Ñ+×6Ñ6Ø×3Ñ3Ø×9Ñ9Ø×8Ñ8ôð'Ø“
à×+Ñ+×8Ñ8×?Ñ?ÔAÜ×&Ñ&¨dÔ3ñ 'ØŸ*™*›,×&Ð&÷'÷	'÷ 	'÷ 	'÷ 	'÷ 	'÷ 	'ñ 	'ùð 	'ùð 	'ùð 'ø÷'ð 'ûð ×+Ñ+×8Ñ8×?Ñ?ÔAÜ×&Ñ&¨dÔ3ñ 'ØŸ*™*›,×&Ñ&÷'÷ 'ñ 'ýð	'ø÷ 	'÷ 	'ñ 	'úð 	'ø÷ 	'÷ 	'ñ 	'úð 	'ø÷ 	'÷ 	'ñ 	'üs?  ‚A-I0Á/F'Á0I0Á3IÂF*ÂIÂIÂF-
ÂIÂA8H-ÄF>Ä:H-ÅF2	Å)F0Å*F2	Å.H-Å6IÆH+ÆIÆIÆIÆIÆI0Æ!IÆ"I0Æ*IÆ-IÆ0F2	Æ2F;Æ7H-Æ>;H(	Ç9HÈHÈHÈ	H(	ÈH%È!H(	È(H-È+IÈ-H?È3H6È4H?È;IÉIÉI	É
IÉI	ÉIÉI0ÉI-É!I$É"I-É)I0c              ƒ  ó¾   K  — | j                   j                  |«      \  }}t        j                  j	                  |«      }| j                  |«      ƒ d{  –—†  |S 7 Œ­w)aK  
        Send a Ping message.

        Args:
            payload:
                Payload to attach to the Ping event.
                Internally, it's used to track this specific event.
                If left empty, a random one will be generated.

        Returns:
            An event that can be used to wait for the corresponding Pong response.

        Examples:
            Send a Ping and wait for the Pong

                pong_callback = await ws.ping()
                # Will block until the corresponding Pong is received.
                await pong_callback.wait()
        Nr€   r…   s        r:   rŠ   zAsyncWebSocketSession.ping´  sS   è ø€ ð( !×.Ñ.×5Ñ5°gÓ>Ñˆ�Ü—‘×#Ñ# GÓ,ˆØ�i‰i˜Ó×ÐØˆð 	ús   ‚AAÁAÁAc              ƒ  ó¨  K  — ddl }	 | j                  j                  |«      }| j                  4 ƒd{  –—†  | j                  j                  |«      ƒ d{  –—†  ddd«      ƒd{  –—†  y7 Œ87 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w# |j                  $ r9}| j                  t        j                  d«      ƒ d{  –—†7   t        «       |‚d}~ww xY w­w)a|  
        Send an Event message.

        Mainly useful to send events that are not supported by the library.
        Most of the time, [ping()][httpx_ws.AsyncWebSocketSession.ping],
        [send_text()][httpx_ws.AsyncWebSocketSession.send_text],
        [send_bytes()][httpx_ws.AsyncWebSocketSession.send_bytes]
        and [send_json()][httpx_ws.AsyncWebSocketSession.send_json] are preferred.

        Args:
            event: The event to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Send an event.

                event = await wsproto.events.Message(b"Hello!")
                ws.send(event)
        r   NrŒ   r�   r’   s        r:   r„   zAsyncWebSocketSession.sendÍ  s³   è ø€ ó6 	ð	1Ø—?‘?×'Ñ'¨Ó.ˆDØ×'Ñ'÷ .ñ .Ø—k‘k×'Ñ'¨Ó-×-Ð-÷.÷ .ñ .øØ-øð.ø÷ .÷ .ñ .ûà×#Ñ#ò 	1Ø—*‘*œ[×7Ñ7Ð9MÓN×NÑNÜ'Ó)¨qÐ0ûð	1üs—   ‚Cˆ+B ³A,´B ·A2ÁA.ÁA2ÁB Á&A0Á'B Á+CÁ,B Á.A2Á0B Á2BÁ8A;Á9BÂ B ÂCÂB ÂCÂ#C
Â9B<Â:C
Ã
CÃCc              ƒ  ó‚   K  — t         j                  j                  |¬«      }| j                  |«      ƒ d{  –—†  y7 Œ­w)aà  
        Send a text message.

        Args:
            data: The text to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Send a text message.

                await ws.send_text("Hello!")
        r–   Nr—   r™   s      r:   rš   zAsyncWebSocketSession.send_textò  s1   è ø€ ô( —‘×*Ñ*°Ð*Ó5ˆØ�i‰i˜Ó×Òúó   ‚5?·=¸?c              ƒ  ó‚   K  — t         j                  j                  |¬«      }| j                  |«      ƒ d{  –—†  y7 Œ­w)aä  
        Send a bytes message.

        Args:
            data: The data to send.

        Raises:
            WebSocketNetworkError: A network error occured.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Send a bytes message.

                await ws.send_bytes(b"Hello!")
        r–   Nrœ   r™   s      r:   rž   z AsyncWebSocketSession.send_bytes	  s1   è ø€ ô( —‘×+Ñ+°Ð+Ó6ˆØ�i‰i˜Ó×Òúr%  c              ƒ  óØ   K  — |dv sJ ‚t        j                  |«      }|dk(  r| j                  |«      ƒ d{  –—†  y| j                  |j	                  d«      «      ƒ d{  –—†  y7 Œ.7 Œ­w)a�  
        Send JSON data.

        Args:
            data:
                The data to send. Must be serializable by [json.dumps][json.dumps].
            mode:
                The sending mode. Should either be `'text'` or `'bytes'`.

        Raises:
            WebSocketNetworkError: A network error occured.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Send JSON data.

                data = {"message": "Hello!"}
                await ws.send_json(data)
        r'   r(   Nr    r¡   r¥   s       r:   r¨   zAsyncWebSocketSession.send_json   sd   è ø€ ð0 Ð)Ñ)Ð)Ð)ÜŸ*™* TÓ*ˆØ�6Š>Ø—.‘. Ó1×1Ñ1à—/‘/ /×"8Ñ"8¸Ó"AÓB×BÑBð 2øàBús!   ‚5A*·A&¸(A*Á A(Á!A*Á(A*c              ƒ  óV  K  — t        j                  |«      5  | j                  j                  «       ƒ d{  –—† }ddd«       t	        t
        «      r|‚t	        |t        j                  j                  «      r t        |j                  |j                  «      ‚|S 7 Œd# 1 sw Y   ŒcxY w­w)a:  
        Receive an event from the server.

        Mainly useful to receive raw [wsproto.events.Event][wsproto.events.Event].
        Most of the time, [receive_text()][httpx_ws.AsyncWebSocketSession.receive_text],
        [receive_bytes()][httpx_ws.AsyncWebSocketSession.receive_bytes],
        and [receive_json()][httpx_ws.AsyncWebSocketSession.receive_json] are preferred.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            A raw [wsproto.events.Event][wsproto.events.Event].

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Wait for an event until one is available.

                try:
                    event = await ws.receive()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for an event for 2 seconds.

                try:
                    event = await ws.receive(timeout=2.)
                except TimeoutError:
                    print("No event received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        N)r  Ú
fail_afterr  r²   r®   r   rL   r‚   r¯   r   r°   r±   rµ   s      r:   r²   zAsyncWebSocketSession.receive?  s†   è ø€ ôX ×Ñ˜gÓ&ñ 	8Ø×-Ñ-×5Ñ5Ó7×7ˆE÷	8ä�eÔ-Ô.ØˆKÜ�eœWŸ^™^×;Ñ;Ô<Ü% e§j¡j°%·,±,Ó?Ð?Øˆð 8ø÷	8ð 	8üs,   ‚B)˜B¶B·B»A B)ÂBÂB&Â"B)c              ƒ  ó¶   K  — | j                  |«      ƒ d{  –—† }t        |t        j                  j                  «      r|j
                  S t        |«      ‚7 Œ?­w)a  
        Receive text from the server.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            Text data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event was not a text message.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Wait for text until available.

                try:
                    text = await ws.receive_text()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for text for 2 seconds.

                try:
                    event = await ws.receive_text(timeout=2.)
                except TimeoutError:
                    print("No text received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        Nr´   rµ   s      r:   r¶   z"AsyncWebSocketSession.receive_texts  sH   è ø€ ðP —l‘l 7Ó+×+ˆÜ�eœWŸ^™^×7Ñ7Ô8Ø—:‘:ÐÜ*¨5Ó1Ð1ð ,ús   ‚A—A˜A Ac              ƒ  óÈ   K  — | j                  |«      ƒ d{  –—† }t        |t        j                  j                  «      rt        |j                  «      S t        |«      ‚7 ŒH­w)a  
        Receive bytes from the server.

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.

        Returns:
            Bytes data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event was not a bytes message.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Wait for bytes until available.

                try:
                    data = await ws.receive_bytes()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for bytes for 2 seconds.

                try:
                    data = await ws.receive_bytes(timeout=2.)
                except TimeoutError:
                    print("No data received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        Nr¸   rµ   s      r:   rº   z#AsyncWebSocketSession.receive_bytes   sM   è ø€ ðP —l‘l 7Ó+×+ˆÜ�eœWŸ^™^×8Ñ8Ô9Ü˜Ÿ™Ó$Ð$Ü*¨5Ó1Ð1ð ,ús   ‚A"—A ˜A	A"c              ƒ  óÂ   K  — |dv sJ ‚|dk(  r| j                  |«      ƒ d{  –—† }n|dk(  r| j                  |«      ƒ d{  –—† }t        j                  «      S 7 Œ87 Œ­w)aÜ  
        Receive JSON data from the server.

        The received data should be parseable by [json.loads][json.loads].

        Args:
            timeout:
                Number of seconds to wait for an event.
                If `None`, will block until an event is available.
            mode:
                Receive mode. Should either be `'text'` or `'bytes'`.

        Returns:
            Parsed JSON data.

        Raises:
            TimeoutError: No event was received before the timeout delay.
            WebSocketDisconnect: The server closed the websocket.
            WebSocketNetworkError: A network error occured.
            WebSocketInvalidTypeReceived: The received event
                didn't correspond to the specified mode.

        Note:
            Exceptions not caught inside the context manager will be
            wrapped in an [ExceptionGroup][ExceptionGroup]. Use `except*` to catch them
            outside the `async with` block.

        Examples:
            Wait for data until available.

                try:
                    data = await ws.receive_json()
                except WebSocketDisconnect:
                    print("Connection closed")

            Wait for data for 2 seconds.

                try:
                    data = await ws.receive_json(timeout=2.)
                except TimeoutError:
                    print("No data received.")
                except WebSocketDisconnect:
                    print("Connection closed")
        r'   r(   Nr)   r¼   r¾   s       r:   r¿   z"AsyncWebSocketSession.receive_jsonÍ  se   è ø€ ðZ Ð)Ñ)Ð)Ð)à�6Š>Ø×*Ñ*¨7Ó3×3‰DØ�XÒØ×+Ñ+¨GÓ4×4ˆDÜ�z‰z˜$ÓÐð 4øà4ús!   ‚ A¢A£AÁAÁAÁAc              ƒ  ó´  K  — ddl }| j                  j                  «        | j                  j                  t
        j                  j                  j                  t
        j                  j                  j                  hvr„t
        j                  j                  ||«      }| j                  j                  |«      }	 | j                  4 ƒd{  –—†  | j                  j                  |«      ƒ d{  –—†  ddd«      ƒd{  –—†  | j                  j!                  «       ƒ d{  –—†  y7 ŒZ7 Œ97 Œ+# 1 ƒd{  –—†7  sw Y   Œ;xY w# |j                  $ r Y ŒOw xY w7 Œ5­w)a  
        Close the WebSocket session.

        Internally, it'll send the
        [CloseConnection][wsproto.events.CloseConnection] event.

        *This method is automatically called when exiting the context manager.*

        Args:
            code:
                The integer close code to indicate why the connection has closed.
            reason:
                Additional reasoning for why the connection has closed.

        Examples:
            Close the WebSocket session.

                await ws.close()
        r   N)rŽ   rY   rÁ   rM   rÃ   rL   rÄ   rÅ   rÆ   r‚   r¯   r„   r[   rK   r�   r�   ÚacloserÇ   s         r:   ry   zAsyncWebSocketSession.close  s  è ø€ ó( 	à×Ñ×ÑÔ Ø�?‰?× Ñ Ü×Ñ×.Ñ.×<Ñ<Ü×Ñ×.Ñ.×5Ñ5ð)
ñ 
ô —N‘N×2Ñ2°4¸Ó@ˆEØ—?‘?×'Ñ'¨Ó.ˆDðØ×+Ñ+÷ 2ñ 2ØŸ+™+×+Ñ+¨DÓ1×1Ð1÷2÷ 2ð �k‰k× Ñ Ó"×"Ñ"ð	2øØ1øð2ø÷ 2÷ 2ñ 2ûà×'Ñ'ò Ùðúà"ús�   ‚B8EÂ;E ÃD&ÃE ÃD,Ã.D(Ã/D,Ã3E Ã>D*Ã?E ÄEÄ EÄ!EÄ&E Ä(D,Ä*E Ä,D>Ä2D5Ä3D>Ä:E ÅEÅEÅEÅEc              ƒ  óú  K  — ddl }d}d}	 | j                  j                  «       �s*| j                  |«      ƒ d{  –—† }| j                  j                  |«       | j                  j                  «       D �]»  }t        |t        j                  j                  «      rr| j                  j                  |j                  «       «      }| j                  4 ƒd{  –—†  | j                  j                  |«      ƒ d{  –—†  ddd«      ƒd{  –—†  Œšt        |t        j                  j                  «      r&| j                   j#                  |j$                  «       Œät        |t        j                  j&                  «      r| j                  j)                  «        t        |t        j                  j*                  «      �rR|t-        t        |j.                  t0        «      r|j.                  j3                  «       n|j.                  «      z  }||kD  re| j5                  t6        j8                  d«      ƒ d{  –—†  | j:                  j                  t=        t6        j8                  d«      «      ƒ d{  –—†   nÂ|j>                  s|€|j.                  }n||j.                  z  }no|€&d}| j:                  j                  |«      ƒ d{  –—†  nGtA        |«      } |||j.                  z   «      }d}d}| j:                  j                  |«      ƒ d{  –—†  �Œ™| j:                  j                  |«      ƒ d{  –—†  �Œ¾ | j                  j                  «       s�Œ)yy7 �Œ7 �Œ7 �Œ_7 �ŒR# 1 ƒd{  –—†7  sw Y   �ŒcxY w7 �ŒD7 �Œ7 Œº7 Œt7 ŒQ# |jB                  |jD                  tF        f$ rX | j5                  t6        jH                  d«      ƒ d{  –—†7   | j:                  j                  tK        «       «      ƒ d{  –—†7   Y yw xY w­w)am  
        Background task listening for data from the server.

        Internally, it'll:

        * Answer to Ping events.
        * Acknowledge Pong events.
        * Put other events in the [_events][_events]
        queue that'll eventually be consumed by the user.

        Args:
            max_bytes: The maximum chunk size to read at each iteration.
        r   NrÉ   rÊ   )&rŽ   rY   rË   rÍ   rM   rÎ   r‚   r®   rL   rƒ   r„   rB   r[   rK   r�   rÏ   rV   rÐ   r†   r¯   rÁ   rÑ   rÒ   r“   rÓ   r¤   ry   r
   rÔ   r  r   rÖ   r×   rØ   r�   r=   r‘   r   rÙ   s	            r:   rr   z)AsyncWebSocketSession._background_receive&  s7  è ø€ ó 	à59ÐØ Ðð,	AØ×(Ñ(×/Ñ/Õ1Ø!×.Ñ.¨yÓ9×9�Ø—‘×,Ñ,¨TÔ2Ø!Ÿ_™_×3Ñ3Ó5ó %7�EÜ! %¬¯©×)<Ñ)<Ô=Ø#Ÿ™×3Ñ3°E·N±NÓ4DÓE˜Ø#'×#3Ñ#3÷ :ñ :Ø"&§+¡+×"3Ñ"3°DÓ"9×9Ð9÷:÷ :à Ü! %¬¯©×)<Ñ)<Ô=Ø×*Ñ*×.Ñ.¨u¯}©}Ô=Ø Ü! %¬¯©×)GÑ)GÔHØ×*Ñ*×.Ñ.Ô0Ü! %¬¯©×)?Ñ)?Õ@Ø,´Ì:ÐV[×V`ÑV`ÔbeÔKf°E·J±J×4EÑ4EÔ4GÐlq×lvÑlvÓ0wÑwÐ,Ø/°)Ò;Ø"&§*¡*¬[×-HÑ-HÐJ[Ó"\×\Ð\Ø"&×"2Ñ"2×"7Ñ"7Ü 3´K×4OÑ4OÐQbÓ có#÷ ð ñ "à$×5Ò5Ø5Ð=Ø9>¿¹Ñ 6à 6¸%¿*¹*Ñ DÑ 6à3Ð;Ø34Ð0Ø"&×"2Ñ"2×"7Ñ"7¸Ó">×>Ñ>ô *.¨e«˜JÙ1;Ð<RÐUZ×U_ÑU_Ñ<_Ó1`Ð.Ø59Ð2Ø34Ð0Ø"&×"2Ñ"2×"7Ñ"7Ð8JÓ"K×KÐKÙ Ø×*Ñ*×/Ñ/°Ó6×6Ò6ðK%7ð ×(Ñ(×/Ñ/×1Ð1Ø9ùð
:ùØ9ùð:ù÷ :÷ :ò :úð ]ùðùð ?øð Løà6ùØ×#Ñ# Y×%9Ñ%9¼;ÐGò 	AØ—*‘*œ[×7Ñ7¸ÓH×HÑHØ×"Ñ"×'Ñ'Ô(=Ó(?Ó@×@Ó@ð	Aüs  ‚	O;Œ/N  »M¼BN  ÃMÃN  ÃMÃ9MÃ:MÃ>N  Ä	MÄ
D&N  È0M4È1:N  É+M7É,AN  Ê?M:Ë AN  ÌM<Ì$N  Ì,M>Ì-!N  ÍO;ÍN  ÍN  ÍMÍN  ÍM1	Í$M'Í%M1	Í,	N  Í7N  Í:N  Í<N  Í>N  Î AO8ÏOÏ+O8Ï/O2Ï0O8Ï5O;Ï7O8Ï8O;c              ƒ  óˆ  K  — | j                   j                  «       s‹t        j                  |«      ƒ d {  –—†  	 | j	                  «       ƒ d {  –—† }|�7	 t        j                  |«      5  |j                  «       ƒ d {  –—†  d d d «       | j                   j                  «       sŒŠy y 7 Œs7 Œ\# t
        j                  j                  $ r Y y w xY w7 ŒP# 1 sw Y   ŒOxY w# t        $ rX | j                  t        j                  d«      ƒ d {  –—†7   | j                  j                  t!        «       «      ƒ d {  –—†7   Y Œ²w xY w­wrà   )rY   rË   r  ÚsleeprŠ   rL   rá   râ   r)  rk   r­   ry   r
   r‘   r  r„   r   )rc   rã   rä   ræ   s       r:   rv   z0AsyncWebSocketSession._background_keepalive_pingf  s
  è ø€ Ø×$Ñ$×+Ñ+Ô-Ü—+‘+Ð.Ó/×/Ð/ðØ&*§i¡i£k× 1�ð
 Ð*ðIÜ×)Ñ)¨/Ó:ñ 3Ø+×0Ñ0Ó2×2Ð2÷3ð ×$Ñ$×+Ñ+×-Ø/øð !2ùä×$Ñ$×7Ñ7ò Ùðúð 3ø÷3ð 3ûä#ò IØŸ*™*¤[×%?Ñ%?ÐAYÓZ×ZÑZØ×*Ñ*×/Ñ/Ô0EÓ0GÓH×HÓHðIüs°   ‚3EµB)¶E»B- ÁB+ÁB- ÁEÁC Á+CÁ?CÂ CÂC ÂEÂ'EÂ+B- Â-CÃ
EÃCÃEÃCÃCÃC Ã,D?Ä
DÄ+D?Ä6D9Ä7D?Ä<EÄ>D?Ä?Ec              ƒ  óv   K  — | j                   j                  |«      ƒ d {  –—† }|dk(  r
t        «       ‚|S 7 Œ­wrõ   rö   rø   s      r:   rÍ   z"AsyncWebSocketSession._read_streamx  s6   è ø€ Ø—[‘[×%Ñ% iÓ0×0ˆØ�3Š;Ü“-ÐØˆð 1ús   ‚9¡7¢9)rK   r   rD   rù   rE   rù   rF   rú   rG   rú   rB   rA   rû   rü   )rû   ú2typing.AsyncGenerator[AsyncWebSocketSession, None]rý   )r†   r¹   rû   zanyio.Eventrþ   r   r  r  r  rf   r  r  r  r	  r
  r  r  r  r  r  )r5   r6   r7   r  r  r   r   r   r   rd   Ú
contextlibÚasynccontextmanagerr!  rŠ   r„   rš   rž   r¨   r²   r¶   rº   r¿   ry   rr   rv   rÍ   r8   r9   r:   r1   r1   V  së   … ñð@ ÓØÓØPÓPØVÓVð 'EØ,Ø8_Ø7]Ø$(ñRà"ðRð !$ð	Rð
 ðRð *6ðRð )5ðRð "ðRð 
óRðB ×#Ñ#ò'ó $ð'ô,ó2#1óJó.ô.Cô>2ôh+2ôZ+2ôZ3 ôj"#óH>Aô@Iô$r9   c                óª   — ddt        j                  t        j                  d«      «      j	                  d«      ddœ}| �dj                  | «      |d<   |S )	NÚupgradeÚ	websocketé   r    Ú13)rM   r7  zsec-websocket-keyzsec-websocket-versionz, rJ   )Úbase64Ú	b64encodeÚsecretsÚtoken_bytesÚdecoderz   )ÚsubprotocolsrQ   s     r:   Ú_get_headersrA    sY   € ð  ØÜ#×-Ñ-¬g×.AÑ.AÀ"Ó.EÓF×MÑMÈgÓVØ!%ñ	€Gð ÐØ,0¯I©I°lÓ,CˆÐ(Ñ)Ø€Nr9   c            
      ó    — e Zd ZdZeeeeedœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	e
j                  ddddeeeddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy)	ÚWebSocketClienta”  
    A sync WebSocket client.

    This class provides an API for connecting to WebSocket.

    Attributes:
        client:
            HTTPX client to use.
        max_message_size_bytes:
            Maximum incoming message size in bytes.
            Larger messages, including fragmented messages whose
            cumulative size exceeds the limit, close the connection
            with `MESSAGE_TOO_BIG`.
            Defaults to 65 KiB.
        queue_size:
            Size of the queue where the received messages will be held
            until they are consumed.
            If the queue is full, the client will stop receive messages
            from the server until the queue has room available.
            Defaults to 512.
        keepalive_ping_interval_seconds:
            Interval at which the client will automatically send a Ping event
            to keep the connection alive. Set it to `None` to disable this mechanism.
            Defaults to 20 seconds.
        keepalive_ping_timeout_seconds:
            Maximum delay the client will wait for an answer to its Ping event.
            If the delay is exceeded,
            [WebSocketNetworkError][httpx_ws.WebSocketNetworkError]
            will be raised and the connection closed.
            Defaults to 20 seconds.
        session_class:
            The session class to use.
            Defaults to [WebSocketSession][httpx_ws.WebSocketSession].
    ©rD   rE   rF   rG   Úsession_classc               óX   — || _         || _        || _        || _        || _        || _        y rf   ©ÚclientrD   rE   rF   rG   rE  ©rc   rH  rD   rE   rF   rG   rE  s          r:   rd   zWebSocketClient.__init__±  ó2   € ð ˆŒØ&<ˆÔ#Ø$ˆŒØ/NˆÔ,Ø.LˆÔ+Ø*ˆÕr9   N©r@  ÚparamsrQ   ÚcookiesÚauthÚfollow_redirectsr«   Ú
extensionsc             #  óª  K  — | j                   j                  d||t        |«      t        |«      z  |||||	¬«	      5 }
|
j                  dk7  rt        |
«      ‚| j                  |
j                  d   | j                  | j                  | j                  | j                  |
¬«      }|5  |–— ddd«       ddd«       y# 1 sw Y   ŒxY w# 1 sw Y   yxY w­w)a×  
        Start a sync WebSocket session.

        It returns a context manager that'll automatically
        call [close()][httpx_ws.WebSocketSession.close] when exiting.

        Args:
            url: The WebSocket URL.
            subprotocols:
                Optional list of subprotocols to negotiate with the server.
            params:
                Query parameters to include in the handshake request.
            headers:
                Headers to include in the handshake request.
            cookies:
                Cookies to include in the handshake request.
            auth:
                Authentication to use for the handshake request.
            follow_redirects:
                Whether to follow redirects on the handshake request.
            timeout:
                Timeout configuration for the handshake request.
            extensions:
                Request extensions for the handshake request.

        Returns:
            A [context manager][contextlib.AbstractContextManager]
                for [WebSocketSession][httpx_ws.WebSocketSession].

        Examples:
            Initialize the client and connect to a WebSocket.

                with httpx2.Client() as client:
                    ws_client = WebSocketClient(client)
                    with ws_client.connect("http://localhost:8000/ws") as ws:
                        message = ws.receive_text()
                        print(message)
                        ws.send_text("Hello!")
        ÚGET©rL  rQ   rM  rN  rO  r«   rP  ée   Únetwork_streamrC   N©rH  rK   r   rA  Ústatus_coder   rE  rP  rD   rE   rF   rG   ©rc   Úurlr@  rL  rQ   rM  rN  rO  r«   rP  rB   Úsessions               r:   ÚconnectzWebSocketClient.connectÂ  sé   è ø€ ðj �[‰[×ÑØØØÜ˜GÓ$¤|°LÓ'AÑAØØØ-ØØ!ð  ó 

ð 	ð Ø×#Ñ# sÒ*Ü+¨HÓ5Ð5à×(Ñ(Ø×#Ñ#Ð$4Ñ5Ø'+×'BÑ'BØŸ?™?Ø04×0TÑ0TØ/3×/RÑ/RØ!ð )ó ˆGð ñ Ø’÷÷-	ð 	÷,ð ú÷-	ð 	üs5   ‚:C¼A)CÂ%B;Â*CÂ2	CÂ;C	Ã CÃCÃC)rH  r   rD   rù   rE   rù   rF   rú   rG   rú   rE  ztype[SyncSession]rû   rü   )rY  rÓ   r@  úlist[str] | NonerL  úQueryParamTypes | NonerQ   úHeaderTypes | NonerM  úCookieTypes | NonerN  ú#AuthTypes | UseClientDefault | NonerO  úbool | UseClientDefaultr«   úTimeoutTypes | UseClientDefaultrP  úRequestExtensions | Nonerû   z)typing.Generator[SyncSession, None, None])r5   r6   r7   r  r   r   r   r   r-   rd   r4  Úcontextmanagerr   r[  r8   r9   r:   rC  rC  �  s  „ ñ!ðN 'EØ,Ø8_Ø7]Ø+;ñ+àð+ð !$ð	+ð
 ð+ð *6ð+ð )5ð+ð )ð+ð 
ó+ð" ×Ñð
 *.Ø)-Ø&*Ø&*Ø4FØ4FØ3EØ/3ñKàðKð 'ð	Kð
 'ðKð $ðKð $ðKð 2ðKð 2ðKð 1ðKð -ðKð 
3òKó ñKr9   rC  )rD   rE   rF   rG   r@  rL  rQ   rM  rN  rO  r«   rP  c             #  ó
  K  — |€ddl m}  |«       }nt        j                  |«      }|5 }t	        |||||¬«      }|j                  | ||||	|
|||¬«	      5 }|–— ddd«       ddd«       y# 1 sw Y   ŒxY w# 1 sw Y   yxY w­w)aÄ
  
    Start a sync WebSocket session.

    It returns a context manager that'll automatically
    call [close()][httpx_ws.WebSocketSession.close] when exiting.

    Args:
        url: The WebSocket URL.
        client:
            HTTPX client to use.
            If not provided, a default one will be initialized.
        max_message_size_bytes:
            Maximum incoming message size in bytes.
            Larger messages, including fragmented messages whose
            cumulative size exceeds the limit, close the connection
            with `MESSAGE_TOO_BIG`.
            Defaults to 65 KiB.
        queue_size:
            Size of the queue where the received messages will be held
            until they are consumed.
            If the queue is full, the client will stop receive messages
            from the server until the queue has room available.
            Defaults to 512.
        keepalive_ping_interval_seconds:
            Interval at which the client will automatically send a Ping event
            to keep the connection alive. Set it to `None` to disable this mechanism.
            Defaults to 20 seconds.
        keepalive_ping_timeout_seconds:
            Maximum delay the client will wait for an answer to its Ping event.
            If the delay is exceeded,
            [WebSocketNetworkError][httpx_ws.WebSocketNetworkError]
            will be raised and the connection closed.
            Defaults to 20 seconds.
        subprotocols:
            Optional list of subprotocols to negotiate with the server.
        params:
            Query parameters to include in the handshake request.
        headers:
            Headers to include in the handshake request.
        cookies:
            Cookies to include in the handshake request.
        auth:
            Authentication to use for the handshake request.
        follow_redirects:
            Whether to follow redirects on the handshake request.
        timeout:
            Timeout configuration for the handshake request.
        extensions:
            Request extensions for the handshake request.

    Returns:
        A [context manager][contextlib.AbstractContextManager]
            for [WebSocketSession][httpx_ws.WebSocketSession].

    Examples:
        Without explicit HTTPX client.

            with connect_ws("http://localhost:8000/ws") as ws:
                message = ws.receive_text()
                print(message)
                ws.send_text("Hello!")

        With explicit HTTPX client.

            with httpx2.Client() as client:
                with connect_ws("http://localhost:8000/ws", client) as ws:
                    message = ws.receive_text()
                    print(message)
                    ws.send_text("Hello!")
    Nr   )r   ©rH  rD   rE   rF   rG   rK  )Ú_clientr   r4  ÚnullcontextrC  r[  )rY  rH  rD   rE   rF   rG   r@  rL  rQ   rM  rN  rO  r«   rP  r   Úowned_clientÚ	ws_clientr8  s                     r:   Ú
connect_wsrk    s®   è ø€ ðp €~Ý$áBHÃ(‰ä!×-Ñ-¨fÓ5ˆà	ð ˜Ü#ØØ#9Ø!Ø,KØ+Iô
ˆ	ð ×ÑØØ%ØØØØØ-ØØ!ð ó 

ð 	ð ØŠO÷	÷ð ÷	ð 	ú÷ð üs4   ‚(Bª+A7ÁA+ÁA7Á"	BÁ+A4	Á0A7Á7B Á<Bc            
      ó    — e Zd ZdZeeeeedœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	e
j                  ddddeeeddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy)	ÚAsyncWebSocketClientaÇ  
    An async WebSocket client.

    This class provides an API for connecting to WebSocket.

    Attributes:
        client:
            HTTPX client to use.
        max_message_size_bytes:
            Maximum incoming message size in bytes.
            Larger messages, including fragmented messages whose
            cumulative size exceeds the limit, close the connection
            with `MESSAGE_TOO_BIG`.
            Defaults to 65 KiB.
        queue_size:
            Size of the queue where the received messages will be held
            until they are consumed.
            If the queue is full, the client will stop receive messages
            from the server until the queue has room available.
            Defaults to 512.
        keepalive_ping_interval_seconds:
            Interval at which the client will automatically send a Ping event
            to keep the connection alive. Set it to `None` to disable this mechanism.
            Defaults to 20 seconds.
        keepalive_ping_timeout_seconds:
            Maximum delay the client will wait for an answer to its Ping event.
            If the delay is exceeded,
            [WebSocketNetworkError][httpx_ws.WebSocketNetworkError]
            will be raised in an [ExceptionGroup][ExceptionGroup] and the connection closed.
            Defaults to 20 seconds.
        session_class:
            The session class to use.
            Defaults to [AsyncWebSocketSession][httpx_ws.AsyncWebSocketSession].
    rD  c               óX   — || _         || _        || _        || _        || _        || _        y rf   rG  rI  s          r:   rd   zAsyncWebSocketClient.__init__ª  rJ  r9   NrK  c              ó   K  — | j                   j                  d||t        |«      t        |«      z  |||||	¬«	      4 ƒd{  –—† }
|
j                  dk7  rt        |
«      ‚| j                  |
j                  d   | j                  | j                  | j                  | j                  |
¬«      }|4 ƒd{  –—†  |­–— ddd«      ƒd{  –—†  ddd«      ƒd{  –—†  y7 Œ›7 Œ,7 Œ# 1 ƒd{  –—†7  sw Y   Œ)xY w7 Œ # 1 ƒd{  –—†7  sw Y   yxY w­w)a  
        Start an async WebSocket session.

        It returns an async context manager that'll automatically
        call [close()][httpx_ws.AsyncWebSocketSession.close] when exiting.

        Args:
            url: The WebSocket URL.
            subprotocols:
                Optional list of subprotocols to negotiate with the server.
            params:
                Query parameters to include in the handshake request.
            headers:
                Headers to include in the handshake request.
            cookies:
                Cookies to include in the handshake request.
            auth:
                Authentication to use for the handshake request.
            follow_redirects:
                Whether to follow redirects on the handshake request.
            timeout:
                Timeout configuration for the handshake request.
            extensions:
                Request extensions for the handshake request.

        Returns:
            An [async context manager][contextlib.AbstractAsyncContextManager]
                for [AsyncWebSocketSession][httpx_ws.AsyncWebSocketSession].

        Examples:
            Initialize the client and connect to a WebSocket.

                async with httpx2.AsyncClient() as client:
                    ws_client = AsyncWebSocketClient(client)
                    async with ws_client.connect("http://localhost:8000/ws") as ws:
                        message = await ws.receive_text()
                        print(message)
                        await ws.send_text("Hello!")
        rR  rS  NrT  rU  rC   rV  rX  s               r:   r[  zAsyncWebSocketClient.connect»  s  è ø€ ðj —;‘;×%Ñ%ØØØÜ˜GÓ$¤|°LÓ'AÑAØØØ-ØØ!ð &ó 

÷ 	ð 	ð Ø×#Ñ# sÒ*Ü+¨HÓ5Ð5à×(Ñ(Ø×#Ñ#Ð$4Ñ5Ø'+×'BÑ'BØŸ?™?Ø04×0TÑ0TØ/3×/RÑ/RØ!ð )ó ˆGð ÷ ñ Ø“÷÷ ÷-	÷ 	ñ 	øð,øð ø÷ ÷ ñ úð-	ø÷ 	÷ 	ñ 	üs�   ‚>DÁ CÁDÁA-C9Â1CÂ2C9Â5C"Â;C9ÃC ÃC9ÃDÃC7ÃDÃC9Ã C9Ã"C4	Ã(C+Ã)C4	Ã0C9Ã7DÃ9DÃ?DÄ DÄD)rH  r   rD   rù   rE   rù   rF   rú   rG   rú   rE  ztype[AsyncSession]rû   rü   )rY  rÓ   r@  r\  rL  r]  rQ   r^  rM  r_  rN  r`  rO  ra  r«   rb  rP  rc  rû   z)typing.AsyncGenerator[AsyncSession, None])r5   r6   r7   r  r   r   r   r   r1   rd   r4  r5  r   r[  r8   r9   r:   rm  rm  †  s  „ ñ!ðN 'EØ,Ø8_Ø7]Ø,Añ+àð+ð !$ð	+ð
 ð+ð *6ð+ð )5ð+ð *ð+ð 
ó+ð" ×#Ñ#ð
 *.Ø)-Ø&*Ø&*Ø4FØ4FØ3EØ/3ñKàðKð 'ð	Kð
 'ðKð $ðKð $ðKð 2ðKð 2ðKð 1ðKð -ðKð 
3òKó $ñKr9   rm  c              ó€  K  — |€ddl m}  |«       }nt        j                  |«      }|4 ƒd{  –—† }t	        |||||¬«      }|j                  | ||||	|
|||¬«	      4 ƒd{  –—† }|­–— ddd«      ƒd{  –—†  ddd«      ƒd{  –—†  y7 Œ]7 Œ,7 Œ# 1 ƒd{  –—†7  sw Y   Œ)xY w7 Œ # 1 ƒd{  –—†7  sw Y   yxY w­w)a@  
    Start an async WebSocket session.

    It returns an async context manager that'll automatically
    call [close()][httpx_ws.AsyncWebSocketSession.close] when exiting.

    Args:
        url: The WebSocket URL.
        client:
            HTTPX client to use.
            If not provided, a default one will be initialized.
        max_message_size_bytes:
            Maximum incoming message size in bytes.
            Larger messages, including fragmented messages whose
            cumulative size exceeds the limit, close the connection
            with `MESSAGE_TOO_BIG`.
            Defaults to 65 KiB.
        queue_size:
            Size of the queue where the received messages will be held
            until they are consumed.
            If the queue is full, the client will stop receive messages
            from the server until the queue has room available.
            Defaults to 512.
        keepalive_ping_interval_seconds:
            Interval at which the client will automatically send a Ping event
            to keep the connection alive. Set it to `None` to disable this mechanism.
            Defaults to 20 seconds.
        keepalive_ping_timeout_seconds:
            Maximum delay the client will wait for an answer to its Ping event.
            If the delay is exceeded,
            [WebSocketNetworkError][httpx_ws.WebSocketNetworkError]
            will be raised in an [ExceptionGroup][ExceptionGroup] and the connection closed.
            Defaults to 20 seconds.
        subprotocols:
            Optional list of subprotocols to negotiate with the server.
        params:
            Query parameters to include in the handshake request.
        headers:
            Headers to include in the handshake request.
        cookies:
            Cookies to include in the handshake request.
        auth:
            Authentication to use for the handshake request.
        follow_redirects:
            Whether to follow redirects on the handshake request.
        timeout:
            Timeout configuration for the handshake request.
        extensions:
            Request extensions for the handshake request.

    Returns:
        An [async context manager][contextlib.AbstractAsyncContextManager]
            for [AsyncWebSocketSession][httpx_ws.AsyncWebSocketSession].

    Examples:
        Without explicit HTTPX client.

            async with aconnect_ws("http://localhost:8000/ws") as ws:
                message = await ws.receive_text()
                print(message)
                await ws.send_text("Hello!")

        With explicit HTTPX client.

            async with httpx2.AsyncClient() as client:
                async with aconnect_ws("http://localhost:8000/ws", client) as ws:
                    message = await ws.receive_text()
                    print(message)
                    await ws.send_text("Hello!")
    Nr   )r   rf  rK  )rg  r   r4  rh  rm  r[  )rY  rH  rD   rE   rF   rG   r@  rL  rQ   rM  rN  rO  r«   rP  r   ri  rj  r8  s                     r:   Úaconnect_wsrq  
  sß   è ø€ ðp €~Ý)áLWËM‰ä!×-Ñ-¨fÓ5ˆà÷ ð ˜vÜ(ØØ#9Ø!Ø,KØ+Iô
ˆ	ð ×$Ñ$ØØ%ØØØØØ-ØØ!ð %ó 

÷ 	ð 	ð Ø‹O÷	÷ 	÷÷ ñ øð	øð 	ø÷ 	÷ 	ñ 	úðø÷ ÷ ñ üsŒ   ‚,B>®B¯B>²/B)Á!BÁ"B)Á%BÁ+B)Á6BÁ7B)Á;B>ÂB'ÂB>ÂB)ÂB)ÂB$	ÂBÂB$	Â B)Â'B>Â)B;Â/B2Â0B;Â7B>)r@  r\  rû   zdict[str, typing.Any]rf   )rY  rÓ   rH  zClient | NonerD   rù   rE   rù   rF   rú   rG   rú   r@  r\  rL  r]  rQ   r^  rM  r_  rN  r`  rO  ra  r«   rb  rP  rc  rû   z.typing.Generator[WebSocketSession, None, None])rY  rÓ   rH  zAsyncClient | NonerD   rù   rE   rù   rF   rú   rG   rú   r@  r\  rL  r]  rQ   r^  rM  r_  rN  r`  rO  ra  r«   rb  rP  rc  rû   r3  )PÚ
__future__r   r;  Úconcurrent.futuresrg   r4  r¢   rS   r=  ÚsysrW   ÚtypingÚtypesr   Úversion_infor   Útyping_extensionsr  rL   Úwsproto.utilitiesÚanyio.streams.memoryr   r	   Úwsproto.frame_protocolr
   rg  r   Ú_configr   r   r   r   Ú_modelsr   Ú_exceptionsr   r   r   r   r   Ú_pingr   r   Ú
_transportr   ÚTYPE_CHECKINGrŽ   r   r   r   r   r   r    Ú_typesr!   r"   r#   r$   r%   r&   ÚLiteralr  r*   r+   r,   r0   Ú	Exceptionr3   r=   r-   ÚAsyncContextManagerMixinr1   rA  ÚGenericrC  rd  rk  rm  r5  rq  r8   r9   r:   ú<module>r‡     s;  ðÝ "ã Û Û Û Û Û Û 
Û Û Ý à×Ñ�wÒÞå)ã Û Û ß RÝ .å (÷ó õ ÷õ ÷ 1Ý 7à	×Òß;ç?Ñ?Ý"÷÷ ð �>‰>Ð*Ñ+€Øˆv�~‰~˜nÓ-€ØˆV�^‰^˜LÓ)€
Ù�mÐ+=ÐGYÔZ€Ù�~Ð-DÐNeÔf€ô	�)ô 	ô	�)ô 	÷Kñ Kô\f˜E×:Ñ:ô fðRØ"ðàóôA�f—n‘n [Ñ1ô AðH ×Ñð !ðqð #AØ(Ø4[Ø3YØ%)Ø%)Ø"&Ø"&Ø0BØ0BØ/AØ+/ñqØ	ðqàðqð  ð	qð
 ðqð &2ðqð %1ðqð #ðqð #ðqð  ðqð  ðqð .ðqð .ðqð -ðqð )ðqð  4ò!qó ðqôhA˜6Ÿ>™>¨,Ñ7ô AðH ×Ñð "&ðqð #AØ(Ø4[Ø3YØ%)Ø%)Ø"&Ø"&Ø0BØ0BØ/AØ+/ñqØ	ðqàðqð  ð	qð
 ðqð &2ðqð %1ðqð #ðqð #ðqð  ðqð  ðqð .ðqð .ðqð -ðqð )ðqð  8ò!qó  ñqr9   