
    f&              
      v   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZmZmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZ d dlmZ d dlm Z m!Z!m"Z"m#Z#m$Z$ erd dl%m&Z& g dZ'dddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 	 	 ddZ(	 	 	 	 	 	 ddZ)d dZ*d!dZ+d dZ,y)"    )annotations)AbstractEventLoop)TYPE_CHECKINGAnyTextIO)Application)get_app_or_noneget_app_sessionrun_in_terminal)FormattedTextStyleAndTextTuplesto_formatted_text)
DummyInput)Layout)
ColorDepthOutput)create_output)print_formatted_text)	BaseStyleStyleTransformationdefault_pygments_styledefault_ui_stylemerge_styles)AnyContainer)r   print_containerclear	set_titleclear_title 
NFT)	sependfileflushstyleoutputcolor_depthstyle_transformationinclude_default_pygments_stylec        	        $   r|rJ #|rt        |      nt               j                  t        t              sJ xs j                         dd}
g t        |	      D ]H  \  }}j                   |
|             | s |t        |	      dz
  k7  s2j                   |
|              J j                   |
|             dfdd}t               }||j                  }||j                  fd       y         y)	a  
    ::

        print_formatted_text(*values, sep=' ', end='\n', file=None, flush=False, style=None, output=None)

    Print text to stdout. This is supposed to be compatible with Python's print
    function, but supports printing of formatted text. You can pass a
    :class:`~prompt_toolkit.formatted_text.FormattedText`,
    :class:`~prompt_toolkit.formatted_text.HTML` or
    :class:`~prompt_toolkit.formatted_text.ANSI` object to print formatted
    text.

    * Print HTML as follows::

        print_formatted_text(HTML('<i>Some italic text</i> <ansired>This is red!</ansired>'))

        style = Style.from_dict({
            'hello': '#ff0066',
            'world': '#884444 italic',
        })
        print_formatted_text(HTML('<hello>Hello</hello> <world>world</world>!'), style=style)

    * Print a list of (style_str, text) tuples in the given style to the
      output.  E.g.::

        style = Style.from_dict({
            'hello': '#ff0066',
            'world': '#884444 italic',
        })
        fragments = FormattedText([
            ('class:hello', 'Hello'),
            ('class:world', 'World'),
        ])
        print_formatted_text(fragments, style=style)

    If you want to print a list of Pygments tokens, wrap it in
    :class:`~prompt_toolkit.formatted_text.PygmentsTokens` to do the
    conversion.

    If a prompt_toolkit `Application` is currently running, this will always
    print above the application or prompt (similar to `patch_stdout`). So,
    `print_formatted_text` will erase the current application, print the text,
    and render the application again.

    :param values: Any kind of printable object, or formatted string.
    :param sep: String inserted between values, default a space.
    :param end: String appended after the last value, default a newline.
    :param style: :class:`.Style` instance for the color scheme.
    :param include_default_pygments_style: `bool`. Include the default Pygments
        style when set to `True` (the default).
    Nstdoutc                t    t        | t              rt        | t              st        |        S t        | d      S )NT)auto_convert)
isinstancelistr   r   )vals    Y/var/www/cvtools/html/venv/lib/python3.12/site-packages/prompt_toolkit/shortcuts/utils.pyto_textz%print_formatted_text.<locals>.to_textw   s1     c4 C)G$u.. 488       c                     t        t              sJ t        t                      rj	                          y y )Nr*   )r(   r)   )r0   r   renderer_print_formatted_text_create_merged_styler%   )r(   r%   	fragmentsr*   r'   r&   r)   s   r3   renderz$print_formatted_text.<locals>.render   sJ    &&)))% 6T $!5	
 LLN r5   c                     t               S )Nr   )r<   s   r3   <lambda>z&print_formatted_text.<locals>.<lambda>   s    /&*A r5   )r2   r   returnr   r?   None)r   r
   r'   r0   r   get_default_color_depth	enumerateextendlenr	   loopcall_soon_threadsafe)r"   r#   r$   r%   r&   r'   r(   r)   r*   valuesr4   ivaluerF   appr;   r<   s      ``````      @@r3   r   r   )   s   ~ 4   ~"$/F$&--Fff%%% A!?!?!AK9 If% +5(1Fa'WS\*	+ WS\" & &*D

C
xx!!"ABr5   c           	         |rt        |      }nt               j                  }t        t	        |       |t               t        ||            }	 |j                  d       y# t        $ r Y yw xY w)z
    Print any layout to the output in a non-interactive way.

    Example usage::

        from prompt_toolkit.widgets import Frame, TextArea
        print_container(
            Frame(TextArea(text='Hello world!')))
    r,   )	containerr8   )layoutr'   inputr&   T)	in_threadN)	r   r
   r'   r   r   r   r:   runEOFError)rM   r$   r&   r*   r'   rK   s         r3   r   r      sl     d+ "))(	*l"2P
C$ s   A$ $	A0/A0c                    t               g}|r|j                  t                      | r|j                  |        t        |      S )z7
    Merge user defined style with built-in style.
    )r   appendr   r   )r&   r*   styless      r3   r:   r:      s<      !F%,./er5   c                     t               j                  } | j                          | j                  dd       | j	                          y)z
    Clear the screen.
    r   N)r
   r'   erase_screencursor_gotor%   )r'   s    r3   r   r      s7     %%F

q!
LLNr5   c                N    t               j                  }|j                  |        y)z!
    Set the terminal title.
    N)r
   r'   r   )textr'   s     r3   r   r      s      %%F
Tr5   c                     t        d       y)z"
    Erase the current title.
     N)r    r5   r3   r   r      s     bMr5   )rH   r   r"   strr#   r^   r$   TextIO | Noner%   boolr&   BaseStyle | Noner'   zOutput | Noner(   zColorDepth | Noner)   zStyleTransformation | Noner*   r`   r?   rA   )NNT)
rM   r   r$   r_   r&   ra   r*   r`   r?   rA   )r&   ra   r*   r`   r?   r   r@   )rZ   r^   r?   rA   )-
__future__r   asyncio.eventsr   typingr   r   r   prompt_toolkit.applicationr   "prompt_toolkit.application.currentr	   r
   *prompt_toolkit.application.run_in_terminalr   prompt_toolkit.formatted_textr   r   r   prompt_toolkit.inputr   prompt_toolkit.layoutr   prompt_toolkit.outputr   r   prompt_toolkit.output.defaultsr   prompt_toolkit.rendererr   r9   prompt_toolkit.stylesr   r   r   r   r    prompt_toolkit.layout.containersr   __all__r   r:   r   r   r   r]   r5   r3   <module>rq      sT   " , - - 2 O F 
 , ( 4 8  = " %)7;+/{{	{ 
{ 	{
 { { { #{ 5{ %){ 
{@ "+/	  
    %)	 
 
 F  =A  r5   