
    hs              
      H   % S r SSKJr  SSK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  SSK	Jr  SSK	Jr  SSK	Jr  S	S
KJr  S	SKJr  S	SKJr  S	SKJr  S	SKJr  \R,                  (       a  S	SKJr  \R2                  " S5      rSr\" \R;                  S5      5      rSr\ V Vs0 s H.  n \  H$  nU  U 3R;                  S5      \ " U  U 3S5      _M&     M0     snn r!\"" S5       Vs/ s H  nSUS 3R;                  S5      PM     snr# " S S\RH                  5      r% " S S\%5      r& " S S\&5      r' " S S\&5      r(\" 5       \!0r)S \*S!'   SHSIS" jjr+          SJS# jr,SHSKS$ jjr- SL       SMS% jjr.    SN         SOS& jjr/\/" 5       r0\/" S'S(S)9r1SPS* jr2    SN           SQS+ jjr3 SR         SSS, jjr4STS- jr5   SU         SVS. jjr6 SW       SXS/ jjr7SYSZS0 jjr8S[S1 jr9\Rt                  " S2\95        S\S3 jr;\<" / \"" S45      QS5PS6P75      R{                  5       r>\;" S7\>5      r?\;" S8\>S9-   5      r@\;" S:\>S;-   5      rA\;" S<\>S=-   5      rB  S]       S^S> jjrC   S_         S`S? jjrDSaS@ jrE     Sb             ScSA jjrF      Sd               SeSB jjrG          SfSC jrH    Sg           ShSD jjrI     Si             SjSE jjrJ Sk       SlSF jjrK SY     SmSG jjrLgs  snn f s  snf )nzFunctions for working with URLs.

Contains implementations of functions from :mod:`urllib.parse` that
handle bytes and strings.
    )annotationsN)quote)unquote)	urlencode)urlsplit)
urlunsplit   )_check_str_tuple)_decode_idna)_make_encode_wrapper)_to_striter_multi_items)datastructuresz^[a-zA-Z0-9+-.]+$zKabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~$!'()*+,;ascii0123456789ABCDEFabcdef      %02Xc                  H    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S'   Srg	)
	_URLTuple2   strschemenetlocpathqueryfragment N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r        bC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\werkzeug/urls.pyr   r   2   s    KK
IJMr'   r   c                    ^  \ rS rSr% SrSrS\S'   S\S'   S\S'   S\S'   SU 4S	 jjrS S
 jrS!S jr	\
S"S j5       r\
S"S j5       r\
S#S j5       r\
S"S j5       r\
S"S j5       r\
S"S j5       r\
S"S j5       r\
S"S j5       rS$S jrSS jrS S jrS S jrS S jrS%S jrS%S jr S&   S'S jjrS(S jrS)S jrS)S jrSrU =r$ )*BaseURL:   zSuperclass of :py:class:`URL` and :py:class:`BytesURL`.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
r    r   _at_colon	_lbracket	_rbracketc                |   > [         R                  " SU R                   S3[        SS9  [        TU ]  " U /UQ70 UD6$ )Nz'werkzeug.urls.z\' is deprecated and will be removed in Werkzeug 3.0. Use the 'urllib.parse' library instead.   
stacklevel)warningswarnr!   DeprecationWarningsuper__new__)clsargskwargs	__class__s      r(   r8   BaseURL.__new__G   sG    cll^ ,E E		
 ws4T4V44r'   c                "    U R                  5       $ N)to_urlselfs    r(   __str__BaseURL.__str__P   s    {{}r'   c                &    U R                   " S0 UD6$ )z~Return an URL with the same values, except for those parameters
given new values by whichever keyword arguments are specified.r    )_replace)rB   r;   s     r(   replaceBaseURL.replaceS   s     }}&v&&r'   c                (    U R                  5       S   $ )zThe host part of the URL if available, otherwise `None`.  The
host is either the hostname or the IP address mentioned in the
URL.  It will not contain the port.
r   )_split_hostrA   s    r(   hostBaseURL.hostX   s     !!$$r'   c                    U R                   nUb8  [        U[        5      (       a#   UR                  S5      R	                  S5      nU$ U$ ! [
         a     U$ f = f)a   Works exactly like :attr:`host` but will return a result that
is restricted to ASCII.  If it finds a netloc that is not ASCII
it will attempt to idna decode it.  This is useful for socket
operations when the URL might include internationalized characters.
idnar   )rK   
isinstancer   encodedecodeUnicodeErrorrB   rvs     r(   
ascii_hostBaseURL.ascii_host`   s`     YY>jS11YYv&--g6 	r	   	s    A
 

AAc                     [        [        U R                  5       S   5      5      nSUs=::  a  S::  a   U$   g g! [        [        4 a     gf = f)zmThe port in the URL as an integer if it was present, `None`
otherwise.  This does not fill in default ports.
r	   r   i  N)intr   rJ   
ValueError	TypeErrorrS   s     r(   portBaseURL.porto   sf    
	WT--/234BB%	   	    I& 		s   4; ; AAc                (    U R                  5       S   $ )zCThe authentication part in the URL if available, `None`
otherwise.
r   )_split_netlocrA   s    r(   authBaseURL.auth|   s    
 !!#A&&r'   c                F    U R                  5       S   nUb  [        U5      $ g)zsThe username if it was part of the URL, `None` otherwise.
This undergoes URL decoding and will always be a string.
r   N_split_auth_url_unquote_legacyrS   s     r(   usernameBaseURL.username   *    
 ">&r**r'   c                (    U R                  5       S   $ )zqThe username if it was part of the URL, `None` otherwise.
Unlike :attr:`username` this one is not being decoded.
r   rc   rA   s    r(   raw_usernameBaseURL.raw_username       
 !!$$r'   c                F    U R                  5       S   nUb  [        U5      $ g)zsThe password if it was part of the URL, `None` otherwise.
This undergoes URL decoding and will always be a string.
r	   Nrb   rS   s     r(   passwordBaseURL.password   rg   r'   c                (    U R                  5       S   $ )zqThe password if it was part of the URL, `None` otherwise.
Unlike :attr:`password` this one is not being decoded.
r	   ri   rA   s    r(   raw_passwordBaseURL.raw_password   rl   r'   c                4    [        U R                  /UQ70 UD6$ )zDecodes the query part of the URL.  Ths is a shortcut for
calling :func:`url_decode` on the query argument.  The arguments and
keyword arguments are forwarded to :func:`url_decode` unchanged.
)
url_decoder   rB   r:   r;   s      r(   decode_queryBaseURL.decode_query   s    
 $**6t6v66r'   c                2    [        [        U /UQ70 UD65      $ )zJoins this URL with another one.  This is just a convenience
function for calling into :meth:`url_join` and then parsing the
return value again.
)	url_parseurl_joinru   s      r(   joinBaseURL.join   s    
 $88899r'   c                    [        U 5      $ )zReturns a URL string or bytes depending on the type of the
information stored.  This is just a convenience function
for calling :meth:`url_unparse` for this URL.
)url_unparserA   s    r(   r@   BaseURL.to_url   s    
 4  r'   c                F   U R                   =(       d    SnSU;   a  SU S3nU R                  nUb  U SU 3nSR                  [        S[	        U R
                  =(       d    SSSS5      [	        U R                  =(       d    SSSS5      /5      5      nU(       a  U S	U 3nU$ )
z6Encodes the netloc part to an ASCII safe URL as bytes. :[]Nutf-8strictz/:%@)rU   r[   r{   filter	url_quoterj   rq   )rB   rT   r[   r_   s       r(   encode_netlocBaseURL.encode_netloc   s    __""9RDByy4qBxxd//52w%Pd//52w%P
 62$B	r'   c           
        U R                   =(       d    Sn[        U[        5      (       a  UR                  5       n[	        U5      nSU;   a  SU S3nU R
                  nUb  U SU 3nSR                  [        S[        U R                  =(       d    SS5      [        U R                  =(       d    SS5      /5      5      nU(       a  U SU 3nU$ )z&Decodes the netloc part into a string.r   r   r   r   Nz/:%@r   )rK   rO   bytesrQ   r   r[   r{   r   rd   rj   rq   )rB   rK   rT   r[   r_   s        r(   decode_netlocBaseURL.decode_netloc   s    yyBdE"";;=D$"9RDByy4qBxx'(9(9(?RH'(9(9(?RH
 62$B	r'   c                *    [        [        U 5      5      $ )a  Returns a :class:`BytesURL` tuple that holds a URI.  This will
encode all the information in the URL properly to ASCII using the
rules a web browser would follow.

It's usually more interesting to directly call :meth:`iri_to_uri` which
will return a string.
)ry   
iri_to_urirA   s    r(   to_uri_tupleBaseURL.to_uri_tuple   s     D)**r'   c                *    [        [        U 5      5      $ )a#  Returns a :class:`URL` tuple that holds a IRI.  This will try
to decode as much information as possible in the URL without
losing information similar to how a web browser does it for the
URL bar.

It's usually more interesting to directly call :meth:`uri_to_iri` which
will return a string.
)ry   
uri_to_irirA   s    r(   to_iri_tupleBaseURL.to_iri_tuple   s     D)**r'   c                ^   U R                   S:w  a  g[        U R                  5      nU R                  =(       d    SnUc  [        R
                  S:X  a  SnOSnUS:X  a  USS S:X  a.  USS	 R                  5       (       a  US	S
 S;   a  USS	  SUS
S  3nUSS
 S;   nSSKnUR                  U5      nU(       a?  Uc<  UR                  S5      R                  SS5      n[        U5      S	:X  a  Uu  p2O3US   nSnO+US:X  a  SSKnUR                  U5      nO[        SU< 35      eUS;   a  SnX24$ )a  Returns a tuple with the location of the file in the form
``(server, location)``.  If the netloc is empty in the URL or
points to localhost, it's represented as ``None``.

The `pathformat` by default is autodetection but needs to be set
when working with URLs of a specific system.  The supported values
are ``'windows'`` when working with Windows or DOS paths and
``'posix'`` when working with posix paths.

If the URL does not point to a local file, the server and location
are both represented as ``None``.

:param pathformat: The expected format of the path component.
                   Currently ``'windows'`` and ``'posix'`` are
                   supported.  Defaults to ``None`` which is
                   autodetect.
fileNNNntwindowsposixr	   /r1      z|:r   )z\\\z///r   \r   zInvalid path format )z	127.0.0.1z::1	localhost)r   url_unquoter   r   osnameisalphantpathnormpathlstripsplitlen	posixpathrZ   )rB   
pathformatr   rK   windows_sharer   partsr   s           r(   get_file_locationBaseURL.get_file_location   sI   ( ;;& 499%{{"dww$&
$
"BQx34!9#4#4#6#64!9;Lq)Ad12hZ0 !H(;;M??4(D
 D)//a8u:?!&JD$ 8DD7"%%d+D2:.ABB44Dzr'   c                    U R                   U R                  ;   a+  U R                  R                  U R                   5      u  pnX4$ S U R                  4$ r?   )r,   r   	partition)rB   r_   _r   s       r(   r^   BaseURL._split_netloc=  sE    88t{{""kk33DHH=ODV<T[[  r'   c                    U R                  5       S   nU(       d  gU R                  U;  a  US 4$ UR                  U R                  5      u  p#nX$4$ )Nr   r   )r^   r-   r   )rB   r_   re   r   rn   s        r(   rc   BaseURL._split_authC  sQ    !!#A&;;d": $t{{ ;X!!r'   c                   U R                  5       S   nU(       d  gUR                  U R                  5      (       d5  U R                  U;   a!  UR	                  U R                  5      u  p#nX$4$ US 4$ UR                  U R                  5      nUS:  a  US 4$ USU nXS-   S  nUR                  U R                  5      (       a  X&SS  4$ US 4$ )Nr	   r   r   )r^   
startswithr.   r-   r   findr/   )rB   rT   rK   r   r[   idxrests          r(   rJ   BaseURL._split_hostM  s    !!$}}T^^,,{{b  "T[[ 9z!t8Oggdnn%7t8O!Cy')}??4;;''ab>!Tzr'   )r:   t.Anyr;   r   returnr*   r   r   )r;   r   r   r*   )r   
str | None)r   
int | None)r:   r   r;   r   r   ds.MultiDict[str, str])r   r*   r?   )r   r   r   tuple[str | None, str | None])r   ztuple[str | None, str])r   r   ) r!   r"   r#   r$   __doc__	__slots__r%   r8   rC   rG   propertyrK   rU   r[   r_   re   rj   rn   rq   rv   r{   r@   r   r   r   r   r   r^   rc   rJ   r&   __classcell__)r<   s   @r(   r*   r*   :   s$    I	HKNN5'
 % %   
 
 ' '   % %   % %7:!*6+	+ (,<$<	&<|!" r'   r*   c                  :    \ rS rSrSrSrSrSrSrSr	S
SS jjr
Srg	)URLic  zRepresents a parsed URL.  This behaves like a regular tuple but
also has some extra attributes that give further insight into the
URL.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
r    r   r   r   r   c           
        [        U R                  R                  S5      U R                  5       U R                  R                  X5      U R
                  R                  X5      U R                  R                  X5      5      $ )zpEncodes the URL to a tuple made out of bytes.  The charset is
only being used for the path, query and fragment.
r   )BytesURLr   rP   r   r   r   r   rB   charseterrorss      r(   rP   
URL.encoder  se     KKw' IIW-JJg.MM  1
 	
r'   Nr   rG   )r   r   r   r   r   r   )r!   r"   r#   r$   r   r   r,   r-   r.   r/   rP   r&   r    r'   r(   r   r   c  s,     I
CFII

 

r'   r   c                  N    \ rS rSrSrSrSrSrSrSr	SS jr
SS	 jrSSS
 jjrSrg)r   i  zRepresents a parsed URL in bytes.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
r       @   :   [   ]c                B    U R                  5       R                  SS5      $ )Nr   rG   )r@   rQ   rA   s    r(   rC   BytesURL.__str__  s    {{}##GY77r'   c                    U R                   $ )z&Returns the netloc unchanged as bytes.)r   rA   s    r(   r   BytesURL.encode_netloc  s    {{r'   c           
        [        U R                  R                  S5      U R                  5       U R                  R                  X5      U R
                  R                  X5      U R                  R                  X5      5      $ )zrDecodes the URL to a tuple made out of strings.  The charset is
only being used for the path, query and fragment.
r   )r   r   rQ   r   r   r   r   r   s      r(   rQ   BytesURL.decode  se     KKw' IIW-JJg.MM  1
 	
r'   Nr   )r   r   r   )r   r   r   r   r   r   )r!   r"   r#   r$   r   r   r,   r-   r.   r/   rC   r   rQ   r&   r    r'   r(   r   r     s6     I
CFII8

 

r'   r   z&dict[frozenset[int], dict[bytes, int]]_unquote_mapsc                   [        U [        5      (       a  U R                  S5      n [        U[        5      (       a  UR                  S5      n[        [	        U5      5      n[        U R                  S5      5      n[	        [        US5      5      n [        U   nU HX  nUS S nX;   a)  UR                  XH   5        UR                  USS  5        M6  UR                  S5        UR                  U5        MZ     [        U5      $ ! [         aC    [        R                  5        VVs0 s H  u  pVXa;  d  M  XV_M     Os  snnf snn=n[        U'    Nf = f)Nr      %r'   r1   %   )rO   r   rP   	frozenset	bytearrayiterr   nextr   KeyError
_hextobyteitemsappendextendr   )	stringunsafegroupsresulthex_to_bytehbgroupcodes	            r(   _unquote_to_bytesr     s&   &#w'&#w'y()F&,,t$%FtFC()F
#F+ RayMM++,MM%)$MM"MM%   =  
'--//
/TQ1?DAD//
 	
mF+
s$   	D !E$D:3D:9EEc              #  f  #    SSK Jn  U" U 5      nU(       a	  [        XSS9nU H  u  pgUc  M
  [        U[        5      (       d  [        U5      R                  U5      nOUn[        U[        5      (       d  [        U5      R                  U5      n	OUn	[        U5       S[        U	5       3v   M     g 7f)Nr	   r   )key=)r   r   sortedrO   r   r   rP   _fast_url_quote_plus)
objr   sortr   r   iterablekey_str	value_str	key_bytesvalue_bytess
             r(   _url_encode_implr     s      1,<S,AH(,&'5))G++G4II)U++i.//8K#K%i013G3T2UVV 's   B/B1c                R     [        U SSUS9$ ! [         a    [        U SUS9s $ f = f)Nr   r   )r   r   r   latin1)r   r   )r   rR   )valuer   s     r(   rd   rd     s9    C5'(6RR C5(6BBCs    &&c                  ^ [         R                  " S[        SS9  [        U 5      m[	        U [
        5      nUc  T" S5      nT" S5      =n=pVU R                  T" S5      5      nUS:  aa  [        R                  [        U SU SS	95      (       a<  XS
-   S nU(       a  [        U4S jU 5       5      (       a  U SU R                  5       UpU SS T" S5      :X  a  [        U 5      n	T" S5       H(  n
U R                  U
S5      nUS:  d  M  [        X5      n	M*     U SU	 X	S pT" S5      U;   a  T" S5      U;  d  T" S5      U;   a  T" S5      U;  a  [        S5      eU(       a&  T" S5      U ;   a  U R                  T" S5      S
5      u  pT" S5      U ;   a  U R                  T" S5      S
5      u  pU(       a  [         O["        nU" XXU5      $ )aW  Parses a URL from a string into a :class:`URL` tuple.  If the URL
is lacking a scheme it can be provided as second argument. Otherwise,
it is ignored.  Optionally fragments can be stripped from the URL
by setting `allow_fragments` to `False`.

The inverse of this function is :func:`url_unparse`.

:param url: the URL to parse.
:param scheme: the default schema to use if the URL is schemaless.
:param allow_fragments: if set to `False` a fragment will be removed
                        from the URL.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlsplit`` instead.
zq'werkzeug.urls.url_parse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlsplit' instead.r1   r2   Nr   r   r   rG   )r   r	   c              3  8   >#    U  H  oT" S 5      ;  v   M     g7f)
0123456789Nr    ).0css     r(   	<genexpr>url_parse.<locals>.<genexpr>
  s     BTAlO3Ts   ///?#r   r   zInvalid IPv6 URL#?)r4   r5   r6   r   rO   r   r   
_scheme_rematchr   anylowerr   minrY   r   r   r   )urlr   allow_fragmentsis_text_basedr   r   r   ir   delimr  wdelimresult_typer  s                @r(   ry   ry     s   $ MM	0	 	S!AsC(M~2 !"%F%U3A1u!!'#bq')"DEE q57|sBTBBBbq'--/4C
2Aw!D'C5AXXa^F{E*  !ElCKcFf3v!5cFf3v!5/001S6S=		!C&!,v}YYqvq)
&#HKvs8<<r'   c                z  ^ [        U[        5      (       a  UR                  X5      n[        U[        5      (       a  UR                  X5      n[        [	        U5      5      [
        -  [        [	        U5      5      -
  n[        S5       Vs/ s H  oDU;   a  [        U5      OSUS 3PM     snmSU4S jjnU$ s  snf )a  Precompile the translation table for a URL encoding function.

Unlike :func:`url_quote`, the generated function only takes the
string to quote.

:param charset: The charset to encode the result with.
:param errors: How to handle encoding errors.
:param safe: An optional sequence of safe characters to never encode.
:param unsafe: An optional sequence of unsafe characters to always encode.
r   r   r   c                X   > SR                  U  Vs/ s H  nTU   PM
     sn5      $ s  snf Nr   )r{   )r   r  tables     r(   r   #_make_fast_url_quote.<locals>.quote=  s(    ww&1&Qa&1221s   'r   r   r   r   )rO   r   rP   r   r   _always_saferangechr)r   r   safer   r  r   r  s         @r(   _make_fast_url_quoter%  $  s      ${{7+&#w/io&59VCT9UUD;@:F:aDySV!Ck1:FE3 L Gs    B8 +)r$  r   c                8    [        U 5      R                  SS5      $ )Nr&  r'  )_fast_quote_plusrG   )r   s    r(   r   r   G  s    F#++C55r'   c                   [         R                  " S[        SS9  [        U [        [
        [        45      (       d  [	        U 5      n [        U [        5      (       a  U R                  X5      n [        U[        5      (       a  UR                  X5      n[        U[        5      (       a  UR                  X5      n[        [        U5      5      [        -  [        [        U5      5      -
  n[        5       n[        U 5       H3  nXc;   a  UR                  U5        M  UR                  [        U   5        M5     [        U5      R                  U5      $ )a  URL encode a single string with a given encoding.

:param s: the string to quote.
:param charset: the charset to be used.
:param safe: an optional sequence of safe characters.
:param unsafe: an optional sequence of unsafe characters.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote`` instead.

.. versionadded:: 0.9.2
   The `unsafe` parameter was added.
zn'werkzeug.urls.url_quote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.quote' instead.r1   r2   )r4   r5   r6   rO   r   r   r   rP   r   r!  r   r   
_bytetohexrQ   )r   r   r   r$  r   rT   chars          r(   r   r   K  s    ( MM	-	 fsE9566V&#w/${{7+&#w/io&59VCT9UUD	B&!<IIdOIIj&'	 "
 9G$$r'   c                v    [         R                  " S[        SS9  [        XX#S-   S5      R	                  SS5      $ )a3  URL encode a single string with the given encoding and convert
whitespace to "+".

:param s: The string to quote.
:param charset: The charset to be used.
:param safe: An optional sequence of safe characters.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote_plus`` instead.
zx'werkzeug.urls.url_quote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.quote_plus' instead.r1   r2   r&  r'  )r4   r5   r6   r   rG   )r   r   r   r$  s       r(   url_quote_plusr.  x  s=     MM	7	 VfSj#>FFsCPPr'   c                   [         R                  " S[        SS9  [        U 5        U u  pp4n[	        U5      nU" S5      nU(       d#  U(       a[  UR                  U" S5      5      (       a?  U(       a  USS U" S5      :w  a  U" S5      U-   nU" S5      U=(       d    U" S5      -   U-   nOU(       a  Xs-  nU(       a  X" S	5      -   U-   nU(       a  Xv" S
5      -   U-   nU(       a  Xv" S5      -   U-   nU$ )aQ  The reverse operation to :meth:`url_parse`.  This accepts arbitrary
as well as :class:`URL` tuples and returns a URL as a string.

:param components: the parsed URL as tuple which should be converted
                   into a URL string.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlunsplit`` instead.
zu'werkzeug.urls.url_unparse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlunsplit' instead.r1   r2   r   r   Nr	   r  r   r  r  )r4   r5   r6   r
   r   r   )
componentsr   r   r   r   r   r  r  s           r(   r~   r~     s     MM	2	 Z ,6)FDV$A
B%C &T__QsV44D!H#&S6D=Dg1R5)D0	qvo#AcFlU"AcFlX%Jr'   c                x    [         R                  " S[        SS9  [        X5      nUc  U$ UR	                  X5      $ )a  URL decode a single string with a given encoding.  If the charset
is set to `None` no decoding is performed and raw bytes are
returned.

:param s: the string to unquote.
:param charset: the charset of the query string.  If set to `None`
    no decoding will take place.
:param errors: the error handling for the charset decoding.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote`` instead.
zr'werkzeug.urls.url_unquote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.unquote' instead.r1   r2   )r4   r5   r6   r   rQ   )r  r   r   r   rT   s        r(   r   r     s@    $ MM	/	 
1	%B	99W%%r'   c                    [         R                  " S[        SS9  [        U [        5      (       a  U R                  SS5      n OU R                  SS5      n [        XU5      $ )a  URL decode a single string with the given `charset` and decode "+" to
whitespace.

Per default encoding errors are ignored.  If you want a different behavior
you can set `errors` to ``'replace'`` or ``'strict'``.

:param s: The string to unquote.
:param charset: the charset of the query string.  If set to `None`
    no decoding will take place.
:param errors: The error handling for the `charset` decoding.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote_plus`` instead.
z|'werkzeug.urls.url_unquote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.unquote_plus' instead.r1   r2   r'  r&     +    )r4   r5   r6   rO   r   rG   r   )r  r   r   s      r(   url_unquote_plusr5    sW    " MM	9	 !SIIc3IIdD!q6**r'   c                   [         R                  " S[        SS9  [        XS5      R	                  SS5      n U R                  S5      (       a)  U SS	 R                  5       (       a  U S	S
 S;   a  SU SS  3n [        U 5      n[        UR                  USS9n[        UR                  USS9n[        UR                  USS9n[        UR                  UR                  5       X4U45      $ )a  Sometimes you get an URL by a user that just isn't a real URL because
it contains unsafe characters like ' ' and so on. This function can fix
some of the problems in a similar way browsers handle data entered by the
user:

>>> url_fix('http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'

:param s: the string with the URL to fix.
:param charset: The target charset for the URL if the url was given
    as a string.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0.
zJ'werkzeug.urls.url_fix' is deprecated and will be removed in Werkzeug 3.0.r1   r2   rG   r   r   zfile://      
   )z:/z|/zfile:///Nz
/%+$!*'(),r$  z:&%=+$!*'(),)r4   r5   r6   r   rG   r   r   ry   r   r   r.  r   r   r~   r   r   )r  r   r  r   qsanchors         r(   url_fixr=    s      MMT 	I&..tS9A 	||I1Qq6>>#3#3!B<8Oqug
A,CSXXw\:D			7	@BCLL'GF

C$5$5$76JKKr'   c                r    [        U R                  U R                  U R                   SS9nXR                  4$ )zJUsed in :func:`uri_to_iri` after unquoting to re-quote any
invalid bytes.
r   r:  )r   objectstartend)eouts     r(   _codec_error_url_quoterD    s/     155)
3C:r'   werkzeug.url_quotec                   ^ SR                  S [        U5       5       5      n[        R                  " SU S3[        R                  5      mSU4S jjnSU  3Ul        U$ )zCreate a function that unquotes all percent encoded characters except those
given. This allows working with unquoted characters if possible while not changing
the meaning of a given part of a URL.
|c              3  <   #    U  H  n[        U5      S  v   M     g7f)r   N)ord)r  r  s     r(   r	  %_make_unquote_part.<locals>.<genexpr>-  s     >1#a&s   z((?:%(?:z))+)c                   > [        TR                  U 5      5      n/ nU H9  nUR                  [        XQU5      5        UR                  [	        US5      5        M;     SR                  U5      $ r  )r   r   r   r   r   r{   )r  encodingr   r   rC  partpatterns         r(   _unquote_partial,_make_unquote_part.<locals>._unquote_partial0  sZ    W]]5)*DJJwtv67JJtE2'  wws|r'   	_unquote_)r  r   rL  r   r   r   r   r   )r{   r   recompileIr!   )r   charschoicesrO  rN  s       @r(   _make_unquote_partrW  (  sW    
 hh>u>>Gjj8G9D12448G #,D6 2r'   !   r      r   r   z&=+#r   r  userz:@/?#c                   [        U [        5      (       a%  [        R                  " S[        SS9  [        U 5      n [        U [        5      (       a*  [        R                  " S[        SS9  U R                  5       n Ub  [        R                  " S[        SS9  OSnUb  [        R                  " S[        SS9  OSn[        U 5      n[        UR                  X5      n[        UR                  X5      n[        UR                  X5      nUR                  (       a  [!        UR                  5      nOS	nS
U;   a  SU S3nUR"                  (       a  U S
UR"                   3nUR$                  (       aI  ['        UR$                  X5      nUR(                  (       a  U S
['        UR(                  X5       3nU SU 3n[        UR*                  XtXV45      $ )a  Convert a URI to an IRI. All valid UTF-8 characters are unquoted,
leaving all reserved and invalid characters quoted. If the URL has
a domain, it is decoded from Punycode.

>>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF")
'http://\u2603.net/p\xe5th?q=\xe8ry%DF'

:param uri: The URI to convert.
:param charset: The encoding to encode unquoted bytes with.
:param errors: Error handler to use during ``bytes.encode``. By
    default, invalid bytes are left quoted.

.. versionchanged:: 2.3
    Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
    deprecated and will be removed in Werkzeug 3.0.

.. versionchanged:: 2.3
    Which characters remain quoted is specific to each part of the URL.

.. versionchanged:: 0.15
    All reserved and invalid characters remain quoted. Previously,
    only some reserved characters were preserved, and invalid bytes
    were replaced instead of left quoted.

.. versionadded:: 0.6
HPassing a tuple is deprecated and will not be supported in Werkzeug 3.0.r1   r2   FPassing bytes is deprecated and will not be supported in Werkzeug 3.0.JThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.r   IThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.rE  r   r   r   r   r   )rO   tupler4   r5   r6   r   r   rQ   r   _unquote_pathr   _unquote_queryr   _unquote_fragmentr   hostnamer   r[   re   _unquote_userrn   r   )	urir   r   r   r   r   r   r   r_   s	            r(   r   r   H  s   > #uV	

 o#uT	

 jjl 		
 W	
 &SMEW5D5;;8E AH~~enn-
f}VHAzz81UZZL)~~U^^W=>>V1]5>>7KLMD66(#u||V5CDDr'   c                   Ub  [         R                  " S[        SS9  OSn[        U [        5      (       a%  [         R                  " S[        SS9  [        U 5      n [        U [        5      (       a+  [         R                  " S[        SS9  U R                  U5      n Ub  [         R                  " S[        SS9  OSnUb  [         R                  " S	[        SS9  U(       a2   U R                  S
5      n[        UR                  5       5      S:X  a  U $  [        U 5      n[        UR                  SXS9n[        UR                  SXS9n[        UR                   SXS9nUR"                  (       a+  UR"                  R                  S5      R                  S
5      n	OSn	SU	;   a  SU	 S3n	UR$                  (       a  U	 SUR$                   3n	UR&                  (       aG  [        UR&                  SS9n
UR(                  (       a  [        UR(                  SS9nU
 SU 3n
U
 SU	 3n	[        UR*                  XXx45      $ ! [         a     GN3f = f)a  Convert an IRI to a URI. All non-ASCII and unsafe characters are
quoted. If the URL has a domain, it is encoded to Punycode.

>>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF')
'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'

:param iri: The IRI to convert.
:param charset: The encoding of the IRI.
:param errors: Error handler to use during ``bytes.encode``.

.. versionchanged:: 2.3
    Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
    deprecated and will be removed in Werkzeug 3.0.

.. versionchanged:: 2.3
    Which characters remain unquoted is specific to each part of the URL.

.. versionchanged:: 2.3
    The ``safe_conversion`` parameter is deprecated and will be removed in Werkzeug
    2.4.

.. versionchanged:: 0.15
    All reserved characters remain unquoted. Previously, only some reserved
    characters were left unquoted.

.. versionchanged:: 0.9.6
   The ``safe_conversion`` parameter was added.

.. versionadded:: 0.6
r^  r1   r2   r   r\  r]  r_  r   zRThe 'safe_conversion' parameter is deprecated and will be removed in Werkzeug 3.0.r   r	   z%!$&'()*+,/:;=@)r$  rL  r   z%!$&'()*+,/:;=?@z%!#$&'()*+,/:;=?@rN   r   r   r   r   z%!$&'()*+,;=r:  r   )r4   r5   r6   rO   r`  r   r   rQ   rP   r   r   rR   r   r   r   r   r   rd  r[   re   rn   r   )irir   r   safe_conversion	ascii_irir   r   r   r   r   r_   pass_quoteds               r(   r   r     s   H  		
 #uV	

 o#uT	

 jj!W	
 "		
 	

7+I 9??$%*
 +
 SME "3gUD%++$6XE07H ~~&&v.55g>
f}VHAzz81UZZL)~~U^^.9>>^DKV1[M*D66(#u||V5CDDA  		s    /H7 7
IIc                     U R                  S5        [        U R                  SS5      5      S:X  a  U $  [	        U 5      $ ! [         a     Nf = f)a  The URL scheme ``itms-services://`` must contain the ``//`` even though it does
not have a host component. There may be other invalid schemes as well. Currently,
responses will always call ``iri_to_uri`` on the redirect ``Location`` header, which
removes the ``//``. For now, if the IRI only contains ASCII and does not contain
spaces, pass it on as-is. In Werkzeug 3.0, this should become a
``response.process_location`` flag.

:meta private:
r   Nr	   )rP   r   r   rR   r   )rh  s    r(   _invalid_iri_to_urirm     sW    

7 syyq!"a'J ( c?  s   A   
AAc                   [         R                  " S[        SS9  Uc  SSKJn  Un[        U [        5      (       a0  [        U[        5      (       d  UR                  U=(       d    S5      nOD[        U [        5      (       a/  [        U[        5      (       d  UR                  U=(       d    S5      nU" [        U R                  U5      XU5      5      $ )aj  Parse a query string and return it as a :class:`MultiDict`.

:param s: The query string to parse.
:param charset: Decode bytes to string with this charset. If not
    given, bytes are returned as-is.
:param include_empty: Include keys with empty values in the dict.
:param errors: Error handling behavior when decoding bytes.
:param separator: Separator character between pairs.
:param cls: Container to hold result instead of :class:`MultiDict`.

.. deprecated:: 2.3
    Will be removed in Werkzeug 3.0. Use ``urllib.parse.parse_qs`` instead.

.. versionchanged:: 2.1
    The ``decode_keys`` parameter was removed.

.. versionchanged:: 0.5
    In previous versions ";" and "&" could be used for url decoding.
    Now only "&" is supported. If you want to use ";", a different
    ``separator`` can be provided.

.. versionchanged:: 0.5
    The ``cls`` parameter was added.
zr'werkzeug.urls.url_decode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r1   r2   r	   	MultiDictr   )r4   r5   r6   r   rp  rO   r   rQ   r   rP   _url_decode_implr   )r  r   include_emptyr   	separatorr9   rp  s          r(   rt   rt   5  s    @ MM	0	 {-!S*Y"<"<$$W%78		Au		jE&B&B$$W%78	GGI	
 r'   c                    [         R                  " S[        SS9  SSKJn  U" XU5      n[        XX#5      n	Uc  SSKJn
  U
nU" U	5      $ )aF  Works like :func:`url_decode` but decodes a stream.  The behavior
of stream and limit follows functions like
:func:`~werkzeug.wsgi.make_line_iter`.  The generator of pairs is
directly fed to the `cls` so you can consume the data while it's
parsed.

:param stream: a stream with the encoded querystring
:param charset: the charset of the query string.  If set to `None`
    no decoding will take place.
:param include_empty: Set to `False` if you don't want empty values to
                      appear in the dict.
:param errors: the decoding error behavior.
:param separator: the pair separator to be used, defaults to ``&``
:param cls: an optional dict class to use.  If this is not specified
                   or `None` the default :class:`MultiDict` is used.
:param limit: the content length of the URL data.  Not necessary if
              a limited stream is provided.

.. deprecated:: 2.3
    Will be removed in Werkzeug 2.4. Use ``urllib.parse.parse_qs`` instead.

.. versionchanged:: 2.1
    The ``decode_keys`` and ``return_iterator`` parameters were removed.

.. versionadded:: 0.8
zy'werkzeug.urls.url_decode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r1   r2   r	   )make_chunk_iterro  )r4   r5   r6   wsgiru  rq  r   rp  )streamr   rr  r   rs  r9   limitru  	pair_iterdecoderrp  s              r(   url_decode_streamr{  k  sP    F MM	>	 &59Iy=IG
{-w<r'   c              #     #    U  Hf  nU(       d  M  [        U5      nU" S5      nXd;   a  UR                  US5      u  pxOU(       d  MB  UnU" S5      n[        XqU5      [        XU5      4v   Mh     g 7f)Nr   r	   r   )r   r   r5  )	ry  r   rr  r   pairr  equalr   r  s	            r(   rq  rq    su       &#=E1-JC CbEES62UV4
 	
 s   A.A0c                    [         R                  " S[        SS9  [        US5      nUR	                  [        XX#5      5      $ )a  URL encode a dict/`MultiDict`.  If a value is `None` it will not appear
in the result string.  Per default only values are encoded into the target
charset strings.

:param obj: the object to encode into a query string.
:param charset: the charset of the query string.
:param sort: set to `True` if you want parameters to be sorted by `key`.
:param separator: the separator to be used for the pairs.
:param key: an optional function to be used for sorting.  For more details
            check out the :func:`sorted` documentation.

.. deprecated:: 2.3
    Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

.. versionchanged:: 2.1
    The ``encode_keys`` parameter was removed.

.. versionchanged:: 0.5
    Added the ``sort``, ``key``, and ``separator`` parameters.
zs'werkzeug.urls.url_encode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r1   r2   r   )r4   r5   r6   r   r{   r   )r   r   r   r   rs  s        r(   
url_encoder    s@    6 MM	1	 	7+I>>*3CDDr'   c                    [         R                  " S[        SS9  [        US5      n[	        XX45      nUc  U$ [        U5       H.  u  pxU(       a  UR                  U5        UR                  U5        M0     g)a  Like :meth:`url_encode` but writes the results to a stream
object.  If the stream is `None` a generator over all encoded
pairs is returned.

:param obj: the object to encode into a query string.
:param stream: a stream to write the encoded object into or `None` if
               an iterator over the encoded pairs should be returned.  In
               that case the separator argument is ignored.
:param charset: the charset of the query string.
:param sort: set to `True` if you want parameters to be sorted by `key`.
:param separator: the separator to be used for the pairs.
:param key: an optional function to be used for sorting.  For more details
            check out the :func:`sorted` documentation.

.. deprecated:: 2.3
    Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

.. versionchanged:: 2.1
    The ``encode_keys`` parameter was removed.

.. versionadded:: 0.8
zz'werkzeug.urls.url_encode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r1   r2   r   N)r4   r5   r6   r   r   	enumeratewrite)	r   rw  r   r   r   rs  genr   chunks	            r(   url_encode_streamr    so    < MM	?	 	7+I
3
3C~
n
LL#U % r'   c                L   [         R                  " S[        SS9  [        U [        5      (       a  [        U 5      n [        U[        5      (       a  [        U5      n[        X45        [        U 5      nU (       d  U$ U(       d  U $ [        XS9u  pEpgn[        XU5      u  ppnX:w  a  U$ U
(       a  [        XXU45      $ Un
USS U" S5      :X  a  UR                  U" S5      5      nOZU(       d!  UR                  U" S5      5      nU(       d  UnO2UR                  U" S5      5      SS UR                  U" S5      5      -   nUS   U" S	5      :X  a  U" S
5      US'   U Vs/ s H  oU" S	5      :w  d  M  UPM     nn Sn[        U5      S-
  nUU:  aB  UU   U" S5      :X  a&  UUS-
     U" S
5      U" S5      4;  a  UUS-
  US-   2	 OUS-  nUU:  a  MB  OM[  U" S
5      U" S5      /nUSS U:X  a  US	 USS U:X  a  M  U" S5      R                  U5      n[        XXU45      $ s  snf )aU  Join a base URL and a possibly relative URL to form an absolute
interpretation of the latter.

:param base: the base URL for the join operation.
:param url: the URL to join.
:param allow_fragments: indicates whether fragments should be allowed.

.. deprecated:: 2.3
    Will be removed in Werkzeug 2.4. Use ``urllib.parse.urljoin`` instead.
zo'werkzeug.urls.url_join' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urljoin' instead.r1   r2   )r  Nr	   r   .r   z..)r4   r5   r6   rO   r`  r~   r
   r   ry   r   r   r{   )baser  r  r  bschemebnetlocbpathbquery	bfragmentr   r   r   r   r   segmentssegmentr  nunwanted_markers                      r(   rz   rz     sI    MM	/	 $4 #u#d[!T"A
1:2.GeY -6cO,T)FD
FDBCCFBQx1S6::af%;;qv&E;;qv&s+djj3.@@ |qvu (0ExGaf3DxHE
MA!e{ag%(1q5/!B%4AQ*QQUQU]+FA	 !e   uag&O
2A,/
)QK 2A,/
) S6;;x DX>??% Fs   H!1H!c                f    [        U 5       Vs/ s H  o"S   c  M
  UPM     nn[        USUS9$ s  snf )Nr	   z!$'()*,/:;?@)r$  rL  )r   r   )r   rL  xr   s       r(   
_urlencoder  \  s8     )/D/1Q4Q/EDU(CC Es   	..)r   )r   str | bytesr   r  r   r   )
r   1t.Mapping[str, str] | t.Iterable[tuple[str, str]]r   r   r   boolr   +t.Callable[[tuple[str, str]], t.Any] | Noner   zt.Iterator[str])r  r   r   r   r   r   )NT)r  r   r   r   r  r  r   r*   )r   r   z/:r   )
r   r   r   r   r$  r  r   r  r   zt.Callable[[bytes], str]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   )r0  ztuple[str, str, str, str, str]r   r   )r   rG   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   )rB  rR   r   ztuple[str, int])r   r   rU  r   r   z t.Callable[[str, str, str], str]r   )rf  $str | tuple[str, str, str, str, str]r   r   r   r   r   r   )NNN)
rh  r  r   r   r   r   ri  zbool | Noner   r   )rh  r   r   r   )r   TrG   &N)r  zt.AnyStrr   r   rr  r  r   r   rs  r   r9   type[ds.MultiDict] | Noner   r   )r   TrG      &NN)rw  zt.IO[bytes]r   r   rr  r  r   r   rs  r   r9   r  rx  r   r   r   )
ry  zt.Iterable[t.AnyStr]r   r   rr  r  r   r   r   zt.Iterator[tuple[str, str]])r   FNr  )r   r  r   r   r   r  r   r  rs  r   r   r   )Nr   FNr  )r   r  rw  zt.IO[str] | Noner   r   r   r  r   r  rs  r   r   None)T)r  r  r  r  r  r  r   r   )r   r  rL  r   r   r   )Mr   
__future__r   codecsr   rR  typingtr4   urllib.parser   r   r   r   r   	_internalr
   r   r   r   r   r   TYPE_CHECKINGr   dsrS  r  _always_safe_charsr   rP   r!  
_hexdigitsrX   r   r"  r+  
NamedTupler   r*   r   r   r   r%   r   r   rd   ry   r%  _fast_url_quoter)  r   r   r.  r~   r   r5  r=  rD  register_errorrW  r   rQ   _always_unsaferc  rb  ra  re  r   r   rm  rt   r{  rq  r  r  rz   r  )ar   r,  s   000r(   <module>r     s.  
 #  	 	      " ! # ' # +  ,??& ZZ,-
  +227;<%
  	c!IWsaS9b11 

 :?sD$sn##G,D
 fi fR	
' 
8
w 
B :Cj8Q5 Q>W	:WW W 
5	W
 W<C BF:=	:= :=:>:=:=| 	  	
 > '('S= 6 *%*%*% *% 	*%
 *% 	*%\ NPQQQ14QGJQQ.%T 	&&& & 	&
 	&> ;D++ +47++@#LL   *,B C2 1t1d1D1299;&z>B #G^f-DE"6>E+AB"6>G+CD
 ZE	-ZEZE ZE 		ZE~ #'	xE	-xExE xE !	xE
 	xEv. %)333 3 	3
 3 
#3 3p %)444 4 	4
 4 
#4 4 4n
#
.1
BF
PS
 
. 7;"E	:"E"E "E 
5	"E
 "E 	"EN  $7;,	:,, , 	,
 
5, , 
,d !N@
.N@	-N@ N@ 		N@d OVD<DHKDDe)
 Es   #5L&L