+
    Tig                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^RI	H
t
HtHtHtHtHt ^RIHt ^RIHtHtHtHtHtHtHtHtHtHt ^RIHtHt ^R	I H!t! ^R
IH"t"H#t#H$t$ . ROt%]]]]3,          t&  ! R R]PN                  4      t(](PR                  t)](PT                  t* ! R R]PN                  4      t+]+PX                  t,]+PZ                  t-]+P\                  t.]+P^                  t/Rt0  ! R R4      t1R# )    )annotationsN)	Generator)Union)ConnectionClosedConnectionClosedErrorConnectionClosedOKInvalidStatePayloadTooBigProtocolError)	Extension)
OK_CLOSE_CODES	OP_BINARYOP_CLOSEOP_CONTOP_PINGOP_PONGOP_TEXTClose	CloseCodeFrame)RequestResponse)StreamReader)
LoggerLikeOriginSubprotocolProtocolSideStatec                  0    ] tR t^/tRt]! ^4      w  ttRtR# )r   z6A WebSocket connection is either a server or a client. N)	__name__
__module____qualname____firstlineno____doc__rangeSERVERCLIENT__static_attributes__r!       ^/home/kuhnn/.local/share/uv/tools/nano-pdf/lib/python3.14/site-packages/websockets/protocol.pyr   r   /   s    @1XNFFr+   c                  4    ] tR t^9tRt]! ^4      w  tttt	Rt
R# )r   z6A WebSocket connection is in one of these four states.r!   N)r"   r#   r$   r%   r&   r'   
CONNECTINGOPENCLOSINGCLOSEDr*   r!   r+   r,   r   r   9   s    @(-a%Jgvr+   r+   c                     ] tR t^ItRtR]RR5RR/R R llt]R R	 l4       t]P                  R
 R l4       t]R R l4       t
]R R l4       t]R R l4       tR R ltR R ltR R ltR6R R lltR6R R lltR7R R lltR R ltR  R! ltR8R" R# lltR$ R% ltR& R' ltR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4tR# )9r   a
  
Sans-I/O implementation of a WebSocket connection.

Args:
    side: :attr:`~Side.CLIENT` or :attr:`~Side.SERVER`.
    state: Initial state of the WebSocket connection.
    max_size: Maximum size of incoming messages in bytes;
        :obj:`None` disables the limit.
    logger: Logger for this connection; depending on ``side``,
        defaults to ``logging.getLogger("websockets.client")``
        or ``logging.getLogger("websockets.server")``;
        see the :doc:`logging guide <../../topics/logging>` for details.

statemax_sizeloggerNc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )   sider   r3   r   r4   
int | Noner5   zLoggerLike | NonereturnNoner!   )formats   "r,   __annotate__Protocol.__annotate__Y   sC     B1 B1B1 	B1
 B1 "B1 
B1r+   c               	J   \         P                  ! 4       V n         Vf2   \        P                  ! RVP
                  P                  4        24      pW@n         VP                  \        P                  4      V n
        Wn        W n        W0n        R V n        RV n        R V n        . V n        R V n        R V n        R V n        R V n        R V n         RV n        \1        4       V n        . V n        . V n        V P9                  4       V n        \=        V P:                  4       R V n        R # )Nzwebsockets.F) uuiduuid4idlogging	getLoggernamelowerr5   isEnabledForDEBUGdebugr8   r3   r4   cur_sizeexpect_continuation_frameorigin
extensionssubprotocol
close_rcvd
close_sentclose_rcvd_then_senthandshake_exceof_sentr   readereventswritesparseparsernext
parser_exc)selfr8   r3   r4   r5   s   &&$$$r,   __init__Protocol.__init__Y   s    "ZZ\B >&&TYY__5F4G'HIF"() ((7
 	 
 ! %) */& &*+-/3 )-(,15! 04	  #n#%#%jjlT[[,0r+   c                   V ^8  d   QhRR/# )r7   r:   r   r!   )r<   s   "r,   r=   r>      s      u r+   c                    V P                   # )au  
State of the WebSocket connection.

Defined in 4.1_, 4.2_, 7.1.3_, and 7.1.4_ of :rfc:`6455`.

.. _4.1: https://datatracker.ietf.org/doc/html/rfc6455#section-4.1
.. _4.2: https://datatracker.ietf.org/doc/html/rfc6455#section-4.2
.. _7.1.3: https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.3
.. _7.1.4: https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.4

)_stater[   s   &r,   r3   Protocol.state   s     {{r+   c                    V ^8  d   QhRRRR/# )r7   r3   r   r:   r;   r!   )r<   s   "r,   r=   r>      s      5 T r+   c                	    V P                   '       d'   V P                  P                  R VP                  4       Wn        R# )z= connection is %sN)rI   r5   rE   r`   )r[   r3   s   &&r,   r3   rb      s)    :::KK2EJJ?r+   c                   V ^8  d   QhRR/# )r7   r:   r9   r!   )r<   s   "r,   r=   r>      s     ( (J (r+   c                    V P                   \        Jd   R# V P                  f   \        P                  # V P                  P
                  # )z
WebSocket close code received from the remote endpoint.

Defined in 7.1.5_ of :rfc:`6455`.

.. _7.1.5: https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5

:obj:`None` if the connection isn't closed yet.

N)r3   r1   rO   r   ABNORMAL_CLOSUREcodera   s   &r,   
close_codeProtocol.close_code   s9     ::V#__$---??'''r+   c                   V ^8  d   QhRR/# )r7   r:   z
str | Noner!   )r<   s   "r,   r=   r>      s     * *j *r+   c                z    V P                   \        Jd   R# V P                  f   R# V P                  P                  # )z
WebSocket close reason  received from the remote endpoint.

Defined in 7.1.6_ of :rfc:`6455`.

.. _7.1.6: https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.6

:obj:`None` if the connection isn't closed yet.

N )r3   r1   rO   reasonra   s   &r,   close_reasonProtocol.close_reason   s0     ::V#__$??)))r+   c                   V ^8  d   QhRR/# )r7   r:   r   r!   )r<   s   "r,   r=   r>      s     ! !+ !r+   c                |   V P                   \        J g   Q R4       hV P                  eT   V P                  eF   V P                  P                  \
        9   d'   V P                  P                  \
        9   d   \        pM\        pV! V P                  V P                  V P                  4      pV P                  Vn
        V# )a  
Exception to raise when trying to interact with a closed connection.

Don't raise this exception while the connection :attr:`state`
is :attr:`~websockets.protocol.State.CLOSING`; wait until
it's :attr:`~websockets.protocol.State.CLOSED`.

Indeed, the exception includes the close code and reason, which are
known only once the connection is closed.

Raises:
    AssertionError: If the connection isn't closed yet.

zconnection isn't closed yet)r3   r1   rO   rP   rh   r   r   r   rQ   rZ   	__cause__)r[   exc_typeexcs   &  r,   	close_excProtocol.close_exc   s      zzV#B%BB# OO'+$$6$$6)H,H (OOOO%%!
 
r+   c                    V ^8  d   QhRRRR/# r7   databytesr:   r;   r!   )r<   s   "r,   r=   r>      s       4 r+   c                f    V P                   P                  V4       \        V P                  4       R# )a  
Receive data from the network.

After calling this method:

- You must call :meth:`data_to_send` and send this data to the network.
- You should call :meth:`events_received` and process resulting events.

Raises:
    EOFError: If :meth:`receive_eof` was called earlier.

N)rT   	feed_datarY   rX   r[   rz   s   &&r,   receive_dataProtocol.receive_data   s"     	d#T[[r+   c                   V ^8  d   QhRR/# r7   r:   r;   r!   )r<   s   "r,   r=   r>     s      T r+   c                    V P                   P                  '       d   R# V P                   P                  4        \        V P                  4       R# )aa  
Receive the end of the data stream from the network.

After calling this method:

- You must call :meth:`data_to_send` and send this data to the network;
  it will return ``[b""]``, signaling the end of the stream, or ``[]``.
- You aren't expected to call :meth:`events_received`; it won't return
  any new events.

:meth:`receive_eof` is idempotent.

N)rT   eoffeed_eofrY   rX   ra   s   &r,   receive_eofProtocol.receive_eof  s0     ;;???T[[r+   c               $    V ^8  d   QhRRRRRR/# r7   rz   r{   finboolr:   r;   r!   )r<   s   "r,   r=   r>   #  s!     3 3e 3$ 34 3r+   c                   V P                   '       g   \        R4      hV P                  \        Jd1   \	        RV P
                  P                  P                  4        24      hV'       * V n         V P                  \        \        W4      4       R# )a  
Send a `Continuation frame`_.

.. _Continuation frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

Parameters:
    data: payload containing the same kind of data
        as the initial frame.
    fin: FIN bit; set it to :obj:`True` if this is the last frame
        of a fragmented message and to :obj:`False` otherwise.

Raises:
    ProtocolError: If a fragmented message isn't in progress.

unexpected continuation frameconnection is N)rK   r   r`   r/   r	   r3   rE   rF   
send_framer   r   r[   rz   r   s   &&&r,   send_continuationProtocol.send_continuation#  si    " --- ?@@;;d"

0E0E0G/HIJJ-0&gt12r+   c               $    V ^8  d   QhRRRRRR/# r   r!   )r<   s   "r,   r=   r>   ;  s!     3 3e 3$ 3$ 3r+   c                   V P                   '       d   \        R4      hV P                  \        Jd1   \	        RV P
                  P                  P                  4        24      hV'       * V n         V P                  \        \        W4      4       R# )aS  
Send a `Text frame`_.

.. _Text frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

Parameters:
    data: payload containing text encoded with UTF-8.
    fin: FIN bit; set it to :obj:`False` if this is the first frame of
        a fragmented message.

Raises:
    ProtocolError: If a fragmented message is in progress.

expected a continuation framer   N)rK   r   r`   r/   r	   r3   rE   rF   r   r   r   r   s   &&&r,   	send_textProtocol.send_text;  si      ))) ?@@;;d"

0E0E0G/HIJJ-0&gt12r+   c               $    V ^8  d   QhRRRRRR/# r   r!   )r<   s   "r,   r=   r>   R  s!     5 5 5D 5D 5r+   c                   V P                   '       d   \        R4      hV P                  \        Jd1   \	        RV P
                  P                  P                  4        24      hV'       * V n         V P                  \        \        W4      4       R# )aU  
Send a `Binary frame`_.

.. _Binary frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

Parameters:
    data: payload containing arbitrary binary data.
    fin: FIN bit; set it to :obj:`False` if this is the first frame of
        a fragmented message.

Raises:
    ProtocolError: If a fragmented message is in progress.

r   r   N)rK   r   r`   r/   r	   r3   rE   rF   r   r   r   r   s   &&&r,   send_binaryProtocol.send_binaryR  si      ))) ?@@;;d"

0E0E0G/HIJJ-0&i34r+   c               $    V ^8  d   QhRRRRRR/# )r7   rh   r9   rn   strr:   r;   r!   )r<   s   "r,   r=   r>   i  s!     " "z "# "t "r+   c                   V P                   \        Jd1   \        RV P                  P                  P                  4        24      hVf0   VR8w  d   \        R4      h\        \        P                  R4      pRpM\        W4      pVP                  4       pV P                  \        \        V4      4       V P                  e   Q hW0n        \         V n        R# )a  
Send a `Close frame`_.

.. _Close frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.1

Parameters:
    code: close code.
    reason: close reason.

Raises:
    ProtocolError: If the code isn't valid or if a reason is provided
        without a code.

r   Nrm   z#cannot send a reason without a coder+   )r`   r/   r	   r3   rE   rF   r   r   r   NO_STATUS_RCVD	serializer   r   r   rO   rP   r0   r[   rh   rn   closerz   s   &&&  r,   
send_closeProtocol.send_closei  s    $ ;;d"

0E0E0G/HIJJ<|#$IJJ)22B7ED$'E??$Dh-. &&&
r+   c                    V ^8  d   QhRRRR/# ry   r!   )r<   s   "r,   r=   r>          . .e . .r+   c                    V P                   \        JdE   V P                   \        Jd1   \        RV P                  P
                  P                  4        24      hV P                  \        \        V4      4       R# )z
Send a `Ping frame`_.

.. _Ping frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2

Parameters:
    data: payload containing arbitrary binary data.

r   N)
r`   r/   r0   r	   r3   rE   rF   r   r   r   r~   s   &&r,   	send_pingProtocol.send_ping  R     ;;d"t{{''A

0E0E0G/HIJJgt,-r+   c                    V ^8  d   QhRRRR/# ry   r!   )r<   s   "r,   r=   r>     r   r+   c                    V P                   \        JdE   V P                   \        Jd1   \        RV P                  P
                  P                  4        24      hV P                  \        \        V4      4       R# )z
Send a `Pong frame`_.

.. _Pong frame:
    https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3

Parameters:
    data: payload containing arbitrary binary data.

r   N)
r`   r/   r0   r	   r3   rE   rF   r   r   r   r~   s   &&r,   	send_pongProtocol.send_pong  r   r+   c               $    V ^8  d   QhRRRRRR/# )r7   rh   intrn   r   r:   r;   r!   )r<   s   "r,   r=   r>     s!     - - -c -4 -r+   c                   V P                   \        J dv   V\        P                  8w  da   \	        W4      pVP                  4       pV P                  \        \        V4      4       W0n	        V P                  e   RV n        \        V n         V P                  \        J d#   V P                  '       g   V P!                  4        V P#                  4       V n        \'        V P$                  4       R# )z
`Fail the WebSocket connection`_.

.. _Fail the WebSocket connection:
    https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.7

Parameters:
    code: close code
    reason: close reason

Raises:
    ProtocolError: If the code isn't valid.
NT)r3   r/   r   rg   r   r   r   r   r   rP   rO   rQ   r0   r8   r(   rS   send_eofdiscardrX   rY   r   s   &&&  r,   failProtocol.fail  s    & ::y111d+(h 56"'
 ??.04D-$
 99t}}}MMO llnT[[r+   c                   V ^8  d   QhRR/# )r7   r:   zlist[Event]r!   )r<   s   "r,   r=   r>     s       r+   c                ,    V P                   . uqn         V# )z
Fetch events generated from data received from the network.

Call this method immediately after any of the ``receive_*()`` methods.

Process resulting events, likely by passing them to the application.

Returns:
    Events read from the connection.
)rU   )r[   rU   s   & r,   events_receivedProtocol.events_received  s     #kk2r+   c                   V ^8  d   QhRR/# )r7   r:   zlist[bytes]r!   )r<   s   "r,   r=   r>     s      k r+   c                ,    V P                   . uqn         V# )ay  
Obtain data to send to the network.

Call this method immediately after any of the ``receive_*()``,
``send_*()``, or :meth:`fail` methods.

Write resulting data to the connection.

The empty bytestring :data:`~websockets.protocol.SEND_EOF` signals
the end of the data stream. When you receive it, half-close the TCP
connection.

Returns:
    Data to write to the connection.

)rV   )r[   rV   s   & r,   data_to_sendProtocol.data_to_send  s    " #kk2r+   c                   V ^8  d   QhRR/# )r7   r:   r   r!   )r<   s   "r,   r=   r>     s     ) ) )r+   c                    V P                   \        J d   R# V P                   \        J d   R# V P                   \        J d   R# V P                   \        J g   Q hV P
                  # )ai  
Tell if the TCP connection is expected to close soon.

Call this method immediately after any of the ``receive_*()``,
``send_close()``, or :meth:`fail` methods.

If it returns :obj:`True`, schedule closing the TCP connection after a
short timeout if the other side hasn't already closed it.

Returns:
    Whether the TCP connection is expected to close soon.

FT)r3   r/   r0   r1   r.   rS   ra   s   &r,   close_expectedProtocol.close_expected  sN    D :::: ::zzZ'''}}r+   c                   V ^8  d   QhRR/# r7   r:   zGenerator[None]r!   )r<   s   "r,   r=   r>   /  s     FC FC FCr+   c              #    "     V P                   P                  4        Rj  xL
 '       d9   V P                  '       d   V P                  P                  R4       \	        R4      hV P
                  f   RpM8V P                  f   V P
                  pMV P
                  V P                  ,
          p\        P                  ! V P                   P                  V P                  \        J VV P                  R7       Rj  xL
 pV P                  '       d   V P                  P                  RV4       V P                  V4       EK<   EL LI  \         d;   pT P                  \         P"                  \%        T4      4       Y0n         Rp?EMORp?i\         d;   pT P                  \         P(                  \%        T4      4       Y0n         Rp?EMRp?i\*         dJ   pT P                  \         P,                  TP.                   RTP0                   24       Y0n         Rp?MRp?i\2         dU   pTP5                  T P                  4       T P                  \         P6                  \%        T4      4       Y0n         Rp?M]Rp?i\8         dM   pT P                  P;                  RRR	7       T P                  \         P<                  4       Y0n         Rp?MRp?ii ; iRx  \?        R
4      h5i)z
Parse incoming data into frames.

:meth:`receive_data` and :meth:`receive_eof` run this generator
coroutine until it needs more data or reaches EOF.

:meth:`parse` never raises an exception. Instead, it sets the
:attr:`parser_exc` and yields control.

TN< EOFzunexpected end of stream)maskr4   rM   z< %sz at position zparser failed)exc_infoz"parse() shouldn't step after error) rT   at_eofrI   r5   EOFErrorr4   rJ   r   rW   
read_exactr8   r(   rM   
recv_framer   r   r   PROTOCOL_ERRORr   rZ   rg   UnicodeDecodeErrorINVALID_DATArn   startr
   set_current_sizeMESSAGE_TOO_BIG	ExceptionerrorINTERNAL_ERRORAssertionError)r[   r4   frameru   s   &   r,   rW   Protocol.parse/  s    6	"#{{11333zzz))'2
 ##=>>==(#H]]*#}}H#}}t}}<H
 $);;KK**f,%#	$  :::KK%%fe4&; 4&  	"IIi..C9!OO 	"IIi00#c(;!OO! 	"IIi,,M#)).UV!OO 	"  /IIi//S:!OO 	"KKo=IIi../!OO		" 	ABBs   K#E E 	E E B:E 9E:E 1E E K/F?K#KK/GK#KK?HK#K'K(A
I72K#7KKAKK#KK#c                   V ^8  d   QhRR/# r   r!   )r<   s   "r,   r=   r>   w  s     C C Cr+   c              #    "   V P                   \        J ;'       g    V P                  \        J V P                  8X  g   Q hV P
                  P                  4        Rj  xL
 '       g   V P
                  P                  4        KD  V P                  '       d   V P                  P                  R4       V P                   \        J d%   V P                  \        Jd   V P                  4        \        V n        Rx  \        R4      h L5i)z
Discard incoming data.

This coroutine replaces :meth:`parse`:

- after receiving a close frame, during a normal closure (1.4);
- after sending a close frame, during an abnormal closure (7.1.7).

Nr   z"discard() shouldn't step after EOF)r8   r(   r3   r.   rS   rT   r   r   rI   r5   r)   r   r1   r   ra   s   &r,   r   Protocol.discardw  s      		V#??tzzZ'?T]]SSS"kk00222KK!:::KKg& 994::Z#?MMO
 ABB 3s   ADD	D(-DA.Dc                    V ^8  d   QhRRRR/# r7   r   r   r:   r;   r!   )r<   s   "r,   r=   r>     s     N" N" N"$ N"r+   c                @   VP                   \        J g   VP                   \        J dH   V P                  e   \	        R4      hVP
                  '       g   \        VP                  4      V n        EMVP                   \        J dc   V P                  f   \	        R4      hVP
                  '       d
   RV n        EMV ;P                  \        VP                  4      ,          un        EMVP                   \        J d.   \        \        VP                  4      pV P                  V4       EM\VP                   \        J d   EMFVP                   \        J Ed   \        P                  ! VP                  4      V n        V P"                  \$        J d   V P&                  f   Q hRV n        V P                  e   \	        R4      hV P"                  \*        J dM   V P                  \        \        VP                  4      4       V P                   V n        RV n        \$        V n        V P,                  \.        J d   V P1                  4        V P3                  4       V n        \7        V P4                  4       M\9        RVP                   R 24      hV P:                  P=                  V4       R# )	z
Process an incoming frame.

Nr   r   Fzincomplete fragmented messageTzunexpected opcode: 02x)opcoder   r   rJ   r   r   lenrz   r   r   r   r   r   r   r   rW   rO   r3   r0   rP   rQ   r/   r8   r(   r   r   rX   rY   r   rU   append)r[   r   
pong_frames   && r,   r   Protocol.recv_frame  s   
 <<7"elli&?}}(#$CDD999 #EJJ\\W$}}$#$CDDyyy $UZZ0\\W$ w

3JOOJ'\\W$ \\X% $kk%**5DOzzW$222,1)}}(#$CDD zzT!
 h

 ;<"&//,0)$
 yyF" ,,.DK !#6u||C6H!IJJ5!r+   c                    V ^8  d   QhRRRR/# r   r!   )r<   s   "r,   r=   r>     s     
 
 
$ 
r+   c                	    V P                   '       d   V P                  P                  R V4       V P                  P                  VP	                  V P
                  \        J V P                  R7      4       R# )z> %s)r   rM   N)rI   r5   rV   r   r   r8   r)   rM   )r[   r   s   &&r,   r   Protocol.send_frame  sU    :::KKfe,OOYY&(??  	
r+   c                   V ^8  d   QhRR/# r   r!   )r<   s   "r,   r=   r>     s     % %$ %r+   c                	    V P                   '       d   Q hR V n         V P                  '       d   V P                  P                  R4       V P                  P	                  \
        4       R# )Tz> EOFN)rS   rI   r5   rV   r   SEND_EOFra   s   &r,   r   Protocol.send_eof  sE    ===  :::KKg&8$r+   )r`   rO   rQ   rP   rJ   rI   rS   rU   rK   rM   rR   rB   r5   r4   rL   rX   rZ   rT   r8   r3   rN   rV   i   )T)Nrm   )rm   )r"   r#   r$   r%   r&   r/   r\   propertyr3   setterri   ro   rv   r   r   r   r   r   r   r   r   r   r   r   r   rW   r   r   r   r   r*   r!   r+   r,   r   r   I   s    B1 	B1
  %B1 %)B1H   \\ 
 ( ($ * *$ ! !J *303.5."H. . -b ()ZFCPC<N"d
% %r+   )r   r   r   r   )2
__future__r   enumrC   r@   collections.abcr   typingr   
exceptionsr   r   r   r	   r
   r   rM   r   framesr   r   r   r   r   r   r   r   r   r   http11r   r   streamsr   r   r   r   __all__EventIntEnumr   r(   r)   r   r.   r/   r0   r1   r   r   r!   r+   r,   <module>r      s    "    %   "   & ! 3 3 	gx&' ?4<<  
	1DLL 1 
zz
--	  Em
% m
%r+   