
    Li                         S r SSKrSSKJr  SSKJr  SSKJr  \R                  " S5      r\" S5      r	S r
S rS	 rSS
 jrg)z
pygments.regexopt
~~~~~~~~~~~~~~~~~

An algorithm that generates optimized regexes for matching long lists of
literal strings.

:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
    N)escape)groupby)
itemgetterz[\[\^\\\-\]]c                     U (       d  g[        U 5      n[        U 5      n[        U5       H  u  p4XBU   :w  d  M  USU s  $    U$ )zJGiven an iterable of strings, returns the longest common leading substring N)minmax	enumerate)ms1s2ics        c/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/pygments/regexopt.pycommonprefixr      sE    	QB	QB"1:bq6M  I    c                 Z    S[         R                  S SR                  U 5      5      -   S-   $ )N[c                 (    SU R                  5       -   $ )N\)group)r   s    r   <lambda>make_charset.<locals>.<lambda>"   s    	)9r   r   ])	CS_ESCAPEsubjoin)letterss    r   make_charsetr   !   s'    92777;KLLsRRr   c           	        ^
^ U=(       a    S=(       d    SnU (       d  gU S   m
[        U 5      S:X  a  U[        T
5      -   U-   $ T
(       d  U[        U SS S5      -   S-   U-   $ [        T
5      S:X  a  / n/ nU  H6  n[        U5      S:X  a  UR                  U5        M%  UR                  U5        M8     [        U5      S:  a9  U(       a!  U[        US5      -   S-   [	        U5      -   U-   $ U[	        U5      -   U-   $ [        U 5      nU(       a<  [        U5      nU[        U5      -   [        U  Vs/ s H  oUUS PM	     snS5      -   U-   $ U  Vs/ s H
  oUSSS	2   PM     nn[        U5      n	U	(       aB  [        U	5      mU[        [        U4S
 jU  5       5      S5      -   [        U	SSS	2   5      -   U-   $ USR                  S [        U U
4S j5       5       5      -   U-   $ s  snf s  snf )zEReturn a regex that matches any string in the sorted list of strings.)r   r      Nz(?:?|c              3   .   >#    U  H
  oS T*  v   M     g 7f)N ).0sslens     r   	<genexpr>"regex_opt_inner.<locals>.<genexpr>S   s     $@1vYs   c              3   R   #    U  H  n[        [        US    5      S5      v   M     g7f)r"   r   N)regex_opt_innerlist)r(   r   s     r   r+   r,   X   s*      LJU !eAh44Js   %'c                    > U S   TS   :H  $ )Nr   r'   )r)   firsts    r   r   !regex_opt_inner.<locals>.<lambda>Y   s    1q9Ir   )	lenr   r.   appendr   r   sortedr   r   )strings
open_parenclose_paren	oneletterrestr)   prefixplenstrings_revsuffixr1   r*   s             @@r   r.   r.   %   s   $*KAJE
7|qF5M)K77OGABK??  	 
5zQ	A1v{  #A	 
 y>A!OD"$==C"9-.0;< < Y 77+EE'"F6{ F6N*9Ax95AB 	 %,,GqTrT7GK,+&F6{f$@$@@%HIVDbD\"#%01 	1
  L%g/IJL 	LL   : -s   -G
G$c                 <    [        U 5      n U[        U S5      -   U-   $ )zReturn a compiled regex that matches any string in the given list.

The strings to match must be literal strings, not regexes.  They will be
regex-escaped.

*prefix* and *suffix* are pre- and appended to the final regex.
()r5   r.   )r6   r;   r>   s      r   	regex_optrA   ]   s$     WoGOGS11F::r   )r   r   )__doc__rer   	itertoolsr   operatorr   compiler   FIRST_ELEMENTr   r   r.   rA   r'   r   r   <module>rH      sE   	 
   JJ'	1	S5p	;r   