U e5d��@s�dZddlZdd�Zdd�Zdd�Zd d �Zd d �Zd Zdd�Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�ZGdd�dej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#eej�ZGd$d%�d%eej�Zd&d'�ZdS)(uY Codec for the Punicode encoding, as specified in RFC 3492 Written by Martin v. Löwis. �NcCsPt�}t�}|D]*}t|�dkr0|�t|��q|�|�qt|�}t|�|fS)z 3.1 Basic code point segregation�)� bytearray�set�ord�append�add�sorted�bytes)�str�base�extended�c�r�*/usr/lib64/python3.8/encodings/punycode.py� segregate s  rcCs&d}|D]}t|�|kr|d7}q|S)z@Return the length of str, considering only characters below max.r�)r)r �max�resr rrr� selective_lens   rcCsNt|�}|d7}||krdS||}||kr8|d|fS||kr|d7}qdS)aReturn a pair (index, pos), indicating the next occurrence of char in str. index is the position of the character considering only ordinals up to and including char, and pos is the position in the full string. index/pos is the starting position in the full string.r)�����rN)�len)r �char�index�pos�lr rrr�selective_finds rc Cs�d}g}d}|D]r}d}}t|�}t||�} | d||} t||||�\}}|dkrZq~| ||7} |�| d�|}d} q>|}q|S)�3.2 Insertion unsort codingrrrr)rrrr) r r Zoldchar�resultZoldindexr rrrZcurlen�deltarrr�insertion_unsort0s"  rcCs,d|d|}|dkrdS|dkr(dS|S)N�$r�r)�j�biasrrrr�TFs r$s$abcdefghijklmnopqrstuvwxyz0123456789cCsnt�}d}t||�}||kr2|�t|�t|�S|�t|||d|�||d|}|d7}q dS)�(3.3 Generalized variable-length integersrr rN)rr$r�digitsr )�Nr#rr"�trrr�generate_generalized_integerNs r)cCsX|r|d}n|d}|||7}d}|dkr@|d}|d7}q&|d||d}|S)Ni��ri��#r �&r)r�first�numcharsZ divisionsr#rrr�adapt[s   r/cCsPt�}d}t|�D]4\}}t||�}|�|�t||dk||d�}qt|�S)z3.4 Bias adaptation�Hrr)r� enumerater)�extendr/r )Zbaselen�deltasrr#Zpointsr�srrr�generate_integersjs  r5cCs8t|�\}}t||�}tt|�|�}|r4|d|S|S)N�-)rrr5r)�textr r r3rrr�punycode_encodeus    r8c Csd}d}d}zt||�}Wn0tk rL|dkrs(