� ]�g� ����ddlmZmZmZmZmZmZerddlmZddl m Z ddl m Z ddl mZerddlmZdZGd�d ��ZGd �d ��Zd ee d efd�Zd ee ded dfd�Zdeded dfd�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 �f�eZdZdZdededdfd�Zdeedeed edeeeffd �Z dS) �JupyterRenderablez)A shim to write html to Jupyter notebook.�html�text�returnNc�"�||_||_dS)N)rr)�selfrrs �\/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/jupyter.py�__init__zJupyterRenderable.__init__s���� ��� � � ��include�exclude�kwargsc ����|j|jd�}�r �fd�|���D��}�r �fd�|���D��}|S)N�z text/plainz text/htmlc�$��i|] \}}|�v� ||�� S�r��.0�k�vrs �r� <dictcomp>z7JupyterRenderable._repr_mimebundle_.<locals>.<dictcomp>�$���D�D�D�V�a��q�G�|�|�A�q�|�|�|rc�$��i|] \}}|�v� ||�� Srr�r r!r"rs �rr#z7JupyterRenderable._repr_mimebundle_.<locals>.<dictcomp> �)���H�H�H�V�a��q��7G�7G�A�q�7G�7G�7Gr)rr�items)rrrr�datas `` r�_repr_mimebundle_z#JupyterRenderable._repr_mimebundle_sp����#�i�d�i�@�@�� � E�D�D�D�D�t�z�z�|�|�D�D�D�D� � I�H�H�H�H�t�z�z�|�|�H�H�H�D�� r) �__name__� __module__� __qualname__�__doc__�strrrrrr*rrrrrs�������3�3��S������������}��/7��}��HK�� �c�3�h�������rrc �Z�eZdZdZdZdddeedeededeeeff d �Z d S) � JupyterMixinz@Add to an Rich renderable to make it render in Jupyter notebook.rrr rrrrc �P���t��}t|�||j����}t |��}|�|��}||d�}�r �fd�|���D��}�r �fd�|���D��}|S)Nrc�$��i|] \}}|�v� ||�� Srrrs �rr#z2JupyterMixin._repr_mimebundle_.<locals>.<dictcomp>5r$rc�$��i|] \}}|�v� ||�� Srrr&s �rr#z2JupyterMixin._repr_mimebundle_.<locals>.<dictcomp>7r'r)r �list�render�options�_render_segments�_render_bufferr() rrrr�console�segmentsrrr)s `` rr*zJupyterMixin._repr_mimebundle_)s����� �-�-������t�W�_�=�=�>�>����)�)���%�%�h�/�/��"��6�6�� � E�D�D�D�D�t�z�z�|�|�D�D�D�D� � I�H�H�H�H�t�z�z�|�|�H�H�H�D�� rN) r+r,r-r.� __slots__rr/rrr*rrrr1r1$sq������J�J��I��!���#����#���� � �c�3�h�� �����rr1r;rc��dtdtfd�}g}|j}t}tj|��D]X\}}}|r� ||��}|r7|�|��}|r d|�d|�d�n|}|jrd|j�d|�d �}||���Yd �|��} t� | � ��} | S) Nrrc�~�|�dd���dd���dd��S)z Escape html.�&z&amp;�<z&lt;�>z&gt;)�replace)rs r�escapez _render_segments.<locals>.escape<s6���|�|�C��)�)�1�1�#�v�>�>�F�F�s�F�S�S�Srz <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) r;rC� fragments�append_fragment�themer�style�control�rulerErs rr8r8;s��T�S�T�S�T�T�T�T��I��&�O� "�E� '� 0�� :� :� � ���e�W� � � ��v�d�|�|�� � L��'�'��.�.�D�<@�J�8�4�8�8�4�8�8�8�8�d�D��z� L�K�5�:�K�K��K�K�K��������� �7�7�9� � �D� � %� %�4� %� 0� 0�D� �KrrNc��t|��}t||��} ddlm}||��dS#t$rYdSwxYw)zRender segments to Jupyter.r)�displayN)r8r�IPython.displayrT�ModuleNotFoundError)r;rr�jupyter_renderable�ipython_displays rrTrTTsq�� �H� %� %�D�*�4��6�6�� �>�>�>�>�>�>���*�+�+�+�+�+�� � � � � ��� ���s�4� A�A�argsrc�8�t��}|j|i|��S)zProxy for Console print.)r �print)rYrr:s rr[r[bs"���m�m�G� �7�=�$� )�&� )� )�)r)�typingrrrrrr� rich.consoler rDr �segmentr �terminal_themer rKrr1r/r8rTr[rrr�<module>r`s��E�E�E�E�E�E�E�E�E�E�E�E�E�E�E�E��/�.�.�.�.�.�.�������������2�2�2�2�2�2��/�.�.�.�.�.�.��� ��������$��������.�x��0��S�����2  �h�w�'�  �s�  �t�  �  �  �  �*��*��*��*�*�*�*�*�*r
Memory