
    h1                         S r SSKrSSKJr  SSSSSSSSSSS.
r " S	 S
\5      r " S S\5      r " S S\5      rS r	S r
S rS rS rS rSS jrg)a  
Functions for reversing a regular expression (used in reverse URL resolving).
Used internally by Django and not intended for external use.

This is not, and is not intended to be, a complete reg-exp decompiler. It
should be good enough for a large class of URLS, however.
    NSimpleLazyObject0x !)
AbBdDsSwWZc                       \ rS rSrSrSrg)Choice   zCRepresent multiple possibilities at this point in a pattern string. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       K/var/www/html/env/lib/python3.13/site-packages/django/utils/regex_helper.pyr   r      s    Mr   r   c                       \ rS rSrSrSrg)Group"   z2Represent a capturing group in the pattern string.r   Nr   r   r   r   r!   r!   "   s    <r   r!   c                       \ rS rSrSrSrg)
NonCapture&   z6Represent a non-capturing group in the pattern string.r   Nr   r   r   r   r$   r$   &   s    @r   r$   c                    / n/ nSn[        [        U 5      5      nSn [        U5      u  pg  U(       a  UR	                  U5        GOUS:X  a  UR	                  S5        GOUS:X  a  [        S5      eUS:X  a  GOUS:X  a  GOUS	:X  a(  UR                  5       n[        XS
 5      n	US
U U	/-   nGOdUS:X  aX  [        U5      u  pgUR	                  U5        [        U5      u  pgU(       d  US:w  a  [        U5      u  pgU(       a  M  US:w  a  M  GOUS:X  Gam  [        U5      u  pgUS:w  d  U(       a6  SU-  n
US-  nUR	                  [        SU
-  U
45      5        [        Xd5        GO[        U5      u  pgUS;   a  [        Xd5        GOUS:X  a  UR	                  [        U5      5        GOmUS:w  a  [        SU-  5      e[        U5      u  pgUS;  a  [        SU-  5      eUS:X  a  SnOS	n/ n
[        U5      u  pgXk:w  a%  U
R	                  U5        [        U5      u  pgXk:w  a  M%  SR                  U
5      nUS	:w  a+  UR	                  [        SU-  U45      5        [        Xd5        OUR	                  [        SU-  S
45      5        OUS;   a{  [        Xd5      u  pU(       a  SnUS:X  a=  [        US   [        5      (       a  [        S
US   /5      US'   ODUR                  5         O3US:  a  UR!                  US   /US-
  -  5        OUR	                  U5        U(       a  [        U5      u  pgSnGM  [#        [%        ['        U5      6 5      $ ! [         a    S/ 4/s $ f = f! [         a     N;[
         a    S/ 4/s $ f = f)a  
Given a reg-exp pattern, normalize it to an iterable of forms that
suffice for reverse matching. This does the following:

(1) For any repeating sections, keeps the minimum number of occurrences
    permitted (this means zero for optional groups).
(2) If an optional group includes parameters, include one occurrence of
    that group (along with the zero occurrence case from step (1)).
(3) Select the first (essentially an arbitrary) element from any character
    class. Select an arbitrary character for any unordered class (e.g. '.'
    or '\w') in the pattern.
(4) Ignore look-ahead and look-behind assertions.
(5) Raise an error on any disjunctive ('|') constructs.

Django's URLs for forward resolving are either all positional arguments or
all keyword arguments. That is assumed here, as well. Although reverse
resolving can be done using positional args when keyword args are
specified, the two cannot be mixed in the same reverse() call.
Tr    .|zAwaiting Implementation^$)N[](?z_%d   z%%(%s)sz!=<:Pz&Non-reversible reg-exp portion: '(?%s')<=z'Non-reversible reg-exp portion: '(?P%s'r4   >z*?+{F)	next_chariternextStopIterationappendNotImplementedErrorpopr$   r!   walk_to_endlen
ValueErrorjoinget_quantifiercontainsr   extendlistzipflatten_result)patternresultnon_capturing_groupsconsume_nextpattern_iternum_argschescapedstartinnernameterminal_charparamcounts                 r   	normalizerW   *   s}   . FLT']+LH
<(pb!sc"s)*CDDsss -002"6&>25'1s"<0b!"<0s"&|"4KB gss"<09 8+DMHMM%)d*:T(B"CD1"&|"4KBU{ $B5s,33CK@s ))QTV)VWW&*<&8Z/", IB N# 
 9,/M -0M!&*<&8 1 KKO*.|*<KB !1 !# )C/"MM%)e2Ce0L*MN'9"MM%)e2Cd0K*LMv*2<	 $)LA:r
E22 &,T6":,>%?r


QYMM6":,%!)"<= b!"<0LU b ^F+,--k  Rz^   RzsD   M AM B M M DM DM MM
M8'M87M8c              #      #    U  H<  nUS:w  a  US4v   M  [        U 5      n[        R                  X5      nUc  M6  US4v   M>     g7f)a  
An iterator that yields the next character from "pattern_iter", respecting
escape sequences. An escaped character is replaced by a representative of
its class (e.g. \w -> "x"). If the escaped character is one that is
skipped, it is not returned (the next character is returned instead).

Yield the next character, along with a boolean indicating whether it is a
raw (unescaped) character or not.
\FNT)r:   ESCAPE_MAPPINGSget)
input_iterrO   representatives      r   r8   r8      sR      :e)O*(,,R4!d"" s   AAc                     U S:X  a  SnOSnU H1  u  pU(       a  M  U S:X  a  US-  nM  U S:X  d  M#  U(       d    gUS-  nM3     g)z
The iterator is currently inside a capturing group. Walk to the close of
this group, skipping over any nested groups and handling escaped
parentheses correctly.
r/   r1   r   r,   Nr   )rO   r\   nestingrP   s       r   r?   r?      sM     
Sy!3YqLG3YqLG "r   c                    U S;   a$   [        U5      u  p#US:X  a  SnU S:X  a  SU4$ SU4$ / nU S:w  a&  [        U5      u  pUR                  U 5        U S:w  a  M&  USS nS	R                  U5      R	                  S
5      n [        U5      u  pU S:X  a  Sn [        US   5      U 4$ ! [         a    Sn Nf = f! [         a    Sn  N8f = f)a  
Parse a quantifier from the input, where "ch" is the first character in the
quantifier.

Return the minimum number of occurrences permitted by the quantifier and
either None or the next character from the input_iter if the next character
is not part of the quantifier.
z*?+Nr0   +r1   r   }r7   r'   ,)r:   r;   r<   rB   splitint)rO   r\   ch2rP   quantvaluess         r   rC   rC      s     
U{	
+LC #:C9c6M#vE
):&R ) #2JEWWU^!!#&F:& 
Syvay>2-  	C	$  s#   B$ ?B6 $B32B36CCc                     [        X5      (       a  g[        U [        5      (       a  U  H  n[        X!5      (       d  M    g   g)zO
Return True if the "source" contains an instance of "inst". False,
otherwise.
TF)
isinstancer$   rD   )sourceinstelts      r   rD   rD     s<    
 &&*%%C""  r   c                    U c  S// /4$ [        U [        5      (       a  U S   c  / nOU S   /nU S   /U/4$ S/n/ /nS=pE[        U 5       GHh  u  pF[        U[        5      (       a  M  SR	                  XU 5      n[        U[        5      (       a  XvS   -  nUS   nOSnUS-   n[        [        U5      5       H+  n	X)==   U-  ss'   U(       d  M  X9   R                  U5        M-     [        U[        [        45      (       d  M  [        U[        5      (       a  U/n/ / pU H2  n[        U5      u  pU
R                  U5        UR                  U5        M4     / n/ n[        X#5       HE  u  p[        X5       H1  u  nnUR                  UU-   5        UR                  USS U-   5        M3     MG     UnUnGMk     XE:  a:  SR	                  XS 5      n[        [        U5      5       H  n	X)==   U-  ss'   M     X#4$ )z
Turn the given source sequence into a list of reg-exp possibilities and
their arguments. Return a list of strings and a list of argument lists.
Each of the two lists will be of the same length.
Nr'   r1   r   )rj   r!   	enumeratestrrB   ranger@   r<   r   r$   rH   rE   rG   )rk   paramsrJ   result_argsposlastrm   piecerU   iinner_result
inner_argsitemresargs
new_resultnew_argsi_itemi_argss                      r   rH   rH   !  s    ~tbTz&%  !9FQi[Fq	{VH$$TF$KNCf%c3C()c5!!VOEFEEQws6{#AIIu%%e, $ cFJ/00#z**e')2**40	##C(!!$'  JH!&6
&),&CNFF%%dVm4OODGf$45 'D 7  F"K; &< {u&s6{#AII $r   c                 *   ^ ^ UU 4S jn[        U5      $ )z"Lazily compile a regex with flags.c                     > [        T[        [        45      (       a  [        R                  " TT 5      $ T (       a   S5       eT$ )Nz3flags must be empty if regex is passed pre-compiled)rj   rp   bytesrecompile)flagsregexs   r   _compile"_lazy_re_compile.<locals>._compileZ  s8    ec5\**::eU++SSS9Lr   r   )r   r   r   s   `` r   _lazy_re_compiler   W  s     H%%r   )r   )r   r   django.utils.functionalr   rZ   rF   r   r!   r$   rW   r8   r?   rC   rD   rH   r   r   r   r   <module>r      s    
 4 
									NT N=D =A AW.t#**"J3l&r   