+
    i>                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^RIHtHt ^RIHtHtHtHtHtHt . RDOt]
! R4      tRR	/R
 R lltR R lt]P2                  ! R4      tR R lt]P2                  ! R4      tR R lt]P2                  ! R4      t]P2                  ! R4      tR R lt ]P2                  ! R4      t!]P2                  ! R4      t"R R lt#R R lt$R R lt%R  R! lt&]P2                  ! R"4      t'R# R$ lt(R% R& lt)R' R( lt*R) R* lt+R+ R, lt,],t-R- R. lt.R/ R0 lt/]/t0R1 R2 lt1R3 R4 lt2]2t3R5 R6 lt4]4t5R7 R8 lt6R9 R: lt7]P2                  ! R;4      t8R< R= lt9R> R? lt:R@ RA lt;RB RC lt<R# )E    )annotationsN)Sequence)CallableTypeVarcast)InvalidHeaderFormatInvalidHeaderValue)ConnectionOptionExtensionHeaderExtensionNameExtensionParameterSubprotocolUpgradeProtocolTalways_include_portFc          
     ,    V ^8  d   QhRRRRRRRRRR/# )	   hoststrportintsecureboolr   return )formats   "Y/home/wkmabra/.openclaw/workspace/venv/lib/python3.14/site-packages/websockets/headers.py__annotate__r   '   s:      

 
  	    c                    \         P                  ! V 4      pVP                  ^8X  d   RV  R2p T'       g   Y'       d   RM^P8w  d   T  RT 2p T #   \         d     L.i ; i)z
Build a ``Host`` header.

[]i  :)	ipaddress
ip_addressversion
ValueError)r   r   r   r   addresss   &&&$ r   
build_hostr)   '   si    &&t, ??atfA;Ddfs"=qK  s   A AAc               $    V ^8  d   QhRRRRRR/# )r   headerr   posr   r   z
str | Noner   )r   s   "r   r   r   I   s!     	7 	7s 	7 	7 	7r   c                6    V\        V 4      8X  d   R# W,          # )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)r+   r,   s   &&r   
peek_aheadr/   I   s     #f+%466;6r   z[\t ]*c               $    V ^8  d   QhRRRRRR/# )r   r+   r   r,   r   r   r   )r   s   "r   r   r   X   s!      c   r   c                X    \         P                  W4      pVf   Q hVP                  4       # )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+   r,   r3   s   && r   	parse_OWSr5   X   s*     MM&&E99;r   z[-!#$%&\'*+.^_`|~0-9a-zA-Z]+c               (    V ^8  d   QhRRRRRRRR/# r   r+   r   r,   r   header_namer   ztuple[str, int]r   )r   s   "r   r   r   j   s(     & & &# &C &O &r   c                    \         P                  W4      pVf   \        VRW4      hVP                  4       VP	                  4       3# )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_rer3   r   groupr4   r+   r,   r8   r3   s   &&& r   parse_tokenr=   j   s>     OOF(E}!+/?MM;;=%))+%%r   zC"(?:[\x09\x20-\x21\x23-\x5b\x5d-\x7e]|\\[\x09\x20-\x7e\x80-\xff])*"z\\([\x09\x20-\x7e\x80-\xff])c               (    V ^8  d   QhRRRRRRRR/# r7   r   )r   s   "r   r   r      s.     D D D# DC DO Dr   c                    \         P                  W4      pVf   \        VRW4      h\        P	                  RVP                  4       ^R 4      VP                  4       3# )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\1)_quoted_string_rer3   r   _unquote_resubr;   r4   r<   s   &&& r   parse_quoted_stringrD      sR     ##F0E}!+/GUU??5%++-""56		CCr   z[\x09\x20-\x7e\x80-\xff]*z([\x22\x5c])c                    V ^8  d   QhRRRR/# )r   valuer   r   r   )r   s   "r   r   r      s     
5 
5s 
5s 
5r   c                    \         P                  V 4      pVf   \        R4      hR\        P	                  RV 4      ,           R,           # )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_rerC   )rF   r3   s   & r   build_quoted_stringrL      s@     ""5)E}HIIw..44r   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   
parse_itemz(Callable[[str, int, str], tuple[T, int]]r+   r   r,   r   r8   r   zlist[T]r   )r   s   "r   r   r      s:     ? ?8?? 
? 	?
 ?r   c                   \        W4      R8X  d   \        W^,           4      pK$  . p V ! WV4      w  rRVP                  V4       \        W4      pV\        V4      8X  d   Mg\        W4      R8X  d   \        W^,           4      pM\	        VRW4      h\        W4      R8X  d   \        W^,           4      pK$  V\        V4      8X  g   K   V\        V4      8X  g   Q hV# )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.

,zexpected comma)r/   r5   appendr.   r   )rN   r+   r,   r8   itemsitems   &&&&  r   
parse_listrT      s    > V
!S
(a(E
vK8	T$ #f+ f"c)F!G,C%k3CVQQ %,F!G,C #f+ #f+Lr   c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   ztuple[ConnectionOption, int]r   )r   s   "r   r   r      s,     - ---(+-!-r   c                B    \        WV4      w  r1\        \        V4      V3# )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+   r,   r8   rS   s   &&& r   parse_connection_optionrX      s%     F5ID $',,r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   zlist[ConnectionOption]r   )r   s   "r   r   r      s     H HS H%; Hr   c                &    \        \        V ^ R4      # )z
Parse a ``Connection`` header.

Return a list of HTTP connection options.

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

Raises:
    InvalidHeaderFormat: On invalid inputs.


Connection)rT   rX   r+   s   &r   parse_connectionr]      s     -vq,GGr   z>[-!#$%&\'*+.^_`|~0-9a-zA-Z]+(?:/[-!#$%&\'*+.^_`|~0-9a-zA-Z]+)?c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   ztuple[UpgradeProtocol, int]r   )r   s   "r   r   r     s,     = ===(+= =r   c                    \         P                  W4      pVf   \        VRW4      h\        \        VP                  4       4      VP                  4       3# )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_rer3   r   r   r   r;   r4   r<   s   &&& r   parse_upgrade_protocolra     sG     v+E}!+/BFPP/<<r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   zlist[UpgradeProtocol]r   )r   s   "r   r   r     s     D D# D"7 Dr   c                &    \        \        V ^ R4      # )z
Parse an ``Upgrade`` header.

Return a list of HTTP protocols.

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

Raises:
    InvalidHeaderFormat: On invalid inputs.

Upgrade)rT   ra   r\   s   &r   parse_upgradere     s     ,faCCr   c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   ztuple[ExtensionParameter, int]r   )r   s   "r   r   r   .  s,     ! !!!(+!#!r   c                B   \        WV4      w  r1\        W4      pRp\        W4      R8X  dq   \        W^,           4      p\        W4      R8X  d6   Tp\        WV4      w  rA\        P                  V4      f   \        VRW4      hM\        WV4      w  rA\        W4      pW43V3# )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=rH   zinvalid quoted header content)r=   r5   r/   rD   r:   rJ   r   )r+   r,   r8   namerF   
pos_befores   &&&   r   parse_extension_item_paramrk   .  s     F5ID
F
 CE&#%a(f"c)J,V+FJE ""5)1)!@&  2
 %V+>JE$=#r   c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   ztuple[ExtensionHeader, int]r   )r   s   "r   r   r   R  s,     8 888(+8 8r   c                    \        WV4      w  r1\        W4      p. p\        W4      R8X  d4   \        W^,           4      p\        WV4      w  rQVP	                  V4       KC  \        \        V4      V3V3# )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=   r5   r/   rk   rQ   r   r   )r+   r,   r8   ri   
parameters	parameters   &&&   r   parse_extension_itemrq   R  so     F5ID
F
 CJ
V
!S
(a(3FM	)$%z2C77r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   zlist[ExtensionHeader]r   )r   s   "r   r   r   k  s     S SC S$9 Sr   c                &    \        \        V ^ R4      # )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.

zSec-WebSocket-Extensions)rT   rq   r\   s   &r   parse_extensionrt   k  s    . *FA7QRRr   c               $    V ^8  d   QhRRRRRR/# )r   ri   r   ro   zSequence[ExtensionParameter]r   r   r   )r   s   "r   r   r     s$      
%Ar   c           
         RP                  \        \        V 4      .V U Uu. uF  w  rVf   T MV  RV 2NK  	  upp ,           4      # u upp i )zW
Build an extension definition.

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

z; rh   )joinr   r   )ri   ro   rF   s   && r   build_extension_itemrx     s`     99	c4  *
  * MD$q'88)
	
 
s   Ac                    V ^8  d   QhRRRR/# )r   
extensionszSequence[ExtensionHeader]r   r   r   )r   s   "r   r   r     s     	 	 9 	c 	r   c                2    RP                  R V  4       4      # )z`
Build a ``Sec-WebSocket-Extensions`` header.

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

, c              3  <   "   T F  w  r\        W4      x  K  	  R # 5i)N)rx   ).0ri   ro   s   &  r   	<genexpr>"build_extension.<locals>.<genexpr>  s      GQ3C4T..zs   rw   )rz   s   &r   build_extensionr     s"     99 GQ  r   c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   ztuple[Subprotocol, int]r   )r   s   "r   r   r     s,     ( ((((+((r   c                B    \        WV4      w  r1\        \        V4      V3# )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   rW   s   &&& r   parse_subprotocol_itemr     s$     F5IDT"C''r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   zlist[Subprotocol]r   )r   s   "r   r   r     s     
S 
Sc 
S&7 
Sr   c                &    \        \        V ^ R4      # )z
Parse a ``Sec-WebSocket-Protocol`` header.

Return a list of WebSocket subprotocols.

Raises:
    InvalidHeaderFormat: On invalid inputs.

zSec-WebSocket-Protocol)rT   r   r\   s   &r   parse_subprotocolr     s     ,fa9QRRr   c                    V ^8  d   QhRRRR/# )r   subprotocolsSequence[Subprotocol]r   r   r   )r   s   "r   r   r     s     # #$9 #c #r   c                $    RP                  V 4      # )z`
Build a ``Sec-WebSocket-Protocol`` header.

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

r|   r   )r   s   &r   build_subprotocolr     s     99\""r   c                    V ^8  d   QhRRRR/# )r   r   r   r   Noner   )r   s   "r   r   r     s     D D(= D$ Dr   c                    \        V \        4      '       g   \        R4      h\        V \        4      '       d   \        R4      hV  F,  p\        P                  V4      '       d   K   \        RV 24      h	  R# )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   	TypeErrorr   r:   rJ   r'   )r   subprotocols   & r   validate_subprotocolsr     sd    
 lH--566,$$@AA#"";//4[MBCC $r   c                    V ^8  d   QhRRRR/# )r   realmr   r   r   )r   s   "r   r   r     s     5 5 5 5r   c                >    \        V 4      p \        R4      pRV  RV 2# )zq
Build a ``WWW-Authenticate`` header for HTTP Basic Auth.

Args:
    realm: Identifier of the protection space.

zUTF-8zBasic realm=z
, charset=)rL   )r   charsets   & r   build_www_authenticate_basicr     s+      &E!'*G%
7)44r   z[A-Za-z0-9-._~+/]+=*c               (    V ^8  d   QhRRRRRRRR/# r7   r   )r   s   "r   r   r     s(     & &# &C &c &o &r   c                    \         P                  W4      pVf   \        VRW4      hVP                  4       VP	                  4       3# )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_rer3   r   r;   r4   r<   s   &&& r   parse_token68r     s@     f*E}!+/A6OO;;=%))+%%r   c               (    V ^8  d   QhRRRRRRRR/# )r   r+   r   r,   r   r8   r   r   r   )r   s   "r   r   r     s.     M Mc M M# M$ Mr   c                @    V\        V 4      8  d   \        VRW4      hR# )z0
Check that parsing reached the end of header.

ztrailing dataN)r.   r   )r+   r,   r8   s   &&&r   	parse_endr     s$    
 S[!+LL r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   ztuple[str, str]r   )r   s   "r   r   r     s     - -c -o -r   c                   \        V ^ R4      w  rVP                  4       R8w  d   \        RRV 24      h\        W4      R8w  d   \	        RRW4      hV^,          p\        WR4      w  r2\        WR4        \        P                  ! VP                  4       4      P                  4       p TP                  R^4      w  rVYV3#   \        P                   d    \        RR4      Rhi ; i  \         d    \        RR	4      Rhi ; i)
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.

Authorizationbasiczunsupported scheme:  zexpected space after schemez#expected base64-encoded credentialsNr#   z&expected username:password credentials)r=   lowerr	   r/   r   r   r   base64	b64decodeencodedecodebinasciiErrorsplitr'   )r+   schemer,   basic_credentials	user_passusernamepasswords   &      r   parse_authorization_basicr     s%     fa9KF||~  "6(+
 	
 &#%!:F
 	
 1HC*6Hf?+$$%6%=%=%?@GGI	&__S!4  >>  1
 	   4
 	s   52B? (C% ?#C"%C>c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   )r   s   "r   r   r   ?  s!     ( ( (s (s (r   c                    RV 9  g   Q hV  RV 2p\         P                  ! VP                  4       4      P                  4       pRV,           # )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   build_authorization_basicr   ?  sQ     h*AhZ(I(()9)9);<CCE'''r   )r)   r]   re   rt   r   r   r   r   r   r   r   )=
__future__r   r   r   r$   recollections.abcr   typingr   r   r   
exceptionsr   r	   r
   r   r   r   r   r   __all__r   r)   r/   compiler2   r5   r:   r=   rA   rB   rD   rI   rK   rL   rT   rX   r]   r`   ra   re   rk   rq   rt   parse_extension_listrx   r   build_extension_listr   r   parse_subprotocol_listr   build_subprotocol_listr   r   r   r   r   r   r   r   r   r   <module>r      sy   "    	 $ * * ?  CL
 !&D	7 **Y
 JJ67	&  JJJ 
 jj89D  zz67 JJ'	
5?D- H  zzE
=$D !H82S4 ' &	 ' ( 
S + # + D5 jj01& M-`(r   