
    jOZ                        S SK r S SKrS SKrS SKrS SKJrJr  SSKJr  SSK	J
r
  SrSr\R                  " S5      r\" S	S
15      r\" 1 Sk5      r\" 1 Sk5      r\" 1 Sk5      r\" SS15      r\" 1 Sk5      r\" SS15      r\" \" S5      \" S5      15      r\" \" S	5      \" S5      15      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS\S\4S jr S\!S\!S\"4S jr#S \!S\$4S! jr%S \S\!4S" jr&S#\\$\!4   S\"4S$ jr'S%\\$\!4   S&\"S\"4S' jr(S;S#\!S(\"S\"4S) jjr)S#\!S\"4S* jr*S#\!S\"4S+ jr+S#\!SS4S, jr,S#\!S-\S\"4S. jr-S;S#\!S-\S/\"S\"4S0 jjr.S#\\!\$\/4   SS4S1 jr0S#\!S\$4S2 jr1S#\\!\$\/4   S\!4S3 jr2S<S%\!S4\"S5\"S\!4S6 jjr3    S=S \\!\$\/4   S7\"S8\"S4\"S5\"S\$4S9 jjr4   S>S \\!\$\/4   S7\"S8\"S4\"S\!4
S: jjr5g)?    N)OptionalUnion   )idnadata)intranges_contain	   s   xn--u   [.。．｡]RAL>   r	   r
   AN>
   r	   r
   r   BNCSENESETONNSM>   r	   r
   r   r   r   r   >   Lr   r   r   r   r   r   r   r   Dc                       \ rS rSrSrSrg)	IDNAError   z5Base exception for all IDNA-encoding related problems N__name__
__module____qualname____firstlineno____doc____static_attributes__r       F/var/www/reloj-farallon/venv/lib/python3.13/site-packages/idna/core.pyr   r      s    ?r    r   c                       \ rS rSrSrSrg)IDNABidiError!   z;Exception when bidirectional requirements are not satisfiedr   Nr   r   r    r!   r#   r#   !   s    Er    r#   c                       \ rS rSrSrSrg)InvalidCodepoint'   z<Exception when a disallowed or unallocated codepoint is usedr   Nr   r   r    r!   r&   r&   '   s    Fr    r&   c                       \ rS rSrSrSrg)InvalidCodepointContext-   zCException when the codepoint is not valid in the context it is usedr   Nr   r   r    r!   r)   r)   -   s    Mr    r)   cpreturnc                     [         R                  " [        U 5      5      nUS:X  a/  [         R                  " [        U 5      5      (       d  [	        S5      eU$ )Nr   z Unknown character in unicodedata)unicodedata	combiningchrname
ValueError)r+   vs     r!   _combining_classr4   3   sB    c"g&AAvk&&s2w//;<<Hr    scriptc                 N    [        [        U 5      [        R                  U   5      $ )N)r   ordr   scripts)r+   r5   s     r!   
_is_scriptr9   :   s    SWh&6&6v&>??r    sc                 $    U R                  S5      $ )Npunycode)encoder:   s    r!   	_punycoder?   >   s    88Jr    c                     SU S 3$ )NzU+04Xr   r>   s    r!   _unotrB   B   s    #w<r    labelc                     [        U 5      S:*  $ )u  Check that a label does not exceed the maximum permitted length.

Per :rfc:`1035` (and :rfc:`5891` §4.2.4) a DNS label must not exceed
63 octets. The argument may be either a :class:`str` (a U-label, where
length is measured in characters) or :class:`bytes` (an A-label, where
length is measured in octets).

:param label: The label to check.
:returns: ``True`` if the label is within the length limit, otherwise
    ``False``.
?   lenrC   s    r!   valid_label_lengthrI   F   s     u:r    domaintrailing_dotc                 4    [        U 5      U(       a  S:*  $ S:*  $ )a  Check that a full domain name does not exceed the maximum length.

Per :rfc:`1035`, a domain name is limited to 253 octets when no trailing
dot is present, or 254 octets when one is included.

:param domain: The full (possibly multi-label) domain name.
:param trailing_dot: ``True`` if ``domain`` includes a trailing ``.``.
:returns: ``True`` if the domain is within the length limit, otherwise
    ``False``.
      rF   )rJ   rK   s     r!   valid_string_lengthrO   U   s     v;,388C88r    	check_ltrc                    Sn[        U S5       HI  u  p4[        R                  " U5      nUS:X  a  [        S[	        U 5       SU 35      eU[
        ;   d  MG  SnMK     U(       d  U(       d  g[        R                  " U S   5      nU[        ;   a  SnO!US:X  a  SnO[        S	[	        U 5       S
35      eSnSn[        U S5       H  u  p4[        R                  " U5      nU(       aW  U[        ;  a  [        SU S35      eU[        ;   a  SnOUS:w  a  SnU[        ;   a  U(       d  UnMe  X:w  a  [        S5      eMw  My  U[        ;  a  [        SU S35      eU[        ;   a  SnM  US:w  d  M  SnM     U(       d  [        S5      eg)a  Validate the Bidi Rule from :rfc:`5893` for a single label.

The Bidi Rule constrains how bidirectional characters (Hebrew, Arabic,
etc.) may appear within a label. By default the check is only applied
when the label contains at least one right-to-left character (Unicode
bidirectional categories ``R``, ``AL``, or ``AN``); set ``check_ltr``
to ``True`` to apply it to LTR-only labels as well.

:param label: The label to validate, as a Unicode string.
:param check_ltr: If ``True``, apply the rules even when the label
    contains no RTL characters.
:returns: ``True`` if the label satisfies the Bidi Rule.
:raises IDNABidiError: If any of Bidi Rule conditions 1-6 are violated,
    or if the directional category of a codepoint cannot be determined.
Fr    z Unknown directionality in label  at position Tr   r   zFirst codepoint in label z" must be directionality L, R or ALNz,Invalid direction for codepoint at position z in a right-to-left labelr   z2Can not mix numeral types in a right-to-left labelz in a left-to-right labelz0Label ends with illegal codepoint directionality)	enumerater.   bidirectionalr#   repr_bidi_rtl_categories_bidi_rtl_first_bidi_rtl_allowed_bidi_rtl_valid_ending_bidi_rtl_numeric_bidi_ltr_allowed_bidi_ltr_valid_ending)	rC   rP   
bidi_labelidxr+   	directionrtlvalid_endingnumber_types	            r!   
check_bidird   c   s   " JUA&--b1	?"B4;-}]`\a bcc,,J ' i ))%(3IO#	c	7U}DfghhL!%KUA&--b1	 11#&RSVRWWp$qrr22#e#$--""+K"/+,`aa 0	 .  11#&RSVRWWp$qrr22#e#$7 ': NOOr    c                 Z    [         R                  " U S   5      S   S:X  a  [        S5      eg)uF  Reject labels that begin with a combining mark.

Per :rfc:`5891` §4.2.3.2 a label must not start with a character of
Unicode general category ``M`` (Mark).

:param label: The label to check.
:returns: ``True`` if the first character is not a combining mark.
:raises IDNAError: If the label begins with a combining character.
r   Mz0Label begins with an illegal combining characterT)r.   categoryr   rH   s    r!   check_initial_combinerrh      s/     E!H%a(C/JKKr    c                 f    U SS S:X  a  [        S5      eU S   S:X  d	  U S   S:X  a  [        S5      eg	)
u  Validate the hyphen restrictions for a label.

Per :rfc:`5891` §4.2.3.1 a label must not start or end with a hyphen
(``U+002D``), and must not have hyphens in both the third and fourth
positions (the prefix reserved for A-labels).

:param label: The label to check.
:returns: ``True`` if the hyphen restrictions are satisfied.
:raises IDNAError: If any of the hyphen restrictions are violated.
      z--z4Label has disallowed hyphens in 3rd and 4th positionr   -z)Label must not start or end with a hyphenT)r   rH   s    r!   check_hyphen_okrn      sC     QqzTNOOQx3%)s*CDDr    c                 P    [         R                  " SU 5      U :w  a  [        S5      eg)zRequire that a label is in Unicode Normalization Form C.

:param label: The label to check.
:raises IDNAError: If ``label`` differs from its NFC normalisation.
NFCz%Label must be in Normalization Form CN)r.   	normalizer   rH   s    r!   	check_nfcrr      s*     UE*e3?@@ 4r    posc                    [        X   5      nUS:X  Ga
  US:  a"  [        [        XS-
     5      5      [        :X  a  gSn[        US-
  SS5       HQ  n[        R
                  " 5       R                  [        X   5      5      nU[        S5      :X  a  MC  U[        ;   a  Sn  O  O   U(       d  gSn[        US-   [        U 5      5       HS  n[        R
                  " 5       R                  [        X   5      5      nU[        S5      :X  a  MC  U[        ;   a  Sn  U$   U$    U$ US:X  a,  US:  =(       a     [        [        XS-
     5      5      [        :H  $ g)	as  Validate the CONTEXTJ rules from :rfc:`5892` Appendix A.

These rules govern the contextual use of the joiner codepoints
``U+200C`` (ZERO WIDTH NON-JOINER, Appendix A.1) and ``U+200D``
(ZERO WIDTH JOINER, Appendix A.2) within a label.

:param label: The label containing the codepoint.
:param pos: Index of the joiner codepoint within ``label``.
:returns: ``True`` if the codepoint at ``pos`` satisfies its CONTEXTJ
    rule, ``False`` otherwise (including when the codepoint at
    ``pos`` is not a recognised joiner).
:raises ValueError: If an adjacent codepoint has no Unicode name when
    determining its combining class.
i   r   r   TFrm   Ti   )
r7   r4   _virama_combining_classranger   joining_typesget_bidi_joiner_l_or_drG   _bidi_joiner_r_or_d)rC   rs   cp_valueokijoining_types         r!   valid_contextjr      sH    5:H67'E'N(;<@WWsQwB'A#11377EHFLs3x'!44 ( sQwE
+A#11377EHFLs3x'!44 	 	 , 	6Qw[+CAg,?@D[[[ r    	exceptionc                    [        X   5      nUS:X  aU  SUs=:  =(       a    [        U 5      S-
  :  Os  =(       a-    [        XS-
     5      S:H  =(       a    [        XS-      5      S:H  $ US:X  a3  U[        U 5      S-
  :  a   [        U 5      S:  a  [        XS-      S5      $ gUS:X  d  US	:X  a  US:  a  [        XS-
     S
5      $ gUS:X  aG  U  H@  nUS:X  a  M  [        US5      (       d$  [        US5      (       d  [        US5      (       d  M@    g   gSUs=::  a  S::  a  O  O[        S U  5       5      (       + $ SUs=::  a  S::  a  O  g[        S U  5       5      (       + $ g)ac  Validate the CONTEXTO rules from :rfc:`5892` Appendix A.

Covers the contextual rules for codepoints such as MIDDLE DOT
(``U+00B7``), Greek lower numeral sign, Hebrew punctuation, Katakana
middle dot, and the Arabic-Indic / Extended Arabic-Indic digit ranges.

:param label: The label containing the codepoint.
:param pos: Index of the codepoint within ``label``.
:param exception: Reserved for forward compatibility; currently unused.
:returns: ``True`` if the codepoint at ``pos`` satisfies its CONTEXTO
    rule, ``False`` otherwise (including when the codepoint is not a
    recognised CONTEXTO codepoint).
   r   r   l   iu  GreekFi  i  Hebrewi0  u   ・HiraganaKatakanaHanT`  i  c              3   ^   #    U  H#  nS [        U5      s=:*  =(       a    S:*  Os  v   M%     g7f)    Nr7   .0r+   s     r!   	<genexpr>!valid_contexto.<locals>.<genexpr>4  $     BEbuB11611E   +-r   r   c              3   ^   #    U  H#  nS [        U5      s=:*  =(       a    S:*  Os  v   M%     g7f)r   r   Nr   r   s     r!   r   r   7  r   r   )r7   rG   r9   any)rC   rs   r   r|   r+   s        r!   valid_contextor     s\    5:H63''Ua'kCAg,?6,IkcRW^_X_R`NaekNkk	V	UaCJNe!Gng66	V	x617e!Gnh77	V	BX~"j))ZJ-G-G:VXZ_K`K`	 
 	(	#e	#BEBBBB	(	#e	#  BEBBBBr    c                    [        U [        [        45      (       a  U R                  S5      n [	        U 5      S:X  a  [        S5      e[        U SS9(       d  [        S5      e[        U 5        [        U 5        [        U 5        [        U 5       GH  u  p[        U5      n[        U[        R                  S   5      (       a  M5  [        U[        R                  S   5      (       a<   [        X5      (       d)  [!        S	[#        U5       S
US-    S[%        U 5       35      eM  [        U[        R                  S   5      (       a;  [)        X5      (       d)  [!        S[#        U5       S
US-    S[%        U 5       35      eM  [+        S[#        U5       SUS-    S[%        U 5       S35      e   [-        U 5        g! [&         a/  n[        S[#        U5       SUS-    S[%        U 5       35      UeSnAff = f)a   Run the full set of IDNA 2008 validity checks on a single label.

Applies, in order: NFC normalisation (:func:`check_nfc`), hyphen
restrictions (:func:`check_hyphen_ok`), the no-leading-combiner rule
(:func:`check_initial_combiner`), per-codepoint validity (PVALID,
CONTEXTJ, CONTEXTO classes from :rfc:`5892`), and the Bidi Rule
(:func:`check_bidi`).

:param label: The label to validate. ``bytes`` or ``bytearray`` input
    is decoded as UTF-8 first.
:raises IDNAError: If the label is empty or fails a structural rule.
:raises InvalidCodepoint: If the label contains a DISALLOWED or
    UNASSIGNED codepoint.
:raises InvalidCodepointContext: If a CONTEXTJ or CONTEXTO codepoint
    is not valid in its context.
:raises IDNABidiError: If the Bidi Rule is violated.
zutf-8r   zEmpty LabelTrK   Label too longPVALIDCONTEXTJzJoiner  not allowed at position r    in z%Unknown codepoint adjacent to joiner rS   NCONTEXTO
Codepoint z of z not allowed)
isinstancebytes	bytearraydecoderG   r   rO   rr   rn   rh   rT   r7   r   r   codepoint_classesr   r)   rB   rV   r2   r   r&   rd   )rC   rs   r+   r|   errs        r!   check_labelr   <  s   $ %%+,,W%
5zQ&& u48())eE5!U#r7Xx'A'A('KLLx)C)CJ)OPP%e111!%/!22KCRSG9TXY]^cYdXef  2 x)C)CJ)OPP!%--- x 11J3QR7)SWX\]bXcWde  .
 #Zh/@cTUgYVZ[_`e[fZggs#tuu) $, u  ;E(O;LMZ]`aZaYbbfgklqgrfsts   %9F55
G.?*G))G.c                 
    U R                  S5      n[        U5        [        U5      (       d  [        S5      eU$ ! [         a     Of = f[        U 5        [        [        U 5      -   n[        U5      (       d  [        S5      eU$ )u  Convert a single U-label into its A-label form.

The result is the ASCII-Compatible Encoding (ACE) form per :rfc:`5891`
§4: the label is validated, Punycode-encoded, and prefixed with
``xn--``. Pure ASCII labels that are already valid IDNA labels are
returned unchanged (as :class:`bytes`).

:param label: The label to convert, as a Unicode string.
:returns: The A-label as ASCII-encoded :class:`bytes`.
:raises IDNAError: If the label is invalid or the resulting A-label
    exceeds 63 octets.
asciir   )r=   ulabelrI   r   UnicodeEncodeErrorr   _alabel_prefixr?   )rC   label_bytess     r!   alabelr   u  s    ll7+{!+..,--   9U#33Kk**())s   8; 
AAc                 @   [        U [        [        45      (       d   U R                  S5      nO[        U 5      nUR                  5       nUR                  [        5      (       aF  U[        [        5      S nU(       d  [        S5      eUR                  S5      (       a  [        S5      eO[        U5        UR                  S5      $  UR                  S5      n [        U 5        U $ ! [         a    [        U 5        U s $ f = f! [         a  n[        S5      UeSnAff = f)a  Convert a single A-label into its U-label form.

Performs the inverse of :func:`alabel`: an ``xn--``-prefixed label is
Punycode-decoded and validated. Labels that are already Unicode (or
plain ASCII without the ACE prefix) are validated and returned as a
Unicode string.

:param label: The label to convert. ``bytes`` or ``bytearray`` input
    is treated as ASCII.
:returns: The U-label as a Unicode string.
:raises IDNAError: If the label is malformed or fails validation.
r   Nz5Malformed A-label, no Punycode eligible content found   -z"A-label must not end with a hyphenr<   zInvalid A-label)r   r   r   r=   r   r   lower
startswithr   rG   r   endswithr   UnicodeError)rC   r   r   s      r!   r   r     s    eeY/00	,,w/K
 El##%Kn--!#n"5"78STT%%@AA & 	K !!'**4"":. L- " 	L	&  4)*34s)   C% D %C?>C?
DDD
std3_rulestransitionalc                    SSK J n  Sn[        U 5       GH!  u  pV[        U5      nX7S:  a  UO[        R                  " X7S45      S-
     nUS   n	Sn
[        U5      S:X  a  US   n
U	S	:H  =(       d8    U	S
:H  =(       a    U(       + =(       d    U	S:H  =(       a    U(       + =(       a    U
SL nU
SL=(       a4    U	S:H  =(       d(    U	S:H  =(       a    U(       + =(       d    U	S
:H  =(       a    UnU(       a  XF-  nM  U(       a  U
c   eXJ-  nM  U	S:X  a  M  [        S[        U5       SUS-    S[        U 5       35      e   [        R                  " SU5      $ )ur  Apply the UTS #46 character mapping to a domain string.

Implements the mapping table from `UTS #46 §4
<https://www.unicode.org/reports/tr46/>`_: each character is kept,
replaced, or rejected based on its status (``V``, ``M``, ``D``, ``3``,
``I``). The result is returned in Normalisation Form C.

:param domain: The full domain name to remap.
:param std3_rules: If ``True``, apply the stricter STD3 ASCII rules
    (status ``3`` codepoints raise instead of being kept or mapped).
:param transitional: If ``True``, use transitional processing (status
    ``D`` codepoints are mapped instead of kept). Transitional
    processing has been removed from UTS #46 and this option is
    retained only for backwards compatibility.
:returns: The remapped domain, in Normalisation Form C.
:raises InvalidCodepoint: If the domain contains a disallowed
    codepoint under the chosen rules.
r   )	uts46datarR      ZN   rj   Vr   3rf   Ir   r   r   rp   )r   rT   r7   bisectbisect_leftrG   r&   rB   rV   r.   rq   )rJ   r   r   r   outputrs   char
code_pointuts46rowstatusreplacement
keep_as_isuse_replacements                r!   uts46_remapr     sb   & %Fv&	Y
+;ZASAST]lo_pAqtuAuv!%)x=A"1+K
 cMfm@L0@fPSmF~\fXfF~kvz~k~ 	
 &T1 
cMcfm>JcFcMDbVb 	 NF***!Fs]"Zj0A/BB[\_bc\c[ddhimntiuhv#wxx7 ':   //r    strictuts46c                    U(       a  [         R                  " S[        SS9  [        U [        5      (       d   [	        U S5      n U(       a  [        XU5      n [        U SS9(       d  [        S	5      eS
n/ nU(       a  U R                  S5      O[        R                  U 5      nU(       a  US/:X  a  [        S5      eUS   S:X  a  US	 SnU H1  n	[        U	5      n U (       a  UR                  U 5        M(  [        S5      e   U(       a  UR                  S5        SR                  U5      n [        X5      (       d  [        S	5      eU $ ! [
        [        4 a  n[        S5      UeSnAff = f)a  Encode a Unicode domain name into its ASCII (A-label) form.

Splits the input on label separators (only ``U+002E`` if ``strict`` is
set; otherwise also IDEOGRAPHIC FULL STOP ``U+3002``, FULLWIDTH FULL
STOP ``U+FF0E``, and HALFWIDTH IDEOGRAPHIC FULL STOP ``U+FF61``),
encodes each label with :func:`alabel`, and rejoins them with ``.``.
Optionally pre-processes the input through :func:`uts46_remap`.

:param s: The domain name to encode.
:param strict: If ``True``, only ``U+002E`` is recognised as a label
    separator.
:param uts46: If ``True``, apply UTS #46 mapping before encoding.
:param std3_rules: Forwarded to :func:`uts46_remap` when ``uts46`` is
    ``True``.
:param transitional: Forwarded to :func:`uts46_remap` when ``uts46``
    is ``True``. Deprecated: emits a :class:`DeprecationWarning` and
    will be removed in a future version.
:returns: The encoded domain as ASCII :class:`bytes`.
:raises IDNAError: If the domain is empty, contains an invalid label,
    or exceeds the maximum domain length.
zuTransitional processing has been removed from UTS #46. The transitional argument will be removed in a future version.rj   )
stacklevelr   zGshould pass a unicode string to the function rather than a byte string.NTr   Domain too longF.rR   Empty domainrm   Empty labelr       .)warningswarnDeprecationWarningr   strUnicodeDecodeError	TypeErrorr   r   rO   split_unicode_dots_rer   appendjoin)
r:   r   r   r   r   r   rK   resultlabelsrC   s
             r!   r=   r=     sM   8 M		
 a	pAwA |4 qt4)**LF#QWWS\)9)?)?)BFVt^''bzR2J5MMM!M**  c		&Aq//)**H; #I. 	pefloo	ps   E E'E""E'c                 Z   [        U [        5      (       d   [        U S5      n U(       a  [        XS5      n [        U SS9(       d  [	        S5      eSn/ nU(       a  U R                  S5      O[        R                  U 5      nU(       a  US	/:X  a  [	        S
5      eUS   (       d  US	 SnU H1  n[        U5      n U (       a  UR                  U 5        M(  [	        S5      e   U(       a  UR                  S	5        SR                  U5      $ ! [        [        4 a  n[	        S5      UeSnAff = f)a  Decode an A-label-encoded domain name back to Unicode.

Splits the input on label separators (see :func:`encode` for the
rules), decodes each label with :func:`ulabel`, and rejoins them
with ``.``. Optionally pre-processes the input through
:func:`uts46_remap`.

:param s: The domain name to decode.
:param strict: If ``True``, only ``U+002E`` is recognised as a label
    separator.
:param uts46: If ``True``, apply UTS #46 mapping before decoding.
:param std3_rules: Forwarded to :func:`uts46_remap` when ``uts46`` is
    ``True``.
:returns: The decoded domain as a Unicode string.
:raises IDNAError: If the input is not valid ASCII, contains an
    invalid label, or is empty.
r   zInvalid ASCII in A-labelNFTr   r   r   rR   r   rm   r   )r   r   r   r   r   r   rO   r   r   r   r   r   )	r:   r   r   r   r   rK   r   r   rC   s	            r!   r   r   :  s   . a	AAwA u- qt4)**LF#QWWS\)9)?)?)BFVt^''":2J5MMM!M**  b88F1 #I. 	A67S@	As   D	 	D*D%%D*)F)TF)FFFF)FFF)6r   rer.   r   typingr   r   rR   r   	intrangesr   rv   r   compiler   	frozensetrX   rW   rY   rZ   r[   r\   r]   r7   rz   r{   r   r   r#   r&   r)   intr4   r   boolr9   r   r?   rB   rI   rO   rd   rh   rn   rr   r   r   r   r   r   r   r   r=   r   r   r    r!   <module>r      s@    	   "  ( :::;  S$K( !23 Z[ "#:; tTl+ NO "C;/ S3s8 45 S3s8 45 	 		I 		y 		i 	  @3 @ @ @     S S eE3J/ D 9eSj 1 9 9$ 9Gc Gd Gt GT# $ 3 4 $AS AT A3# 3C 3D 3l+# +C +D +T +\6uS%23 6 6r# % >&%UI-. &3 &R40 40 40D 40UX 40r CS%"#CC C 	C
 C CP 	2S%"#22 2 	2
 	2r    