
    gL                       d dl mZ ddlmZmZ d dlmZ d dlZd dlZe G d d             Z	 G d d	ej                        Z G d
 dej                        Z G d de      Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZ	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 d dZ	 	 d	 	 	 	 	 	 	 	 	 	 	 d!dZ	 	 	 	 	 	 	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZ	 	 	 d$	 	 	 	 	 	 	 	 	 	 	 d%dZy)&    )annotations   )event_classT_JSON_DICT)	dataclassNc                  ~    e Zd ZU ded<   ded<   dZded<   dZded<   dZded<   dZded	<   dZded
<   d Z	e
d        Zy)
TouchPointfloatxyNtyping.Optional[float]radius_xradius_yrotation_angleforceid_c                d   t               }| j                  |d<   | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j
                  | j
                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   |S )Nr   r   radiusXradiusYrotationAngler   id)dictr   r   r   r   r   r   r   )selfjsons     `/var/www/html/venv/lib/python3.12/site-packages/selenium/webdriver/common/devtools/v85/input_.pyto_jsonzTouchPoint.to_json%   s    vFFS	FFS	==$"mmDO==$"mmDO*$($7$7D!::! JJDM88DJ    c                    | t        |d         t        |d         d|v rt        |d         nd d|v rt        |d         nd d|v rt        |d         nd d|v rt        |d         nd d|v rt        |d               S d       S )	Nr   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r
   clsr   s     r   	from_jsonzTouchPoint.from_json5   s    DIDI/8D/@U4	?+d/8D/@U4	?+d;Jd;R5o!67X\*1T/%W&t%)T\d4j!
 	
 8<
 	
r   )__name__
__module____qualname____annotations__r   r   r   r   r   r   classmethodr!    r   r   r	   r	      sj     H H (,H$+ (,H$+ .2N*1 %)E!( #'C	&  	
 	
r   r	   c                  .    e Zd ZdZdZdZd Zed        Zy)GestureSourceTypedefaulttouchmousec                    | j                   S Nvaluer   s    r   r   zGestureSourceType.to_jsonG       zzr   c                     | |      S r.   r'   r   s     r   r!   zGestureSourceType.from_jsonJ       4yr   N)	r"   r#   r$   DEFAULTTOUCHMOUSEr   r&   r!   r'   r   r   r)   r)   B   s*    GEE  r   r)   c                  :    e Zd ZdZdZdZdZdZdZd Z	e
d        Zy	)
MouseButtonnoneleftmiddlerightbackforwardc                    | j                   S r.   r/   r1   s    r   r   zMouseButton.to_jsonW   r2   r   c                     | |      S r.   r'   r   s     r   r!   zMouseButton.from_jsonZ   r4   r   N)r"   r#   r$   NONELEFTMIDDLERIGHTBACKFORWARDr   r&   r!   r'   r   r   r9   r9   O   s9    DDFEDG  r   r9   c                  <     e Zd ZdZddZedd       Z fdZ xZS )TimeSinceEpochz<
    UTC time in seconds, counted from January 1, 1970.
    c                    | S r.   r'   r1   s    r   r   zTimeSinceEpoch.to_jsonc   s    r   c                     | |      S r.   r'   r   s     r   r!   zTimeSinceEpoch.from_jsonf   r4   r   c                >    dj                  t        | 	               S )NzTimeSinceEpoch({}))formatsuper__repr__)r   	__class__s    r   rO   zTimeSinceEpoch.__repr__j   s    #**57+;+=>>r   )returnr
   )r   r
   rQ   rI   )	r"   r#   r$   __doc__r   r&   r!   rO   __classcell__)rP   s   @r   rI   rI   _   s+      ? ?r   rI   c              #  B  K   t               }| |d<   |||d<   ||j                         |d<   |||d<   |||d<   |||d<   |||d<   |||d	<   |||d
<   |	|	|d<   |
|
|d<   |||d<   |||d<   |||d<   ||D cg c]  }| c}|d<   d|d}|}yc c}w w)a-  
    Dispatches a key event to the page.

    :param type_: Type of the key event.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    :param text: *(Optional)* Text as generated by processing a virtual key code with a keyboard layout. Not needed for for ```keyUp```` and ````rawKeyDown```` events (default: "")
    :param unmodified_text: *(Optional)* Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
    :param key_identifier: *(Optional)* Unique key identifier (e.g., 'U+0041') (default: "").
    :param code: *(Optional)* Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
    :param key: *(Optional)* Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
    :param windows_virtual_key_code: *(Optional)* Windows virtual key code (default: 0).
    :param native_virtual_key_code: *(Optional)* Native virtual key code (default: 0).
    :param auto_repeat: *(Optional)* Whether the event was generated from auto repeat (default: false).
    :param is_keypad: *(Optional)* Whether the event was generated from the keypad (default: false).
    :param is_system_key: *(Optional)* Whether the event was a system key event (default: false).
    :param location: *(Optional)* Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0).
    :param commands: **(EXPERIMENTAL)** *(Optional)* Editing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal the command names used in ````document.execCommand``` and NSStandardKeyBindingResponding. See https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
    typeN	modifiers	timestamptextunmodifiedTextkeyIdentifiercodekeywindowsVirtualKeyCodenativeVirtualKeyCode
autoRepeatisKeypadisSystemKeylocationcommandszInput.dispatchKeyEventmethodparamsr   r   )type_rV   rW   rX   unmodified_textkey_identifierr[   r\   windows_virtual_key_codenative_virtual_key_codeauto_repeat	is_keypadis_system_keyrb   rc   rf   icmd_dictr   s                      r   dispatch_key_eventrr   n   s'    H &FF6N'{'//1{v"#2 !"0v
u+*B&'*)@%&*|&z  -}%z)12Aa2z*H >D 3s   A?B	B
Bc              #  <   K   t               }| |d<   d|d}|}yw)z
    This method emulates inserting text that doesn't come from a key press,
    for example an emoji keyboard or an IME.

    **EXPERIMENTAL**

    :param text: The text to insert.
    rX   zInput.insertTextrd   Nr   )rX   rf   rq   r   s       r   insert_textru      s.      &FF6N$H >D   c              #     K   t               }| |d<   ||d<   ||d<   |||d<   ||j                         |d<   ||j                         |d<   |||d<   |||d	<   |||d
<   |	|	|d<   |
|
|d<   d|d}|}yw)a  
    Dispatches a mouse event to the page.

    :param type_: Type of the mouse event.
    :param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
    :param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    :param button: *(Optional)* Mouse button (default: "none").
    :param buttons: *(Optional)* A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
    :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
    :param delta_x: *(Optional)* X delta in CSS pixels for mouse wheel event (default: 0).
    :param delta_y: *(Optional)* Y delta in CSS pixels for mouse wheel event (default: 0).
    :param pointer_type: *(Optional)* Pointer type (default: "mouse").
    rU   r   r   NrV   rW   buttonbuttons
clickCountdeltaXdeltaYpointerTypezInput.dispatchMouseEventrd   rg   )rh   r   r   rV   rW   rx   ry   click_countdelta_xdelta_ypointer_typerf   rq   r   s                 r   dispatch_mouse_eventr      s     8 &FF6NF3KF3K'{'//1{!>>+x#y*|"x"x ,},H >Ds   A8A:c              #     K   t               }| |d<   |D cg c]  }|j                          c}|d<   |||d<   ||j                         |d<   d|d}|}yc c}w w)au  
    Dispatches a touch event to the page.

    :param type_: Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one.
    :param touch_points: Active touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    rU   touchPointsNrV   rW   zInput.dispatchTouchEventrd   rg   )rh   touch_pointsrV   rW   rf   rp   rq   r   s           r   dispatch_touch_eventr     sx      &FF6N2>?QQYY[?F='{'//1{,H >D @s   AA1Ac	              #     K   t               }	| |	d<   ||	d<   ||	d<   |j                         |	d<   ||j                         |	d<   |||	d<   |||	d<   |||	d	<   |||	d
<   d|	d}
|
}yw)a)  
    Emulates touch event from the mouse event parameters.

    **EXPERIMENTAL**

    :param type_: Type of the mouse event.
    :param x: X coordinate of the mouse pointer in DIP.
    :param y: Y coordinate of the mouse pointer in DIP.
    :param button: Mouse button. Only "none", "left", "right" are supported.
    :param timestamp: *(Optional)* Time at which the event occurred (default: current time).
    :param delta_x: *(Optional)* X delta in DIP for mouse wheel event (default: 0).
    :param delta_y: *(Optional)* Y delta in DIP for mouse wheel event (default: 0).
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
    rU   r   r   rx   NrW   r{   r|   rV   rz   z Input.emulateTouchFromMouseEventrd   rg   )rh   r   r   rx   rW   r   r   rV   r~   rf   rq   r   s               r   emulate_touch_from_mouse_eventr     s     4 &FF6NF3KF3K~~'F8'//1{"x"x'{*|4H >Ds   A(A*c              #  <   K   t               }| |d<   d|d}|}yw)z
    Ignores input events (useful while auditing page).

    :param ignore: Ignores input events processing when set to true.
    ignorezInput.setIgnoreInputEventsrd   Nrt   )r   rf   rq   r   s       r   set_ignore_input_eventsr   N  s/      &FF8.H >Drv   c              #     K   t               }| |d<   ||d<   ||d<   |||d<   ||j                         |d<   d|d}|}yw)	ai  
    Synthesizes a pinch gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param scale_factor: Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
    :param relative_speed: *(Optional)* Relative pointer speed in pixels per second (default: 800).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    r   r   scaleFactorNrelativeSpeedgestureSourceTypezInput.synthesizePinchGesturerd   rg   )r   r   scale_factorrelative_speedgesture_source_typerf   rq   r   s           r   synthesize_pinch_gesturer   _  sk     $ &FF3KF3K(F=!"0&&9&A&A&C"#0H >Ds   A Ac              #     K   t               }| |d<   ||d<   |||d<   |||d<   |||d<   |||d<   |||d<   |||d	<   ||j                         |d
<   |	|	|d<   |
|
|d<   |||d<   d|d}|}yw)ai  
    Synthesizes a scroll gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param x_distance: *(Optional)* The distance to scroll along the X axis (positive to scroll left).
    :param y_distance: *(Optional)* The distance to scroll along the Y axis (positive to scroll up).
    :param x_overscroll: *(Optional)* The number of additional pixels to scroll back along the X axis, in addition to the given distance.
    :param y_overscroll: *(Optional)* The number of additional pixels to scroll back along the Y axis, in addition to the given distance.
    :param prevent_fling: *(Optional)* Prevent fling (default: true).
    :param speed: *(Optional)* Swipe speed in pixels per second (default: 800).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    :param repeat_count: *(Optional)* The number of times to repeat the gesture (default: 0).
    :param repeat_delay_ms: *(Optional)* The number of milliseconds delay between each repeat. (default: 250).
    :param interaction_marker_name: *(Optional)* The name of the interaction markers to generate, if not empty (default: "").
    r   r   N	xDistance	yDistancexOverscrollyOverscrollpreventFlingspeedr   repeatCountrepeatDelayMsinteractionMarkerNamezInput.synthesizeScrollGesturerd   rg   )r   r   
x_distance
y_distancex_overscrolly_overscrollprevent_flingr   r   repeat_countrepeat_delay_msinteraction_marker_namerf   rq   r   s                  r   synthesize_scroll_gesturer     s     @ &FF3KF3K({({ ,} ,} !.~w&&9&A&A&C"# ,}""1**A&'1H >Ds   A3A5c              #     K   t               }| |d<   ||d<   |||d<   |||d<   ||j                         |d<   d|d}|}yw)	au  
    Synthesizes a tap gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param duration: *(Optional)* Duration between touchdown and touchup events in ms (default: 50).
    :param tap_count: *(Optional)* Number of times to perform the tap (e.g. 2 for double tap, default: 1).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    r   r   NdurationtapCountr   zInput.synthesizeTapGesturerd   rg   )r   r   r   	tap_countr   rf   rq   r   s           r   synthesize_tap_gesturer     sq     $ &FF3KF3K%z&z&&9&A&A&C"#.H >Ds   AA)NNNNNNNNNNNNNN) rh   strrV   typing.Optional[int]rW   typing.Optional[TimeSinceEpoch]rX   typing.Optional[str]ri   r   rj   r   r[   r   r\   r   rk   r   rl   r   rm   typing.Optional[bool]rn   r   ro   r   rb   r   rc   z!typing.Optional[typing.List[str]]rQ   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])rX   r   rQ   r   )NNNNNNNN)rh   r   r   r
   r   r
   rV   r   rW   r   rx   ztyping.Optional[MouseButton]ry   r   r~   r   r   r   r   r   r   r   rQ   r   )NN)
rh   r   r   ztyping.List[TouchPoint]rV   r   rW   r   rQ   r   )NNNNN)rh   r   r   intr   r   rx   r9   rW   r   r   r   r   r   rV   r   r~   r   rQ   r   )r   boolrQ   r   )r   r
   r   r
   r   r
   r   r   r   "typing.Optional[GestureSourceType]rQ   r   )
NNNNNNNNNN)r   r
   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   r   )NNN)r   r
   r   r
   r   r   r   r   r   r   rQ   r   )
__future__r   utilr   r   dataclassesr   enumtypingr	   Enumr)   r9   r
   rI   rr   ru   r   r   r   r   r   r   r   r'   r   r   <module>r      s   # * !  
1
 1
 1
h
		 
$))  ?U ?" +/59%)04/3%)$(9=8<-1+//3)-6:FF'F 3F #	F
 .F -F #F "F #7F "6F +F )F -F 'F 4F  
8!FR	70 +/59/3(,,0*.*.-1444 4 (	4
 34 -4 &4 *4 (4 (4 +4 
84t +/59	- ( 3	
 
8B 6:*.*.*.,0--- - 	-
 3- (- (- (- *- 
8-`	7* 04BF  -	
 @ 
8H .2-1/3/3/3&*BF-1048<;;; +; +	;
 -; -; -; $; @; +; .; "6; 
8;B *.*.BF ' (	
 @ 
8r   