
    Cj(                    L   % S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  S	rS
\S'    \R"                  " \S5      R#                  SS5      rS
\S'    SrS
\S'    \" S\ \ S35      rS\S'    \" S5      rS\S'    SS jr " S S5      r\" S5      rSS jrg)aO  Provides a utility function and class for creating Markdown-friendly slugs.

The approach to creating slugs is designed to be as close to
GitHub-flavoured Markdown as possible. However, because there doesn't appear
to be any actual documentation for this 'standard', the code here involves
some guesswork and also some pragmatic shortcuts.

Expect this to grow over time.

The main rules used in here at the moment are:

1. Strip all leading and trailing whitespace.
2. Remove all non-lingual characters (emoji, etc).
3. Remove all punctuation and whitespace apart from dash and underscore.
    )annotations)defaultdict)compile)punctuation)Pattern)quote)Final-z
Final[str]WHITESPACE_REPLACEMENT _	REMOVABLEz\U000024C2-\U0001F251\U00002702-\U000027B0\U0001F1E0-\U0001F1FF\U0001F300-\U0001F5FF\U0001F600-\U0001F64F\U0001F680-\U0001F6FF\U0001F900-\U0001F9FF\u200D\u2640-\u2642
NONLINGUAL[z]+zFinal[Pattern]STRIP_REz\sWHITESPACE_REc                    U R                  5       R                  5       n[        S4[        [        44 H  u  p#UR                  X15      nM     [        U5      $ )zCreate a Markdown-friendly slug from the given text.

Args:
    text: The text to generate a slug from.

Returns:
    A slug for the given text.

The rules used in generating the slug are based on observations of how
GitHub-flavoured Markdown works.
r   )striplowerr   r   r   subr   )textresultrulereplacements       _/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/_slug.pyslugr   5   sS     ZZ\!F	2	./ +.	
 =    c                  ,    \ rS rSrSrSS jrSS jrSrg)	TrackedSlugsJ   av  Provides a class for generating tracked slugs.

While [`slug`][textual._slug.slug] will generate a slug for a given
string, it does not guarantee that it is unique for a given context. If
you want to ensure that the same string generates unique slugs (perhaps
heading slugs within a Markdown document, as an example), use an
instance of this class to generate them.

Example:
    ```python
    >>> slug("hello world")
    'hello-world'
    >>> slug("hello world")
    'hello-world'
    >>> unique = TrackedSlugs()
    >>> unique.slug("hello world")
    'hello-world'
    >>> unique.slug("hello world")
    'hello-world-1'
    ```
c                ,    [        [        5      U l        g)z#Initialise the tracked slug object.N)r   int_used)selfs    r   __init__TrackedSlugs.__init__a   s    ,7,<
Lr   c                    [        U5      nU R                  U   nU R                  U==   S-  ss'   U(       a  U SU 3nU$ )zCreate a Markdown-friendly unique slug from the given text.

Args:
    text: The text to generate a slug from.

Returns:
    A slug for the given text.
   r
   )r   r#   )r$   r   sluggeduseds       r   r   TrackedSlugs.slugf   sG     t*zz'"

7q  	4&)Gr   )r#   N)returnNoner   strr,   r/   )__name__
__module____qualname____firstlineno____doc__r%   r   __static_attributes__ r   r   r   r   J   s    ,M
r   r   z%abcdefghijklmnopqrstuvwxyz0123456789-c                   ^ [         R                  mSR                  U4S jU R                  5       R	                  SS5       5       5      nU(       d  gUS   R                  5       (       a  SU 3$ U$ )zProduce a slug usable as a TCSS id from the given text.

Args:
    text: Text.

Returns:
    A slugified version of text suitable for use as a TCSS id.
r   c              3  v   >#    U  H.  nT" U5      (       a  UOS R                  [        U5      5      v   M0     g7f)z{:x}N)formatord).0	characteris_valids     r   	<genexpr>#slug_for_tcss_id.<locals>.<genexpr>   s4      :I y))v}}S^/L	L:s   69 r
   r   r   )VALID_ID_CHARACTERS__contains__joincasefoldreplace	isdecimal)r   r   r=   s     @r   slug_for_tcss_idrG   z   sj     #//H77 00c: D Aw4&zKr   Nr.   )r4   
__future__r   collectionsr   rer   stringr   typingr   urllib.parser   typing_extensionsr	   r   __annotations__rE   r   r   r   r   r   r   	frozensetrA   rG   r6   r   r   <module>rQ      s     # #     #%( 
 ( ;#++,BBGOOPSUWX	: X E J 
 _"Qyk*R#@A. A Q '~ . \** *Z   GH r   