
    m`                        d dl Z d dlZd dlZd dlZ	 d dlmZ eZej        Z	n# e
$ r d dlmZ eZeZ	eZY nw xY w	 d dlZn# e
$ r d dlZY nw xY wddgZ e j        dd                    e          z            Z e j        d          Z e j        d          Z e j        d	          Z e j        d
          Z e j        d          Z e j        d          Z e j        d          ZdZddZdddd dedddddfdZdS )    N)name2codepointslugifysmart_truncatez&(%s);|z&#(\d+);z&#x([\da-fA-F]+);z[\']+z[^-a-z0-9]+z[^-a-zA-Z0-9]+z-{2,}z(?<=\d),(?=\d)-F c                    |                      |          } |s| S t          |           |k     r| S |s| d|                              |          S || vr
| d|         S d}|                     |          D ]g}|rct          |          t          |          z   }||k     r|d                    ||          z  }C||k    r|d                    |          z  } n|r nh|s
| d|         }|                     |          S )a=  
    Truncate a string.
    :param string (str): string for modification
    :param max_length (int): output string length
    :param word_boundary (bool):
    :param save_order (bool): if True then word order of output string is like input string
    :param separator (str): separator between words
    :return:
    N z{}{}z{})striplensplitformat)string
max_lengthword_boundary	separator
save_order	truncatedwordnext_lens           /lib/python3.11/site-packages/slugify/slugify.pyr   r   #   s6    \\)$$F 
6{{Z 4kzk"((333kzk""IY'' 
 
 		9~~D		1H*$$V]]4;;;		Z''T[[...	 E (;J;'	??9%%%    T c                    |r|D ]\  }}|                      ||          } t          | t                    st          | dd          } t                              t          |           } t          j        |           } t          | t                    st          | dd          } |rt                              d |           } |r.	 t                              d |           } n# t          $ r Y nw xY w|r.	 t                              d |           } n# t          $ r Y nw xY wt          j        d|           } t          j        dk     r|                     dd          } |
r|                                 } t                              d	|           } t$                              d	|           } |
r
|	pt&          }n	|	pt(          }t+          j        |t          |           } t,                              t          |                               t                    } ru|
r3d
 D             fd|                     t                    D             }n&fd|                     t                    D             }t                              |          } |r|D ]\  }}|                      ||          } |dk    rt5          | ||t          |          } |t          k    r|                      t          |          } | S )a  
    Make a slug from the given text.
    :param text (str): initial text
    :param entities (bool): converts html entities to unicode
    :param decimal (bool): converts html decimal to unicode
    :param hexadecimal (bool): converts html hexadecimal to unicode
    :param max_length (int): output string length
    :param word_boundary (bool): truncates to complete word even if length ends up shorter than max_length
    :param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
    :param separator (str): separator between words
    :param stopwords (iterable): words to discount
    :param regex_pattern (str): regex pattern for allowed characters
    :param lowercase (bool): activate case sensitivity by setting it to False
    :param replacements (iterable): list of replacement rules e.g. [['|', 'or'], ['%', 'percent']]
    :return (str):
    zutf-8ignorec                 \    t          t          |                     d                             S N   )unichrr   groupms    r   <lambda>zslugify.<locals>.<lambda>v   s    qwwqzz8R1S1S r   c                 `    t          t          |                     d                              S r   r   intr    r!   s    r   r#   zslugify.<locals>.<lambda>{   s    AGGAJJ1H1H r   c                 b    t          t          |                     d          d                    S )Nr      r%   r!   s    r   r#   zslugify.<locals>.<lambda>   s"    VC

B4G4G-H-H r   NFKD)   asciir
   c                 6    g | ]}|                                 S r   )lower).0ss     r   
<listcomp>zslugify.<locals>.<listcomp>   s     <<<Qqwwyy<<<r   c                     g | ]}|v|	S r   r   )r.   wstopwords_lowers     r   r0   zslugify.<locals>.<listcomp>   s#    ZZZ1/AYAYQAYAYAYr   c                     g | ]}|v|	S r   r   )r.   r2   	stopwordss     r   r0   zslugify.<locals>.<listcomp>   s#    TTT1)ASASQASASASr   r   )replace
isinstance_unicode_type_unicodeQUOTE_PATTERNsubDEFAULT_SEPARATOR	unidecodeCHAR_ENTITY_PATTERNDECIMAL_PATTERN	ExceptionHEX_PATTERNunicodedata	normalizesysversion_infoencoder-   NUMBERS_PATTERNALLOWED_CHARS_PATTERN$ALLOWED_CHARS_PATTERN_WITH_UPPERCASEreDUPLICATE_DASH_PATTERNr   r   joinr   )textentitiesdecimalhexadecimalr   r   r   r   r5   regex_pattern	lowercasereplacementsoldnewpatternwordsr3   s           `       @r   r   r   M   s9   *  *$ 	* 	*HC<<S))DD dM** 1gx00 .55D t$$D dM** 1gx00  ["&&'S'SUYZZ  	"&&'H'H$OODD 	 	 	D	  	??#H#H$OODD 	 	 	D	  ..D
${{7H--  zz|| R&&D r4((D  H8#8G#G6',d33D "%%&7>>DDEVWWD  - 	U<<)<<<OZZZZ

+< = =ZZZEETTTT

+< = =TTTE %%e,,  *$ 	* 	*HC<<S))DD A~~dJ?PR\]]%%%||-y99Ks$   C! !
C.-C.4D 
DD)r   Fr   F)rJ   rB   typesrD   htmlentitydefsr   unicoder9   UnicodeTyper8   ImportErrorhtml.entitiesstrchrr   text_unidecoder=   __all__compilerL   r>   r?   rA   r:   rH   rI   rK   rG   r<   r   r   r   r   r   <module>rc      s   				      



------H%MM   ,,,,,,HMFFF	&&&&&    &
' !bjSXXn-E-E!EFF "*[))bj-..
8$$"
>22 '1rz2C'D'D $#H-- "*.// '& '& '& '&T  4A]b'ERW[gkg g g g g gs   " 66? 	A
A