Ë
    Õ±1h®>  ã                  ó  — d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZmZmZmZ g d¢Z e
d	«      Zd
dœ	 	 	 	 	 	 	 	 	 d-d„Zd.d„Z ej2                  d«      Zd/d„Z ej2                  d«      Zd0d„Z ej2                  d«      Z ej2                  d«      Zd0d„Z  ej2                  d«      Z! ej2                  d«      Z"d1d„Z#	 	 	 	 	 	 	 	 	 	 d2d„Z$	 	 	 	 	 	 	 	 d3d„Z%d4d„Z& ej2                  d«      Z'	 	 	 	 	 	 	 	 d5d„Z(d6d„Z)	 	 	 	 	 	 	 	 d7d„Z*	 	 	 	 	 	 	 	 d8d„Z+d9d „Z,e,Z-	 	 	 	 	 	 d:d!„Z.d;d"„Z/e/Z0	 	 	 	 	 	 	 	 d<d#„Z1d=d$„Z2e2Z3d>d%„Z4e4Z5d?d&„Z6d@d'„Z7 ej2                  d(«      Z8d0d)„Z9dAd*„Z:dBd+„Z;dCd,„Z<y)Dé    )ÚannotationsN)ÚSequence)ÚCallableÚTypeVarÚcasté   )ÚInvalidHeaderFormatÚInvalidHeaderValue)ÚConnectionOptionÚExtensionHeaderÚExtensionNameÚExtensionParameterÚSubprotocolÚUpgradeProtocol)Ú
build_hostÚparse_connectionÚparse_upgradeÚparse_extensionÚbuild_extensionÚparse_subprotocolÚbuild_subprotocolÚvalidate_subprotocolsÚbuild_www_authenticate_basicÚparse_authorization_basicÚbuild_authorization_basicÚTF)Úalways_include_portc               ó    — 	 t        j                  | «      }|j                  dk(  rd| › d�} 	 |s	||rdndk7  r| › d|› �} | S # t        $ r Y Œw xY w)z#
    Build a ``Host`` header.

    é   ú[ú]i»  éP   ú:)Ú	ipaddressÚ
ip_addressÚversionÚ
ValueError)ÚhostÚportÚsecurer   Úaddresss        úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/websockets/headers.pyr   r   '   si   € ðÜ×&Ñ& tÓ,ˆð �?‰?˜aÒØ�t�f˜A�;‰Dá˜d©f¡s¸"Ò=Ø��q˜˜Ðˆà€Køô ò áðús   ‚A Á	AÁAc                ó,   — |t        | «      k(  rdS | |   S )z·
    Return the next character from ``header`` at the given position.

    Return :obj:`None` at the end of ``header``.

    We never need to peek more than one character ahead.

    N)Úlen)ÚheaderÚposs     r,   Ú
peek_aheadr1   I   s   € ð œ#˜f›+Ò%ˆ4Ð6¨6°#©;Ð6ó    z[\t ]*c                óV   — t         j                  | |«      }|€J ‚|j                  «       S )z±
    Parse optional whitespace from ``header`` at the given position.

    Return the new position.

    The whitespace itself isn't returned because it isn't significant.

    )Ú_OWS_reÚmatchÚend)r/   r0   r5   s      r,   Ú	parse_OWSr7   X   s,   € ô �M‰M˜& #Ó&€EØÐÐÐØ�9‰9‹;Ðr2   z[-!#$%&\'*+.^_`|~0-9a-zA-Z]+c                óŽ   — t         j                  | |«      }|€t        |d| |«      ‚|j                  «       |j	                  «       fS )z®
    Parse a token from ``header`` at the given position.

    Return the token value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    zexpected token)Ú	_token_rer5   r	   Úgroupr6   ©r/   r0   Úheader_namer5   s       r,   Úparse_tokenr=   j   sB   € ô �O‰O˜F CÓ(€EØ€}Ü! +Ð/?ÀÈÓMÐMØ�;‰;‹=˜%Ÿ)™)›+Ð%Ð%r2   zC"(?:[\x09\x20-\x21\x23-\x5b\x5d-\x7e]|\\[\x09\x20-\x7e\x80-\xff])*"z\\([\x09\x20-\x7e\x80-\xff])c                ó¼   — t         j                  | |«      }|€t        |d| |«      ‚t        j	                  d|j                  «       dd «      |j                  «       fS )z¹
    Parse a quoted string from ``header`` at the given position.

    Return the unquoted value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    zexpected quoted stringz\1r   éÿÿÿÿ)Ú_quoted_string_rer5   r	   Ú_unquote_reÚsubr:   r6   r;   s       r,   Úparse_quoted_stringrC   ‚   sW   € ô ×#Ñ# F¨CÓ0€EØ€}Ü! +Ð/GÈÐQTÓUÐUÜ�?‰?˜5 %§+¡+£-°°"Ð"5Ó6¸¿	¹	»ÐCÐCr2   z[\x09\x20-\x7e\x80-\xff]*z([\x22\x5c])c                ó~   — t         j                  | «      }|€t        d«      ‚dt        j	                  d| «      z   dz   S )zh
    Format ``value`` as a quoted string.

    This is the reverse of :func:`parse_quoted_string`.

    z-invalid characters for quoted-string encodingú"z\\\1)Ú_quotable_reÚ	fullmatchr'   Ú	_quote_rerB   )Úvaluer5   s     r,   Úbuild_quoted_stringrJ   ˜   s@   € ô ×"Ñ" 5Ó)€EØ€}ÜÐHÓIÐIØ”—‘˜w¨Ó.Ñ.°Ñ4Ð4r2   c                óÐ  — t        ||«      dk(  rt        ||dz   «      }t        ||«      dk(  rŒg }	  | |||«      \  }}|j                  |«       t        ||«      }|t        |«      k(  rnkt        ||«      dk(  rt        ||dz   «      }nt	        |d||«      ‚t        ||«      dk(  rt        ||dz   «      }t        ||«      dk(  rŒ|t        |«      k(  rnŒ¤|t        |«      k(  sJ ‚|S )aö  
    Parse a comma-separated list from ``header`` at the given position.

    This is appropriate for parsing values with the following grammar:

        1#item

    ``parse_item`` parses one item.

    ``header`` is assumed not to start or end with whitespace.

    (This function is designed for parsing an entire header value and
    :func:`~websockets.http.read_headers` strips whitespace from values.)

    Return a list of items.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    ú,r   zexpected comma)r1   r7   Úappendr.   r	   )Ú
parse_itemr/   r0   r<   ÚitemsÚitems         r,   Ú
parse_listrQ   ¥   s  € ô> �V˜SÓ
! SÒ
(Ü˜  a¡Ó(ˆô �V˜SÓ
! SÓ
(ð €EØ
á˜v s¨KÓ8‰	ˆˆcØ�‰�TÔÜ˜ Ó$ˆð ”#�f“+ÒØô �f˜cÓ" cÒ)Ü˜F C¨!¡GÓ,‰Cä% kÐ3CÀVÈSÓQÐQô ˜ Ó%¨Ò,Ü˜F C¨!¡GÓ,ˆCô ˜ Ó%¨Ó,ð ”#�f“+ÒØð- ð4 ”#�f“+ÒÐÐà€Lr2   c                óF   — t        | ||«      \  }}t        t        |«      |fS )z½
    Parse a Connection option from ``header`` at the given position.

    Return the protocol value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    )r=   r   r   ©r/   r0   r<   rP   s       r,   Úparse_connection_optionrT   ç   s)   € ô ˜F C¨Ó5�I€Dˆ#ÜÔ  $Ó'¨Ð,Ð,r2   c                ó&   — t        t        | dd«      S )zÓ
    Parse a ``Connection`` header.

    Return a list of HTTP connection options.

    Args
        header: value of the ``Connection`` header.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    r   Ú
Connection)rQ   rT   ©r/   s    r,   r   r   ÷   s   € ô Ô-¨v°q¸,ÓGÐGr2   z>[-!#$%&\'*+.^_`|~0-9a-zA-Z]+(?:/[-!#$%&\'*+.^_`|~0-9a-zA-Z]+)?c                óª   — t         j                  | |«      }|€t        |d| |«      ‚t        t        |j                  «       «      |j                  «       fS )z½
    Parse an Upgrade protocol from ``header`` at the given position.

    Return the protocol value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    zexpected protocol)Ú_protocol_rer5   r	   r   r   r:   r6   r;   s       r,   Úparse_upgrade_protocolrZ     sK   € ô ×Ñ˜v sÓ+€EØ€}Ü! +Ð/BÀFÈCÓPÐPÜ” §¡£Ó/°·±³Ð<Ð<r2   c                ó&   — t        t        | dd«      S )zÆ
    Parse an ``Upgrade`` header.

    Return a list of HTTP protocols.

    Args:
        header: Value of the ``Upgrade`` header.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    r   ÚUpgrade)rQ   rZ   rW   s    r,   r   r     s   € ô Ô,¨f°a¸ÓCÐCr2   c                óF  — t        | ||«      \  }}t        | |«      }d}t        | |«      dk(  rot        | |dz   «      }t        | |«      dk(  r5|}t        | ||«      \  }}t        j                  |«      €t        |d| |«      ‚t        | ||«      \  }}t        | |«      }||f|fS )zÌ
    Parse a single extension parameter from ``header`` at the given position.

    Return a ``(name, value)`` pair and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    Nú=r   rE   zinvalid quoted header content)r=   r7   r1   rC   r9   rG   r	   )r/   r0   r<   ÚnamerI   Ú
pos_befores         r,   Úparse_extension_item_paramra   .  sÅ   € ô ˜F C¨Ó5�I€Dˆ#Ü
�F˜CÓ
 €Cà€EÜ�&˜#Ó #Ò%Ü˜  a¡Ó(ˆÜ�f˜cÓ" cÒ)ØˆJÜ,¨V°S¸+ÓF‰JˆE�3ô ×"Ñ" 5Ó)Ð1Ü)ØÐ!@À&È*óð ô % V¨S°+Ó>‰JˆE�3Ü˜ Ó$ˆà�%ˆ=˜#ÐÐr2   c                ó  — t        | ||«      \  }}t        | |«      }g }t        | |«      dk(  r@t        | |dz   «      }t        | ||«      \  }}|j	                  |«       t        | |«      dk(  rŒ@t        t        |«      |f|fS )a  
    Parse an extension definition from ``header`` at the given position.

    Return an ``(extension name, parameters)`` pair, where ``parameters`` is a
    list of ``(name, value)`` pairs, and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    ú;r   )r=   r7   r1   ra   rM   r   r   )r/   r0   r<   r_   Ú
parametersÚ	parameters         r,   Úparse_extension_itemrf   R  s�   € ô ˜F C¨Ó5�I€Dˆ#Ü
�F˜CÓ
 €Cà€JÜ
�V˜SÓ
! SÒ
(Ü˜  a¡Ó(ˆÜ3°F¸CÀÓM‰ˆ	�3Ø×Ñ˜)Ô$ô �V˜SÓ
! SÓ
(ô ” Ó% zÐ2°CÐ7Ð7r2   c                ó&   — t        t        | dd«      S )aâ  
    Parse a ``Sec-WebSocket-Extensions`` header.

    Return a list of WebSocket extensions and their parameters in this format::

        [
            (
                'extension name',
                [
                    ('parameter name', 'parameter value'),
                    ....
                ]
            ),
            ...
        ]

    Parameter values are :obj:`None` when no value is provided.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    r   zSec-WebSocket-Extensions)rQ   rf   rW   s    r,   r   r   k  s   € ô. Ô*¨F°AÐ7QÓRÐRr2   c           
     óŒ   — dj                  t        t        | «      g|D � �cg c]  \  } }|€| n| › d|› �‘Œ c}} z   «      S c c}} w )zc
    Build an extension definition.

    This is the reverse of :func:`parse_extension_item`.

    z; r^   )Újoinr   Ústr)r_   rd   rI   s      r,   Úbuild_extension_itemrk   ˆ  s]   € ð �9‰9Ü	Œc�4‹Ðð  *÷
ñ ��eð �M‰D¨$¨¨q°°Ð'8Ñ8ó
ñ	
óð ùó
s   ¡A c                ó2   — dj                  d„ | D «       «      S )zl
    Build a ``Sec-WebSocket-Extensions`` header.

    This is the reverse of :func:`parse_extension`.

    ú, c              3  ó:   K  — | ]  \  }}t        ||«      –— Œ y ­w)N)rk   )Ú.0r_   rd   s      r,   ú	<genexpr>z"build_extension.<locals>.<genexpr>¢  s!   è ø€ ò Ù3C°4¸Ô˜T :×.ñùs   ‚©ri   )Ú
extensionss    r,   r   r   ›  s"   € ð �9‰9ñ ØGQôó ð r2   c                óF   — t        | ||«      \  }}t        t        |«      |fS )zº
    Parse a subprotocol from ``header`` at the given position.

    Return the subprotocol value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    )r=   r   r   rS   s       r,   Úparse_subprotocol_itemrt   ª  s(   € ô ˜F C¨Ó5�I€Dˆ#Ü”˜TÓ" CÐ'Ð'r2   c                ó&   — t        t        | dd«      S )z 
    Parse a ``Sec-WebSocket-Protocol`` header.

    Return a list of WebSocket subprotocols.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    r   zSec-WebSocket-Protocol)rQ   rt   rW   s    r,   r   r   º  s   € ô Ô,¨f°aÐ9QÓRÐRr2   c                ó$   — dj                  | «      S )zl
    Build a ``Sec-WebSocket-Protocol`` header.

    This is the reverse of :func:`parse_subprotocol`.

    rm   rq   )Úsubprotocolss    r,   r   r   Ê  s   € ð �9‰9�\Ó"Ð"r2   c                óÄ   — t        | t        «      st        d«      ‚t        | t        «      rt        d«      ‚| D ]%  }t        j                  |«      rŒt        d|› �«      ‚ y)zT
    Validate that ``subprotocols`` is suitable for :func:`build_subprotocol`.

    zsubprotocols must be a listz&subprotocols must be a list, not a strzinvalid subprotocol: N)Ú
isinstancer   Ú	TypeErrorrj   r9   rG   r'   )rw   Úsubprotocols     r,   r   r   ×  sb   € ô
 �l¤HÔ-ÜÐ5Ó6Ð6Ü�,¤Ô$ÜÐ@ÓAÐAØ#ò DˆÜ×"Ñ" ;Õ/ÜÐ4°[°MÐBÓCÐCñDr2   c                ó>   — t        | «      } t        d«      }d| › d|› �S )z�
    Build a ``WWW-Authenticate`` header for HTTP Basic Auth.

    Args:
        realm: Identifier of the protection space.

    zUTF-8zBasic realm=z
, charset=)rJ   )ÚrealmÚcharsets     r,   r   r   å  s+   € ô   Ó&€EÜ! 'Ó*€GØ˜%˜ 
¨7¨)Ð4Ð4r2   z[A-Za-z0-9-._~+/]+=*c                óŽ   — t         j                  | |«      }|€t        |d| |«      ‚|j                  «       |j	                  «       fS )z°
    Parse a token68 from ``header`` at the given position.

    Return the token value and the new position.

    Raises:
        InvalidHeaderFormat: On invalid inputs.

    zexpected token68)Ú_token68_rer5   r	   r:   r6   r;   s       r,   Úparse_token68r�   ö  sD   € ô ×Ñ˜f cÓ*€EØ€}Ü! +Ð/AÀ6È3ÓOÐOØ�;‰;‹=˜%Ÿ)™)›+Ð%Ð%r2   c                ó<   — |t        | «      k  rt        |d| |«      ‚y)z8
    Check that parsing reached the end of header.

    ztrailing dataN)r.   r	   )r/   r0   r<   s      r,   Ú	parse_endrƒ     s&   € ð
 ŒS�‹[ÒÜ! +¨ÀÈÓLÐLð r2   c                óø  — t        | dd«      \  }}|j                  «       dk7  rt        dd|› �«      ‚t        | |«      dk7  rt	        dd| |«      ‚|dz  }t        | |d«      \  }}t        | |d«       	 t        j                  |j                  «       «      j                  «       }	 |j                  d
d«      \  }}||fS # t        j                  $ r t        dd«      d	‚w xY w# t        $ r t        dd«      d	‚w xY w)a!  
    Parse an ``Authorization`` header for HTTP Basic Auth.

    Return a ``(username, password)`` tuple.

    Args:
        header: Value of the ``Authorization`` header.

    Raises:
        InvalidHeaderFormat: On invalid inputs.
        InvalidHeaderValue: On unsupported inputs.

    r   ÚAuthorizationÚbasiczunsupported scheme: ú zexpected space after schemer   z#expected base64-encoded credentialsNr#   z&expected username:password credentials)r=   Úlowerr
   r1   r	   r�   rƒ   Úbase64Ú	b64decodeÚencodeÚdecodeÚbinasciiÚErrorÚsplitr'   )r/   Úschemer0   Úbasic_credentialsÚ	user_passÚusernameÚpasswords          r,   r   r     s5  € ô  ˜f a¨Ó9�K€FˆCØ‡|�|ƒ~˜Ò Ü ØØ" 6 (Ð+ó
ð 	
ô �&˜#Ó #Ò%Ü!ØÐ:¸FÀCó
ð 	
ð ˆ1�H€CÜ*¨6°3¸ÓHÑÐ�sÜˆf�c˜?Ô+ðÜ×$Ñ$Ð%6×%=Ñ%=Ó%?Ó@×GÑGÓIˆ	ðØ&Ÿ_™_¨S°!Ó4Ñˆ�(ð �XÐÐøô �>‰>ò Ü ØØ1ó
ð ð	ðûô ò Ü ØØ4ó
ð ð	ðús   Á31B> Â%C" Â>!CÃ"C9c                óˆ   — d| vsJ ‚| › d|› �}t        j                  |j                  «       «      j                  «       }d|z   S )z€
    Build an ``Authorization`` header for HTTP Basic Auth.

    This is the reverse of :func:`parse_authorization_basic`.

    r#   zBasic )r‰   Ú	b64encoder‹   rŒ   )r“   r”   r’   r‘   s       r,   r   r   ?  sQ   € ð �hÑÐÐØ�*˜A˜h˜ZÐ(€IÜ×(Ñ(¨×)9Ñ)9Ó);Ó<×CÑCÓEÐØÐ'Ñ'Ð'r2   )
r(   rj   r)   Úintr*   Úboolr   r˜   Úreturnrj   )r/   rj   r0   r—   r™   z
str | None)r/   rj   r0   r—   r™   r—   )r/   rj   r0   r—   r<   rj   r™   ztuple[str, int])rI   rj   r™   rj   )
rN   z(Callable[[str, int, str], tuple[T, int]]r/   rj   r0   r—   r<   rj   r™   zlist[T])r/   rj   r0   r—   r<   rj   r™   ztuple[ConnectionOption, int])r/   rj   r™   zlist[ConnectionOption])r/   rj   r0   r—   r<   rj   r™   ztuple[UpgradeProtocol, int])r/   rj   r™   zlist[UpgradeProtocol])r/   rj   r0   r—   r<   rj   r™   ztuple[ExtensionParameter, int])r/   rj   r0   r—   r<   rj   r™   ztuple[ExtensionHeader, int])r/   rj   r™   zlist[ExtensionHeader])r_   r   rd   zSequence[ExtensionParameter]r™   rj   )rr   zSequence[ExtensionHeader]r™   rj   )r/   rj   r0   r—   r<   rj   r™   ztuple[Subprotocol, int])r/   rj   r™   zlist[Subprotocol])rw   úSequence[Subprotocol]r™   rj   )rw   rš   r™   ÚNone)r}   rj   r™   rj   )r/   rj   r0   r—   r<   rj   r™   r›   )r/   rj   r™   ztuple[str, str])r“   rj   r”   rj   r™   rj   )=Ú
__future__r   r‰   r�   r$   ÚreÚcollections.abcr   Útypingr   r   r   Ú
exceptionsr	   r
   r   r   r   r   r   r   Ú__all__r   r   r1   Úcompiler4   r7   r9   r=   r@   rA   rC   rF   rH   rJ   rQ   rT   r   rY   rZ   r   ra   rf   r   Úparse_extension_listrk   r   Úbuild_extension_listrt   r   Úparse_subprotocol_listr   Úbuild_subprotocol_listr   r   r€   r�   rƒ   r   r   © r2   r,   ú<module>r¨      s˜  ðÝ "ã Û Û Û 	Ý $ß *Ñ *ç ?÷÷ ò€ñ ˆCƒL€ð !&ñØ
ðà
ðð ðð
 ðð 	óóD	7ð ˆ"�*‰*�YÓ
€óð ˆB�J‰JÐ6Ó7€	ó&ð  �B—J‘JØJóÐ ð
 ˆb�j‰jÐ8Ó9€óDð  ˆr�z‰zÐ6Ó7€ð ˆB�J‰J�Ó'€	ó
5ð?Ø8ð?àð?ð 
ð?ð ð	?ð
 ó?ðD-Øð-Øð-Ø(+ð-à!ó-ó Hð  ˆr�z‰zØEó€ð
=Øð=Øð=Ø(+ð=à ó=ó$Dð !Øð!Øð!Ø(+ð!à#ó!ðH8Øð8Øð8Ø(+ð8à ó8ó2Sð4 'Ð ðØ
ðØ%Aðàóó&	ð 'Ð ð(Øð(Øð(Ø(+ð(àó(ó 
Sð +Ð ó#ð +Ð óDó5ð ˆb�j‰jÐ0Ó1€ó&ó Mó-ô`(r2   