o
    c                     @   sH  U d dl Z d dlZd dlmZmZmZmZmZmZ e j	dkr%d dlm
Z
 nd dlm
Z
 ddlmZmZmZ erAddlmZmZmZ g dZe
ed	< d
d eD Ze
ed< ddddddZe
ed< i ejdd ejdd ejdd ejdd ejdd ejdd ejdd ejdd ej dd ej!dd ej"dd ej#dd ej$d d ej%d!d ej&d"d ej'd#d Z(ee)ed$e*f f ed%< G d&d' d'Z+efd(e*d)ee)df d*e*fd+d,Z,efd(e*d)ee)e*f d*e*fd-d.Z-e.d/kr d d0l/mZ e Ze0d1 e1d2D ]Z2e3d3d4e2   e4d5 qdS dS )6    N)TYPE_CHECKINGCallableDictIterableListUnion)      )Final   )ControlCodeControlTypeSegment)ConsoleConsoleOptionsRenderResult)   r	            STRIP_CONTROL_CODESc                 C   s   i | ]}|d qS N ).0
_codepointr   r   E/opt/certbot/lib/python3.10/site-packages/pip/_vendor/rich/control.py
<dictcomp>   s    r   _CONTROL_STRIP_TRANSLATEz\az\bz\vz\fz\rCONTROL_ESCAPEc                   C      dS )Nr   r   r   r   r   <lambda>#       r!   c                   C   r   )Nr   r   r   r   r   r!   $   r"   c                   C   r   )Nz[Hr   r   r   r   r   r!   %   r"   c                   C   r   )Nz[2Jr   r   r   r   r   r!   &   r"   c                   C   r   )Nz[?1049hr   r   r   r   r   r!   '   r"   c                   C   r   )Nz[?1049lr   r   r   r   r   r!   (   r"   c                   C   r   )Nz[?25hr   r   r   r   r   r!   )   r"   c                   C   r   )Nz[?25lr   r   r   r   r   r!   *   r"   c                 C      d|  dS )N[Ar   paramr   r   r   r!   +       c                 C   r$   )Nr%   Br   r'   r   r   r   r!   ,   r)   c                 C   r$   )Nr%   Cr   r'   r   r   r   r!   -   r)   c                 C   r$   )Nr%   Dr   r'   r   r   r   r!   .   r)   c                 C   s   d| d  dS )Nr%   r   Gr   r'   r   r   r   r!   /   s    c                 C   r$   )Nr%   Kr   r'   r   r   r   r!   0   r)   c                 C   s   d|d  d| d  dS )Nr%   r   ;Hr   xyr   r   r   r!   1   s    c                 C   r$   )Nz]0;r    r   )titler   r   r   r!   2   r)   .CONTROL_CODES_FORMATc                   @   s  e Zd ZdZdgZdeeef ddfddZe	d)dd	Z
e	d)d
dZe	d*dededd fddZe	d+dededd fddZe	dededd fddZe	d)ddZe	dedd fddZe	dedd fddZe	dedd fddZdefd d!Z	"	#	$	%		&d,d'd(ZdS )-ControlzA renderable that inserts a control code (non printable but may move cursor).

    Args:
        *codes (str): Positional arguments are either a :class:`~rich.segment.ControlType` enum or a
            tuple of ControlType and an integer parameter
    segmentcodesreturnNc                    s<   dd |D }t  d fdd|D }t|d || _d S )Nc                 S   s    g | ]}t |tr|fn|qS r   )
isinstancer   )r   coder   r   r   
<listcomp>A   s    z$Control.__init__.<locals>.<listcomp> c                 3   s     | ]^}} | | V  qd S r   r   )r   r;   
parameters_format_mapr   r   	<genexpr>E   s    
z#Control.__init__.<locals>.<genexpr>)r5   joinr   r7   )selfr8   control_codesrendered_codesr   r?   r   __init__@   s   zControl.__init__c                 C   
   | t jS )zRing the 'bell'.)r   BELLclsr   r   r   bellJ      
zControl.bellc                 C   rG   )zMove cursor to 'home' position.)r   HOMErI   r   r   r   homeO   rL   zControl.homer   r2   r3   c                    s&   dt t f fdd}| |  }|S )zMove cursor relative to current position.

        Args:
            x (int): X offset.
            y (int): Y offset.

        Returns:
            ~Control: Control object.

        r9   c                  3   sR    t }  r dkr| jn| jt fV  r'dkr| jn| jtfV  d S d S )Nr   )r   CURSOR_FORWARDCURSOR_BACKWARDabsCURSOR_DOWN	CURSOR_UP)controlr1   r   r   	get_codesa   s   
zControl.move.<locals>.get_codes)r   r   )rJ   r2   r3   rU   rT   r   r1   r   moveT   s   
zControl.movec                 C   s:   |r| t j|f|dkrt jnt jt|fS | t j|fS )zMove to the given column, optionally add offset to row.

        Returns:
            x (int): absolute x (column)
            y (int): optional y offset (row)

        Returns:
            ~Control: Control object.
        r   )r   CURSOR_MOVE_TO_COLUMNrR   rS   rQ   rJ   r2   r3   r   r   r   move_to_columnq   s   	zControl.move_to_columnc                 C   s   | t j||fS )zMove cursor to absolute position.

        Args:
            x (int): x offset (column)
            y (int): y offset (row)

        Returns:
            ~Control: Control object.
        )r   CURSOR_MOVE_TOrX   r   r   r   move_to   s   zControl.move_toc                 C   rG   )zClear the screen.)r   CLEARrI   r   r   r   clear   rL   zControl.clearshowc                 C   s   | |rt jS t jS )zShow or hide the cursor.)r   SHOW_CURSORHIDE_CURSOR)rJ   r^   r   r   r   show_cursor   s   zControl.show_cursorenablec                 C   s   |r	| t jt jS | t jS )zEnable or disable alt screen.)r   ENABLE_ALT_SCREENrM   DISABLE_ALT_SCREEN)rJ   rb   r   r   r   
alt_screen   s   
zControl.alt_screenr4   c                 C   s   | t j|fS )zlSet the terminal window title

        Args:
            title (str): The new terminal window title
        )r   SET_WINDOW_TITLE)rJ   r4   r   r   r   r4      s   zControl.titlec                 C   s   | j jS r   r7   text)rC   r   r   r   __str__   s   zControl.__str__consoler   optionsr   r   c                 c   s    | j jr| j V  d S d S r   rg   )rC   rj   rk   r   r   r   __rich_console__   s   zControl.__rich_console__)r9   r6   )r   r   )r   )rj   r   rk   r   r9   r   )__name__
__module____qualname____doc__	__slots__r   r   r   rF   classmethodrK   rN   intrV   rY   r[   r]   boolra   re   strr4   ri   rl   r   r   r   r   r6   6   s<    
r6   rh   _translate_tabler9   c                 C   
   |  |S )zRemove control codes from text.

    Args:
        text (str): A string possibly contain control codes.

    Returns:
        str: String with control codes removed.
    	translaterh   rv   r   r   r   strip_control_codes   s   
r{   c                 C   rw   )a  Replace control codes with their "escaped" equivalent in the given text.
    (e.g. "" becomes "\b")

    Args:
        text (str): A string possibly containing control codes.

    Returns:
        str: String with control codes replaced with their escaped version.
    rx   rz   r   r   r   escape_control_codes   s   
r|   __main__)r   z+Look at the title of your terminal window ^
   u   🚀 Loading.g      ?)5systimetypingr   r   r   r   r   r   version_infor
   pip._vendor.typing_extensionsr7   r   r   r   rj   r   r   r   r   __annotations__r   r   rH   CARRIAGE_RETURNrM   r\   rc   rd   r_   r`   rS   rR   rO   rP   rW   ERASE_IN_LINErZ   rf   r5   rs   ru   r6   r{   r|   rm   pip._vendor.rich.consoleprintrangeiset_window_titlesleepr   r   r   r   <module>   s   
  









	







 





