
    jK_                     p   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
  S SKJrJr  S SKJrJr  S SKJr  S SKJr  S SKJrJr  S S	KJr  S S
KJr  \" S\R8                  5      r\" S\R8                  5      r " S S\5      r " S S5      r  " S S\ 5      r! " S S\!\5      r" " S S\5      r#\#" 5       r$g)    N)md5)unquote	urldefragurlsplit
urlunsplit)STATICFILES_STORAGE_ALIASsettings)check_settingsmatches_patterns)ImproperlyConfigured)ContentFile)FileSystemStoragestorages)
LazyObject)_lazy_re_compilez5/\*.*?\*/|\\.|'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"zP/\*.*?\*/|//[^\n]*|\\.|'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"|`(?:[^`\\]|\\.)*`c                   <   ^  \ rS rSrSrSU 4S jjrU 4S jrSrU =r$ )StaticFilesStorage"   z
Standard file system storage for static files.

The defaults for ``location`` and ``base_url`` are
``STATIC_ROOT`` and ``STATIC_URL``.
c                    > Uc  [         R                  nUc  [         R                  n[        U5        [        TU ]  " X/UQ70 UD6  U(       d  S U l        S U l        g g N)r	   STATIC_ROOT
STATIC_URLr
   super__init__base_locationlocation)selfr   base_urlargskwargs	__class__s        Z/var/www/html/KUNJ/venv/lib/python3.13/site-packages/django/contrib/staticfiles/storage.pyr   StaticFilesStorage.__init__*   s]    ++H**Hx =d=f= !%D DM     c                 Z   > U R                   (       d  [        S5      e[        TU ]  U5      $ )NzaYou're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.)r   r   r   path)r   namer!   s     r"   r&   StaticFilesStorage.path7   s-    }}&0 
 w|D!!r$   )r   r   NN)	__name__
__module____qualname____firstlineno____doc__r   r&   __static_attributes____classcell__r!   s   @r"   r   r   "   s    !" "r$   r   c                      ^  \ rS rSrSrSrSrSSS\4SS	\4S
S\4SS\444rSSSS\4444r	Sr
U 4S jrS!S jrS"S jrS#U 4S jjrS$S jrS rS rS"S jrS$S jrS rS rS rS rS rS rU =r$ )%HashedFilesMixinA   zurl("%(url)s")   Fz*.jsz[(?P<matched>import(?P<import>[\s\{][^;]*?|\*\s*as\s*\w+)\s*from\s*['"](?P<url>[./].*?)["'])zimport%(import)s from "%(url)s"zN(?P<matched>export(?P<exports>[\s\{][^;]*?)\s*from\s*["'](?P<url>[./].*?)["'])z export%(exports)s from "%(url)s"z.(?P<matched>import\s*['"](?P<url>[./].*?)["'])zimport"%(url)s"z/(?P<matched>import\(["'](?P<url>[./].*?)["']\))zimport("%(url)s"))z*.css)zA(?P<matched>url\((?P<quote>['"]{0,1})\s*(?P<url>.*?)(?P=quote)\)))z.(?P<matched>@import\s*["']\s*(?P<url>.*?)["'])z@import url("%(url)s"))zG(?m)^(?P<matched>/\*#[ \t](?-i:sourceMappingURL)=(?P<url>.*)[ \t]*\*/)$z/*# sourceMappingURL=%(url)s */z9(?m)^(?P<matched>//# (?-i:sourceMappingURL)=(?P<url>.*))$z//# sourceMappingURL=%(url)sTc                   > U R                   (       a   U =R                  U R                  4-  sl        [        T	U ]  " U0 UD6  0 U l        0 U l        U R                   H  u  p4U H  n[        U[        [        45      (       a   [        U5      S:X  a  Uu  pVnOUu  pV[        nOU R                  n[        n[        R                  " U[        R                  5      nU R
                  R!                  U/ 5      R#                  XU45        M     M     g )N   )$support_js_module_import_aggregationpatterns&_js_module_import_aggregation_patternsr   r   	_patternshashed_files
isinstancetuplelistlen_css_ignored_redefault_templaterecompile
IGNORECASE
setdefaultappend)
r   r   r    	extensionr9   patterntemplate
ignored_recompiledr!   s
            r"   r   HashedFilesMixin.__init__   s    44MMdIIKKM$)&)#'==I#gt}557|q(8?5:,3)%4
#44H!0J::gr}}=)))R8??4 $ $1r$   c                     Uc  g[        SS9nUR                  5        H  nUR                  U5        M     UR                  5       SS $ )zE
Return a hash of the file with the given name and optional content.
NF)usedforsecurity   )r   chunksupdate	hexdigest)r   r'   contenthasherchunks        r"   	file_hashHashedFilesMixin.file_hash   sI     ?U+^^%EMM%  &!#2&&r$   c                 v   [        [        U5      5      nUR                  R                  5       nU=(       a,    [        [        U5      5      R                  R                  5       =(       d    UnUS L nU(       a<  U R	                  U5      (       d  [        SU< SU < S35      e U R                  U5      n U R                  XR5      nU(       a  UR                  5         [        R                  R                  U5      u  p[        R                  R                  U5      u  pU(       a  SU-  OSn[        R                  R                  X< U< U
< 35      n[        U5      nXS'   SU;   a  US   (       d  US==   S	-  ss'   [        U5      $ ! [         a    Us $ f = f! U(       a  UR                  5         f f = f)
Nz
The file 'z' could not be found with .z.%s    ?#r7   ?)r   r   r&   stripexists
ValueErroropenOSErrorrW   closeossplitsplitextjoinr?   r   )r   r'   rT   filenameparsed_name
clean_nameopenedrW   r&   rootexthashed_nameunparsed_names                r"   ro   HashedFilesMixin.hashed_name   sj    wt}- %%++-
I'(*;!<!A!A!G!G!IXjD;;x(( CKTR ))H-	 z;Iz2GG$$X.	+4UY&"	ggll4T9c)JK[)&a 4<a 0!#-((%    s   #F 5F FFF8c                   > [         R                  (       a  U(       d  USpeOI[        U5      u  pv[        U5      R                  R                  S5      (       a  UnOU4nUb  X4-  nU" U6 n[        TU ]  U5      n	SU;   n
U(       d  U
(       aR  [        [        U	5      5      nU(       a  US   (       d  XkS'   U
(       a  US   (       d  US==   S-  ss'   [        U5      n	[        U	5      $ )*
Return the non-hashed URL in DEBUG mode.
r[   /r]      r7   r\   r^   )r	   DEBUGr   r   r&   endswithr   urlr?   r   r   )r   hashed_name_funcr'   forcer<   ro   fragmentrk   r   	final_urlquery_fragmenturlpartsr!   s               r"   _urlHashedFilesMixin._url   s     >>%$("#,T? J
#((11#66""}+O+D.5GK,	 ~HY/0H&hqks""8,Iy!!r$   c                 :    U R                  U R                  X5      $ )rs   )r   stored_name)r   r'   rz   s      r"   rx   HashedFilesMixin.url   s     yy))477r$   c                     [         R                  " X!5       Vs/ s H"  o3R                  5       UR                  5       4PM$     sn$ s  snf )z
Return a sorted list of (start, end) tuples for content that should
be ignored during URL rewriting based on the specified pattern:
e.g. block comments and string literals for CSS, plus line comments
(// ...) and template literals (`...`) for JS.
)rC   finditerstartend)r   rT   rI   matchs       r"   get_ignored_blocks#HashedFilesMixin.get_ignored_blocks   s6     ;=++g:WX:W		,:WXXXs   )Ac                 H    U H  u  p4X1s=:  a  U:  a     g  X:  d  M    g   g)NTF )r   posignored_blocksr   r   s        r"   is_in_ignored_block$HashedFilesMixin.is_in_ignored_block   s.    (JE S  !{	 )
 r$   c                 L   ^ ^^^^^ Tc  T R                   mS mUUUUU U4S jnU$ )z:
Return the custom URL converter for the given file name.
c                     U R                  SSU5      S-   nU R                  SU5      nUS:w  a  UO
[        U 5      nU R                  SSU5      S-   nSU SXU  3n[        U5      S:  a  SU 3$ U$ )N
r      z: O   )rfindfindr@   count)rT   positionr   r   line_nummsgs         r"   _line_at_position9HashedFilesMixin.url_converter.<locals>._line_at_position  s    MM$84q8E,,tX.C#GC}}T1e4q8Hxj7#5"67C3x"}H:&Jr$   c                   > U R                  5       nUS   nUS   nT(       a'  TR                  U R                  5       T5      (       a  U$ [        R                  " SU5      (       d  UR                  S5      (       a  U$ UR                  S5      (       a&  UR                  [        R                  5      (       d  U$ [        U5      u  pEU(       d  U$ UR                  S5      (       aF  UR                  [        R                  5      (       d   eUR                  [        R                  5      nOa[        R                  S:X  a  TOTR                  [        R                  S5      n[        R                  " [        R                  " U5      U5      n TR!                  TR"                  [%        U5      STS9nSR                  UR-                  S5      S
S UR-                  S5      SS
 -   5      nU(       a  USU;   a  SOSU-   -  n[%        U5      US'   TU-  $ ! [&         aE  n	T" U R(                  U R                  5       5      n
T< SU< S	U
 3nU	R+                  U5        U	eS
n	A	ff = f)z
Convert the matched URL to a normalized and hashed URL.

This requires figuring out which files the matched URL resolves
to and calling the url() method of the storage.
matchedrx   z^[a-z]+:z//rt   T)rz   r<   z contains this reference z	 on line Nr   r]   #)	groupdictr   r   rC   r   
startswithr	   r   r   removeprefixre   sepreplace	posixpathrh   dirnamer   _stored_namer   ra   stringadd_noterf   )matchobjmatchesr   rx   url_pathr{   target_namesource_name
hashed_urlexclinenotetransformed_urlr   r<   r   r'   r   rJ   s                r"   	converter1HashedFilesMixin.url_converter.<locals>.converter  s,    ((*Gi(G%.C $":": .# #  xxS))S^^D-A-A ~~c""3>>(:M:M+N+N "+3H ""3''  **8+>+>????&33H4G4GH ')ffmdbffc9R'nnY->->{-KXV!YY%%K(!-	 ' 
 "hhs#CR(:+;+;C+@+EEO
 DCKDSH#LL %_5GENg%%!  ((..:JK!:7+YtfUT"		s   %H 
I$A II$)rB   )r   r'   r<   rJ   r   r   r   s   ````` @r"   url_converterHashedFilesMixin.url_converter   s0     ,,H	E	& E	&N r$   c              +     #    U(       a  g0 nU Vs/ s H!  n[        XPR                  5      (       d  M  UPM#     nn0 nU R                  XU5       H.  u  ppX;  d  [        U
[        5      (       a  XU
4v   M(  XU
4Xx'   M0     U Vs0 s H  oUX   _M	     nn/ n[        U R                  5       HJ  n/ nU R                  XU5       H&  u  ppXU
4Xx'   U(       d  M  UR                  U5        M(     U(       a  MJ    O   U(       a*  SR                  [        U5      5      nUS[        S5      4v   U R                  R                  U5        UR                  5        Sh  vN   gs  snf s  snf  N7f)a  
Post process the given dictionary of files (called from collectstatic).

Processing is actually two separate operations:

1. renaming files to include a hash of their content for cache-busting,
   and copying those files to the target storage.
2. adjusting files which contain references to other files so they
   refer to the cache-busting filenames.

If either of these are performed on a file, then that file is
considered post-processed.
Nz, z!Max post-process passes exceeded.)r   r;   _post_processr=   	Exceptionrangemax_post_process_passesrG   rh   sortedRuntimeErrorr<   rR   values)r   pathsdry_runoptionsr<   r&   adjustable_pathsprocessed_adjustable_pathsr'   ro   	processed_unresolved_pathsisubstproblem_pathss                   r"   post_processHashedFilesMixin.post_processX  s       #
"T&6t^^&LDU 	 

 &(" 04/A/A\0
+Dy +z)Y/O/O2248y3Q*00
 0@@/?tu{"/?@t334A!7;7I7I839 59y3Q*05$++D18 $# 5  IIf-=&>?M|4W'XXX 	  . .44666Q
" A. 	7s;   E+EEAE+E$AE+E+6A#E+E)E+c              #   t  ^#    S n[        XSS9 GHM  nSnX   u  pxUR                  U5       n	U R                  U5      n
U R                  U
5      nX;  a  U R	                  XY5      nOX;   n[        U	S5      (       a  U	R                  S5        U R                  U5      nSnXR;   Gas  Un U	R                  5       R                  S5      mU R                  R                  5        Hz  u  nn[        UU45      (       d  M  [        U4S jU 5       5      (       d  M6  U H>  u  nnnU R                  UUUU R!                  TU5      5      n UR#                  UT5      mM@     M|     U(       a  U R'                  U5        [)        TR+                  5       5      nU R,                  (       a  U R/                  UU5        U R	                  UU5      nU R                  U5      (       a  U R'                  U5        U R/                  UU5      nU R                  U5      nX:X  a  SnSnU(       d+  U(       d$  SnU R/                  X5      nU R                  U5      nXU'   X\X4v   S S S 5        GMP     g ! [         a  nUS US4v    S nAGNS nAff = f! [$         a  nUS US4v    S nAGM  S nAff = f! , (       d  f       GM  = f7f)	Nc                 R    [        U R                  [        R                  5      5      $ r   )r@   rf   re   r   )r'   s    r"   
path_level2HashedFilesMixin._post_process.<locals>.path_level  s    tzz"&&)**r$   T)keyreverseseekr   Fzutf-8c              3   L   >#    U  H  u  n  o!R                  T5      v   M     g 7fr   )search).0pr   rT   s      r"   	<genexpr>1HashedFilesMixin._post_process.<locals>.<genexpr>  s!     &QWQ1xx'8'8s   !$)r   rb   rk   hash_keyro   hasattrr   r`   readdecodeUnicodeDecodeErrorr;   itemsr   anyr   r   subra   deleter   encodekeep_intermediate_files_save)r   r   r   r<   r   r'   substitutionsstorager&   original_filecleaned_namer   ro   hashed_file_existsr   old_hashed_namer   rH   r9   rI   rJ   rK   r   content_file
saved_namerT   s                            @r"   r   HashedFilesMixin._post_process  s    	+ 5$?D M "KMGd#}#t4==6 /"&"2"24"GK"."8K =&11!&&q)%)[[%="!	 +&1O5"/"4"4"6"="=g"F 04~~/C/C/E+	8+D9,??#&&Q&Q#Q#Q (AI =:,0,>,>$($0$,$($;$;(/(2%&	-"	!A.5kk)W.MG BJ	 0F$ *K0#.w~~/?#@L33

;="&"2"24"FK{{;//K0!%K!FJ"&//*"=K&5(- $I  .$(	%)ZZ%K
&*ooj&A *5X&AAS $# @8 . 5"D#u4445$ (2 !A*.c5*@$@$@!AS $#sy   +J8A;J%*I$	0J%=A	J%JC=J%J8$
J.I<6J%<JJ%
J"JJ%J""J%%
J5	/	J8c                 &    UR                  SS5      $ )N\rt   )r   r   r'   s     r"   rk   HashedFilesMixin.clean_name  s    ||D#&&r$   c                     U$ r   r   r   s     r"   r   HashedFilesMixin.hash_key  s    r$   c                     [         R                  " U5      nU R                  U5      nU R                  U5      nUR	                  U5      nUc   U R                  U R                  U5      5      nU$ r   )r   normpathrk   r   getro   )r   r'   r<   r   r   
cache_names         r"   r   HashedFilesMixin._stored_name  se     !!$'t,==.!%%h/
)9)9$)?@Jr$   c           	      j   U R                  U5      nU R                  U5      nU R                  R                  U5      nU(       a  U$ Un[	        U R
                  S-   5       H<  nU R                  U R                  US US95      nXT:X  a  X@R                  U'   Us  $ UnM>     [        SU< SU < S35      e)Nr   )rT   ri   z
The name 'z' could not be hashed with rZ   )rk   r   r<   r   r   r   ro   ra   )r   r'   r   r   r   intermediate_namer   s          r"   r   HashedFilesMixin.stored_name  s    t,==.&&**84
 t33a78A  t>O PJ !..8!!(+!! %/! 9 tTUUr$   )r;   r<   r   r)   )FN)F)r*   r+   r,   r-   rB   r   r8   _js_ignored_rer:   r9   r   r   rW   ro   r   rx   r   r   r   r   r   rk   r   r   r   r/   r0   r1   s   @r"   r3   r3   A   s    ++0(? 7? 8 F& G'/	
.*B	
&  Q2"		
'H< #,	' )D">8YXt>7@SBj'
V Vr$   r3   c                   d   ^  \ rS rSrSrSrSrSrSS.U 4S jjrS	 r	S
 r
U 4S jrS rS rSrU =r$ )ManifestFilesMixini  1.1zstaticfiles.jsonTFN)manifest_storagec                v   > [         TU ]  " U0 UD6  Uc  U nXl        U R                  5       u  U l        U l        g r   )r   r   r  load_manifestr<   manifest_hash)r   r  r   r    r!   s       r"   r   ManifestFilesMixin.__init__  s@    $)&)## 0040B0B0D-4-r$   c                      U R                   R                  U R                  5       nUR                  5       R	                  5       sS S S 5        $ ! , (       d  f       g = f! [
         a     g f = fr   )r  rb   manifest_namer   r   FileNotFoundError)r   manifests     r"   read_manifest ManifestFilesMixin.read_manifest%  sS    	&&++D,>,>?8}}--/ @??  		s.   %A  A	A  
AA  A   
A-,A-c                 Z   U R                  5       nUc  0 S4$  [        R                  " U5      nUR                  S5      nUS;   a$  UR                  S0 5      UR                  SS5      4$  [        SU R                  < SU R                  < S35      e! [        R                   a     N>f = f)	Nr[   version)z1.0r  r   hashzCouldn't load manifest 'z' (version ))r  jsonloadsr   JSONDecodeErrorra   r	  manifest_version)r   rT   storedr  s       r"   r   ManifestFilesMixin.load_manifest,  s    $$&?r6M	GZZ(F jj+G.(zz'2.

620FFF )!!4#8#8:
 	
 ## 		s   B B*)B*c              /      >#    0 U l         [        TU ]  " U0 UD6 S h  vN   UR                  S5      (       d  U R	                  5         g g  N,7f)Nr   )r<   r   r   r   save_manifest)r   r   r    r!   s      r"   r   ManifestFilesMixin.post_process=  sK     7'8888zz)$$  % 	9s   AA-Ac                 X   [        U R                  R                  5       5      nU R                  S [	        [
        R                  " U5      R                  5       5      5      U l        [        U5      U R                  U R                  S.nU R                  R                  U R                  5      (       a%  U R                  R                  U R                  5        [
        R                  " U5      R                  5       nU R                  R                  U R                  [	        U5      5        g )N)r   r  r  )r   r<   r   rW   r   r  dumpsr   r  dictr  r  r`   r	  r   r   )r   sorted_hashed_filespayloadcontentss       r"   r   ManifestFilesMixin.save_manifestC  s    $T%6%6%<%<%>?!^^+djj)<=DDFG
 -.,,&&

   ''(:(:;;!!((););<::g&--/##D$6$6H8MNr$   c                    [        [        U5      5      nUR                  R                  5       nU R	                  U5      nU R
                  R                  U5      nUc?  U R                  (       a  [        SU-  5      eU R                  U R                  U5      5      n[        U5      nXVS'   SU;   a  US   (       d  US==   S-  ss'   [        U5      $ )Nz+Missing staticfiles manifest entry for '%s'r\   r]   r7   r^   )r   r   r&   r_   r   r<   r   manifest_strictra   rk   ro   r?   r   )r   r'   rj   rk   r   r   rp   s          r"   r   ManifestFilesMixin.stored_nameR  s    wt}- %%++-
==,&&**84
## AJN  )9)9$)?@J[)%a 4<a 0!#-((r$   )r<   r  r  )r*   r+   r,   r-   r  r	  r#  r   r   r  r  r   r  r   r/   r0   r1   s   @r"   r  r    sG    &MO#/3 E E
"!O) )r$   r  c                       \ rS rSrSrSrg)ManifestStaticFilesStorageif  z\
A static file system storage backend which also saves
hashed copies of the files it saves.
r   N)r*   r+   r,   r-   r.   r/   r   r$   r"   r&  r&  f  s    
 	r$   r&  c                       \ rS rSrS rSrg)ConfiguredStorageio  c                 (    [         [           U l        g r   )r   r   _wrapped)r   s    r"   _setupConfiguredStorage._setupp  s     !:;r$   )r*  N)r*   r+   r,   r-   r+  r/   r   r$   r"   r(  r(  o  s    <r$   r(  )%r  re   r   rC   hashlibr   urllib.parser   r   r   r   django.confr   r	    django.contrib.staticfiles.utilsr
   r   django.core.exceptionsr   django.core.files.baser   django.core.files.storager   r   django.utils.functionalr   django.utils.regex_helperr   DOTALLrA   r   r   r3   r  r&  r(  staticfiles_storager   r$   r"   <module>r8     s     	  	  A A ; M 7 . A . 6" II " II"* ">TV TVnK)) K)\	!35G 	<
 <
 () r$   