o
    Úó”iK  ã                   @   sú   d dl mZ d dl mZ d dl mZ d dl mZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ ddeddddfdededededee dedee dee dedefdd„ZdS )é    )ÚAny)ÚList)ÚOptional)ÚTuple)ÚDocument)ÚLexer)ÚSimpleLexer)ÚPromptSession)ÚStyle)ÚDEFAULT_QUESTION_PREFIX)ÚINSTRUCTION_MULTILINE)Úbuild_validator)ÚQuestion)Úmerge_styles_defaultÚ NFÚmessageÚdefaultÚvalidateÚqmarkÚstyleÚ	multilineÚinstructionÚlexerÚkwargsÚreturnc                    s„   t |gƒ}	|p
tdƒ}t|ƒ}
ˆ du r|rt‰ dttttf  f‡ ‡‡fdd„}t|f|	|
||dœ|¤Ž}|j 	t
|ƒ¡ t|jƒS )aÏ  Prompt the user to enter a free text message.

    This question type can be used to prompt the user for some text input.

    Example:
        >>> import questionary
        >>> questionary.text("What's your first name?").ask()
        ? What's your first name? Tom
        'Tom'

    .. image:: ../images/text.gif

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

    Args:
        message: Question text.

        default: Default value will be returned if the user just hits
                 enter.

        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.

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

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

        multiline: If ``True``, multiline input will be enabled.

        instruction: Write instructions for the user if needed. If ``None``
                     and ``multiline=True``, some instructions will appear.

        lexer: Supply a valid lexer to style the answer. Leave empty to
               use a simple one by default.

        kwargs: Additional arguments, they will be passed to prompt toolkit.

    Returns:
        :class:`Question`: Question instance, ready to be prompted (using ``.ask()``).
    zclass:answerNr   c                     s2   dˆfdd  ˆ¡fg} ˆ r|  dd  ˆ ¡f¡ | S )Nzclass:qmarkzclass:questionz {} zclass:instruction)ÚformatÚappend)Úresult©r   r   r   © úL/home/ubuntu/.local/lib/python3.10/site-packages/questionary/prompts/text.pyÚget_prompt_tokensU   s   ztext.<locals>.get_prompt_tokens)r   Ú	validatorr   r   )r   r   r   r   r   r   Ústrr	   Údefault_bufferÚresetr   r   Úapp)r   r   r   r   r   r   r   r   r   Úmerged_styler"   r!   Úpr   r   r    Útext   s$   
;"ÿûú
r)   )Útypingr   r   r   r   Úprompt_toolkit.documentr   Úprompt_toolkit.lexersr   r   Úprompt_toolkit.shortcuts.promptr	   Úprompt_toolkit.stylesr
   Úquestionary.constantsr   r   Úquestionary.prompts.commonr   Úquestionary.questionr   Úquestionary.stylesr   r#   Úboolr)   r   r   r   r    Ú<module>   sT    øÿþýüûúùø	÷
ö