� ]�g ����UddlmZddlmZddlmZddlmZgd�Zde d<e d �eD����Z e j Z d e d <ed ��d&d���Zefd'd�Zed ���d(d���Zd)d�Zd*d�Zedkrdeed����edd ��D] Zee���ed!dd"��D]*Zeede��d#z��ed$ez���)d%Sd%S)+�)� annotations)� lru_cache)�Callable�)� CELL_WIDTHS))� �~)��)�i�)ipi�)i%i�%)i(i�(zlist[tuple[int, int]]�_SINGLE_CELL_UNICODE_RANGESc �j�g|]0\}}ttt||dz����D]}|���1S)r)�map�chr�range)�.0�_start�_end� characters �Z/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/cells.py� <listcomp>rs[����� �F�D��S�%���q��"9�"9�:�:��� � �����zCallable[[str], bool]�_is_single_cell_widthsi�text�str�return�intc��t|��rt|��Sttt|����S)a/Get the number of cells required to display text. This method always caches, which may use up a lot of memory. It is recommended to use `cell_len` over this method. Args: text (str): Text to display. Returns: int: Get the number of cells required to display text. )r�len�sumr�get_character_cell_size)rs r�cached_cell_lenr"!s9���d�#�#���4�y�y�� �s�*�D�1�1� 2� 2�2r� _cell_len�Callable[[str], int]c��t|��dkr ||��St|��rt|��Sttt|����S)z�Get the number of cells required to display text. Args: text (str): Text to display. Returns: int: Get the number of cells required to display text. i)rrr rr!)rr#s r�cell_lenr&3sV�� �4�y�y�3����y������d�#�#���4�y�y�� �s�*�D�1�1� 2� 2�2r)�maxsizerc���t|��}t}d}t|��dz }||zdz} ||\}}}||kr|dz }n||kr|dz}n |dkrdn|S||krn ||zdz}�>dS)z�Get the cell size of a character. Args: character (str): A single character. Returns: int: Number of cells (0, 1 or 2) occupied by that character. rr�T�����)�ordrr) r� codepoint�_table� lower_bound� upper_bound�index�start�end�widths rr!r!Cs����I���I� �F��K��f�+�+��/�K� �;� &�1� ,�E� 1�"�5�M���s�E� �u� � ��!�)�K�K� ��_�_��!�)�K�K��� � �1�1�� .� �� $� $� ��{�*�q�0�� 1� �1r�totalc���t|��r*t|��}||kr |d||z zzS|d|�S|dkrdSt|��}||kr|S||kr |d||z zzSd}t|��} ||zdz}|d|dz�}t|��}||dzkr&t|d��dkr |dd�dzS||kr|S||kr|}n|}�g) z?Set the length of a string to fit within given number of cells.� Nr�Tr)rr*)rrr&) rr4�size� cell_sizer1r2�pos�before� before_lens r� set_cell_sizer=`s8���d�#�#���4�y�y�� �%�<�<��#����.�.� .��F�U�F�|�� ��z�z��r�����I��E���� ��5����c�U�Y�.�/�/�/� �E� �d�)�)�C� ��s�{�q� ���i��a��i����f�%�%� � ���� "� "�x��r� �';�';�q�'@�'@��#�2�#�;��$� $� �� � ��M� �� � ��C�C��E� rr3� list[str]c���t}gg}|j}|dj}d}|D]D}||��}||z|k} | r||g��|dj}|}�4||��||z }�Ed�|D��S)ahSplit text into lines such that each line fits within the available (cell) width. Args: text: The text to fold such that it fits in the given width. width: The width available (number of cells). Returns: A list of strings such that each string in the list has cell width less than or equal to the available width. r*rc�8�g|]}d�|����S)r7)�join)r�lines rrzchop_cells.<locals>.<listcomp>�s"�� ,� ,� ,�d�B�G�G�D�M�M� ,� ,� ,r)r!�append) rr3�_get_character_cell_size�lines�append_new_line�append_to_last_line� total_widthr� cell_width�char_doesnt_fits r� chop_cellsrK�s��� 7�� �T�E��l�O���)�*���K�� &� &� �-�-�i�8�8� �%� �2�U�:�� � &� �O�Y�K� (� (� (�"'��)�"2� �$�K�K� � � � *� *� *� �:� %�K�K� ,� ,�e� ,� ,� ,�,r�__main__u😽u]这是对亚洲语言支持的测试。面对模棱两可的想法,拒绝猜测的诱惑。��Pr*�|�xN)rrrr)rrr#r$rr)rrrr)rrr4rrr)rrr3rrr>)� __future__r� functoolsr�typingr� _cell_widthsrr �__annotations__� frozenset� _SINGLE_CELLS� issupersetrr"r&r!r=rK�__name__�printrBr�n�rr�<module>r]s:��"�"�"�"�"�"�"�������������%�%�%�%�%�%�6�6�6������� ���7������ �1>�0H��H�H�H�H� ��4���3�3�3���3�";J� 3� 3� 3� 3� 3�  ��4���� � � ��� �8 � � � �F"-�"-�"-�"-�J �z��� �E� !� !�&� )� )�*�*�*�� �~�AB�C�C���� ��d� � � � � �U�2�q�"� � ���� ��m�m��BC�D�D�GJ�J� K� K� K� ��c�A�g����� ���r
Memory