~0-/_ d dl mZ d dlZd dlmZ ddlmZ ddlmZm Z ej d ZddZdddZ edk rddlmZ ed Ze d e e dd ed Ze e d e e d dS dS ) )annotationsN)Iterable ) loop_last)cell_len chop_cellsz \s*\S+\s*textstrreturnIterable[tuple[int, int, str]]c # K d}t | | }|R| \ }}| d }|||fV t | | }|PdS dS )zYields each word from the text as a tuple containing (start_index, end_index, word). A "word" in this context may include the actual word and any whitespace to the right. r N)re_wordmatchspangroup)r position word_matchstartendwords v/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/_wrap.pywordsr s HtX..J __&& s""S$]]4-- Twidthintfoldbool list[int]c g }|j }d}t }t | D ]\ }}} || } ||z }|| k }|r| || z }?| |k ro|rTt | | } t | D ]2\ }}|r || |r || } |t | z }3|r || || }|r|r || || }|S )a Given a string of text, and a width (measured in cells), return a list of cell offsets which the string should be split at in order for it to fit within the given width. Args: text: The text to examine. width: The available cell width. fold: If True, words longer than `width` will be folded onto a new line. Returns: A list of indices to break the line at. r r )appendr r rstripr r len)r r r break_positionsr! cell_offset _cell_lenr _endr word_lengthremaining_spaceword_fits_remaining_spacefolded_wordlastlines r divide_liner. s^ "$O #FKI"4[[ . .tTi ..+-$3{$B!$ .99T??*KK U"" 2",T"?"?"?K&/&<&<