o
    c                     @   s   d dl mZ ddlmZ ddlmZ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 dd	lmZ G d
d deZedkrxd dlZd dlmZ zejd ZW n ey^   dZY nw e Zeeed e Zejeddd dS dS )    )Union   )AlignMethod)cell_lenset_cell_size)ConsoleConsoleOptionsRenderResult)JupyterMixinMeasurement)Style)Textc                   @   s   e Zd ZdZ	dddddddeeef d	ed
eeef dededdfddZ	defddZ
dededefddZdededefddZdededefddZdS )Ruleu  A console renderable to draw a horizontal rule (line).

    Args:
        title (Union[str, Text], optional): Text to render in the rule. Defaults to "".
        characters (str, optional): Character(s) used to draw the line. Defaults to "─".
        style (StyleType, optional): Style of Rule. Defaults to "rule.line".
        end (str, optional): Character at end of Rule. defaults to "\\n"
        align (str, optional): How to align the title, one of "left", "center", or "right". Defaults to "center".
     u   ─z	rule.line
center)
charactersstyleendaligntitler   r   r   r   returnNc                C   sN   t |dk r
td|dvrtd|d|| _|| _|| _|| _|| _d S )Nr   z:'characters' argument must have a cell width of at least 1)leftr   rightzAinvalid value for align, expected "left", "center", "right" (not ))r   
ValueErrorr   r   r   r   r   )selfr   r   r   r   r    r   B/opt/certbot/lib/python3.10/site-packages/pip/_vendor/rich/rule.py__init__   s   	

zRule.__init__c                 C   s   d| j d| jdS )NzRule(z, r   )r   r   )r   r   r   r   __repr__.   s   zRule.__repr__consoleoptionsc                 c   s2   |j }ttdd pdd }|jr|| jsdn| j}t|}| js+| ||V  d S t| jt	r5| j}n|j
| jdd}|jdd|_|  | jd	krPd
nd}td|| }	|	sd| ||V  d S t	| jd}
| jd	kr|j|	dd |t|j d }t	||| d  }||d  |t|j t|j }t	||| d  }|| |
|jd | j |
| |
d|j | j nH| jdkr|j|	dd |
| |
d |
|||
j  | j n%| jdkr|j|	dd |
|||j d  | j |
d |
| t|
j||
_|
V  d S )Nisasciic                 S   s   t dd | D S )Nc                 s   s    | ]	}t |d k V  qdS )   N)ord).0cr   r   r   	<genexpr>8   s    z:Rule.__rich_console__.<locals>.<lambda>.<locals>.<genexpr>)all)sr   r   r   <lambda>8   s    z'Rule.__rich_console__.<locals>.<lambda>-z	rule.text)r   r    r         r   )r   ellipsis)overflowr   r   r   )	max_widthgetattrstr
ascii_onlyr   r   r   
_rule_line
isinstancer   
render_strplainreplaceexpand_tabsr   maxr   truncateappendr   r   )r   r"   r#   widthr$   r   	chars_len
title_textrequired_spacetruncate_width	rule_text
side_widthr   right_lengthr   r   r   r   __rich_console__1   sb   








zRule.__rich_console__rA   r@   c                 C   s6   t | j|| d  | j}|| t|j||_|S Nr   )r   r   r   r>   r   r:   )r   rA   r@   rE   r   r   r   r7   m   s   
zRule._rule_linec                 C   s
   t ddS rI   r   )r   r"   r#   r   r   r   __rich_measure__s   s   
zRule.__rich_measure__)r   )__name__
__module____qualname____doc__r   r5   r   r   r   r    r!   r   r   r	   rH   intr7   r   rJ   r   r   r   r   r      sJ    



<r   __main__N)r   zHello, World)r   foor/   )r@   )typingr   r   r   cellsr   r   r"   r   r   r	   jupyterr
   measurer   r   r   textr   r   rK   syspip._vendor.rich.consoleargv
IndexErrorprintr   r   r   r   <module>   s,    m