+
    O|jÎ‰  ã            %      ó(  € ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIHtHtHtHtHt ^RIHt ^RIHt ^RIH t  ^R	I!H"t" ^R
I#H$t$H%t%H&t& ^RI'H(t(H)t)H*t* ^RI+H,t,H-t-H.t. ^RI/H0t0 ^RIH1t1H2t2H3t3H4t4 ^RI5H6t6 ^RI7H8t8H9t9 ^RI5H:t: . R3Ot; ! R R]84      t< ! R R4      t=R R lt>R4RRRRRRRRRRRRRRR RR!RR"](R#^
R$^R%^R&^
R'R5R(^R)RR*R/R+ R, lllt?R6R- R. llt@R/ R0 ltAR7R1 R2 lltBR# )8é    )ÚannotationsN)ÚIterableÚSequence)ÚTracebackType)ÚAnyÚCallableÚMappingÚSelfÚcast)ÚInvalidHeader)ÚServerExtensionFactory)Ú enable_server_permessage_deflate)Ú	CloseCode)Úbuild_www_authenticate_basicÚparse_authorization_basicÚvalidate_subprotocols)ÚSERVERÚRequestÚResponse)Ú
CONNECTINGÚOPENÚEvent)ÚServerProtocol)Ú
LoggerLikeÚOriginÚ
StatusLikeÚSubprotocol)Úget_socket_name)Ú
ConnectionÚ	broadcast)ÚDeadlineÚServerConnectionÚServerc                  óŽ   a € ] tR t^/tRtR^R^R^
R^/R V 3R llltR R	 ltR
R
]R
3R R lltR V 3R llt	R V 3R llt
RtV ;t# )r"   a  
:mod:`threading` implementation of a WebSocket server connection.

:class:`ServerConnection` provides :meth:`recv` and :meth:`send` methods for
receiving and sending messages.

It supports iteration to receive messages::

    for message in websocket:
        process(message)

The iterator exits normally when the connection is closed with code
1000 (OK) or 1001 (going away) or without a close code. It raises a
:exc:`~websockets.exceptions.ConnectionClosedError` when the connection is
closed with any other code.

The ``ping_interval``, ``ping_timeout``, ``close_timeout``, and
``max_queue`` arguments have the same meaning as in :func:`serve`.

Args:
    socket: Socket connected to a WebSocket client.
    protocol: Sans-I/O connection.
    server: Server that manages this connection.

Úping_intervalÚping_timeoutÚclose_timeoutÚ	max_queuec               ó8   € V ^8„  d   QhRRRRRRRRR	RR
RRRRR/# )é   Úsockúsocket.socketÚprotocolr   Úserverr#   r%   úfloat | Noner&   r'   r(   ú*int | None | tuple[int | None, int | None]ÚreturnÚNone© )Úformats   "ÚOC:\Users\alokc\chatbot\backend\venv\Lib\site-packages\websockets/sync/server.pyÚ__annotate__ÚServerConnection.__annotate__J   sZ   € ÷ /ñ /àð/ð !ð/ð ð	/ð $ð/ð #ð/ð $ð/ð >ð/ð 
ñ/ó    c          	     	ó‚   <€ V  \         P                  ! 4       V n        \        SV `  VVVVVVR 7       W0n        V  V  V  R# )©r%   r&   r'   r(   N)Ú	threadingr   Úrequest_rcvdÚsuperÚ__init__r.   )	Úselfr+   r-   r.   r%   r&   r'   r(   Ú	__class__s	   &&&&$$$$€r5   r>   ÚServerConnection.__init__J   sK   ø€ ñ 	Ü%ŸOšOÓ-ˆÔÜ‰ÑØØØ'Ø%Ø'Øð 	ô 	
ð ŒÙÙÛr8   c               ó$   € V ^8„  d   QhRRRRRR/# )r*   Ústatusr   ÚtextÚstrr1   r   r3   )r4   s   "r5   r6   r7   d   s!   € ÷ 2ñ 2˜jð 2°ð 2¸ñ 2r8   c                ó8   € V P                   P                  W4      # )a¥  
Create a plain text HTTP response.

``process_request`` and ``process_response`` may call this method to
return an HTTP response instead of performing the WebSocket opening
handshake.

You can modify the response before returning it, for example by changing
HTTP headers.

Args:
    status: HTTP status code.
    text: HTTP response body; it will be encoded to UTF-8.

Returns:
    HTTP response to send to the client.

)r-   Úreject)r?   rC   rD   s   &&&r5   ÚrespondÚServerConnection.respondd   s   € ð& �}‰}×#Ñ# FÓ1Ð1r8   Nc          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r*   Úprocess_requestú=Callable[[ServerConnection, Request], Response | None] | NoneÚprocess_responseúGCallable[[ServerConnection, Request, Response], Response | None] | NoneÚserver_headerú
str | NoneÚtimeoutr/   r1   r2   r3   )r4   s   "r5   r6   r7   y   sE   € ÷ U?ñ U?ððU?ððU?ð  "ð!U?ð" ð#U?ð$ 
ñ%U?r8   c                ó°  € V P                   P                  V4      '       g   \        R4      hV P                  Ee“   RpVe    V! W P                  4      pVf,   V P
                  P                  V P                  4      V n        MWPn        Ve   W0P                  P                  R&   RpVe)    V! W P                  V P                  4      pVe   WPn        V P                  P                   \        P                  P"                  8X  dd   V P$                  P&                  P)                  4       '       d:   V P
                  P                  \        P                  P*                  R	4      V n        V P,                  \.        J dO   V P1                  \.        R
7      ;_uu_ 4        V P
                  P3                  V P                  4       RRR4       R# R# R#   \         dm   pY`P
                  n        T P                  P                  RRR7       T P
                  P                  \        P                  P                  R4      p Rp?ELíRp?ii ; i  \         dm   pY`P
                  n        T P                  P                  RRR7       T P
                  P                  \        P                  P                  R4      p Rp?ELòRp?ii ; i  + '       g   i     R# ; i)z!
Perform the opening handshake.

z-timed out while waiting for handshake requestNzprocess_request failedT©Úexc_infozLFailed to open a WebSocket connection.
See server log for more information.
r#   zprocess_response failedzServer is shutting down.
)Úexpected_state)r<   ÚwaitÚTimeoutErrorÚrequestÚ	Exceptionr-   Úhandshake_excÚloggerÚerrorrG   ÚhttpÚ
HTTPStatusÚINTERNAL_SERVER_ERRORÚacceptÚresponseÚheadersÚstatus_codeÚSWITCHING_PROTOCOLSr.   Úsocket_closedÚis_setÚSERVICE_UNAVAILABLEÚstater   Úsend_contextÚsend_response)r?   rK   rM   rO   rQ   ra   Úexcs   &&&&&  r5   Ú	handshakeÚServerConnection.handshakey   s*  € ð. × Ñ ×%Ñ% g×.Ò.ÜÐNÓOÐOà�<‰<Ó#ØˆHàÒ*ðÙ.¨t·\±\ÓB�Hð ÒØ $§¡× 4Ñ 4°T·\±\Ó B�•à (”àÒ(Ø2?—‘×%Ñ% hÑ/àˆHàÒ+ðÙ/°·l±lÀDÇMÁMÓR�Hð Ò'Ø$,”Mð —‘×)Ñ)¬T¯_©_×-PÑ-PÔPØ—K‘K×-Ñ-×4Ñ4×6Ò6à $§¡× 4Ñ 4Ü—O‘O×7Ñ7Ø0ó!�”ð �z‰zœZÓ'Ø×&Ñ&´jÐ&×AÕAØ—M‘M×/Ñ/°·±Ô>÷ BÑAñ (ñs $øô !ô 	Ø25—M‘MÔ/Ø—K‘K×%Ñ%Ð&>ÈÐ%ÔNØ#Ÿ}™}×3Ñ3ÜŸ™×=Ñ=ðEó –Hûð	ûô0 !ô 	Ø25—M‘MÔ/Ø—K‘K×%Ñ%Ð&?È$Ð%ÔOØ#Ÿ}™}×3Ñ3ÜŸ™×=Ñ=ðEó –Hûð	ú÷8 B×AÐAús>   ÁG Â-I
 Æ&KÇIÇA!IÉIÉ
KÉA!J<Ê<KËK	c               ó    € V ^8„  d   QhRRRR/# )r*   Úeventr   r1   r2   r3   )r4   s   "r5   r6   r7   Ð   s   € ÷ )ñ ) 5ð )¨Tñ )r8   c                ó¶   <€ V P                   f;   \        V\        4      '       g   Q hWn         V P                  P	                  4        R# \
        SV `  V4       R# )z
Process one incoming event.

N)rX   Ú
isinstancer   r<   Úsetr=   Úprocess_event)r?   ro   r@   s   &&€r5   rs   ÚServerConnection.process_eventÐ   sH   ø€ ð �<‰<ÒÜ˜e¤W×-Ò-Ð-Ð-Ø ŒLØ×Ñ×!Ñ!Ö#ô ‰GÑ! %Ö(r8   c               ó   € V ^8„  d   QhRR/# ©r*   r1   r2   r3   )r4   s   "r5   r6   r7   Þ   s   € ÷ 	$ñ 	$˜Tñ 	$r8   c                ó˜   <€  \         SV `  4        V P                  P                  4        R#   T P                  P                  4        i ; i)z9
Read incoming data from the socket and process events.

N)r=   Úrecv_eventsr<   rr   )r?   r@   s   &€r5   rx   ÚServerConnection.recv_eventsÞ   s:   ø€ ð
	$Ü‰GÑÔ!ð ×Ñ×!Ñ!Ö#øˆD×Ñ×!Ñ!Õ#ús	   ƒ- ­A	)rX   r<   ra   r.   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r>   rH   r   rl   rs   rx   Ú__static_attributes__Ú__classcell__)r@   s   @r5   r"   r"   /   sl   ø† ñð4/ð ')ð/ð &(ð/ð ')ð/ð AC÷/ò /õ42ð: ð Ø$*Ø $÷#U?÷n)ð )÷	$ö 	$r8   c                  óž   € ] tR t^êtRtRtRR R llt]R R l4       tR R	 lt	R
]
P                  R3R R lltR R ltR R ltR R ltRtR# )r#   aå  
WebSocket server returned by :func:`serve`.

This class mirrors partially the API of :class:`~socketserver.BaseServer`.

Args:
    socket: Server socket accepting new connections.
    handler: Handler for one connection. It receives the socket and address
        returned by :meth:`~socket.socket.accept`.
    logger: Logger for this server.
        It defaults to ``logging.getLogger("websockets.server")``.
        See the :doc:`logging guide <../../topics/logging>` for details.

gš™™™™™¹?Nc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r*   r+   r,   Úhandlerz$Callable[[socket.socket, Any], None]r[   úLoggerLike | Noner1   r2   r3   )r4   s   "r5   r6   ÚServer.__annotate__ü   s2   € ÷ /ñ /àð/ð 6ð/ð "ð	/ð
 
ñ/r8   c                	óp  € Wn         W n        Vf   \        P                  ! R4      pW0n        \
        P                  ! 4       V n        \        4       V n	        \        4       V n
        \        P                  R8w  d#   \         P                  ! 4       w  V n        V n        \
        P                   ! 4       V n        R # )Nzwebsockets.serverÚwin32)Úsocketrƒ   ÚloggingÚ	getLoggerr[   r;   ÚLockÚlockrr   Úall_connectionsÚhandler_threadsÚsysÚplatformÚ
socketpairÚshutdown_watcherÚshutdown_notifierr   re   )r?   r+   rƒ   r[   s   &&&&r5   r>   ÚServer.__init__ü   s‡   € ð ŒØŒØŠ>Ü×&Ò&Ð':Ó;ˆFØŒô —N’NÓ$ˆŒ	ô 7:³eˆÔÜ69³eˆÔô �<‰<˜7Ô"Ü<B×<MÒ<MÓ<OÑ9ˆDÔ! 4Ô#9ô 'Ÿ_š_Ó.ˆÖr8   c               ó   € V ^8„  d   QhRR/# )r*   r1   zset[ServerConnection]r3   )r4   s   "r5   r6   r…     s   € ÷ ñ Ð2ñ r8   c                óê   € V P                   ;_uu_ 4        V P                   Uu0 uF%  pVP                  P                  \        J g   K#  VkK'  	  upuuRRR4       # u upi   + '       g   i     R# ; i)zÜ
Set of active connections.

This property contains all connections that completed the opening
handshake successfully and didn't start the closing handshake yet.
It can be useful in combination with :func:`~broadcast`.

N)rŒ   r�   r-   rh   r   )r?   Ú
connections   & r5   ÚconnectionsÚServer.connections  s\   € ð �Y�Y‹Yð #'×"6Ò"6óá"6�JØ×&Ñ&×,Ñ,´Ð4÷ �
Ù"6ñ÷ ŠYùò÷ �YˆYús"   •A!¤ AÁ	AÁA!ÁA!Á!A2	c               ó   € V ^8„  d   QhRR/# rv   r3   )r4   s   "r5   r6   r…   )  s   € ÷ 4.ñ 4.˜tñ 4.r8   c                óÜ  € \         P                  ! 4       p\        P                  R8w  d+   VP	                  V P
                  \         P                  4         VP	                  V P                  \         P                  4       T P                  P                  R\        T P                  4      4        TP!                  4         T P                  P#                  4       w  r#\$        P&                  ! T P(                  Y#3R7      pT P*                  ;_uu_ 4        T P,                  P/                  T4       RRR4       TP1                  4        K›    \        \        3 dP     T P                  P                  4        \        P                  R8w  d   T P
                  P                  4        R# R# i ; i  \         d     Mi ; i  + '       g   i     L–; iT P                  P                  4        \        P                  R8w  d   T P
                  P                  4        R# R#   T P                  P                  4        \        P                  R8w  d   T P
                  P                  4        i i ; i)zß
See :meth:`socketserver.BaseServer.serve_forever`.

This method doesn't return. Calling :meth:`shutdown` from another thread
stops the server.

Typical use::

    with serve(...) as server:
        server.serve_forever()

r‡   Nzserver listening on %s)ÚtargetÚargs)Ú	selectorsÚDefaultSelectorr�   r�   Úregisterr’   Ú
EVENT_READrˆ   ÚOSErrorÚ
ValueErrorre   rr   Úcloser[   Úinfor   Úselectr`   r;   ÚThreadrƒ   rŒ   rŽ   ÚaddÚstart)r?   Úpollerr+   ÚaddrÚthreads   &    r5   Úserve_foreverÚServer.serve_forever)  sÅ  € ô ×*Ò*Ó,ˆÜ�<‰<˜7Ô"Ø�O‰O˜D×1Ñ1´9×3GÑ3GÔHð#	.ðØ—‘ §¡¬Y×-AÑ-AÔBð �K‰K×ÑÐ5´ÀtÇ{Á{Ó7SÔTàØ—‘”ðð "&§¡×!3Ñ!3Ó!5‘J�Dô #×)Ò)°·±ÀTÀLÔQ�ð
 —Y—Y“YØ×(Ñ(×,Ñ,¨VÔ4÷ à—‘–øô9 œZÐ(ô ð ð0 ×Ñ×"Ñ"Ô$Ü�|‰|˜wÔ&Ø×%Ñ%×+Ñ+Ö-ñ 'ð?ûô  ô Ùðú÷ —Yúð ×Ñ×"Ñ"Ô$Ü�|‰|˜wÔ&Ø×%Ñ%×+Ñ+Ö-ñ 'øð ×Ñ×"Ñ"Ô$Ü�|‰|˜wÔ&Ø×%Ñ%×+Ñ+Õ-ð 'úsh   Á*E ÂA H ÃF. Ã7H ÄF?Ä1H ÅF+ÅH Æ*F+Æ+H Æ.F<Æ9H Æ;F<Æ<H Æ?G	Ç
H ÈAI+TÚ c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r*   Úclose_connectionsÚboolÚcodezCloseCode | intÚreasonrE   r1   r2   r3   )r4   s   "r5   r6   r…   _  s8   € ÷ U*ñ U*àðU*ð ðU*ð ð	U*ð
 
ñU*r8   c                óè  € V P                   P                  R4       V P                  P                  4        \        P
                  R8w  d7    V P                  P                  R4       V P                  P                  4        V P                  P                  4        V'       dø    V P                  ;_uu_ 4        V P                   Uu. uF%  pVP                  P                  \        J g   K#  VNK'  	  pp\!        V P"                  4      pRRR4       X'       g   MËX'       g#   \$        P&                  ! V P(                  4       K¡  \*        P,                  P/                  4       ;_uu_ 4       pV F  pVP1                  VP                  W#4       K!  	  RRR4       K÷  V P                  ;_uu_ 4        \!        V P"                  4      pRRR4       X F  pVP3                  4        K  	  V P                   P                  R4       R#   \         d     EL©i ; i  T P                  P                  4        i ; iu upi   + '       g   i     EL8; i  + '       g   i     EK»  ; i  + '       g   i     L¥; i)aŽ  
Close the server.

* Close the listening socket to stop accepting new connections.
* When ``close_connections`` is :obj:`True`, which is the default, close
  existing connections. Specifically:

  * Reject opening WebSocket connections with an HTTP 503 (service
    unavailable) error. This happens when the server accepted the TCP
    connection but didn't complete the opening handshake before closing.
  * Close open WebSocket connections with code 1001 (going away).
    ``code`` and ``reason`` can be customized, for example to use code
    1012 (service restart).

* Wait until all connection handlers terminate.

:meth:`shutdown` is idempotent.

zserver closingr‡   ó   xNzserver closed)r[   r¥   rˆ   r¤   r�   r�   r“   Úsendr¢   re   rV   rŒ   r�   r-   rh   r   ÚlistrŽ   ÚtimeÚsleepÚSHUTDOWN_POLLING_INTERVALÚ
concurrentÚfuturesÚThreadPoolExecutorÚsubmitÚjoin)	r?   r±   r³   r´   r—   r˜   ÚthreadsÚexecutorr¬   s	   &&&&     r5   ÚshutdownÚServer.shutdown_  sÔ  € ð2 	�‰×ÑÐ)Ô*ð 	�‰×ÑÔÜ�<‰<˜7Ô"ð/Ø×&Ñ&×+Ñ+¨DÔ1ð ×&Ñ&×,Ñ,Ô.ð 	×Ñ×ÑÔ!÷ ð
 Ø—Y—Y“Yð
 +/×*>Ò*>ó#á*>˜JØ%×.Ñ.×4Ñ4¼Ð<÷ #˜
Ù*>ð  ð #ô
 # 4×#7Ñ#7Ó8�G÷ ÷ Ø÷ #Ü—J’J˜t×=Ñ=Ô>Ùä×'Ñ'×:Ñ:×<Ô<ÀÛ&1˜
Ø Ÿ™¨
×(8Ñ(8¸$ÖGñ '2÷ =Ñ<ð ——“Ü˜t×3Ñ3Ó4�÷ ó "�ð
 —‘–ñ "ð 	�‰×Ñ˜Ö)øôk ô Úðûð ×&Ñ&×,Ñ,Õ.üò$#÷ —Y�Yú÷& =×<Ñ<ú÷ —ús`   ÁH Â8H8Ã H3Ã,H3Ã2H8Å*&IÆ.I!ÈHÈH ÈHÈH ÈH0È3H8È8I		ÉI	É!I1	c               ó   € V ^8„  d   QhRR/# )r*   r1   Úintr3   )r4   s   "r5   r6   r…   ¶  s   € ÷ $ñ $˜ñ $r8   c                ó6   € V P                   P                  4       # )z.
See :meth:`socketserver.BaseServer.fileno`.

)rˆ   Úfileno©r?   s   &r5   rÈ   ÚServer.fileno¶  s   € ð
 �{‰{×!Ñ!Ó#Ð#r8   c               ó   € V ^8„  d   QhRR/# )r*   r1   r
   r3   )r4   s   "r5   r6   r…   ½  s   € ÷ ñ ˜4ñ r8   c                	ó   € V # ©Nr3   rÉ   s   &r5   Ú	__enter__ÚServer.__enter__½  s   € Øˆr8   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r*   Úexc_typeztype[BaseException] | NoneÚ	exc_valuezBaseException | NoneÚ	tracebackzTracebackType | Noner1   r2   r3   )r4   s   "r5   r6   r…   À  s2   € ÷ ñ à,ðð (ðð (ð	ð
 
ñr8   c                	ó&   € V P                  4        R # rÍ   )rÃ   )r?   rÑ   rÒ   rÓ   s   &&&&r5   Ú__exit__ÚServer.__exit__À  s   € ð 	�‰Žr8   )	r�   rƒ   rŽ   rŒ   r[   r“   r’   rˆ   re   rÍ   )rz   r{   r|   r}   r~   r»   r>   Úpropertyr˜   r­   r   Ú
GOING_AWAYrÃ   rÈ   rÎ   rÕ   r   r3   r8   r5   r#   r#   ê   sZ   † ñð !$Ð÷/ð8 ôó ðõ 4.ðp #'Ø )× 4Ñ 4Ø÷	U*õn$õ÷ñ r8   c               ó    € V ^8„  d   QhRRRR/# )r*   ÚnamerE   r1   r   r3   )r4   s   "r5   r6   r6   É  s   € ÷ Kñ K�cð K˜cñ Kr8   c                ó€   € V R 8X  d"   \         P                  ! R\        4       \        # \	        R\
        : RV : 24      h)ÚWebSocketServerz%WebSocketServer was renamed to Serverzmodule z has no attribute )ÚwarningsÚwarnÚDeprecationWarningr#   ÚAttributeErrorrz   )rÚ   s   &r5   Ú__getattr__rá   É  s=   € ØÐ Ô Ü�ŠØ3Üô	
ô ˆÜ
˜7¤8¡,Ð.@ÀÁÐIÓ
JÐJr8   r+   ÚsslÚoriginsÚ
extensionsÚsubprotocolsÚselect_subprotocolÚcompressionÚdeflaterK   rM   rO   Úopen_timeoutr%   r&   r'   Úmax_sizer(   r[   Úcreate_connectionc          .     ót   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRRRRRRRRRRRRRRR RR!R"R#R$R%R&R'R(/# ))r*   rƒ   ú"Callable[[ServerConnection], None]ÚhostrP   Úportz
int | Noner+   zsocket.socket | Nonerâ   zssl_module.SSLContext | Nonerã   z0Sequence[Origin | re.Pattern[str] | None] | Nonerä   z'Sequence[ServerExtensionFactory] | Nonerå   zSequence[Subprotocol] | Noneræ   zNCallable[[ServerConnection, Sequence[Subprotocol]], Subprotocol | None] | Nonerç   rK   rL   rM   rN   rO   ré   r/   r%   r&   r'   rê   r0   r(   r[   r„   rë   ztype[ServerConnection] | NoneÚkwargsr   r1   r#   r3   )r4   s   "r5   r6   r6   Ó  s  € ÷ Dñ DØ/ðDà
ðDð ðDð ðDð 
&ðDð >ðDð 8ðDð /ðDð	ðDð& ð'Dð,	ð-Dð:	ð;DðF ðGDðJ ðKDðL  ðMDðN ðODðP  ðQDðT 9ðUDðV :ðWDðZ ð[Dð^ 5ð_Dð` ðaDðb ñcDr8   c               ó  a aaaaaa
aaaaaaaaaaaa€ Sf4   RV9   d-   VP                  R4      o\        P                  ! R\        4       Se   \	        S4       V	R8X  d   \        S4      oMV	e   \        RV	 24      hSf   \        oVP                  RR4      oVP                  RR4      pVfi   S'       dH   Vf   \        R	4      hVP                  R
\        P                  4       \        P                  ! V3/ VB pMF\        P                  ! W33/ VB pM-Ve   \        R4      hVe   \        R4      hVe   \        R4      hSe   SP                  VRRR7      pR VVVV VVVVVVVV
VVVVVVV3R llp\        VVS4      oS# )a¿  
Create a WebSocket server listening on ``host`` and ``port``.

Whenever a client connects, the server creates a :class:`ServerConnection`,
performs the opening handshake, and delegates to the ``handler`` function.

The handler receives the :class:`ServerConnection` instance, which you can
use to send and receive messages.

Once the handler completes, either normally or with an exception, the server
performs the closing handshake and closes the connection.

This function returns a :class:`Server` object whose API mirrors
:class:`~socketserver.BaseServer`. Treat it as a context manager to ensure
that it will be closed gracefully and call :meth:`~Server.serve_forever` to
serve requests::

    from websockets.sync.server import serve

    def handler(websocket):
        ...

    with serve(handler, ...) as server:
        server.serve_forever()

    To stop the server gracefully, call its :meth:`~Server.shutdown` method
    from another thread.

Args:
    handler: Connection handler. It receives the WebSocket connection,
        which is a :class:`ServerConnection`, in argument.
    host: Network interfaces the server binds to.
        See :func:`~socket.create_server` for details.
    port: TCP port the server listens on.
        See :func:`~socket.create_server` for details.
    sock: Preexisting TCP socket. ``sock`` replaces ``host`` and ``port``.
        You may call :func:`socket.create_server` to create a suitable TCP
        socket.
    ssl: Configuration for enabling TLS on the connection.
    origins: Acceptable values of the ``Origin`` header, for defending
        against Cross-Site WebSocket Hijacking attacks. Values can be
        :class:`str` to test for an exact match or regular expressions
        compiled by :func:`re.compile` to test against a pattern. Include
        :obj:`None` in the list if the lack of an origin is acceptable.
    extensions: List of supported extensions, in order in which they
        should be negotiated and run.
    subprotocols: List of supported subprotocols, in order of decreasing
        preference.
    select_subprotocol: Callback for selecting a subprotocol among
        those supported by the client and the server. It receives a
        :class:`ServerConnection` (not a
        :class:`~websockets.server.ServerProtocol`!) instance and a list of
        subprotocols offered by the client. Other than the first argument,
        it has the same behavior as the
        :meth:`ServerProtocol.select_subprotocol
        <websockets.server.ServerProtocol.select_subprotocol>` method.
    compression: The "permessage-deflate" extension is enabled by default.
        Set ``compression`` to :obj:`None` to disable it. See the
        :doc:`compression guide <../../topics/compression>` for details.
    process_request: Intercept the request during the opening handshake.
        Return an HTTP response to force the response. Return :obj:`None` to
        continue normally. When you force an HTTP 101 Continue response, the
        handshake is successful. Else, the connection is aborted.
    process_response: Intercept the response during the opening handshake.
        Modify the response or return a new HTTP response to force the
        response. Return :obj:`None` to continue normally. When you force an
        HTTP 101 Continue response, the handshake is successful. Else, the
        connection is aborted.
    server_header: Value of  the ``Server`` response header.
        It defaults to ``"Python/x.y.z websockets/X.Y"``. Setting it to
        :obj:`None` removes the header.
    open_timeout: Timeout for opening connections in seconds.
        :obj:`None` disables the timeout.
    ping_interval: Interval between keepalive pings in seconds.
        :obj:`None` disables keepalive.
    ping_timeout: Timeout for keepalive pings in seconds.
        :obj:`None` disables timeouts.
    close_timeout: Timeout for closing connections in seconds.
        :obj:`None` disables the timeout.
    max_size: Maximum size of incoming messages in bytes.
        :obj:`None` disables the limit. You may pass a ``(max_message_size,
        max_fragment_size)`` tuple to set different limits for messages and
        fragments when you expect long messages sent in short fragments.
    max_queue: High-water mark of the buffer where frames are received.
        It defaults to 16 frames. The low-water mark defaults to ``max_queue
        // 4``. You may pass a ``(high, low)`` tuple to set the high-water
        and low-water marks. If you want to disable flow control entirely,
        you may set it to ``None``, although that's a bad idea.
    logger: Logger for this server.
        It defaults to ``logging.getLogger("websockets.server")``.
        See the :doc:`logging guide <../../topics/logging>` for details.
    create_connection: Factory for the :class:`ServerConnection` managing
        the connection. Set it to a wrapper or a subclass to customize
        connection handling.

Any other keyword arguments are passed to :func:`~socket.create_server`.

NÚssl_contextzssl_context was renamed to sslrè   zunsupported compression: ÚunixFÚpathzmissing path argumentÚfamilyzhost is incompatible with sockzport is incompatible with sockzpath is incompatible with sockT)Úserver_sideÚdo_handshake_on_connectc               ó$   € V ^8„  d   QhRRRRRR/# )r*   r+   r,   r«   r   r1   r2   r3   )r4   s   "r5   r6   Úserve.<locals>.__annotate__Ÿ  s+   € ÷ rKñ rK˜=ð rK°ð rK¸ñ rKr8   c           
     ó‚	  <a€ \        S4      p S'       g0   V P                  \        P                  \        P                  R4       Sec   V P                  VP                  4       4       \        V \        P                  4      '       g   Q hV P                  4        V P                  R4       RpSe   R VV3R llp\        SSSVSS
R7      pSf   Q hS! V VSSSSSR7      o SP'                  SSSTP                  4       4       SP(                  P*                  \,        Jd_   SP/                  4         SP                  ;_uu_ 4        SP                  P!                  \"        P$                  ! 4       4       RRR4       R# SP                  ;_uu_ 4        SP0                  P3                  S4       RRR4       SP5                  4         S	! S4       SP                  4        SP                  ;_uu_ 4        SP0                  P!                  S4       RRR4       SP                  ;_uu_ 4        SP                  P!                  \"        P$                  ! 4       4       RRR4       R#   \         dÚ     T P                  4         SP                  ;_uu_ 4        SP                  P!                  \"        P$                  ! 4       4       RRR4        R#   + '       g   i      R# ; i  SP                  ;_uu_ 4        SP                  P!                  \"        P$                  ! 4       4       RRR4       i   + '       g   i     i ; i; ii ; i  + '       g   i     R# ; i  + '       g   i     ELº; i  \         dA    SP6                  P9                  RRR7       SP                  \:        P<                  4        ELÞi ; i  + '       g   i     EL»; i  SP                  ;_uu_ 4        SP0                  P!                  S4       RRR4       i   + '       g   i     i ; i; i  \         d    SP/                  4         EL,i ; i  + '       g   i     R# ; i  SP                  ;_uu_ 4        SP                  P!                  \"        P$                  ! 4       4       RRR4       i   + '       g   i     i ; i; i)	zÜ
Handle the lifecycle of a WebSocket connection.

Since this function doesn't have a caller that can handle exceptions,
it attempts to log relevant ones.

It guarantees that the TCP connection is closed before exiting.

TNc               ó$   € V ^8„  d   QhRRRRRR/# )r*   r-   r   rå   zSequence[Subprotocol]r1   zSubprotocol | Noner3   )r4   s   "r5   r6   Ú1serve.<locals>.sock_handler.<locals>.__annotate__Ç  s+   € ÷ Hñ HØ,ðHà"7ðHð (ñHr8   c                óF   <€ Sf   Q hV SP                   J g   Q hS! SV4      # rÍ   )r-   )r-   rå   r—   ræ   s   &&€€r5   Úprotocol_select_subprotocolÚ@serve.<locals>.sock_handler.<locals>.protocol_select_subprotocolÇ  s2   ø€ ð
 .Ò9Ð9Ð9à# z×':Ñ':Ó:Ð:Ð:Ù-¨j¸,ÓGÐGr8   )rã   rä   rå   ræ   rê   r[   r:   zconnection handler failedrS   )r!   Ú
setsockoptrˆ   ÚIPPROTO_TCPÚTCP_NODELAYÚ
settimeoutrQ   rq   Ú
ssl_moduleÚ	SSLSocketÚdo_handshaker   rY   r¤   rŒ   rŽ   Údiscardr;   Úcurrent_threadrl   r-   rh   r   Úclose_socketr�   r¨   Ústart_keepaliver[   r\   r   ÚINTERNAL_ERROR)r+   r«   Údeadlinerþ   r-   r—   r'   rë   rä   rƒ   r[   r(   rê   ré   rã   r%   r&   rK   rM   ræ   r.   rO   râ   rå   ró   s   &&   @€€€€€€€€€€€€€€€€€€€r5   Úsock_handlerÚserve.<locals>.sock_handlerŸ  sm  ù€ ô ˜LÓ)ˆð@	O÷ Ø—‘¤× 2Ñ 2´F×4FÑ4FÈÔMð ŠØ—‘ × 0Ñ 0Ó 2Ô3ä! $¬
×(<Ñ(<×=Ò=Ð=Ð=Ø×!Ñ!Ô#Ø—‘ Ô%ð ð (ð "Ò-÷Hñ Hô &ØØ%Ø)Ø#>Ø!ØôˆHð %Ò0Ð0Ð0Ù*ØØØØ+Ø)Ø+Ø#ôˆJð"!	KØ× Ñ ØØ ØØ× Ñ Ó"ô	ð ×"Ñ"×(Ñ(´Ó4Ø×'Ñ'Ô)Øð, ——“Ø×&Ñ&×.Ñ.¬y×/GÒ/GÓ/IÔJ÷ ‘ð) ——“Ø×&Ñ&×*Ñ*¨:Ô6÷ à×&Ñ&Ô(ð	?Ù˜
Ô#ð
 × Ñ Ô"à—[—[“[Ø×*Ñ*×2Ñ2°:Ô>÷ !ð ——“Ø×&Ñ&×.Ñ.¬y×/GÒ/GÓ/IÔJ÷ ‘øôQ ô 	OðOØ—
‘
”Øà—[—[“[Ø×*Ñ*×2Ñ2´9×3KÒ3KÓ3MÔN÷ !—[—[”[û�V—[—[“[Ø×*Ñ*×2Ñ2´9×3KÒ3KÓ3MÔN÷ !—[—[�[ýð	Oú÷P —�ú÷) —�ûô
 ô ;Ø×!Ñ!×'Ñ'Ð(CÈdÐ'ÔSØ× Ñ ¤×!9Ñ!9×:ð;ú÷ !—[�[û�V—[—[“[Ø×*Ñ*×2Ñ2°:Ô>÷ !—[—[�[þô ô 	&ð ×#Ñ#×%ð	&ú÷ —�û�——“Ø×&Ñ&×.Ñ.¬y×/GÒ/GÓ/IÔJ÷ ——�ýsE  �I' —CI' Ã#AP( Å/MÆP( ÆM"Æ1P( Ç
M6 ÇO Ç"P( Ç6OÈP( È./Q
É'MÉ3K'ÊMÊ/KËMËK$ËMË$MË'MË</L4Ì+	MÌ4MÌ?MÍMÍM	Í"M3	Í-	P( Í6AOÎ=O Ï OÏO ÏO	ÏP( ÏQ ÏP( ÏP%Ï-P	Ð		P%ÐP"ÐP%Ð%P( Ð(QÑQ ÑQÑQ Ñ
Q	ÑR>Ñ3/R+	Ò"	R>Ò+R;Ò6R>)ÚpoprÝ   rÞ   rß   r   r   r£   r"   Ú
setdefaultrˆ   ÚAF_UNIXÚcreate_serverÚwrap_socketr#   )rƒ   rî   rï   r+   râ   rã   rä   rå   ræ   rç   rK   rM   rO   ré   r%   r&   r'   rê   r(   r[   rë   rð   rô   r  r.   ró   s   f&&$ddddd$ddddddddddd,  @@r5   Úserver  Ó  s�  ÿÿú€ ðp ‚{�}¨Ô.Ø�j‰j˜Ó'ˆÜ�ŠØ,Üô	
ð
 ÒÜ˜lÔ+à�iÔÜ5°jÓA‰
Ø	Ò	 ÜÐ4°[°MÐBÓCÐCàÒ Ü,Ðð
 —‘˜F EÓ*€DØ—z‘z &¨$Ó/€Dà‚|ßØŠ|Ü Ð!8Ó9Ð9Ø×Ñ˜h¬¯©Ô7Ü×'Ò'¨Ñ7°Ñ7‰Dä×'Ò'¨¨Ñ?¸Ñ?‰DàÒÜÐ=Ó>Ð>ØÒÜÐ=Ó>Ð>ØÒÜÐ=Ó>Ð>ð ‚Ø�‰ØØà$)ð	 ó 
ˆ÷rK÷ rK÷ rKò rKôn �D˜,¨Ó/€FØ€Mr8   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r*   rƒ   rí   rô   rP   rð   r   r1   r#   r3   )r4   s   "r5   r6   r6     s0   € ÷ :ñ :Ø/ð:à
ð:ð ð:ð ñ	:r8   c                ó"   € \        V 3RRRV/VB # )aœ  
Create a WebSocket server listening on a Unix socket.

This function accepts the same keyword arguments as :func:`serve`.

It's only available on Unix.

It's useful for deploying a server behind a reverse proxy such as nginx.

Args:
    handler: Connection handler. It receives the WebSocket connection,
        which is a :class:`ServerConnection`, in argument.
    path: File system path to the Unix socket.

ró   Trô   )r  )rƒ   rô   rð   s   &&,r5   Ú
unix_server    s   € ô( �Ñ9˜tÐ9¨$Ð9°&Ñ9Ð9r8   c               ó    € V ^8„  d   QhRRRR/# )r*   Úcredentialsr   r1   r²   r3   )r4   s   "r5   r6   r6   1  s   € ÷ Gñ G ð G¨ñ Gr8   c                óŒ   €  V w  r\        V\        4      ;'       d    \        V\        4      #   \        \        3 d     R # i ; i©F)rq   rE   Ú	TypeErrorr£   )r  ÚusernameÚpasswords   &  r5   Úis_credentialsr  1  sG   € ðGØ(Ñˆô ˜(¤CÓ(×FÐF¬Z¸Ä#Ó-FÐFøô ”zÐ"ô Úðús   ‚. ®AÁAc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r*   ÚrealmrE   r  z2tuple[str, str] | Iterable[tuple[str, str]] | NoneÚcheck_credentialsz!Callable[[str, str], bool] | Noner1   z6Callable[[ServerConnection, Request], Response | None]r3   )r4   s   "r5   r6   r6   :  s6   € ÷ jñ jØðjàCðjð 9ðjð <ñ	jr8   c                ó4  a aa€ VRJ SRJ 8X  d   \        R4      hVeë   \        V4      '       d$   \        \        \        \        3,          V4      .pM¢\        V\        4      '       d   \        \        \        \        \        \        3,          ,          V4      4      p\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   \        RV 24      hM\        RV 24      h\        V4      oR V3R lloSf   Q hR	 VV 3R
 llpV# )aü  
Factory for ``process_request`` to enforce HTTP Basic Authentication.

:func:`basic_auth` is designed to integrate with :func:`serve` as follows::

    from websockets.sync.server import basic_auth, serve

    with serve(
        ...,
        process_request=basic_auth(
            realm="my dev server",
            credentials=("hello", "iloveyou"),
        ),
    ):

If authentication succeeds, the connection's ``username`` attribute is set.
If it fails, the server responds with an HTTP 401 Unauthorized status.

One of ``credentials`` or ``check_credentials`` must be provided; not both.

Args:
    realm: Scope of protection. It should contain only ASCII characters
        because the encoding of non-ASCII characters is undefined. Refer to
        section 2.2 of :rfc:`7235` for details.
    credentials: Hard coded authorized credentials. It can be a
        ``(username, password)`` pair or a list of such pairs.
    check_credentials: Function that verifies credentials.
        It receives ``username`` and ``password`` arguments and returns
        whether they're valid.
Raises:
    TypeError: If ``credentials`` or ``check_credentials`` is wrong.
    ValueError: If ``credentials`` and ``check_credentials`` are both
        provided or both not provided.

Nz/provide either credentials or check_credentialsc              3  ó8   "  € T F  p\        V4      x € K  	  R # 5irÍ   )r  )Ú.0Úitems   & r5   Ú	<genexpr>Úbasic_auth.<locals>.<genexpr>j  s   é € ÐIÑ8H°”~ d×+Ð+Ó8Hùs   ‚FTzinvalid credentials argument: c               ó$   € V ^8„  d   QhRRRRRR/# )r*   r  rE   r  r1   r²   r3   )r4   s   "r5   r6   Ú basic_auth.<locals>.__annotate__q  s&   € ÷ 	Dñ 	D¨ð 	D°sð 	D¸tñ 	Dr8   c                óh   <€  SV ,          p\        P                  ! Y!4      #   \          d     R # i ; ir  )ÚKeyErrorÚhmacÚcompare_digest)r  r  Úexpected_passwordÚcredentials_dicts   && €r5   r"  Ú%basic_auth.<locals>.check_credentialsq  s;   ø€ ðØ$4°XÕ$>Ð!ô ×&Ò&Ð'8ÓCÐCøô ô Úðús   ƒ	" ¢1°1c               ó$   € V ^8„  d   QhRRRRRR/# )r*   r—   r"   rX   r   r1   zResponse | Noner3   )r4   s   "r5   r6   r*  z  s&   € ÷ (ñ (Ø$ð(àð(ð 
ñ(r8   c                óP  <€  VP                   R,          p \        T4      w  rES! YE4      '       gE   T P                  \        P                  P
                  R4      p\        S4      TP                   R&   T# Y@n	        R#   \         dH    T P                  \        P                  P
                  R4      p\        S4      TP                   R&   Tu # i ; i  \         dH    T P                  \        P                  P
                  R4      p\        S4      TP                   R&   Tu # i ; i)z±
Perform HTTP Basic Authentication.

If it succeeds, set the connection's ``username`` attribute and return
:obj:`None`. If it fails, return an HTTP 401 Unauthorized responss.

ÚAuthorizationzMissing credentials
zWWW-AuthenticatezUnsupported credentials
zInvalid credentials
N)
rb   r,  rH   r]   r^   ÚUNAUTHORIZEDr   r   r   r  )r—   rX   Úauthorizationra   r  r  r"  r!  s   &&    €€r5   rK   Ú#basic_auth.<locals>.process_requestz  s  ø€ ð	Ø#ŸO™O¨OÕ<ˆMð	Ü!:¸=Ó!IÑˆHñ ! ×4Ò4Ø!×)Ñ)Ü—‘×,Ñ,Ø'óˆHô 4PÐPUÓ3VˆH×ÑÐ/Ñ0ØˆOà&ÔÙøô7 ô 	Ø!×)Ñ)Ü—‘×,Ñ,Ø'óˆHô 4PÐPUÓ3VˆH×ÑÐ/Ñ0ØŠOð	ûô ô 	Ø!×)Ñ)Ü—‘×,Ñ,Ø+óˆHô 4PÐPUÓ3VˆH×ÑÐ/Ñ0ØŠOð	ús$   ƒA> —C Á>ACÃCÃAD%Ä$D%)r£   r  r   ÚtuplerE   rq   r   r¸   Úallr  Údict)r!  r  r"  Úcredentials_listrK   r0  s   f&f  @r5   Ú
basic_authr<  :  s  ú€ ðP 	�tÐÐ!2°dÐ!:Ô;ÜÐJÓKÐKàÒÜ˜+×&Ò&Ü $¤U¬3´¨8¥_°kÓ BÐCÑÜ˜¤X×.Ò.Ü#¤D¬´%¼¼S¸µ/Õ)BÀKÓ$PÓQÐß“3ÑIÑ8HÓI—3—3’3ÑIÑ8HÓI×IÒIÜÐ"@ÀÀÐ NÓOÐOð Jô Ð<¸[¸MÐJÓKÐKäÐ 0Ó1Ð÷	Dð 	Dð Ò(Ð(Ð(÷(ñ (ðT Ðr8   )r    r  r  r"   r#   r<  )NNi   rÍ   )r¯   NN)CÚ
__future__r   Úconcurrent.futuresr¼   r-  r]   r‰   Úrerž   rˆ   râ   r  r�   r;   r¹   rÝ   Úcollections.abcr   r   Útypesr   Útypingr   r   r	   r
   r   Ú
exceptionsr   Úextensions.baser   Úextensions.permessage_deflater   Úframesr   rb   r   r   r   Úhttp11r   r   r   r-   r   r   r   r.   r   r   r   r   r   Úutilsr   r—   r   r    r!   Ú__all__r"   r#   rá   r  r  r  r<  r3   r8   r5   Ú<module>rJ     s˜  ðÝ "ã Û Û Û Û 	Û Û Û Û 
Û Û Û ß .Ý ß 5Õ 5å &Ý 4Ý LÝ ÷ñ ÷
 /Ñ .ß .Ñ .Ý #ß @Ó @Ý #ß -Ý ò€ôx$�zô x$÷v\ñ \õ~KñDð "&ðDð )-ðDð AEðDð ;?ðDð 26ðDð$ 	ð%Dð& (ð'Dð6 	ð7DðD 	ðEDðF !'ðGDðJ "$ðKDðL #%ðMDðN "$ðODðP #%ðQDðT <AðUDðV =?ðWDðZ !%ð[Dð^ 8<÷_Dð D÷N
:õ.G÷jñ jr8   