o �J�h� �@s�ddlmZmZmZmZmZmZerddlmZddl m Z ddl m Z ddl mZer2ddlmZdZGdd �d �ZGd d �d �Zd ee d efdd�Zd ee ded dfdd�Zdeded dfdd�ZdS)�)� TYPE_CHECKING�Any�Dict�Iterable�List�Sequence)�ConsoleRenderable�)� get_console)�Segment)�DEFAULT_TERMINAL_THEMEz�<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">{code}</pre> c @sPeZdZdZdededdfdd�Zdeed eed edeeeffd d �Z dS) �JupyterRenderablez)A shim to write html to Jupyter notebook.�html�text�returnNcCs||_||_dS)N)rr)�selfrr�r�JC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\rich\jupyter.py�__init__s zJupyterRenderable.__init__�include�exclude�kwargsc sF|j|jd�}�r�fdd�|��D�}�r!�fdd�|��D�}|S)N�z text/plainz text/htmlc�i|] \}}|�vr||�qSrr��.0�k�v�rrr� <dictcomp>�z7JupyterRenderable._repr_mimebundle_.<locals>.<dictcomp>c�i|] \}}|�vr||�qSrrr�rrrr r )rr�items)rrrr�datar�rrr�_repr_mimebundle_s z#JupyterRenderable._repr_mimebundle_) �__name__� __module__� __qualname__�__doc__�strrrrrr&rrrrr s��� �r c @sBeZdZdZdZdddeedeededeeeff d d �Z d S) � JupyterMixinz@Add to an Rich renderable to make it render in Jupyter notebook.rrrrrrrc  slt�}t|�||j��}t|�}|�|�}||d�}�r'�fdd�|��D�}�r4�fdd�|��D�}|S)Nrcrrrrrrrr5r z2JupyterMixin._repr_mimebundle_.<locals>.<dictcomp>cr!rrrr"rrr7r )r �list�render�options�_render_segments�_render_bufferr#) rrrr�console�segmentsrrr$rr%rr&)s  zJupyterMixin._repr_mimebundle_N) r'r(r)r*� __slots__rr+rrr&rrrrr,$s���� �r,r3rc Cs�dtdtfdd�}g}|j}t}t�|�D]1\}}}|rq||�}|rB|�|�}|r3d|�d|�d�n|}|jrBd|j�d |�d �}||�qd �|�} tj | d �} | S) NrrcSs|�dd��dd��dd�S)z Escape html.�&z&amp;�<z&lt;�>z&gt;)�replace)rrrr�escape<sz _render_segments.<locals>.escapez <span style="z">z</span>z <a href="z" target="_blank">z</a>�)�code) r+�appendr r �simplify�get_html_style�link�join�JUPYTER_HTML_FORMAT�format) r3r9� fragmentsZappend_fragment�themer�style�control�ruler;rrrrr0;s"    r0rNcCsBt|�}t||�}z ddlm}||�WdSty YdSw)zRender segments to Jupyter.r)�displayN)r0r ZIPython.displayrH�ModuleNotFoundError)r3rrZjupyter_renderableZipython_displayrrrrHTs   �rH�argsrcOst�}|j|i|��S)zProxy for Console print.)r �print)rJrr2rrrrKbsrK)�typingrrrrrr� rich.consolerr:r �segmentr �terminal_themer rAr r,r+r0rHrKrrrr�<module>s      
Memory