
    hC                        S 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
JrJrJr  SSKJr  SSKJr  SSKJr  SSKJrJrJrJr  SS	KJrJrJr  SS
KJr  SSKJ r J!r!J"r"  SSK#J$r$  \%" S5      r&Sr'\" \!5      S 5       r(\)" S5      S\)" S5      S\)" S5      S\)" S5      S\)" S5      S\)" S5      S\)" S5      S\)" S5      S\)" S 5      S!\)" S"5      S#\)" S$5      S%\)" S&5      S'0r*\*RW                  S( \," S)5       5       5        \" \!5      S* 5       r-\)" S5      S\)" S5      S\)" S5      S0r.S=S+ jr/S, r0S- r1S. r2\S>S/ j5       r3 " S0 S1\5      r4S2 r5\S3 5       r6\S4 5       r7S5 r8 " S6 S7\95      r: " S8 S95      r;\;" 5       r<\S?S: j5       r=S; r>S< r?g)@z'HTML utilities suitable for global use.    N)
HTMLParser)	parse_qslquoteunquote	urlencodeurlsplit
urlunsplit)SuspiciousOperation)RemovedInDjango60Warning)punycode)Promisecached_property	keep_lazykeep_lazy_text)MAX_URL_LENGTHRFC3986_GENDELIMSRFC3986_SUBDELIMS)_lazy_re_compile)SafeData
SafeString	mark_safe)normalize_newlines)areabasebrcolembedhrimginputlinkmetaparamsourcetrackwbrframespacer2   c                 R    [        [        R                  " [        U 5      5      5      $ )z
Return the given text with ampersands, quotes and angle brackets encoded
for use in HTML.

Always escape input, even if it's already escaped and marked as such.
This may result in double-escaping. If this is a concern, use
conditional_escape() instead.
)r   htmlescapestrtexts    C/var/www/html/env/lib/python3.13/site-packages/django/utils/html.pyr,   r,   -   s     dkk#d),--    \z\u005C'z\u0027"z\u0022>z\u003E<z\u003C&z\u0026=z\u003D-z\u002D;z\u003B`z\u0060u    z\u2028u    z\u2029c              #   H   #    U  H  n[        S U-  5      SU-  4v   M     g7f)z%cz\u%04XN)ord).0zs     r0   	<genexpr>r@   J   s!     E9aCqM9q=19s    "    c                 P    [        [        U 5      R                  [        5      5      $ )z4Hex encode characters for use in JavaScript strings.)r   r-   	translate_js_escapesvalues    r0   escapejsrG   M   s     SZ))+677r1   c                     SSK Jn  [        R                  " X=(       d    US9R	                  [
        5      nU(       a  SnU[        U5      4nOSn[        U5      4n[        U/UQ76 $ )z
Escape all the HTML/XML special characters with their unicode escapes, so
value is safe to be output anywhere except for inside a tag attribute. Wrap
the escaped JSON in a script tag.
r   )DjangoJSONEncoder)clsz3<script id="{}" type="application/json">{}</script>z+<script type="application/json">{}</script>)django.core.serializers.jsonrI   jsondumpsrC   _json_script_escapesr   format_html)rF   
element_idencoderrI   json_strtemplateargss          r0   json_scriptrU   Z   sd     ?zz%%A0ABLLH HIh/0@(#%x'$''r1   c                     [        U [        5      (       a  [        U 5      n [        U S5      (       a  U R	                  5       $ [        U 5      $ )z
Similar to escape(), except that it doesn't operate on pre-escaped strings.

This function relies on the __html__ convention used both by Django's
SafeData class and by third-party libraries like markupsafe.
__html__)
isinstancer   r-   hasattrrW   r,   r.   s    r0   conditional_escaperZ   n   s=     $  4ytZ  }}d|r1   c                    U(       d!  U(       d  [         R                  " S[        SS9  [        [        U5      nUR                  5        VVs0 s H  u  pEU[	        U5      _M     nnn[        U R                  " U0 UD65      $ s  snnf )z
Similar to str.format, but pass all arguments through conditional_escape(),
and call mark_safe() on the result. This function should be used instead
of str.format or % interpolation to build up small HTML fragments.
zCCalling format_html() without passing args or kwargs is deprecated.   )
stacklevel)warningswarnr   maprZ   itemsr   format)format_stringrT   kwargs	args_safekvkwargs_safes          r0   rO   rO   }   sw     F 	Q$	

 &-I:@,,.I.1(++.KI]))9DDEE Js   Bc                 ^   ^ [        [        U 5      R                  U4S jU 5       5      5      $ )a  
    A wrapper of format_html, for the common case of a group of arguments that
    need to be formatted using the same format string, and then joined using
    'sep'. 'sep' is also passed through conditional_escape.

    'args_generator' should be an iterator that returns the sequence of 'args'
    that will be passed to format_html.

    Example:

      format_html_join('
', "<li>{} {}</li>", ((u.first_name, u.last_name)
                                                  for u in users))
    c              3   <   >#    U  H  n[        T/UQ76 v   M     g 7fN)rO   )r>   rT   rc   s     r0   r@   #format_html_join.<locals>.<genexpr>   s      %
:H$K--.s   )r   rZ   join)seprc   args_generators    ` r0   format_html_joinrp      s2     3$$ %
:H%
 	
 r1   c                 D   [        U 5      n [        R                  " S[        U 5      5      nU(       a/  U Vs/ s H!  nS[	        U5      R                  SS5      -  PM#     nnO%U Vs/ s H  nSUR                  SS5      -  PM     nnSR                  U5      $ s  snf s  snf )z$Convert newlines into <p> and <br>s.z
{2,}z	<p>%s</p>
z<br>z

)r   resplitr-   r,   replacerm   )rF   
autoescapeparasps       r0   
linebreaksry      s     u%EHHXs5z*EHMN1vay00v>>N@EF1qyyv66F;;u OFs   (B&Bc                   @   ^  \ rS rSrU 4S jrS rS rS rS rSr	U =r
$ )
MLStripper   c                 N   > [         TU ]  SS9  U R                  5         / U l        g )NF)convert_charrefs)super__init__resetfed)self	__class__s    r0   r   MLStripper.__init__   s#    %0

r1   c                 :    U R                   R                  U5        g rk   r   append)r   ds     r0   handle_dataMLStripper.handle_data   s    r1   c                 @    U R                   R                  SU-  5        g )Nz&%s;r   r   names     r0   handle_entityrefMLStripper.handle_entityref   s    &r1   c                 @    U R                   R                  SU-  5        g )Nz&#%s;r   r   s     r0   handle_charrefMLStripper.handle_charref   s    $'r1   c                 8    SR                  U R                  5      $ N )rm   r   r   s    r0   get_dataMLStripper.get_data   s    wwtxx  r1   )r   )__name__
__module____qualname____firstlineno__r   r   r   r   r   __static_attributes____classcell__r   s   @r0   r{   r{      s!    
'(! !r1   r{   c                 x    [        5       nUR                  U 5        UR                  5         UR                  5       $ )z4
Internal tag stripping utility used by strip_tags.
)r{   feedcloser   )rF   ss     r0   _strip_oncer      s+     	AFF5MGGI::<r1   c                     [        U 5      n SnSU ;   a]  SU ;   aW  U[        :  a  [        e[        U 5      nU R	                  S5      UR	                  S5      :X  a   U $ Un US-  nSU ;   a  SU ;   a  MW  U $ )z-Return the given HTML with all tags stripped.r   r6   r5      )r-   MAX_STRIP_TAGS_DEPTHr
   r   count)rF   strip_tags_depth	new_values      r0   
strip_tagsr      s     JE 
,3%<33%%&	;;sys33 L A ,3%< Lr1   c                 D    [         R                  " SS[        U 5      5      $ )z7Return the given HTML with spaces between tags removed.z>\s+<z><)rs   subr-   rE   s    r0   strip_spaces_between_tagsr      s     66(D#e*--r1   c                 r   S n [        U 5      u  p#pEn [        U5      nU(       a?  [	        USS9 Vs/ s H  n[        US   5      [        US   5      4PM!     nn[        U5      nU" U5      nU" U5      n[        X#XEU45      $ ! [         a    U" U 5      s $ f = f! [         a    U" U 5      s $ f = fs  snf )z'Quote a URL if it isn't already quoted.c                 H    [        U 5      n [        U [        [        -   S-   S9$ )N~)safe)r   r   r   r   )segments    r0   unquote_quote%smart_urlquote.<locals>.unquote_quote   s'    '" W#47H#H3#NOOr1   T)keep_blank_valuesr   r   )r   
ValueErrorr   UnicodeErrorr   r   r   r	   )	urlr   schemenetlocpathqueryfragmentqquery_partss	            r0   smart_urlquoter      s    P"08-X
"&! 
 u=
= QqT]GAaDM*= 	 

 +&DX&HvtH=>>-  "S!!"  "S!!"
s'   B B &B4BBB10B1c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )
CountsDicti  c                6   > [         TU ]  " / UQUQ76   Xl        g rk   )r   r   word)r   r   rT   rd   r   s       r0   r   CountsDict.__init__  s    ($((	r1   c                 D    U R                   R                  U5      X'   X   $ rk   )r   r   )r   keys     r0   __missing__CountsDict.__missing__  s    IIOOC(	yr1   r   )r   r   r   r   r   r   r   r   r   s   @r0   r   r     s     r1   r   c                       \ rS rSrSrSrSS/r\" S\R                  5      r
\" S\R                  5      r\" S5      rS	rS
rSS jrSSSS.S jrS r\S 5       r\S 5       r\S 5       rS r\S 5       rSrg)Urlizeri  aU  
Convert any URLs in text into clickable links.

Work on http://, https://, www. links, and also on links ending in one of
the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org).
Links can have trailing punctuation (periods, commas, close-parens) and
leading punctuation (opening parens) and it'll still do the right thing.
z.,:;!)())[]z^https?://\[?\wz>^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)($|/.*)$z([\s<>"']+)zmailto:{local}@{domain}z!<a href="{href}"{attrs}>{url}</a>NFc                     [        U[        5      nU R                  R                  [	        U5      5      nSR                  U Vs/ s H  nU R                  UUUUUS9PM     sn5      $ s  snf )a  
If trim_url_limit is not None, truncate the URLs in the link text
longer than this limit to trim_url_limit - 1 characters and append an
ellipsis.

If nofollow is True, give the links a rel="nofollow" attribute.

If autoescape is True, autoescape the link text and URLs.
r   )
safe_inputtrim_url_limitnofollowrv   )rX   r   word_split_rert   r-   rm   handle_word)r   r/   r   r   rv   r   wordsr   s           r0   __call__Urlizer.__call__,  s      h/
""((T3ww "	 "D   )#1%) !  "	
 	
	s   A(r   r   rv   c                   SU;   d  SU;   d  SU;   Ga  U R                  U5      u  pgnS n	U(       a  SOSn
[        U5      [        ::  a@  U R                  R	                  U5      (       a   [        [        R                  " U5      5      n	O[        U5      [        ::  aC  U R                  R	                  U5      (       a#  [        S[        R                  " U5      -  5      n	OWSU;  aQ  U R                  U5      (       a;  UR                  SS5      u  p [        U5      nU R                  R                  XS9n	Sn
U	(       ar  U R                  XsS	9nU(       a'  U(       d   [!        U5      [!        U5      p[!        U5      nU R"                  R                  [!        U	5      U
US
9n[%        U U U 35      $ U(       a  [%        U5      $ U(       a  [!        U5      $  U$ U(       a  [%        U5      $ U(       a  [!        U5      $ U$ ! [         a    Us $ f = f)N.@:z rel="nofollow"r   z	http://%sr   )localdomain)limit)hrefattrsr   )trim_punctuationlenr   simple_url_rematchr   r+   unescapesimple_url_2_reis_email_simplersplitr   r   mailto_templaterb   trim_urlr,   url_templater   )r   r   r   r   r   rv   leadmiddletrailr   nofollow_attrr   r   trimmeds                 r0   r   Urlizer.handle_wordF  s    $;#+ #'"7"7"=D%C19-rM6{n,1C1C1I1I&1Q1Q$T]]6%:;V.43G3G3M3Mf3U3U$[4==3H%HIF"t';';F'C'C &c1 5 %f-F **111M "---Ej"(,u%$WoG**11' 2 
 !D6&%!9::$T?*!$<'   	 T?"$<3 $  K s   G; ;H
	H
c                T    Ub  [        U5      U::  a  U$ SUS [        SUS-
  5       -  $ )Nu   %s…r   r   )r   max)r   xr   s      r0   r   Urlizer.trim_urlz  s4    =CFeOH.SEAI.///r1   c                 f    SR                  [        U R                  5      R                  5       5      $ r   )rm   dictwrapping_punctuationkeysr   s    r0   wrapping_punctuation_openings%Urlizer.wrapping_punctuation_openings  s%    wwtD556;;=>>r1   c                 :    U R                   R                  SS5      $ )Nr:   r   )trailing_punctuation_charsru   r   s    r0   'trailing_punctuation_chars_no_semicolon/Urlizer.trailing_punctuation_chars_no_semicolon  s    ..66sB??r1   c                      SU R                   ;   $ )Nr:   )r  r   s    r0   (trailing_punctuation_chars_has_semicolon0Urlizer.trailing_punctuation_chars_has_semicolon  s    d5555r1   c                 .   UR                  U R                  5      nUS[        U5      [        U5      -
   nSnSn[        US9nU(       Ga  U(       Ga  SnU R                   HK  u  pxXg   Xh   :  d  M  UR                  U5      n	X:w  d  M)  Xh   Xg   -
  n
X** S nUSU
*  nSnXh==   U
-  ss'   MM     UR                  S5      nUS:X  a  UR                  U R                  5      n	OUR                  U R                  5      n	X:w  a  U[        U	5      S U-   nU	nSnU R                  (       a  UR                  S5      (       a  X+S n[        R                  " U5      nX:X  d  UR                  S5      (       a  UR                  U R                  5      n	[        U	5      n[        U5      [        UR                  S5      5      -
  nUS:  a1  US	:  a+  X.S R                  S5      nUU-   S	-   nUUS U-   nXUU -   nO	X.S U-   nU	nSnU(       a
  U(       a  GM  X2U4$ )
zX
Trim trailing and wrapping punctuation from `word`. Return the items of
the new state.
Nr   Tr   Fr7   r:   r   )lstripr   r   r   r   rstriprfindr  r  r  endswithr+   r   index)r   r   r   r   r   trimmed_somethingcountsopeningclosing	rstrippedstripamppotential_entityescapedtrail_startamount_trailing_semicolonsrecent_semicolonmiddle_semicolon_indexs                     r0   r   Urlizer.trim_punctuation  s2    T??@-c$i#f+-. !(F %$($=$= ?V_4 &g 6I * &&/ A &vw!'%,0)50 %> ,,s#Cby"MM$*I*IJ	"MM$*V*VW	"s9~/058"$(!<<QTAUAU#)$< --(89.'2B2B32G2G &d.M.M NI"%i.K14Vs6==QTCU?V1V.Rx$>$B+1,+?+E+Ec+J(1AK1ORS1S. &'='> ?% G!*K@V-W!W &| 4u <!*(,%Q  FFT U""r1   c                    SU ;  d,  U R                  S5      (       d  U R                  S5      (       a  g U R                  S5      u  p[	        U5      S:  a  gSU;  d  UR                  S5      (       a  gg! [         a     gf = f)z1Return True if value looks like an email address.r   F?   r   T)
startswithr  rt   r   r   )rF   p1p2s      r0   r   Urlizer.is_email_simple  s     eu//44s8K8K	[[%FB r7R<b=BMM#..  		s   A6 6
BB NFF)r   r   r   r   __doc__r  r   r   rs   
IGNORECASEr   r   r   r   r   r   r   r   r   r   r  r  r   staticmethodr   r   r#  r1   r0   r   r     s     ")&
3$%7GM&I2==O %%78M/O6L
> 2h0
 ? ? @ @ 6 67#r  r1   r   c                     [        XX#S9$ )Nr   )urlizer)r/   r   r   rv   s       r0   urlizer*    s    h r1   c                 &    U R                  SS5      $ )zx
Avoid text wrapping in the middle of a phrase by adding non-breaking
spaces where there previously were normal spaces.
     )ru   rE   s    r0   avoid_wrappingr.    s    
 ==f%%r1   c                    ^ SU R                   ;   a  [        SU R                  -  5      eSU R                   ;  a  [        SU R                  -  5      eU R                  mU4S jU l        S U l        U $ )z
A decorator that defines the __html__ method. This helps non-Django
templates to detect classes whose __str__ methods return SafeString.
rW   z;can't apply @html_safe to %s because it defines __html__().__str__zAcan't apply @html_safe to %s because it doesn't define __str__().c                 &   > [        T" U 5      5      $ rk   )r   )r   	klass_strs    r0   <lambda>html_safe.<locals>.<lambda>  s    9T?!;r1   c                     [        U 5      $ rk   )r-   r   s    r0   r3  r4    s    #d)r1   )__dict__r   r   r0  rW   )klassr2  s    @r0   	html_safer8    sy    
 U^^#!NN+
 	
 & "'..1
 	
 I;EM+ENLr1   )NN)Fr$  )@r%  r+   rL   rs   r^   html.parserr   urllib.parser   r   r   r   r   r	   django.core.exceptionsr
   django.utils.deprecationr   django.utils.encodingr   django.utils.functionalr   r   r   r   django.utils.httpr   r   r   django.utils.regex_helperr   django.utils.safestringr   r   r   django.utils.textr   	frozensetVOID_ELEMENTSr   r,   r=   rD   updaterangerG   rN   rU   rZ   rO   rp   ry   r{   r   r   r   r   r   r   r   r)  r*  r.  r8  r#  r1   r0   <module>rG     s   -   	  " S S 6 = * W W R R 6 C C 0 ,   :	. 	. IyHiHiHiHiHiHiHiHiHiM9M9    E59E E :8 8 HiHiHi ((F&*  ! !&  $ . .
"?J @ @F )  &r1   