
    9 f                     p    d Z ddlmZ ddlZddlmZ ddlmZ dede	d	e
d
e	fdZdede	dej        d
e	fdZdS )zFormat attributes.    )partialN   )child_of_ignored_block)Configconfig
attributesspacingreturnc                 T   dt           dt          dt          dt          fd}dt          dt          j        dt          fd}| j        }t          |d	          }t          j        t          j        |d
z   | j	        z   dz   t          j
        t          j        z  t          j        z            ||          }t          |d          }t          j        t          j        d| j	        z   dz   t          j
        t          j        z  t          j        z            ||          } || ||          }|S )z#Format template tags in attributes.r   r   r	   r
   c                    d}d}|pd}t          |                                          D ]L\  }}t          j        t          j        | j        t          j        t          j        z            |                                          r,|dz
  }|| j	        z  |dz  z   |                                z   }nt          j        t          j        | j
        t          j        t          j        z            |                                          r7t          |dz
  d          | j	        z  |dz  z   |                                z   }nt          j        t          j        | j        t          j        t          j        z            |                                          rt          j        t          j        | j        t          j        t          j        z            |                                          s+|| j	        z  |dz  z   |                                z   }|dz   }n%|| j	        z  |dz  z   |                                z   }|dk    r||                                z  }0|                                r|d| z  }N|S )zIndent template tags.

        |    <form class="this"
        |    ----- attribute name
        |
        |    <form class="this"
        |---^ leading space
        |
        |    <form class="this"
        |    ^----^ base indent
        |
        r        
)	enumerate
splitlinesrematchcompiletemplate_unindentIXstripindenttag_unindent_linemaxsearchtemplate_indent)	r   r   r	   r   indentedindent_adderline_numberlinetmps	            Q/var/www/equiseq/venv/lib/python3.11/site-packages/djlint/formatter/attributes.pyadd_indentationz-format_template_tags.<locals>.add_indentation   s-    |!!*:+@+@+B+B!C!C "	' "	'Kx
63RTBD[AA4::<<  U  !-,2DE

T
63RTBD[AA4::<<  U
 
A&&6"S()jjll#  
6124"$;??  
Ui
63RTBD[AA4::<< 
U -,2DE

T! -,2DE

TaDJJLL( 'JJJ&    patternr   c                     | dk    rd|                                  S |                     d           d|                     d                                           S )z+Make a decision if a break should be added.beforer   r   r   )groupr   )r'   r   s     r$   	add_breakz'format_template_tags.<locals>.add_breakH   sW    h''''++a..<<EKKNN$8$8$:$:<<<r&   r)   z.\K((?:{%|{{\#)[ ]*?(?:z)[^}]+?[%|}]}))flagsafterz((?:{%|{{\#)[ ]*?(?:z)[^}]+?[%|}]})([^
]+)$)r   strintr   Matchbreak_beforer   subr   break_template_tags
IGNORECASE	MULTILINEVERBOSE)r   r   r	   r%   r+   
break_charfuncs          r$   format_template_tagsr9      s]   5 5C 5# 5# 5 5 5 5n=3 =rx =C = = = = $J9h''D

()()  -",.;	
 	
 	
 	
 
J 9g&&D

#()'( -",.;		
 	
 	
 		 	J !W==Jr&   htmlr   c                 	   t          | ||          s=t          |                    d                                                    | j        k     r|                                S |                    d          }|                    d          dz   }|t          |          dz  z   }g }t          j        | j        |                    d                                          t
          j                  D ]x}|                    d          }|                    d          o|                    d          d         dv }	|	r|                    d          d         nd}
d}|                    d          r|                    d          d         |                    d          d	         k    r|                    d          d         d
k    r)|                    d                              d
          }ns|                    d          d         dk    r)|                    d                              d          }n+|                    d          }n|                    d          }|                    d          }d}|r|r|dz  }| j	        rd|z   }n*d|z   t          |t          |pd          z             dz  z   }|rN|                                dk    r6d|z                       d |                    d          D                       }n|r|                                dv rjd|z                       d |                    d          D                       }d|z                       d |                    d          D                       }| j	        r|rI|| j        vr@t          | |t          t          |          t          |pd          z   |z                       }|r=t          | |t          t          |          t          |pd          z                       }|r|s|	r$|pd}|                    | d|
 | |
            W|                    |pd|pdz   |pdz              zd|z                       d |D                       }|                    d          }| | | | }d                    d |                                D                       }| S )z+Spread long attributes over multiple lines.   r   r   r   r   )'"r>   Nr=   r   r   style;c                 ^    g | ]*}|                                 |                                 +S  r   .0values     r$   
<listcomp>z%format_attributes.<locals>.<listcomp>   s-    UUU5u{{}}UUUUr&   )srcsetzdata-srcsetsizeszw,c                 ^    g | ]*}|                                 |                                 +S rC   rD   rE   s     r$   rH   z%format_attributes.<locals>.<listcomp>   -    VVV5VVVVr&   zx,c                 ^    g | ]*}|                                 |                                 +S rC   rD   rE   s     r$   rH   z%format_attributes.<locals>.<listcomp>   rL   r&   =c                     g | ]}||S rC   rC   rF   xs     r$   rH   z%format_attributes.<locals>.<listcomp>   s    -I-I-IAq-Ia-I-I-Ir&      c                 6    g | ]}|                                 S rC   )rstriprP   s     r$   rH   z%format_attributes.<locals>.<listcomp>   s     !T!T!T!((**!T!T!Tr&   )r   lenr*   r   max_attribute_lengthr   finditerattribute_patternr6   format_attribute_template_tagsr/   lowerjoinsplitignored_attributesr9   appendr   )r   r:   r   leading_spacetagr	   r   attr_grpattrib_name	is_quotedquoteattrib_value
standalonequote_length
join_spaceattribute_stringcloses                    r$   format_attributesrk   p   s0    	vtU33u{{1~~##%%&&)DDD{{}}KKNNM
++a..3
Cc#hhn,GJ K %++a.."6"6"8"8"*  H H nnQ''NN1%%L(..*;*;A*>**L	(1:q!!!$$s>>! 
	-!2!21!59J9J29N!N!N~~a  #s**'~~a0066s;;""1%,,'~~a0066s;;  (~~a00#>>!,,L^^A&&
 	< 	AL0 	JJ w\C8Ir4J4J%J!K!Kc!QQ 
  	;,,..'99*,22UUL,>,>s,C,CUUU LL  	[..004VVV :-33VVL,>,>t,D,DVVV L !:-33VVL,>,>t,D,DVVV L
 0 	 63L L L3 Gs;+<"'='==LMM     1JCLL3{?Pb;Q;Q,Q(R(R 
  	< 	9 	'-2LKKuKlKEKKLLLL"|'9r:j>NBO    w,,-I-I-I-I-IJJKKNNE'GG.>GGG yy!T!T6F6Q6Q6S6S!T!T!TUU  r&   )__doc__	functoolsr   regexr   helpersr   settingsr   r.   r/   r9   r   rk   rC   r&   r$   <module>rq      s                , , , , , ,      b bS b3 b3 b b b bJd!f d!C d! d!S d! d! d! d! d! d!r&   