
    ,j[                        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y
)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_CONSONANTNc                   |+| j                         r| j                         rt        |       S dk(  rt        nfd}|t        |       n|}d}d}d}d}	d}
d}||k  rr| |   }t	        |      }|dk(  r |
r|dz  }n|dz   |k  rd}
|dz  }nd}
|dz  };|d	k(  r/|dk\  r*|t        t	        | |         t        d
         z  }d}|dz  }o|dkD  r|t        v rTd}|dz
  }|dk\  r8t	        | |         t        v r$|dz  }|dz  }|dk\  rt	        | |         t        v r$|dz  dk(  r2|}	|dz  }t        d   |cxk  rt        d   k  rn n|	t        v r|dz  }|
rt        |t              r|}|}	d}
d}|dz  } ||      }|dk  ry|dkD  r|r|dz  }d}||z  }|}|}	d}
n)|dk\  rt        |t              r|dz  }d}d}
d}n|t        v }
|dz  }||k  rr|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/
    r   c                    t        | d      S )Nautor   )cambiguous_widths    S/home/ubuntu/waydroid_script/venv/lib/python3.12/site-packages/wcwidth/_wcswidth.py<lambda>zwcswidth.<locals>.<lambda>=   s    gaQ`>a     r   Fi      i  z9.0.0i  T)isasciiisprintablelenr   ordr   r   r   r   r	   r   r   r
   )pwcsnunicode_versionr   _wcwidthendtotal_widthidxlast_measured_idxlast_measured_ucslast_was_viramaconjunct_pendingcharucs	ri_beforejws      `             r   wcswidthr/      s   L 	yT\\^(8(8(:4y *Q.w4aHy#d)aCK
C O
)Cy$i &=qq3"'q"'q &=.!38D*+,#G, K !#1HC <--	!G1fT!W1H!HNIFA 1fT!W1H!H q=A%(+%1HC$Q'3G2DQ2GG'>9q x]; # ##O#1HC TNq5q5q #( 1K # ##O!#6H(I1K "#O$!_4OqS )V qr   )Nr   r   )
r   strr    zOptional[int]r!   r0   r   intreturnr1   )__doc__
__future__r   typingr   r"   r   r   
_constantsr	   r
   r   r   r   
table_vs16r   table_graphemer   r/    r   r   <module>r:      sl    4 "   2 2
 , )
 !	C
CC C 	C
 	Cr   