
    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		 d dlZddgZ e j$                  ddj'                  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y# e
$ r d dlmZ eZeZ	eZY w xY w# e
$ r d dlZY w xY w)    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)-Fc                    | j                  |      } |s| S t        |       |k  r| S |s| d| j                  |      S || vr| d| S d}| j                  |      D ]V  }|st        |      t        |      z   }||k  r|dj                  ||      z  }8||k(  r|dj                  |      z  } n|sV n |s| d| }|j                  |      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.12/site-packages/slugify/slugify.pyr   r   #   s     \\)$F
6{Zkz"((33kz""IY'9~D	1H*$V]]4;;	Z'T[[..	 ( ;J'	??9%%    T c                 p   |r|D ]  \  }}| j                  ||      }  t        | t              st        | dd      } t        j                  t        |       } t        j                  |       } t        | t              st        | dd      } |rt        j                  d |       } |r	 t        j                  d |       } |r	 t        j                  d |       } t        j                  d|       } t        j                  dk  r| j!                  dd      } |
r| j#                         } t        j                  d	|       } t$        j                  d	|       } |
r|	xs t&        }n
|	xs t(        }t+        j
                  |t        |       } t,        j                  t        |       j/                  t              } |r|
rE|D cg c]  }|j#                          }}| j1                  t              D cg c]	  }||vs| }}n'| j1                  t              D cg c]	  }||vs| }}t        j3                  |      } |r|D ]  \  }}| j                  ||      }  |d
kD  rt5        | ||t        |      } |t        k7  r| j                  t        |      } | S # t        $ r Y w xY w# t        $ r Y w xY wc c}w c c}w c c}w )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                 D    t        t        | j                  d               S N   )unichrr   groupms    r   <lambda>zslugify.<locals>.<lambda>v   s    qwwqz8R1Sr   c                 H    t        t        | j                  d                  S r   r   intr   r    s    r   r"   zslugify.<locals>.<lambda>{   s    AGGAJ1Hr   c                 J    t        t        | j                  d      d            S )Nr      r$   r    s    r   r"   zslugify.<locals>.<lambda>   s    VC
B4G-Hr   NFKD)   asciir	   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encodelowerNUMBERS_PATTERNALLOWED_CHARS_PATTERN$ALLOWED_CHARS_PATTERN_WITH_UPPERCASEreDUPLICATE_DASH_PATTERNr
   r   joinr   )textentitiesdecimalhexadecimalr   r   r   r   	stopwordsregex_pattern	lowercasereplacementsoldnewpatternsstopwords_lowerwwordss                      r   r   r   M   s   * $HC<<S)D % dM*gx0 .5D t$D dM*gx0 "&&'SUYZ 	"&&'H$OD
 	??#H$OD
   .D
${{7H- zz| R&D r4(D 8#8G#G66',d3D "%%&7>DDEVWD 2;<)Qqwwy)O< $

+< =Z =1/AYQ =EZ $

+< =T =1)ASQ =ET %%e, $HC<<S)D % A~dJ?PR\]%%||-y9Kq  		  		> =ZTsB   $J	 >J 5J)%	J./J.	J3J3		JJ	J&%J&)r   F F)r@   r7   typesr9   htmlentitydefsr   unicoder.   UnicodeTyper-   ImportErrorhtml.entitiesstrchrr   text_unidecoder2   __all__compilerB   r3   r4   r6   r/   r>   r?   rA   r=   r1   r   r   r   r   r   <module>r^      s<   	   
-H%%M& &
' !bjjSXXn-E!EF "**[)bjj-.

8$"

>2 '1rzz2C'D $#H- "**./ '&T  4A]b'ERW[gkgG  ,HMF	  s"   C' C> 'C;:C;>	D
	D
