
    Ii;              
           S r SSKJr  SSKJr  SSKrSSKJrJr  SSK	J
r
   " S S	5      r\
S
S
S
S.S\S\S\S\4S jj5       rg)zDomain.    )environ)PathN)OptionalSet   )	validatorc                   d    \ rS rSr% SrSr\\\      \	S'   1 Skr
\S 5       r\S\4S j5       rS	rg)
_IanaTLD   z*Read IANA TLDs, and optionally cache them.N_full_cache>
   BRDEFRITJPRUUKCOMNETORGc              #      #    [        [        5      R                  R                  S5      R	                  5        n[        U5      nU H  nUR                  5       v   M     S S S 5        g ! , (       d  f       g = f7f)Nz_tld.txt)r   __file__parentjoinpathopennextstrip)clstld_f_lines       7/venv/lib/python3.13/site-packages/validators/domain.py	_retrieve_IanaTLD._retrieve   sR     (^""++J7<<>%UAjjl"  ?>>s   7A:'A) 	A:)
A73A:tldc                     XR                   ;   a  gU R                  cK  [        R                  " S5      S:X  a  [	        U R                  5       5      U l        OXR                  5       ;   $ XR                  ;   $ )NTPYVLD_CACHE_TLDTrue)_popular_cacher   r   getsetr#   )r   r%   s     r"   check_IanaTLD.check   s[    $$$??"{{,-7"%cmmo"6mmo--oo%%     )__name__
__module____qualname____firstlineno____doc__r   r   r   str__annotations__r)   classmethodr#   r,   __static_attributes__r/   r.   r"   r
   r
      sJ    4&*K#c(#*TN# # & & &r.   r
   F)consider_tldrfc_1034rfc_2782valuer9   r:   r;   c               *   U (       d  gU(       aK  [         R                  U R                  S5      R                  SS5      S   R	                  5       5      (       d  g U(       a  SOSnU(       a  SOSn[
        R                  " S	U 5      (       + =(       a_    [
        R                  " S
U S3SU S3-   SU S3-   S-   SU 3-   U R                  S5      R                  S5      [
        R                  5      $ ! [         a  n[        SU  35      UeSnAff = f)a  Return whether or not given value is a valid domain.

Examples:
    >>> domain('example.com')
    # Output: True
    >>> domain('example.com/')
    # Output: ValidationError(func=domain, ...)
    >>> # Supports IDN domains as well::
    >>> domain('xn----gtbspbbmkef.xn--p1ai')
    # Output: True

Args:
    value:
        Domain string to validate.
    consider_tld:
        Restrict domain to TLDs allowed by IANA.
    rfc_1034:
        Allows optional trailing dot in the domain name.
        Ref: [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034).
    rfc_2782:
        Domain name is of type service record.
        Allows optional underscores in the domain name.
        Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782).


Returns:
    (Literal[True]): If `value` is a valid domain name.
    (ValidationError): If `value` is an invalid domain name.

Raises:
    (UnicodeError): If `value` cannot be encoded into `idna` or decoded into `utf-8`.
F.r   r     z\.?$$z\s|__+z^(?:[a-z0-9]z(?:[a-z0-9-z]{0,61}z[a-z0-9z])?\.)z+[a-z0-9][a-z0-9-_]{0,61}z[a-z]idnazutf-8zUnable to encode/decode N)r
   r,   rstriprsplitupperresearchmatchencodedecode
IGNORECASEUnicodeError)r<   r9   r:   r;   service_recordtrailing_doterrs          r"   domainrQ   '   s   H HNN5<<+<+C+CC+KB+O+U+U+WXXH!)r"*w99Y.. 
288>*!,^,I67 (/	0 ++ |n%& LL ''0MM4
 	
  H5eW=>CGHs   BC4 4
D>DD)r4   osr   pathlibr   rG   typingr   r   utilsr   r
   r5   boolrQ   r/   r.   r"   <module>rW      sg       	   & &4 +05[`=H=H$(=H<@=HTX=H =Hr.   