ó
    ÖÁ“i®>  ã                  óL  • S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	J
r
Jr  SSKJrJr  SSKJrJrJrJrJrJr  / SQr\
" S	5      rS
S.         S-S jjrS.S jr\R2                  " S5      rS/S jr\R2                  " S5      rS0S jr\R2                  " S5      r\R2                  " S5      rS0S jr \R2                  " S5      r!\R2                  " S5      r"S1S jr#          S2S jr$        S3S jr%S4S jr&\R2                  " S5      r'        S5S jr(S6S jr)        S7S jr*        S8S jr+S9S  jr,\,r-      S:S! jr.S;S" jr/\/r0        S<S# jr1S=S$ jr2\2r3S>S% jr4\4r5S?S& jr6S@S' jr7\R2                  " S(5      r8S0S) jr9SAS* jr:SBS+ jr;SCS, jr<g)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               ó¸   •  [         R                  " U 5      nUR                  S:X  a  SU  S3n U(       d  X(       a  SOS:w  a  U  SU 3n U $ ! [         a     N*f = f)z
Build a ``Host`` header.

é   Ú[Ú]i»  éP   Ú:)Ú	ipaddressÚ
ip_addressÚversionÚ
ValueError)ÚhostÚportÚsecurer   Úaddresss        ÚO/home/mande/repo/quber/.venv/lib/python3.13/site-packages/websockets/headers.pyr   r   '   si   € ðÜ×&Ò& tÓ,ˆð �?‰?˜aÓØ�t�f˜A�;ˆDæ˜d­f¡s¸"Ó=Ø��q˜˜Ðˆà€Køô ó áðús   ‚A Á
AÁAc                ó,   • U[        U 5      :X  a  S$ X   $ )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   • [         R                  X5      nUc   eUR                  5       $ )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                óŒ   • [         R                  X5      nUc  [        USX5      eUR                  5       UR	                  5       4$ )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   s>   € ô �O‰O˜FÓ(€EØ�}Ü! +Ð/?ÀÓMÐMØ�;‰;‹=˜%Ÿ)™)›+Ð%Ð%r2   zC"(?:[\x09\x20-\x21\x23-\x5b\x5d-\x7e]|\\[\x09\x20-\x7e\x80-\xff])*"z\\([\x09\x20-\x7e\x80-\xff])c                óº   • [         R                  X5      nUc  [        USX5      e[        R	                  SUR                  5       SS 5      UR                  5       4$ )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   ‚   sR   € ô ×#Ñ# FÓ0€EØ�}Ü! +Ð/GÈÓUÐUÜ�?‰?˜5 %§+¡+£-°°"Ð"5Ó6¸¿	¹	»ÐCÐCr2   z[\x09\x20-\x7e\x80-\xff]*z([\x22\x5c])c                ó€   • [         R                  U 5      nUc  [        S5      eS[        R	                  SU 5      -   S-   $ )z\
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                óÎ  • [        X5      S:X  a  [        XS-   5      n[        X5      S:X  a  M  / n U " XU5      u  pRUR                  U5        [        X5      nU[        U5      :X  a  Ok[        X5      S:X  a  [        XS-   5      nO[	        USX5      e[        X5      S:X  a  [        XS-   5      n[        X5      S:X  a  M  U[        U5      :X  a  OM¢  U[        U5      :X  d   eU$ )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Ó
(Ü˜ a¡Ó(ˆô �VÓ
! SÕ
(ð €EØ
á˜v¨KÓ8‰	ˆØ�‰�TÔÜ˜Ó$ˆð ”#�f“+ÓØô �fÓ" cÓ)Ü˜F¨!¡GÓ,‰Cä% kÐ3CÀVÓQÐQô ˜Ó%¨Ó,Ü˜F¨!¡GÓ,ˆCô ˜Ó%¨Õ,ð ”#�f“+ÓØñ- ð4 ”#�f“+ÓÐÐà€Lr2   c                óB   • [        XU5      u  p1[        [        U5      U4$ )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¨Ó5�I€DÜÔ  $Ó'¨Ð,Ð,r2   c                ó&   • [        [        U SS5      $ )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                ó¨   • [         R                  X5      nUc  [        USX5      e[        [        UR                  5       5      UR                  5       4$ )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     sG   € ô ×Ñ˜vÓ+€EØ�}Ü! +Ð/BÀFÓPÐPÜ” §¡£Ó/°·±³Ð<Ð<r2   c                ó&   • [        [        U SS5      $ )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                ó4  • [        XU5      u  p1[        X5      nSn[        X5      S:X  aj  [        XS-   5      n[        X5      S:X  a4  Un[        XU5      u  pA[        R                  U5      c  [        USX5      eO[        XU5      u  pA[        X5      nX44U4$ )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¨Ó5�I€DÜ
�FÓ
 €Cà€EÜ�&Ó #Ó%Ü˜ a¡Ó(ˆÜ�fÓ" cÓ)ØˆJÜ,¨V¸+ÓF‰JˆEô ×"Ñ" 5Ó)Ñ1Ü)ØÐ!@À&óð ð 2ô
 % V°+Ó>‰JˆEÜ˜Ó$ˆàˆ=˜#ÐÐr2   c                óú   • [        XU5      u  p1[        X5      n/ n[        X5      S:X  a>  [        XS-   5      n[        XU5      u  pQUR	                  U5        [        X5      S:X  a  M>  [        [        U5      U4U4$ )zÿ
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¨Ó5�I€DÜ
�FÓ
 €Cà€JÜ
�VÓ
! SÓ
(Ü˜ a¡Ó(ˆÜ3°FÀÓM‰ˆ	Ø×Ñ˜)Ô$ô �VÓ
! SÕ
(ô ” Ó% zÐ2°CÐ7Ð7r2   c                ó&   • [        [        U SS5      $ )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           
     ó’   • SR                  [        [        U 5      /U V Vs/ s H  u  pUc  U OU  SU 3PM     snn -   5      $ s  snn f )zW
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‹Ðñ  *ô
ò  *‘�ð ‘M‰D¨$¨¨q°°Ð'8Ò8Ù)ò
ñ	
óð ùó
s   ¡Ac                ó2   • SR                  S U  5       5      $ )z`
Build a ``Sec-WebSocket-Extensions`` header.

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

ú, c              3  ó<   #   • U  H  u  p[        X5      v •  M     g 7f)N)rk   )Ú.0r_   rd   s      r,   Ú	<genexpr>Ú"build_extension.<locals>.<genexpr>¢  s   é € ð ÚGQÑ3C°4Ô˜T×.Ð.Âzùs   ‚©ri   )Ú
extensionss    r,   r   r   ›  s"   € ð �9‰9ñ ÙGQóó ð r2   c                óB   • [        XU5      u  p1[        [        U5      U4$ )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_itemru   ª  s$   € ô ˜F¨Ó5�I€DÜ”˜TÓ" CÐ'Ð'r2   c                ó&   • [        [        U SS5      $ )zŒ
Parse a ``Sec-WebSocket-Protocol`` header.

Return a list of WebSocket subprotocols.

Raises:
    InvalidHeaderFormat: On invalid inputs.

r   zSec-WebSocket-Protocol)rQ   ru   rW   s    r,   r   r   º  s   € ô Ô,¨f°aÐ9QÓRÐRr2   c                ó$   • SR                  U 5      $ )z`
Build a ``Sec-WebSocket-Protocol`` header.

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

rm   rr   )Úsubprotocolss    r,   r   r   Ê  s   € ð �9‰9�\Ó"Ð"r2   c                óæ   • [        U [        5      (       d  [        S5      e[        U [        5      (       a  [        S5      eU  H+  n[        R                  U5      (       a  M  [        SU 35      e   g)zL
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'   )rx   Úsubprotocols     r,   r   r   ×  sd   € ô
 �l¤H×-Ñ-ÜÐ5Ó6Ð6Ü�,¤×$Ñ$ÜÐ@ÓAÐAÛ#ˆÜ×"Ñ" ;×/Ó/ÜÐ4°[°MÐBÓCÐCò $r2   c                ó>   • [        U 5      n [        S5      nSU  SU 3$ )zq
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                óŒ   • [         R                  X5      nUc  [        USX5      eUR                  5       UR	                  5       4$ )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‚   ö  s@   € ô ×Ñ˜fÓ*€EØ�}Ü! +Ð/AÀ6ÓOÐOØ�;‰;‹=˜%Ÿ)™)›+Ð%Ð%r2   c                ó<   • U[        U 5      :  a  [        USX5      eg)z0
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                óò  • [        U SS5      u  pUR                  5       S:w  a  [        SSU 35      e[        X5      S:w  a  [	        SSX5      eUS-  n[        XS5      u  p2[        XS5         [        R                  " UR                  5       5      R                  5       n UR                  S
S5      u  pVXV4$ ! [        R                   a    [        SS5      S	ef = f! [         a    [        SS5      S	ef = f)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     s%  € ô  ˜f a¨Ó9�K€FØ‡|�|ƒ~˜Ó Ü ØØ" 6 (Ð+ó
ð 	
ô �&Ó #Ó%Ü!ØÐ:¸Fó
ð 	
ð ˆ1�H€CÜ*¨6¸ÓHÑÐÜˆf˜?Ô+ðÜ×$Ò$Ð%6×%=Ñ%=Ó%?Ó@×GÑGÓIˆ	ðØ&Ÿ_™_¨S°!Ó4Ñˆð ÐÐøô �>‰>ó Ü ØØ1ó
ð ð	ðûô ó Ü ØØ4ó
ð ð	ðús   Á/2B9 Â"C Â9"CÃC6c                óŽ   • SU ;  d   eU  SU 3n[         R                  " UR                  5       5      R                  5       nSU-   $ )zt
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   )rs   zSequence[ExtensionHeader]rš   rj   )r/   rj   r0   r˜   r<   rj   rš   ztuple[Subprotocol, int])r/   rj   rš   zlist[Subprotocol])rx   úSequence[Subprotocol]rš   rj   )rx   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_listru   r   Úparse_subprotocol_listr   Úbuild_subprotocol_listr   r   r�   r‚   r„   r   r   © r2   r,   Ú<module>r©      sˆ  ðÝ "ã Û Û Û 	Ý $ß *Ñ *ç ?÷÷ ò€ñ ˆCƒL€ð !&ñØ
ðà
ðð ðð
 ðð 	õôD	7ð �*Š*�YÓ
€ôð �JŠJÐ6Ó7€	ô&ð  —J’JØJóÐ ð
 �jŠjÐ8Ó9€ôDð  �zŠzÐ6Ó7€ð �JŠJ�Ó'€	ô
5ð?Ø8ð?àð?ð 
ð?ð ð	?ð
 ô?ðD-Øð-Øð-Ø(+ð-à!ô-ô Hð  �zŠzØEó€ð
=Øð=Øð=Ø(+ð=à ô=ô$Dð !Øð!Øð!Ø(+ð!à#ô!ðH8Øð8Øð8Ø(+ð8à ô8ô2Sð4 'Ð ðØ
ðØ%Aðàôô&	ð 'Ð ð(Øð(Øð(Ø(+ð(àô(ô 
Sð +Ð ô#ð +Ð ôDô5ð �jŠjÐ0Ó1€ô&ô Mô-õ`(r2   