
    i[                    ~    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ dd	lmZ 	 	 	 dddZd
S )z.This is a python implementation of wcswidth().    )annotations)Optional   wcwidth)bisearch)_EMOJI_ZWJ_SET_ISC_VIRAMA_SET_CATEGORY_MC_TABLE_FITZPATRICK_RANGE_REGIONAL_INDICATOR_SET)VS16_NARROW_TO_WIDE)ISC_CONSONANTNautopwcsstrnOptional[int]unicode_versionambiguous_widthintreturnc                v   |7|                                  r#|                                 rt          |           S dk    rt          nfd}|t          |           n|}d}d}d}d}	d}
d}||k     r| |         }t	          |          }|dk    r!|
r|dz  }n|dz   |k     rd}
|d	z  }nd}
|dz  }E|d
k    r?|dk    r9|t          t	          | |                   t          d                   z  }d}|dz  }|dk    r|t          v rgd}|dz
  }|dk    rHt	          | |                   t          v r,|dz  }|dz  }|dk    rt	          | |                   t          v ,|d	z  dk    r|}	|dz  }n6t          d         |cxk    rt          d         k    rn n|	t          v r|dz  }6|
r$t          |t                    r|}|}	d}
d}|dz  }\ ||          }|dk     rdS |dk    r|r|dz  }d}||z  }|}|}	d}
n0|dk    r!t          |t                    r|dz  }d}d}
d}n	|t          v }
|dz  }||k     |r|dz  }|S )a  
    Given a unicode string, return its printable length on a terminal.

    See :ref:`Specification` for details of cell measurement.

    This implementation differs from Markus Khun's original POSIX C implementation, in that this
    ``wcswidth()`` processes graphemes strings yielded by :func:`wcwidth.iter_graphemes` defined by
    `Unicode Standard Annex #29`_. POSIX wcswidth(3) is not grapheme-aware and does not measure many
    kinds of Emojis or complex scripts correctly.

    :param pwcs: Measure width of given unicode string.
    :param n: When ``n`` is None (default), return the length of the entire
        string, otherwise only the first ``n`` characters are measured.

    :param unicode_version: Ignored. Retained for backwards compatibility.

        .. deprecated:: 0.3.0
           Only the latest Unicode version is now shipped.

    :param ambiguous_width: Width to use for East Asian Ambiguous (A)
        characters. Default is ``1`` (narrow). Set to ``2`` for CJK contexts.
    :returns: The width, in cells, needed to display the first ``n`` characters
        of the unicode string ``pwcs``.  Returns ``-1`` for C0 and C1 control
        characters!

    .. _`Unicode Standard Annex #29`: https://www.unicode.org/reports/tr29/
    Nr   c                &    t          | d          S )Nr   r   )cr   s    X/home/piyush/.hermes/hermes-agent/venv/lib/python3.11/site-packages/wcwidth/_wcswidth.py<lambda>zwcswidth.<locals>.<lambda>=   s    gaQ`>a>a     r   Fi      i  z9.0.0i  T)isasciiisprintablelenr   ordr   r   r   r   r	   r   r   r
   )r   r   r   r   _wcwidthendtotal_widthidxlast_measured_idxlast_measured_ucslast_was_viramaconjunct_pendingcharucs	ri_beforejws      `             r   wcswidthr3      s9   L 	yT\\^^y(8(8(:(:y4yy *Q..ww4a4a4a4aHy#d)))aCK
C O
))Cy$ii &== qq3"'q"'q &==.!338D*+,,#G,  K !#1HC <<---	!G1ffT!W1H!H!HNIFA 1ffT!W1H!H!H q=A%%(+%1HC & %Q'3GGGG2DQ2GGGGGG'>99q  	x];; 	 # ##O#1HC HTNNq552q55 )q #( 1K # ##OO!##6H(I(I#1K "#O$!_4OqS ))V  qr   )Nr   r   )
r   r   r   r   r   r   r   r   r   r   )__doc__
__future__r   typingr   r&   r   r   
_constantsr	   r
   r   r   r   
table_vs16r   table_graphemer   r3    r   r   <module>r;      s    4 4 " " " " " "                  2 2 2 2 2 2 2 2 2 2 2 2 2 2
 , + + + + + ) ) ) ) ) )
 !	C C C C C C Cr   