o
    Ð­j5  ã                   @  sV   d dl mZ d dlZd dlZddlmZ ddgZdZej	G dd„ dƒƒZ
ddd„ZdS )é    )ÚannotationsNé   )Ú
InvalidURIÚ	parse_uriÚWebSocketURIz:/?#[]@!$&'()*+,;=c                   @  sn   e Zd ZU dZded< ded< ded< ded< ded	< d
Zded< d
Zded< eddd„ƒZeddd„ƒZ	d
S )r   a  
    WebSocket URI.

    Attributes:
        secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI.
        host: Normalized to lower case.
        port: Always set even if it's the default.
        path: May be empty.
        query: May be empty if the URI doesn't include a query component.
        username: Available when the URI contains `User Information`_.
        password: Available when the URI contains `User Information`_.

    .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1

    ÚboolÚsecureÚstrÚhostÚintÚportÚpathÚqueryNz
str | NoneÚusernameÚpasswordÚreturnc                 C  s*   | j r| j }nd}| jr|d| j 7 }|S )Nú/ú?)r   r   )ÚselfÚresource_name© r   úK/var/www/html/CropPilot/venv/lib/python3.10/site-packages/websockets/uri.pyr   *   s   zWebSocketURI.resource_nameútuple[str, str] | Nonec                 C  s(   | j d u rd S | jd usJ ‚| j | jfS )N)r   r   )r   r   r   r   Ú	user_info4   s   
zWebSocketURI.user_info)r   r	   )r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   Úpropertyr   r   r   r   r   r   r      s   
 	Úurir	   r   c           	      C  s4  t j | ¡}|jdvrt| dƒ‚|jdu rt| dƒ‚|jdkr$t| dƒ‚|jdk}|j}|jp4|r3dnd	}|j}|j	}|j
}|j}|durN|du rNt| d
ƒ‚z|  d¡ W n: ty�   | d¡ ¡ }t jj|td�}t jj|td�}|dur�|dus}J ‚t jj|td�}t jj|td�}Y nw t|||||||ƒS )zÊ
    Parse and validate a WebSocket URI.

    Args:
        uri: WebSocket URI.

    Returns:
        Parsed WebSocket URI.

    Raises:
        InvalidURI: If ``uri`` isn't a valid WebSocket URI.

    )ÚwsÚwsszscheme isn't ws or wssNzhostname isn't providedÚ z"fragment identifier is meaninglessr"   i»  éP   z"username provided without passwordÚasciiÚidna)Úsafe)ÚurllibÚparseÚurlparseÚschemer   ÚhostnameÚfragmentr   r   r   r   r   ÚencodeÚUnicodeEncodeErrorÚdecodeÚquoteÚDELIMSr   )	r    Úparsedr   r
   r   r   r   r   r   r   r   r   r   <   s:   







€÷)r    r	   r   r   )Ú
__future__r   ÚdataclassesÚurllib.parser(   Ú
exceptionsr   Ú__all__r2   Ú	dataclassr   r   r   r   r   r   Ú<module>   s    +