o
    4@Hh8                     @   sJ   d dl mZmZ d dlmZ G dd dZG dd dZG dd dZd	S )
    )DictList)command_builderc                   @   s    e Zd ZdZdZdZdZdZdS )ClientWindowStatezRepresents a window state.
fullscreen	maximized	minimizednormalN)__name__
__module____qualname____doc__
FULLSCREEN	MAXIMIZED	MINIMIZEDNORMAL r   r   f/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/selenium/webdriver/common/bidi/browser.pyr      s    r   c                   @   s   e Zd ZdZdededededededefd	d
ZdefddZdefddZ	defddZ
defddZdefddZdefddZdefddZededd fddZdS )ClientWindowInfoz'Represents a client window information.client_windowstatewidthheightxyactivec                 C   s.   || _ || _|| _|| _|| _|| _|| _d S Nr   r   r   r   r   r   r   )selfr   r   r   r   r   r   r   r   r   r   __init__#   s   

zClientWindowInfo.__init__returnc                 C      | j S )zGets the state of the client window.

        Returns:
        -------
            str: The state of the client window (one of the ClientWindowState constants).
        )r   r   r   r   r   	get_state5      zClientWindowInfo.get_statec                 C   r!   )z|Gets the client window identifier.

        Returns:
        -------
            str: The client window identifier.
        )r   r"   r   r   r   get_client_window>   r$   z"ClientWindowInfo.get_client_windowc                 C   r!   )zGets the width of the client window.

        Returns:
        -------
            int: The width of the client window.
        )r   r"   r   r   r   	get_widthG   r$   zClientWindowInfo.get_widthc                 C   r!   )zGets the height of the client window.

        Returns:
        -------
            int: The height of the client window.
        )r   r"   r   r   r   
get_heightP   r$   zClientWindowInfo.get_heightc                 C   r!   )zGets the x coordinate of the client window.

        Returns:
        -------
            int: The x coordinate of the client window.
        )r   r"   r   r   r   get_xY   r$   zClientWindowInfo.get_xc                 C   r!   )zGets the y coordinate of the client window.

        Returns:
        -------
            int: The y coordinate of the client window.
        )r   r"   r   r   r   get_yb   r$   zClientWindowInfo.get_yc                 C   r!   )zChecks if the client window is active.

        Returns:
        -------
            bool: True if the client window is active, False otherwise.
        )r   r"   r   r   r   	is_activek   r$   zClientWindowInfo.is_activedatac              
   C   s@   | | d| d| d| d| d| d| ddS )	a  Creates a ClientWindowInfo instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the client window information.

        Returns:
        -------
            ClientWindowInfo: A new instance of ClientWindowInfo.
        clientWindowr   r   r   r   r   r   r   )get)clsr+   r   r   r   	from_dictt   s   zClientWindowInfo.from_dictN)r
   r   r   r   strintboolr   r#   r%   r&   r'   r(   r)   r*   classmethodr   r/   r   r   r   r   r       s4    
							r   c                   @   s\   e Zd ZdZdd ZdefddZdee fddZd	edd
fddZ	dee
 fddZd
S )Browserz4
    BiDi implementation of the browser module.
    c                 C   s
   || _ d S r   )conn)r   r5   r   r   r   r      s   
zBrowser.__init__r    c                 C   s   | j tdi }|d S )z{Creates a new user context.

        Returns:
        -------
            str: The ID of the created user context.
        zbrowser.createUserContextuserContextr5   executer   r   resultr   r   r   create_user_context   s   zBrowser.create_user_contextc                 C   $   | j tdi }dd |d D S )zuGets all user contexts.

        Returns:
        -------
            List[str]: A list of user context IDs.
        zbrowser.getUserContextsc                 S   s   g | ]}|d  qS )r6   r   ).0context_infor   r   r   
<listcomp>   s    z-Browser.get_user_contexts.<locals>.<listcomp>userContextsr7   r9   r   r   r   get_user_contexts      zBrowser.get_user_contextsuser_context_idNc                 C   s.   |dkrt dd|i}| jtd| dS )zRemoves a user context.

        Parameters:
        -----------
            user_context_id: The ID of the user context to remove.

        Raises:
        ------
            Exception: If the user context ID is "default" or does not exist.
        defaultz&Cannot remove the default user contextr6   zbrowser.removeUserContextN)	Exceptionr5   r8   r   )r   rC   paramsr   r   r   remove_user_context   s   zBrowser.remove_user_contextc                 C   r<   )zGets all client windows.

        Returns:
        -------
            List[ClientWindowInfo]: A list of client window information.
        zbrowser.getClientWindowsc                 S   s   g | ]}t |qS r   )r   r/   )r=   windowr   r   r   r?      s    z.Browser.get_client_windows.<locals>.<listcomp>clientWindowsr7   r9   r   r   r   get_client_windows   rB   zBrowser.get_client_windows)r
   r   r   r   r   r0   r;   r   rA   rG   r   rJ   r   r   r   r   r4      s    

r4   N)typingr   r   %selenium.webdriver.common.bidi.commonr   r   r   r4   r   r   r   r   <module>   s
   	k