
    ,h                         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 dd
lmZ ddlmZ ddlmZ  G d d      Zy)    )List)Optional)Union)Command   )interaction)
KeyActions)KeyInput)PointerActions)PointerInput)WheelActions)
WheelInputc                   :   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         r/var/www/html/Resume-Scraper/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x/%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_with3   s     F.=tDDr"   c                 |    | j                   D cg c]"  }|j                  t        j                  k(  s!|$ c}S c c}w r&   )r   typer   POINTERr   devices     r    pointer_inputszActionBuilder.pointer_inputsA   s+    %)\\X6V[[KDWDW5WXXX   "99c                 |    | j                   D cg c]"  }|j                  t        j                  k(  s!|$ c}S c c}w r&   )r   r.   r   r   r0   s     r    
key_inputszActionBuilder.key_inputsE   s)    %)\\T6V[[KOO5STTTr3   c                     | j                   S r&   )r   r   s    r    
key_actionzActionBuilder.key_actionI   s    r"   c                     | j                   S r&   )r   r7   s    r    pointer_actionzActionBuilder.pointer_actionM   s    ###r"   c                     | j                   S r&   )r   r7   s    r    wheel_actionzActionBuilder.wheel_actionQ   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_inputU   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   rB   r#   r@   s       r    add_pointer_inputzActionBuilder.add_pointer_inputj   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appendrH   r   executer   W3C_ACTIONS)r   encr1   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   rK   r   W3C_CLEAR_ACTIONSr7   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   rJ   )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,   propertyr   r2   r5   r	   r8   r   r:   r   r<   rA   rD   rF   rO   rR   r>   r'   r"   r    r   r   !   sw    )-&*'+ % 
#	
 8$  
"EC EHU;c5d,e E Y\ 2 Y Y UDN U U  J     $ $ $ "l " "# ( *c   6C J *6$7'E(L**L$M 'RV 'r"   r   N)typingr   r   r   !selenium.webdriver.remote.commandr    r   key_actionsr	   	key_inputr
   pointer_actionsr   pointer_inputr   wheel_actionsr   wheel_inputr   r   r'   r"   r    <module>rd      s4   $    5  #  + ' ' #`' `'r"   