
    ,i                         d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d d	lmZ  G d
 d      Zy)    )AnyOptionalUnion)interaction)
KeyActions)KeyInput)PointerActions)PointerInput)WheelActions)
WheelInput)Commandc                   :   e Zd Z	 	 	 	 ddee   dee   dee   deddf
dZde	dee
d	      fd
Zedee   fd       Zedee   fd       Zedefd       Zedefd       Zedefd       Zde	defdZde	de	defdZde	defdZddZddZde
eeef   ddfdZy)ActionBuilderNmousewheelkeyboarddurationreturnc                 :   |xs t        t        j                  d      }|xs t        t        j                        }|xs t        t        j                        }|||g| _        t        |      | _	        t        ||      | _        t        |      | _        || _        y )Nr   )r   )r
   r   POINTER_MOUSEr   KEYr   WHEELdevicesr   _key_actionr	   _pointer_actionr   _wheel_actiondriver)selfr   r   r   r   r   s         /var/www/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/selenium/webdriver/common/actions/action_builder.py__init__zActionBuilder.__init__    s     Ik&?&?I8x86K$5$56INPXZ_H`%h/-ehG)%0    name)r   r
   r   c                 J    t        t        fd| j                        d      S )a  Get the device with the given name.

        Parameters:
        -----------
        name : str
            The name of the device to get.

        Returns:
        --------
        Optional[Union[WheelInput, PointerInput, KeyInput]] : The device with the given name.
        c                     | k(  S N )xr"   s    r   <lambda>z/ActionBuilder.get_device_with.<locals>.<lambda>=   s    Q$Y r!   N)nextfilterr   )r   r"   s    `r   get_device_withzActionBuilder.get_device_with1   s     F.=tDDr!   c                 b    | j                   D cg c]  }t        |t              s| c}S c c}w r%   )r   
isinstancer
   r   devices     r   pointer_inputszActionBuilder.pointer_inputs?   s#    %)\\V6Z5UVVV   ,,c                 b    | j                   D cg c]  }t        |t              s| c}S c c}w r%   )r   r-   r   r.   s     r   
key_inputszActionBuilder.key_inputsC   s#    %)\\R6Z5QRRRr1   c                     | j                   S r%   )r   r   s    r   
key_actionzActionBuilder.key_actionG   s    r!   c                     | j                   S r%   )r   r5   s    r   pointer_actionzActionBuilder.pointer_actionK   s    ###r!   c                     | j                   S r%   )r   r5   s    r   wheel_actionzActionBuilder.wheel_actionO   s    !!!r!   c                 >    t        |      }| j                  |       |S )a  Add a new key input device to the action builder.

        Parameters:
        -----------
        name : str
            The name of the key input device.

        Returns:
        --------
        KeyInput : The newly created key input device.

        Example:
        --------
        >>> action_builder = ActionBuilder(driver)
        >>> action_builder.add_key_input(name="keyboard2")
        )r   
_add_inputr   r"   	new_inputs      r   add_key_inputzActionBuilder.add_key_inputS   s    " TN		"r!   kindc                 @    t        ||      }| j                  |       |S )a;  Add a new pointer input device to the action builder.

        Parameters:
        -----------
        kind : str
            The kind of pointer input device.
                - "mouse"
                - "touch"
                - "pen"

        name : str
            The name of the pointer input device.

        Returns:
        --------
        PointerInput : The newly created pointer input device.

        Example:
        --------
        >>> action_builder = ActionBuilder(driver)
        >>> action_builder.add_pointer_input(kind="mouse", name="mouse")
        )r
   r<   )r   r@   r"   r>   s       r   add_pointer_inputzActionBuilder.add_pointer_inputh   s"    . !t,		"r!   c                 >    t        |      }| j                  |       |S )a  Add a new wheel input device to the action builder.

        Parameters:
        -----------
        name : str
            The name of the wheel input device.

        Returns:
        --------
        WheelInput : The newly created wheel input device.

        Example:
        --------
        >>> action_builder = ActionBuilder(driver)
        >>> action_builder.add_wheel_input(name="wheel2")
        )r   r<   r=   s      r   add_wheel_inputzActionBuilder.add_wheel_input   s     " t$		"r!   c                     dg i}| j                   D ]3  }|j                         }|d   s|d   j                  |       g |_        5 | j                  j                  t        j                  |       y)aP  Performs all stored actions.

        Example:
        --------
        >>> action_builder = ActionBuilder(driver)
        >>> keyboard = action_builder.key_input
        >>> el = driver.find_element(id: "some_id")
        >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
        actionsN)r   encodeappendrF   r   executer   W3C_ACTIONS)r   encr/   encodeds       r   performzActionBuilder.perform   sh     &/Oll 	$FmmoGy!I%%g.!#		$
 	G//5r!   c                 V    | j                   j                  t        j                         y)a  Clears actions that are already stored on the remote end.

        Example:
        --------
        >>> action_builder = ActionBuilder(driver)
        >>> keyboard = action_builder.key_input
        >>> el = driver.find_element(By.ID, "some_id")
        >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys")
        >>> action_builder.clear_actions()
        N)r   rI   r   W3C_CLEAR_ACTIONSr5   s    r   clear_actionszActionBuilder.clear_actions   s     	G556r!   r>   c                 :    | j                   j                  |       y)zAdd a new input device to the action builder.

        Parameters:
        -----------
        new_input : Union[KeyInput, PointerInput, WheelInput]
            The new input device to add.
        N)r   rH   )r   r>   s     r   r<   zActionBuilder._add_input   s     	I&r!   )NNN   )r   N)__name__
__module____qualname__r   r
   r   r   intr    strr   r+   propertylistr0   r3   r   r6   r	   r8   r   r:   r?   rB   rD   rM   rP   r<   r&   r!   r   r   r      sw    )-&*'+ % 
#	
 8$  
"EC EHU;c5d,e E W\ 2 W W SDN S S  J     $ $ $ "l " "# ( *c   6C J *6$7'E(L**L$M 'RV 'r!   r   N)typingr   r   r   !selenium.webdriver.common.actionsr   -selenium.webdriver.common.actions.key_actionsr   +selenium.webdriver.common.actions.key_inputr   1selenium.webdriver.common.actions.pointer_actionsr	   /selenium.webdriver.common.actions.pointer_inputr
   /selenium.webdriver.common.actions.wheel_actionsr   -selenium.webdriver.common.actions.wheel_inputr   !selenium.webdriver.remote.commandr   r   r&   r!   r   <module>rc      s1   & ( ' 9 D @ L H H D 5`' `'r!   