
    k"gk                     B    d dl Z d dlmZ d dlmZ d ed      fdZd Zy)    N)ValidationError)gettext_lazyFz!This is not a valid IPv6 address.c           	      V   	 t        j                  t        t        j                  |                   }|r!|j                  rt        |j                        S |j                  rdt        |j                        z  S t        |      S # t        $ r t	        |ddt        d      i      w xY w)a  
    Clean an IPv6 address string.

    Raise ValidationError if the address is invalid.

    Replace the longest continuous zero-sequence with "::", remove leading
    zeroes, and make sure all hextets are lowercase.

    Args:
        ip_str: A valid IPv6 address.
        unpack_ipv4: if an IPv4-mapped address is found,
        return the plain IPv4 address (default=False).
        error_message: An error message used in the ValidationError.

    Return a compressed IPv6 address or the same value.
    invalidprotocolIPv6)codeparamsz	::ffff:%s)	ipaddressIPv6Addressint
ValueErrorr   _ipv4_mappedstr)ip_strunpack_ipv4error_messageaddrs       J/var/www/html/djangosite/lib/python3.12/site-packages/django/utils/ipv6.pyclean_ipv6_addressr      s    &
$$S)>)>v)F%GH t''4##$$			S!1!1222t9  
	:qy2I
 	

s   1B #B(c                 N    	 t        j                  |        y# t        $ r Y yw xY w)zL
    Return whether or not the `ip_str` string is a valid IPv6 address.
    FT)r   r   r   )r   s    r   is_valid_ipv6_addressr   )   s.    f%   s    	$$)r   django.core.exceptionsr   django.utils.translationr   r   r   r        r   <module>r      s&     2 6 Q/R-SDr   