
    h                         d dl Z d dlZd dlmZ d dlmZ d dlmZ  ej                  dej                        Z
 ej                  d      Zd Zd Zd	 Zdd
Zd Zedd       Zedd       Zy)    N)deque)contextmanager)	text_typeaZ  
(
 (?:                     # Start of non-capturing group
  (?:\r\n|\r|\n)      |  # Match any single newline, or
  [^\r\n'"]+          |  # Match any character series without quotes or
                         # newlines, or
  "(?:[^"\\]|\\.)*"   |  # Match double-quoted strings, or
  '(?:[^'\\]|\\.)*'      # Match single quoted strings
 )
)
z(\r\n|\r|\n)c                     t        |       }t        j                  |      }dg}|D ]9  }|st        j	                  |      r|j                  d       -|dxx   |z  cc<   ; |S )zSplit a string on all unquoted newlines.

    Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite
    character is inside of a string. )r   SPLIT_REGEXsplit
LINE_MATCHmatchappend)stmttextlinesoutputlineslines        Q/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/sqlparse/utils.pysplit_unquoted_newlinesr   %   sk    
 T?Dd#E$K $d#r"Ot#O$     c                 :    | y| d   dv r| d   | d   k(  r| dd } | S )z4Helper that removes surrounding quotes from strings.Nr   )"'r       )vals    r   remove_quotesr   7   s5    
{
1vA#b' 1!BiJr   c                        fd}|S )zqFunction decorator to help with recursion

    :param cls: Classes to not recurse over
    :return: function
    c                       fdS )Nc                 j    | j                         D ]  }t        |      r |         |        y N)get_sublists
isinstance)tlistsgroupclsf	wrapped_fs     r   r'   z(recurse.<locals>.wrap.<locals>.wrapped_fG   s6    ,,. &!&#.f%& eHr   r   )r&   r'   r%   s   `@r   wrapzrecurse.<locals>.wrapF   s    	 r   r   )r%   r(   s   ` r   recurser)   @   s     Kr   c                      |}|rt        |t              s|gn|}|rt        |t              s|gn|} y|rt         |      ry|rt         fd|D              ry|rt         fd|D              ryy)a  Helper function to simplify comparisons Instance, Match and TokenType
    :param token:
    :param i: Class or Tuple/List of Classes
    :param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
    :param t: TokenType or Tuple/List of TokenTypes
    :return:  bool
    FTc              3   <   K   | ]  } j                   |   y wr    )r   ).0patterntokens     r   	<genexpr>zimt.<locals>.<genexpr>b   s     JW;5;;0Js   c              3   :   K   | ]  }j                   |v   y wr    )ttype)r,   r1   r.   s     r   r/   zimt.<locals>.<genexpr>d   s     ?u{{e+?s   )r"   listany)r.   imtclsstypes	mpatternss   `      r   imtr:   R   sr     Dz!T2QEE:a#6AI}	*UD)	sJ	JJ	3???r   c                 F    t        t        j                  | |      d       y)zCAdvance the iterator n-steps ahead. If n is none, consume entirely.r   )maxlenN)r   	itertoolsislice)iteratorns     r   consumerA   j   s    	)

8Q
'2r   c              #   h   K   | xj                   |z  c_         d  | xj                   |z  c_         y wr    )offsetfilter_r@   s     r   rC   rC   o   %     NNaN	NNaN   02c              #   h   K   | xj                   |z  c_         d  | xj                   |z  c_         y wr    )indentrD   s     r   rI   rI   v   rF   rG   )NNN)r   )r   )r=   recollectionsr   
contextlibr   sqlparse.compatr   compileVERBOSEr	   r   r   r   r)   r:   rA   rC   rI   r   r   r   <module>rP      s     	  % % bjj 
 ZZ
 RZZ(
$$03
    r   