
    ,ji|                        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 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 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 S\5      r S\SSSS\RB                  SS4	S\"S\\"   S\"S\"S\\   S \\\"\4      S!\#S"\#S#\S$\S%\\   S&\S'\4S( jjr$g))    )Any)Callable)Dict)Iterable)List)Optional)Tuple)Union)CompleteEvent)	Completer)
Completion)Document)HTML)SimpleLexer)CompleteStyle)PromptSession)Style)DEFAULT_QUESTION_PREFIX)build_validator)Question)merge_styles_defaultc                   *   \ rS rSr% \\\   \/ \\   4   4   \S'   \	\S'   \
\\4   \S'   \	\S'      SS\\\   \/ \\   4   4   S\	S\\
\\4      S\	SS4
S	 jjrS\\   4S
 jrS\S\S\4S jr\S\S\S\S\4S j5       rS\S\S\\   4S jrSrg)WordCompleter   choices_sourceignore_casemeta_informationmatch_middleNchoicesreturnc                 H    Xl         X l        U=(       d    0 U l        X@l        g N)r   r   r   r   )selfr   r   r   r   s        Z/home/james-whalen/.local/lib/python3.13/site-packages/questionary/prompts/autocomplete.py__init__WordCompleter.__init__    s#     && 0 6B(    c                 n    [        U R                  5      (       a  U R                  5       $ U R                  $ r"   )callabler   )r#   s    r$   _choicesWordCompleter._choices,   s8     ++,, !	
 $$	
r'   word_before_cursorchoicec                     U R                   (       a  UR                  5       nU R                  (       a  UR                  U5      $ UR	                  U5      (       a  gg)z Match index if found, -1 if not.r   )r   lowerr   find
startswith)r#   r,   r-   s      r$   _choice_matchesWordCompleter._choice_matches3   sI     \\^F;;122122r'   indexc           	          [        S5      R                  U S U XU[        U5      -    X[        U5      -   [        U 5       5      $ )Nz{}<b><u>{}</u></b>{})r   formatlen)r-   r5   r,   s      r$   _display_for_choice!WordCompleter._display_for_choice@   sN    *+226EN53'9#::;3122S[A
 	
r'   documentcomplete_eventc           
   #   n  #    U R                  5       nUR                  nU R                  (       a  UR                  5       nU Hn  nU R	                  XE5      nUS:X  a  M  U R
                  R                  US5      nU R                  XVU5      n[        U[        U5      * UR                  USSS9v   Mp     g 7f)Nr/    class:answerzclass:selected)start_positiondisplaydisplay_metastyleselected_style)r*   text_before_cursorr   r0   r3   r   getr9   r   r8   formatted_text)	r#   r;   r<   r   r,   r-   r5   rB   rA   s	            r$   get_completionsWordCompleter.get_completionsH   s      --/ &88!3!9!9!;F(();DE{0044VR@L..v>PQG #F|..)$/  s   B3B5)r   r   r   r   )TNT)__name__
__module____qualname____firstlineno__r
   r   strr   __annotations__boolr   r   r   r%   r   r*   intr3   staticmethodr   r9   r   r   r   rH   __static_attributes__ r'   r$   r   r      s"   $s)Xb$s)m%<<==38n$
 !59!
)tCy(2tCy="99:
) 
) #4S>2	
)
 
) 

)
(3- 
# s s  
C 
 
 
QU 
 
 2?	*	r'   r   r>   NTmessager   defaultqmark	completerr   r   r   complete_stylevalidaterC   kwargsr    c           	        ^ ^ [        U
/5      nS[        [        [        [        4      4U U4S jjnS[        [
        [        [        4      S[        [
        [        [        4      4S jn[        U	5      nUc$  U(       d  [        S5      e[        UUU" U5      US9n[        U4[        S5      UUUUS.UD6nUR                  R                  [        U5      5        [        UR                   5      $ )	az  Prompt the user to enter a message with autocomplete help.

Example:
    >>> import questionary
    >>> questionary.autocomplete(
    ...    'Choose ant species',
    ...    choices=[
    ...         'Camponotus pennsylvanicus',
    ...         'Linepithema humile',
    ...         'Eciton burchellii',
    ...         "Atta colombica",
    ...         'Polyergus lucidus',
    ...         'Polyergus rufescens',
    ...    ]).ask()
    ? Choose ant species Atta colombica
    'Atta colombica'

.. image:: ../images/autocomplete.gif

This is just a really basic example, the prompt can be customised using the
parameters.


Args:
    message: Question text

    choices: Items shown in the selection, this contains items as strings

    default: Default return value (single value).

    qmark: Question prefix displayed in front of the question.
           By default this is a ``?``

    completer: A prompt_toolkit :class:`prompt_toolkit.completion.Completion`
               implementation. If not set, a questionary completer implementation
               will be used.

    meta_information: A dictionary with information/anything about choices.

    ignore_case: If true autocomplete would ignore case.

    match_middle: If true autocomplete would search in every string position
                  not only in string begin.

    complete_style: How autocomplete menu would be shown, it could be ``COLUMN``
                    ``MULTI_COLUMN`` or ``READLINE_LIKE`` from
                    :class:`prompt_toolkit.shortcuts.CompleteStyle`.

    validate: Require the entered value to pass a validation. The
              value can not be submitted until the validator accepts
              it (e.g. to check minimum password length).

              This can either be a function accepting the input and
              returning a boolean, or an class reference to a
              subclass of the prompt toolkit Validator class.

    style: A custom color and style for the question parts. You can
           configure colors as well as font types for different elements.

Returns:
    :class:`Question`: Question instance, ready to be prompted (using ``.ask()``).
r    c                  2   > ST4SSR                  T 5      4/$ )Nzclass:qmarkzclass:questionz {} )r7   )rU   rW   s   r$   get_prompt_tokens'autocomplete.<locals>.get_prompt_tokens   s"    &)96==;Q(RSSr'   metac                 b    U (       a'  U  H!  n[        S5      R                  X   5      X'   M#     U $ )Nz<text>{}</text>)r   r7   )r`   keys     r$   get_meta_style$autocomplete.<locals>.get_meta_style   s0     !23::49E	  r'   z2No choices is given, you should use Text question.)r   r   r   r?   )lexerrC   rX   	validatorrY   )r   r   r	   rN   r   r   r   r   
ValueErrorr   r   r   default_bufferresetr   r   app)rU   r   rV   rW   rX   r   r   r   rY   rZ   rC   r[   merged_styler^   rc   rf   ps   `  `             r$   autocompleterm   f   s    X (0LTtE#s(O4 T TXd38n5 (4S>:R   )IQRR!#+,<=%	
	 %.)% A 8G,-AEE?r'   )%typingr   r   r   r   r   r   r	   r
   prompt_toolkit.completionr   r   r   prompt_toolkit.documentr   prompt_toolkit.formatted_textr   prompt_toolkit.lexersr   prompt_toolkit.shortcuts.promptr   r   prompt_toolkit.stylesr   questionary.constantsr   questionary.prompts.commonr   questionary.questionr   questionary.stylesr   r   COLUMNrN   rP   rm   rT   r'   r$   <module>rz      s!           3 / 0 , . - 9 9 ' 9 6 ) 3II I^ (%)15$1$8$8!pp#Yp p 	p
 	"p tCH~.p p p "p p E?p p pr'   