
    iV8                     (   d dl Z d dlmZmZ d dlmZmZmZ d dlm	Z	 d dl
mZ  G d d          Z G d d	          Ze G d
 d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d  d!                      Ze G d" d#                      Ze G d$ d%                      Ze G d& d'                      Z G d( d)          Z G d* d+          ZdS ),    N)	dataclassfield)AnyOptionalUnion)command_builder)Sessionc                   (    e Zd ZdZdZdZdZeeehZdS )PointerTypez&Represents the possible pointer types.mousepentouchN)__name__
__module____qualname____doc__MOUSEPENTOUCHVALID_TYPES     p/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/selenium/webdriver/common/bidi/input.pyr   r      s/        00E
CE#u%KKKr   r   c                       e Zd ZdZdZdZdS )Originz%Represents the possible origin types.viewportpointerN)r   r   r   r   VIEWPORTPOINTERr   r   r   r   r   $   s        //HGGGr   r   c                   @    e Zd ZU dZeed<   eed<   defdZdefdZdS )	ElementOriginz/Represents an element origin for input actions.typeelementelement_referencec                 "    d| _         || _        d S )Nr#   r"   r#   )selfr$   s     r   __init__zElementOrigin.__init__2   s    	(r   returnc                      | j         | j        dS )z*Convert the ElementOrigin to a dictionary.r&   r&   r'   s    r   to_dictzElementOrigin.to_dict6   s    	dl;;;r   N)	r   r   r   r   str__annotations__dictr(   r,   r   r   r   r!   r!   +   sd         99
IIIMMM)$ ) ) ) )< < < < < < <r   r!   c                   >    e Zd ZU dZej        Zeed<   d Z	de
fdZdS )PointerParametersz2Represents pointer parameters for pointer actions.pointer_typec                 t    | j         t          j        vr$t          d| j          dt          j                   d S )NzInvalid pointer type: z. Must be one of )r2   r   r   
ValueErrorr+   s    r   __post_init__zPointerParameters.__post_init__A   sA    K$;;;sd6GssZeZqssttt <;r   r)   c                     d| j         iS )z.Convert the PointerParameters to a dictionary.pointerType)r2   r+   s    r   r,   zPointerParameters.to_dictE   s    t011r   N)r   r   r   r   r   r   r2   r-   r.   r5   r/   r,   r   r   r   r1   r1   ;   s\         <<#)L#)))u u u2 2 2 2 2 2 2r   r1   c                       e Zd ZU dZdZeed<   dZeed<   dZe	ed<   dZ
e	ed<   dZeed	<   dZe	ed
<   dZe	ed<   d ZdefdZdS )PointerCommonPropertiesz&Common properties for pointer actions.   widthheight        pressuretangential_pressurer   twistaltitude_angleazimuth_anglec                     | j         dk     rt          d          | j        dk     rt          d          d| j        cxk    rdk    sn t          d          d| j        cxk    rdk    sn t          d          d| j        cxk    rd	k    sn t          d
          d| j        cxk    rt          j        dz  k    sn t          d          d| j	        cxk    rdt          j        z  k    sn t          d          d S )Nr:   zwidth must be at least 1zheight must be at least 1r=   g      ?z$pressure must be between 0.0 and 1.0z/tangential_pressure must be between 0.0 and 1.0r   ig  ztwist must be between 0 and 359   u+   altitude_angle must be between 0.0 and π/2u)   azimuth_angle must be between 0.0 and 2π)
r;   r4   r<   r>   r?   r@   rA   mathpirB   r+   s    r   r5   z%PointerCommonProperties.__post_init__V   s=   :>>7888;??8999t}++++++++CDDDt/666636666NOOOTZ&&&&3&&&&>???t*9999dgk9999JKKKt)8888Q[8888HIII 98r   r)   c                 0   i }| j         dk    r
| j         |d<   | j        dk    r
| j        |d<   | j        dk    r
| j        |d<   | j        dk    r
| j        |d<   | j        dk    r
| j        |d<   | j        dk    r
| j        |d	<   | j        dk    r
| j        |d
<   |S )z4Convert the PointerCommonProperties to a dictionary.r:   r;   r<   r=   r>   tangentialPressurer   r@   altitudeAngleazimuthAngle)r;   r<   r>   r?   r@   rA   rB   r'   results     r   r,   zPointerCommonProperties.to_dictf   s    !#:??"jF7O;!#{F8=C!%F:#s**+/+CF'(:??"jF7O#%%&*&9F?#$$%)%7F>"r   N)r   r   r   r   r;   intr.   r<   r>   floatr?   r@   rA   rB   r5   r/   r,   r   r   r   r9   r9   J   s         00E3NNNFCOOOHe!$$$$E3NNNNEM5J J J       r   r9   c                   V    e Zd ZU dZdZee         ed<   ede	fd            Z
defdZdS )PauseActionzRepresents a pause action.Ndurationr)   c                     dS )Npauser   r+   s    r   r"   zPauseAction.type       wr   c                 :    d| j         i}| j        
| j        |d<   |S )z(Convert the PauseAction to a dictionary.r"   NrQ   )r"   rQ   rK   s     r   r,   zPauseAction.to_dict   s'    "($)!4=$!%F:r   )r   r   r   r   rQ   r   rM   r.   propertyr-   r"   r/   r,   r   r   r   rP   rP   {   sp         $$"Hhsm"""c    X      r   rP   c                   J    e Zd ZU dZdZeed<   edefd            Zde	fdZ
dS )KeyDownActionzRepresents a key down action. valuer)   c                     dS )NkeyDownr   r+   s    r   r"   zKeyDownAction.type       yr   c                      | j         | j        dS )z*Convert the KeyDownAction to a dictionary.r"   rZ   r_   r+   s    r   r,   zKeyDownAction.to_dict       	DJ777r   Nr   r   r   r   rZ   r-   r.   rV   r"   r/   r,   r   r   r   rX   rX      si         ''E3OOOc    X8 8 8 8 8 8 8r   rX   c                   J    e Zd ZU dZdZeed<   edefd            Zde	fdZ
dS )KeyUpActionzRepresents a key up action.rY   rZ   r)   c                     dS )NkeyUpr   r+   s    r   r"   zKeyUpAction.type   rT   r   c                      | j         | j        dS )z(Convert the KeyUpAction to a dictionary.r_   r_   r+   s    r   r,   zKeyUpAction.to_dict   r`   r   Nra   r   r   r   rc   rc      si         %%E3OOOc    X8 8 8 8 8 8 8r   rc   c                   d    e Zd ZU dZdZeed<   dZee	         ed<   e
defd            ZdefdZdS )	PointerDownActionz!Represents a pointer down action.r   buttonN
propertiesr)   c                     dS )NpointerDownr   r+   s    r   r"   zPointerDownAction.type       }r   c                     | j         | j        d}| j        r,|                    | j                                                   |S )z.Convert the PointerDownAction to a dictionary.r"   ri   )r"   ri   rj   updater,   rK   s     r   r,   zPointerDownAction.to_dict   sB    *.)t{!K!K? 	5MM$/1133444r   )r   r   r   r   ri   rM   r.   rj   r   r9   rV   r-   r"   r/   r,   r   r   r   rh   rh      s         ++FCOOO48J01888c    X      r   rh   c                   J    e Zd ZU dZdZeed<   edefd            Z	de
fdZdS )PointerUpActionzRepresents a pointer up action.r   ri   r)   c                     dS )N	pointerUpr   r+   s    r   r"   zPointerUpAction.type   s    {r   c                      | j         | j        dS )z,Convert the PointerUpAction to a dictionary.ro   ro   r+   s    r   r,   zPointerUpAction.to_dict   s    	T[999r   N)r   r   r   r   ri   rM   r.   rV   r-   r"   r/   r,   r   r   r   rr   rr      si         ))FCOOOc    X: : : : : : :r   rr   c                       e Zd ZU dZdZeed<   dZeed<   dZe	e
         ed<   dZe	eeef                  ed<   dZe	e         ed<   ed	efd
            Zd	efdZdS )PointerMoveActionz!Represents a pointer move action.r   xyNrQ   originrj   r)   c                     dS )NpointerMover   r+   s    r   r"   zPointerMoveAction.type   rm   r   c                 H   | j         | j        | j        d}| j        
| j        |d<   | j        At          | j        t                    r| j                                        |d<   n
| j        |d<   | j        r,|	                    | j                                                   |S )z.Convert the PointerMoveAction to a dictionary.)r"   rx   ry   NrQ   rz   )
r"   rx   ry   rQ   rz   
isinstancer!   r,   rj   rp   rK   s     r   r,   zPointerMoveAction.to_dict   s    *.)$&tv!N!N=$!%F:;"$+}55 /#';#6#6#8#8x  #';x ? 	5MM$/1133444r   )r   r   r   r   rx   rN   r.   ry   rQ   r   rM   rz   r   r-   r!   rj   r9   rV   r"   r/   r,   r   r   r   rw   rw      s         ++AuLLLAuLLL"Hhsm"""26FHU3-./66648J01888c    X      r   rw   c                       e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dZ
ee         ed<   ej        Zeeeef                  ed	<   ed
efd            Zd
efdZdS )WheelScrollActionz!Represents a wheel scroll action.r   rx   ry   delta_xdelta_yNrQ   rz   r)   c                     dS )Nscrollr   r+   s    r   r"   zWheelScrollAction.type   s    xr   c                     | j         | j        | j        | j        | j        d}| j        
| j        |d<   | j        At          | j        t                    r| j        	                                |d<   n
| j        |d<   |S )z.Convert the WheelScrollAction to a dictionary.)r"   rx   ry   deltaXdeltaYNrQ   rz   )
r"   rx   ry   r   r   rQ   rz   r~   r!   r,   rK   s     r   r,   zWheelScrollAction.to_dict   s     Ill"
 "
 =$!%F:;"$+}55 /#';#6#6#8#8x  #';x r   )r   r   r   r   rx   rM   r.   ry   r   r   rQ   r   r   r   rz   r   r-   r!   rV   r"   r/   r,   r   r   r   r   r      s         ++AsJJJAsJJJGSGS"Hhsm"""28/FHU3-./AAAc    X      r   r   c                   x    e Zd ZU dZdZeed<    ee          Z	ee
         ed<   edefd            ZdefdZd	S )
NoneSourceActionsz&Represents a sequence of none actions.rY   iddefault_factoryactionsr)   c                     dS )Nnoner   r+   s    r   r"   zNoneSourceActions.type  s    vr   c                 @    | j         | j        d | j        D             dS )z.Convert the NoneSourceActions to a dictionary.c                 6    g | ]}|                                 S r   r,   .0actions     r   
<listcomp>z-NoneSourceActions.to_dict.<locals>.<listcomp>  #    =j=j=jSYfnn>N>N=j=j=jr   r"   r   r   r   r+   s    r   r,   zNoneSourceActions.to_dict  )    	=j=j]a]i=j=j=jkkkr   N)r   r   r   r   r   r-   r.   r   listr   rP   rV   r"   r/   r,   r   r   r   r   r     s         00BLLL!&t!<!<!<GT+<<<c    Xl l l l l l lr   r   c                       e Zd ZU dZdZeed<    ee          Z	ee
eeef                  ed<   edefd            ZdefdZd	S )
KeySourceActionsz%Represents a sequence of key actions.rY   r   r   r   r)   c                     dS )Nkeyr   r+   s    r   r"   zKeySourceActions.type$  s    ur   c                 @    | j         | j        d | j        D             dS )z-Convert the KeySourceActions to a dictionary.c                 6    g | ]}|                                 S r   r   r   s     r   r   z,KeySourceActions.to_dict.<locals>.<listcomp>*  r   r   r   r   r+   s    r   r,   zKeySourceActions.to_dict(  r   r   N)r   r   r   r   r   r-   r.   r   r   r   r   rP   rX   rc   rV   r"   r/   r,   r   r   r   r   r     s         //BLLLDIEZ^D_D_D_GT%]K?@A___c    Xl l l l l l lr   r   c                       e Zd ZU dZdZeed<   dZee	         ed<    e
e          Zeeeeeef                  ed<   d Zed	efd
            Zd	efdZdS )PointerSourceActionsz)Represents a sequence of pointer actions.rY   r   N
parametersr   r   c                 >    | j         t                      | _         d S d S N)r   r1   r+   s    r   r5   z"PointerSourceActions.__post_init__7  s#    ?"/11DOOO #"r   r)   c                     dS )Nr   r   r+   s    r   r"   zPointerSourceActions.type;  r]   r   c                     | j         | j        d | j        D             d}| j        r| j                                        |d<   |S )z1Convert the PointerSourceActions to a dictionary.c                 6    g | ]}|                                 S r   r   r   s     r   r   z0PointerSourceActions.to_dict.<locals>.<listcomp>D  s"    DDDV((DDDr   r   r   )r"   r   r   r   r,   rK   s     r   r,   zPointerSourceActions.to_dict?  sV     I'DDt|DDD"
 "

 ? 	=#'?#:#:#<#<F< r   )r   r   r   r   r   r-   r.   r   r   r1   r   r   r   r   rP   rh   rr   rw   r5   rV   r"   r/   r,   r   r   r   r   r   -  s         33BLLL.2J*+222_d_d` ` `GT%%6IZZ[\   2 2 2 c    X	 	 	 	 	 	 	r   r   c                       e Zd ZU dZdZeed<    ee          Z	ee
eef                  ed<   edefd            ZdefdZd	S )
WheelSourceActionsz'Represents a sequence of wheel actions.rY   r   r   r   r)   c                     dS )Nwheelr   r+   s    r   r"   zWheelSourceActions.typeR  rT   r   c                 @    | j         | j        d | j        D             dS )z/Convert the WheelSourceActions to a dictionary.c                 6    g | ]}|                                 S r   r   r   s     r   r   z.WheelSourceActions.to_dict.<locals>.<listcomp>X  r   r   r   r   r+   s    r   r,   zWheelSourceActions.to_dictV  r   r   N)r   r   r   r   r   r-   r.   r   r   r   r   rP   r   rV   r"   r/   r,   r   r   r   r   r   K  s         11BLLL;@5QU;V;V;VGT%%6678VVVc    Xl l l l l l lr   r   c                   b    e Zd ZU dZeed<   eed<   dZee	         ed<   e
de	dd fd            ZdS )	FileDialogInfozERepresents file dialog information from input.fileDialogOpened event.contextmultipleNr#   datar)   c                 \     | |d         |d         |                     d                    S )a  Creates a FileDialogInfo instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the file dialog information.

        Returns:
        -------
            FileDialogInfo: A new instance of FileDialogInfo.
        r   r   r#   )r   r   r#   )get)clsr   s     r   	from_dictzFileDialogInfo.from_dictc  s1     s4	?T*5EtxxXaObObccccr   )r   r   r   r   r-   r.   boolr#   r   r/   classmethodr   r   r   r   r   r   [  sw         OOLLLNNN"GXd^"""dT d&6 d d d [d d dr   r   c                   ,    e Zd ZdZdZed             ZdS )FileDialogOpenedz-Event class for input.fileDialogOpened event.zinput.fileDialogOpenedc                 6    t                               |          S )z%Create FileDialogInfo from JSON data.)r   r   )r   jsons     r   	from_jsonzFileDialogOpened.from_jsonx  s     ''---r   N)r   r   r   r   event_classr   r   r   r   r   r   r   s  s8        77*K. . [. . .r   r   c            	           e Zd ZdZd Zdedeeee	e
ef                  ddfdZdeddfdZded	ed
ee         ddfdZd ZdeddfdZdS )Inputz2
    BiDi implementation of the input module.
    c                 0    || _         i | _        i | _        d S r   )connsubscriptions	callbacks)r'   r   s     r   r(   zInput.__init__  s    	r   r   r   r)   Nc                 t    |d |D             d}| j                             t          d|                     dS )zPerforms a sequence of user input actions.

        Parameters:
        -----------
            context: The browsing context ID where actions should be performed.
            actions: A list of source actions to perform.
        c                 6    g | ]}|                                 S r   r   r   s     r   r   z)Input.perform_actions.<locals>.<listcomp>  s"    1Y1Y1Yv&..2B2B1Y1Y1Yr   )r   r   zinput.performActionsNr   executer   )r'   r   r   paramss       r   perform_actionszInput.perform_actions  sH     %1Y1YQX1Y1Y1YZZ	/*@&IIJJJJJr   c                 ^    d|i}| j                             t          d|                     dS )zReleases all input state for the given context.

        Parameters:
        -----------
            context: The browsing context ID to release actions for.
        r   zinput.releaseActionsNr   )r'   r   r   s      r   release_actionszInput.release_actions  s5     W%	/*@&IIJJJJJr   r#   filesc                 b    |||d}| j                             t          d|                     dS )zSets files for a file input element.

        Parameters:
        -----------
            context: The browsing context ID.
            element: The element reference (script.SharedReference).
            files: A list of file paths to set.
        )r   r#   r   zinput.setFilesNr   )r'   r   r#   r   r   s        r   	set_fileszInput.set_files  s:     %5II	/*:FCCDDDDDr   c                    t           j        | j        vr_t          | j                  }| j                            |                    t           j                             g | j        t           j        <   | j                            t           |          }| j        t           j                                     |           || j	        |<   |S )a	  Add a handler for file dialog opened events.

        Parameters:
        -----------
            handler: Callback function that takes a FileDialogInfo object.

        Returns:
        --------
            int: Callback ID for removing the handler later.
        )
r   r   r   r	   r   r   	subscribeadd_callbackappendr   )r'   handlersessioncallback_ids       r   add_file_dialog_handlerzInput.add_file_dialog_handler  s     't/AAAdi((GIg//0@0LMMNNN?AD/;< i,,-=wGG+78??LLL&-{#r   r   c                    || j         v r| j         |= t          j        | j        v r|| j        t          j                 v r*| j        t          j                                     |           | j        t          j                 s]t          | j                  }| j                            |                    t          j                             | j        t          j        = | j        	                    t          |           dS )zRemove a file dialog handler.

        Parameters:
        -----------
            callback_id: The callback ID returned by add_file_dialog_handler.
        N)
r   r   r   r   remover	   r   r   unsubscriberemove_callback)r'   r   r   s      r   remove_file_dialog_handlerz Input.remove_file_dialog_handler  s     $.(({+'4+===d01A1MNNN"#3#?@GGTTT %&6&BC E!$),,	!!'"5"56F6R"S"STTT&'7'CD	!!"2K@@@@@r   )r   r   r   r   r(   r-   r   r   r   r   r   r   r   r   r/   r   r   rM   r   r   r   r   r   r   ~  s          
KK e-/?AUWiijkK 
	K K K KKs Kt K K K K
E 
Et 
EDI 
E$ 
E 
E 
E 
E  2Ac Ad A A A A A Ar   r   )rE   dataclassesr   r   typingr   r   r   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr	   r   r   r!   r1   r9   rP   rX   rc   rh   rr   rw   r   r   r   r   r   r   r   r   r   r   r   <module>r      sV  $  ( ( ( ( ( ( ( ( ' ' ' ' ' ' ' ' ' ' A A A A A A : : : : : :& & & & & & & &        < < < < < < < < 2 2 2 2 2 2 2 2 , , , , , , , ,`        " 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8        $ : : : : : : : :        8        D l l l l l l l l l l l l l l l l        : l l l l l l l l d d d d d d d d.. . . . . . . .\A \A \A \A \A \A \A \A \A \Ar   