
    Rh%                     B   d dl Z d dlZd dlZd dlmZ  ej
                  d      ZdZdZd Z	d Z
d Z G d	 d
ej                        Z G d dej                        Z G d dej                        Z G d deej"                        Z G d deej$                        Zd Zy)    N)	ucd_3_2_0u   [.。．｡]s   xn--zxn--c                 F   g }| D ]<  }t        j                  |      r|j                  t        j                  |             > dj	                  |      } t        j                  d|       } | D ]  }t        j                  |      st        j                  |      st        j                  |      st        j                  |      sjt        j                  |      sUt        j                  |      s@t        j                  |      s+t        j                  |      st        j                  |      st!        d|z         | D cg c]  }t        j"                  |       }}t%        |      r2t%        d | D              rt!        d      |d   r|d   st!        d      | S c c}w )	N NFKCzInvalid character %rc              3   F   K   | ]  }t        j                  |        y w)N)
stringprepin_table_d2).0xs     %/usr/lib/python3.12/encodings/idna.py	<genexpr>znameprep.<locals>.<genexpr>1   s     8Qz%%a(8s   !zViolation of BIDI requirement 2r   zViolation of BIDI requirement 3)r   in_table_b1appendmap_table_b2joinunicodedata	normalizein_table_c12in_table_c22in_table_c3in_table_c4in_table_c5in_table_c6in_table_c7in_table_c8in_table_c9UnicodeErrorin_table_d1any)labelnewlabelcr   RandALs        r   nameprepr%      sj   H 4!!!$
//23	4
 GGHE !!&%0E  
;""1%""1%!!!$!!!$!!!$!!!$!!!$!!!$!!!$59::
; 277Aj$$Q'7F7
6{ 8%88@AA
 ayr
@AAL# 8s   Fc                    	 | j                  d      } dt        |       cxk  rdk  r| S  t        d      t        d      # t        $ r Y nw xY wt        |       } 	 | j                  d      } dt        |       cxk  rdk  r| S  t        d      t        d      # t        $ r Y nw xY w| j	                  t
              rt        d      | j                  d      } t        | z   } dt        |       cxk  rdk  r| S  t        d      t        d      )Nasciir   @   label empty or too longzLabel starts with ACE prefixpunycode)encodelenr   r%   
startswithsace_prefix
ace_prefix)r!   s    r   ToASCIIr0   <   s/   
6W% s5zBL 455l455   UOE6W%
 s5zBL 455l455   $9:: LL$E E 	3u: 
0
11,0
11s#   A   	AAB 	B%$B%c                    t        |       dkD  rt        d      t        | t              rd}n	 | j	                  d      } d}|st        |       } 	 | j	                  d      } | j                  t              st        | d      S | t        t              d  }|j                  d      }t        |      }t        | d      j                         t        |d      k7  rt        d| |      |S # t        $ r d}Y w xY w# t        $ r t        d      w xY w)	Ni   zlabel way too longTr'   FzInvalid character in IDN labelr*   zIDNA does not round-trip)r,   r   
isinstancebytesr+   r%   r-   r/   strdecoder0   lower)r!   
pure_asciilabel1resultlabel2s        r   	ToUnicoder;   g   s   
5zD /00%
	LL)EJ 	ALL)E J'5'"" 3z?#$F ]]:&F V_F 5'  "c&'&::5ufEE M;  	J	  	A?@@	As   C% C6 %C32C36Dc                       e Zd ZddZddZy)Codecc                 D   |dk7  rt        d|z         |sy	 |j                  d      }|j                  d      }|d d D ]-  }dt        |      cxk  rdk  rt        d	       t        d	       t        |d         dk\  rt        d
      |t        |      fS # t        $ r Y nw xY wt               }t        j                  |      }|r|d   sd}|d= nd}|D ]/  }|r|j                  d       |j                  t        |             1 t        ||z         t        |      fS )Nstrictunsupported error handling     r   r'      .r   r   r(   r)   zlabel too longrB   )
r   r+   splitr,   UnicodeEncodeError	bytearraydotsextendr0   r3   )selfinputerrorsr9   labelsr!   trailing_dots          r   r+   zCodec.encode   sD   X<VCDD	&\\'*F
 \\$'F BCJ++&'@AA ,&'@AAB 6":"$"#3443u:%% " 		 E"&*Lr
L 	*Ed#MM'%.)		*
 VL()3u:55s   B 	B$#B$c                    |dk7  rt        d|z         |syt        |t              st        |      }t        |vr	 |j	                  d      t        |      fS |j                  d      }|rt        |d         dk(  rd}|d= nd	}g }|D ]  }|j                  t        |              dj                  |      |z   t        |      fS # t        $ r Y yw xY w)
Nr?   Unsupported error handling r   r   r'   rC   r   r   .r   )r   r2   r3   r/   r5   r,   UnicodeDecodeErrorrD   r   r;   r   )rI   rJ   rK   rL   rM   r9   r!   s          r   r5   zCodec.decode   s    X<VCDD %'%LEU"||G,c%j88 T"c&*o*Lr
L 	,EMM)E*+	, xx,c%j88 & s   C 	CCN)r?   )__name__
__module____qualname__r+   r5    rB   r   r=   r=      s    #6J 9rB   r=   c                       e Zd Zd Zy)IncrementalEncoderc                 n   |dk7  rt        d|z         |syt        j                  |      }d}|r|d   sd}|d= n	|s|d= |rd}t               }d}|D ]B  }|r|j	                  d       |dz  }|j	                  t        |             |t        |      z  }D ||z  }|t        |      z  }t        |      |fS )	Nr?   r@   rA   rB   r   rC   r      )r   rG   rD   rF   rH   r0   r,   r3   	rI   rJ   rK   finalrL   rM   r9   sizer!   s	            r   _buffer_encodez!IncrementalEncoder._buffer_encode   s    X<VCDDE"":#2J2J#'L 	Ed#	MM'%.)CJD	 	,L!!ft$$rB   N)rS   rT   rU   r^   rV   rB   r   rX   rX      s     %rB   rX   c                       e Zd Zd Zy)IncrementalDecoderc                    |dk7  rt        d|z         |syt        |t              rt        j	                  |      }nt        |d      }|j	                  d      }d}|r|d   sd}|d= n	|s|d= |rd}g }d}|D ]1  }|j                  t        |             |r|d	z  }|t        |      z  }3 dj                  |      |z   }|t        |      z  }||fS )
Nr?   rO   rP   r'   rQ   r   r   r   rZ   )	r   r2   r4   rG   rD   r   r;   r,   r   r[   s	            r   _buffer_decodez!IncrementalDecoder._buffer_decode  s    X<VCDD eS!ZZ&F w'E[[%F":"2J2J#&L 	EMM)E*+	CJD		 &!L0L!!~rB   N)rS   rT   rU   rb   rV   rB   r   r`   r`     s    $rB   r`   c                       e Zd Zy)StreamWriterNrS   rT   rU   rV   rB   r   rd   rd   ,      rB   rd   c                       e Zd Zy)StreamReaderNre   rV   rB   r   rh   rh   /  rf   rB   rh   c            	          t        j                  dt               j                  t               j                  t
        t        t        t              S )Nidna)namer+   r5   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInfor=   r+   r5   rX   r`   rd   rh   rV   rB   r   getregentryrr   4  s6    w~~w~~--!! rB   )r   rerp   r   r   compilerG   r/   r.   r%   r0   r;   r=   BufferedIncrementalEncoderrX   BufferedIncrementalDecoderr`   rd   rh   rr   rV   rB   r   <module>rw      s      0 rzz./ 
,\)2V/fF9FLL F9P!%:: !%F%:: %N	5,, 		5,, 	
	rB   