o
    -˜Žjä  ã                   @   sZ   d dl Z d dlmZ e  d¡Zdd„ Zdd„ Zded	ed
edefdd„Z	ddœdd„Z
dS )é    N)Úunpackz[\U00010000-\U0010FFFF]c                 C   s   t  dd„ | ¡S )Nc                 S   s$   d  dd„ td|  ¡  d¡ƒD ƒ¡S )NÚ c                 s   s   � | ]}t |ƒV  qd S )N)Úchr)Ú.0Úi© r   úR/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/parser/utils.pyÚ	<genexpr>   s   € z3add_surrogates.<locals>.<lambda>.<locals>.<genexpr>z<HHzutf-16le)Újoinr   ÚgroupÚencode)Úmatchr   r   r   Ú<lambda>   s   $z add_surrogates.<locals>.<lambda>)ÚSMP_REÚsub©Útextr   r   r   Úadd_surrogates   s   ýr   c                 C   s   |   dd¡ d¡S )Nzutf-16Úsurrogatepass)r   Údecoder   r   r   r   Úremove_surrogates$   s   r   ÚsourceÚoldÚnewÚstartc                 C   s"   | d |… | |d …   ||d¡ S )Né   )Úreplace)r   r   r   r   r   r   r   Úreplace_once)   s   "r   )Úlengthc                C   sh   |du rt | ƒ}d|  k ot | ƒk n  o3d| |d    ko#dkn  o3d| |   ko1dkS   S )zS
    `True` if ``index`` is within a surrogate (before and after it, not at!).
    Nr   u   í €u   í¯¿u   í¿¿)Úlen)r   Úindexr   r   r   r   Úwithin_surrogate,   s   ÿýýr!   )ÚreÚstructr   Úcompiler   r   r   ÚstrÚintr   r!   r   r   r   r   Ú<module>   s   
	