o
    ҷhe                     @  s`  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ddl	m
Z
 ddl	mZ ddl	mZ eG d	d
 d
ZeG dd dZeG dd dZG dd dejZeG dd dZeG dd dZG dd dejZdddZdddZdddZdd d!Zdd$d%Z	ddd'd(Zdd+d,Z	ddd/d0Z									dddDdEZddGdHZddJdKZ	dddNdOZ 		dddSdTZ!ddWdXZ"			ddd\d]Z#dd`daZ$ddbdcZ%ddedfZ&ddhdiZ'ddkdlZ(	dddndoZ)			dddvdwZ*	dddydzZ+dd|d}Z,dd~dZ-dddZ.dddZ/			ddddZ0dddZ1edeG dd dZ2dS )    )annotations   )event_classT_JSON_DICT)	dataclassN)dom)network)pagec                   @  s6   e Zd ZU dZded< ded< dd Zedd	 Zd
S )ScreenOrientationz
    Screen orientation.
    strtype_intanglec                 C     t  }| j|d< | j|d< |S )Ntyper   )dictr   r   selfjson r   d/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v118/emulation.pyto_json      

zScreenOrientation.to_jsonc                 C  s   | t |d t|d dS )Nr   r   )r   r   r   r   clsr   r   r   r   	from_json"      

zScreenOrientation.from_jsonN__name__
__module____qualname____doc____annotations__r   classmethodr   r   r   r   r   r
      s   
 r
   c                   @  s:   e Zd ZU ded< ded< ded< dd Zedd	 Zd
S )DisplayFeaturer   orientationr   offsetmask_lengthc                 C  s(   t  }| j|d< | j|d< | j|d< |S )Nr&   r'   
maskLength)r   r&   r'   r(   r   r   r   r   r   8   s
   


zDisplayFeature.to_jsonc                 C  s&   | t |d t|d t|d dS )Nr&   r'   r)   )r&   r'   r(   r   r   r   r   r   r   ?   s
   


zDisplayFeature.from_jsonNr   r    r!   r#   r   r$   r   r   r   r   r   r%   *   s   
 r%   c                   @  s2   e Zd ZU ded< ded< dd Zedd ZdS )	MediaFeaturer   namevaluec                 C  r   )Nr,   r-   )r   r,   r-   r   r   r   r   r   N   r   zMediaFeature.to_jsonc                 C     | t |d t |d dS )Nr,   r-   )r,   r-   r   r   r   r   r   r   T   r   zMediaFeature.from_jsonNr*   r   r   r   r   r+   H   s   
 r+   c                   @  s0   e Zd ZdZdZdZdZdd Zedd Z	d	S )
VirtualTimePolicya?  
    advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to
    allow the next delayed task (if any) to run; pause: The virtual time base may not advance;
    pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending
    resource fetches.
    advancepausepauseIfNetworkFetchesPendingc                 C     | j S Nr-   r   r   r   r   r   g      zVirtualTimePolicy.to_jsonc                 C     | |S r5   r   r   r   r   r   r   j      zVirtualTimePolicy.from_jsonN)
r   r    r!   r"   ADVANCEPAUSE PAUSE_IF_NETWORK_FETCHES_PENDINGr   r$   r   r   r   r   r   r0   \   s    r0   c                   @  s6   e Zd ZU dZded< ded< dd Zedd Zd	S )
UserAgentBrandVersionzg
    Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
    r   brandversionc                 C  r   )Nr?   r@   )r   r?   r@   r   r   r   r   r   x   r   zUserAgentBrandVersion.to_jsonc                 C  r.   )Nr?   r@   )r?   r@   r/   r   r   r   r   r   ~   r   zUserAgentBrandVersion.from_jsonNr   r   r   r   r   r>   o   s   
 r>   c                   @  s   e Zd ZU dZded< ded< ded< 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d Z
edd Zd	S )UserAgentMetadataz
    Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
    Missing optional values will be filled in by the target with what it would normally use.
    r   platformplatform_versionarchitecturemodelboolmobileNz3typing.Optional[typing.List[UserAgentBrandVersion]]brandsfull_version_listtyping.Optional[str]full_versionbitnesstyping.Optional[bool]wow64c                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | jd ur+dd | jD |d< | jd ur:d	d | jD |d
< | jd urD| j|d< | j	d urN| j	|d< | j
d urX| j
|d< |S )NrB   platformVersionrD   rE   rG   c                 S     g | ]}|  qS r   r   .0ir   r   r   
<listcomp>       z-UserAgentMetadata.to_json.<locals>.<listcomp>rH   c                 S  rP   r   rQ   rR   r   r   r   rU      rV   fullVersionListfullVersionrL   rN   )r   rB   rC   rD   rE   rG   rH   rI   rK   rL   rN   r   r   r   r   r      s"   












zUserAgentMetadata.to_jsonc                 C  s   | t |d t |d t |d t |d t|d d|v r'dd |d D nd d	|v r5d
d |d	 D nd d|v r@t |d nd d|v rKt |d nd d|v rXt|d d
S d d
S )NrB   rO   rD   rE   rG   rH   c                 S     g | ]}t |qS r   r>   r   rR   r   r   r   rU          z/UserAgentMetadata.from_json.<locals>.<listcomp>rW   c                 S  rY   r   rZ   rR   r   r   r   rU      r[   rX   rL   rN   )
rB   rC   rD   rE   rG   rH   rI   rK   rL   rN   )r   rF   r   r   r   r   r      s   





zUserAgentMetadata.from_json)r   r    r!   r"   r#   rH   rI   rK   rL   rN   r   r$   r   r   r   r   r   rA      s   
 rA   c                   @  s,   e Zd ZdZdZdZdd Zedd ZdS )	DisabledImageTypez3
    Enum of image types that can be disabled.
    avifwebpc                 C  r4   r5   r6   r7   r   r   r   r      r8   zDisabledImageType.to_jsonc                 C  r9   r5   r   r   r   r   r   r      r:   zDisabledImageType.from_jsonN)	r   r    r!   r"   AVIFWEBPr   r$   r   r   r   r   r   r\      s    r\   return0typing.Generator[T_JSON_DICT, T_JSON_DICT, bool]c                  c  s    ddi} | V }t |d S )z^
    Tells whether emulation is supported.

    :returns: True if emulation is supported.
    methodzEmulation.canEmulateresult)rF   cmd_dictr   r   r   r   can_emulate   s
   rg   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c      ddi} | V }dS )z/
    Clears the overridden device metrics.
    rc   z$Emulation.clearDeviceMetricsOverrideNr   re   r   r   r   clear_device_metrics_override      
rj   c                  c  ri   )z?
    Clears the overridden Geolocation Position and Error.
    rc   z"Emulation.clearGeolocationOverrideNr   re   r   r   r   clear_geolocation_override   rk   rl   c                  c  ri   )z[
    Requests that page scale factor is reset to initial values.

    **EXPERIMENTAL**
    rc   zEmulation.resetPageScaleFactorNr   re   r   r   r   reset_page_scale_factor      
rm   enabledrF   c                 c  $    t  }| |d< d|d}|V }dS )z
    Enables or disables simulating a focused and active page.

    **EXPERIMENTAL**

    :param enabled: Whether to enable to disable focus emulation.
    ro   z"Emulation.setFocusEmulationEnabledrc   paramsNr   ro   rr   rf   r   r   r   r   set_focus_emulation_enabled     

ru   rM   c                 c  ,    t  }| dur| |d< d|d}|V }dS )z
    Automatically render all web contents using a dark theme.

    **EXPERIMENTAL**

    :param enabled: *(Optional)* Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
    Nro   z!Emulation.setAutoDarkModeOverriderq   rs   rt   r   r   r   set_auto_dark_mode_override     

rx   ratefloatc                 c  rp   )z
    Enables CPU throttling to emulate slow CPUs.

    **EXPERIMENTAL**

    :param rate: Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
    rz   zEmulation.setCPUThrottlingRaterq   Nrs   )rz   rr   rf   r   r   r   r   set_cpu_throttling_rate(  rv   r|   colortyping.Optional[dom.RGBA]c                 c  s0    t  }| dur|  |d< d|d}|V }dS )a  
    Sets or clears an override of the default background color of the frame. This override is used
    if the content does not specify one.

    :param color: *(Optional)* RGBA of the default background color. If not specified, any existing override will be cleared.
    Nr}   z+Emulation.setDefaultBackgroundColorOverriderq   r   r   )r}   rr   rf   r   r   r   r   %set_default_background_color_override;  s   	
r   widthr   heightdevice_scale_factorrG   scaletyping.Optional[float]screen_widthtyping.Optional[int]screen_height
position_x
position_ydont_set_visible_sizescreen_orientation"typing.Optional[ScreenOrientation]viewporttyping.Optional[page.Viewport]display_featuretyping.Optional[DisplayFeature]c                 c  s    t  }| |d< ||d< ||d< ||d< |dur||d< |dur$||d< |dur,||d< |dur4||d	< |dur<||d
< |	durD|	|d< |
durN|
 |d< |durX| |d< |durb| |d< d|d}|V }dS )a[  
    Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
    window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
    query results).

    :param width: Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
    :param height: Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
    :param device_scale_factor: Overriding device scale factor value. 0 disables the override.
    :param mobile: Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
    :param scale: **(EXPERIMENTAL)** *(Optional)* Scale to apply to resulting view image.
    :param screen_width: **(EXPERIMENTAL)** *(Optional)* Overriding screen width value in pixels (minimum 0, maximum 10000000).
    :param screen_height: **(EXPERIMENTAL)** *(Optional)* Overriding screen height value in pixels (minimum 0, maximum 10000000).
    :param position_x: **(EXPERIMENTAL)** *(Optional)* Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
    :param position_y: **(EXPERIMENTAL)** *(Optional)* Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
    :param dont_set_visible_size: **(EXPERIMENTAL)** *(Optional)* Do not set visible view size, rely upon explicit setVisibleSize call.
    :param screen_orientation: *(Optional)* Screen orientation override.
    :param viewport: **(EXPERIMENTAL)** *(Optional)* If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions.
    :param display_feature: **(EXPERIMENTAL)** *(Optional)* If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
    r   r   deviceScaleFactorrG   Nr   screenWidthscreenHeight	positionX	positionYdontSetVisibleSizescreenOrientationr   displayFeaturez"Emulation.setDeviceMetricsOverriderq   r   )r   r   r   rG   r   r   r   r   r   r   r   r   r   rr   rf   r   r   r   r   set_device_metrics_overrideN  s8   "
r   hiddenc                 c  rp   )z\


    **EXPERIMENTAL**

    :param hidden: Whether scrollbars should be always hidden.
    r   zEmulation.setScrollbarsHiddenrq   Nrs   )r   rr   rf   r   r   r   r   set_scrollbars_hidden  rv   r   disabledc                 c  rp   )zc


    **EXPERIMENTAL**

    :param disabled: Whether document.coookie API should be disabled.
    r   z#Emulation.setDocumentCookieDisabledrq   Nrs   )r   rr   rf   r   r   r   r   set_document_cookie_disabled  rv   r   configurationrJ   c                 c  4    t  }| |d< |dur||d< d|d}|V }dS )z


    **EXPERIMENTAL**

    :param enabled: Whether touch emulation based on mouse input should be enabled.
    :param configuration: *(Optional)* Touch/gesture events configuration. Default: current platform.
    ro   Nr   z$Emulation.setEmitTouchEventsForMouserq   rs   )ro   r   rr   rf   r   r   r   r   set_emit_touch_events_for_mouse  s   
r   mediafeatures*typing.Optional[typing.List[MediaFeature]]c                 c  sF    t  }| dur| |d< |durdd |D |d< d|d}|V }dS )z
    Emulates the given media type or media feature for CSS media queries.

    :param media: *(Optional)* Media type to emulate. Empty string disables the override.
    :param features: *(Optional)* Media features to emulate.
    Nr   c                 S  rP   r   rQ   rR   r   r   r   rU     rV   z&set_emulated_media.<locals>.<listcomp>r   zEmulation.setEmulatedMediarq   rs   )r   r   rr   rf   r   r   r   r   set_emulated_media  s   

r   r   r   c                 c  rp   )a  
    Emulates the given vision deficiency.

    **EXPERIMENTAL**

    :param type_: Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
    r   z%Emulation.setEmulatedVisionDeficiencyrq   Nrs   )r   rr   rf   r   r   r   r   set_emulated_vision_deficiency  rv   r   latitude	longitudeaccuracyc                 c  sL    t  }| dur| |d< |dur||d< |dur||d< d|d}|V }dS )a  
    Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
    unavailable.

    :param latitude: *(Optional)* Mock latitude
    :param longitude: *(Optional)* Mock longitude
    :param accuracy: *(Optional)* Mock accuracy
    Nr   r   r   z Emulation.setGeolocationOverriderq   rs   )r   r   r   rr   rf   r   r   r   r   set_geolocation_override  s   
r   is_user_activeis_screen_unlockedc                 c  ,    t  }| |d< ||d< d|d}|V }dS )z
    Overrides the Idle state.

    **EXPERIMENTAL**

    :param is_user_active: Mock isUserActive
    :param is_screen_unlocked: Mock isScreenUnlocked
    isUserActiveisScreenUnlockedzEmulation.setIdleOverriderq   Nrs   )r   r   rr   rf   r   r   r   r   set_idle_override  s   
r   c                  c  ri   )z<
    Clears Idle state overrides.

    **EXPERIMENTAL**
    rc   zEmulation.clearIdleOverrideNr   re   r   r   r   clear_idle_override%  rn   r   rB   c                 c  rp   )z
    Overrides value returned by the javascript navigator object.

    **EXPERIMENTAL**

    :param platform: The platform navigator.platform should return.
    rB   zEmulation.setNavigatorOverridesrq   Nrs   )rB   rr   rf   r   r   r   r   set_navigator_overrides1  rv   r   page_scale_factorc                 c  rp   )zu
    Sets a specified page scale factor.

    **EXPERIMENTAL**

    :param page_scale_factor: Page scale factor.
    pageScaleFactorzEmulation.setPageScaleFactorrq   Nrs   )r   rr   rf   r   r   r   r   set_page_scale_factorD  rv   r   r-   c                 c  rp   )z|
    Switches script execution in the page.

    :param value: Whether script execution should be disabled in the page.
    r-   z$Emulation.setScriptExecutionDisabledrq   Nrs   )r-   rr   rf   r   r   r   r   set_script_execution_disabledW  s   
r   max_touch_pointsc                 c  r   )z
    Enables touch on platforms which do not support them.

    :param enabled: Whether the touch event emulation should be enabled.
    :param max_touch_points: *(Optional)* Maximum touch points supported. Defaults to one.
    ro   NmaxTouchPointsz"Emulation.setTouchEmulationEnabledrq   rs   )ro   r   rr   rf   r   r   r   r   set_touch_emulation_enabledh  s   

r   policybudget&max_virtual_time_task_starvation_countinitial_virtual_time'typing.Optional[network.TimeSinceEpoch]1typing.Generator[T_JSON_DICT, T_JSON_DICT, float]c                 c  sd    t  }|  |d< |dur||d< |dur||d< |dur$| |d< d|d}|V }t|d S )	a#  
    Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets
    the current virtual time policy.  Note this supersedes any previous time budget.

    **EXPERIMENTAL**

    :param policy:
    :param budget: *(Optional)* If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
    :param max_virtual_time_task_starvation_count: *(Optional)* If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
    :param initial_virtual_time: *(Optional)* If set, base::Time::Now will be overridden to initially return this value.
    :returns: Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
    r   Nr   !maxVirtualTimeTaskStarvationCountinitialVirtualTimezEmulation.setVirtualTimePolicyrq   virtualTimeTicksBase)r   r   r{   )r   r   r   r   rr   rf   r   r   r   r   set_virtual_time_policy}  s   r   localec                 c  rw   )z
    Overrides default host system locale with the specified one.

    **EXPERIMENTAL**

    :param locale: *(Optional)* ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
    Nr   zEmulation.setLocaleOverriderq   rs   )r   rr   rf   r   r   r   r   set_locale_override  ry   r   timezone_idc                 c  rp   )z
    Overrides default host system timezone with the specified one.

    **EXPERIMENTAL**

    :param timezone_id: The timezone identifier. If empty, disables the override and restores default host system timezone.
    
timezoneIdzEmulation.setTimezoneOverriderq   Nrs   )r   rr   rf   r   r   r   r   set_timezone_override  rv   r   c                 c  r   )a<  
    Resizes the frame/viewport of the page. Note that this does not affect the frame's container
    (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported
    on Android.

    **EXPERIMENTAL**

    :param width: Frame width (DIP).
    :param height: Frame height (DIP).
    r   r   zEmulation.setVisibleSizerq   Nrs   )r   r   rr   rf   r   r   r   r   set_visible_size  s   
r   image_typestyping.List[DisabledImageType]c                 c  s.    t  }dd | D |d< d|d}|V }dS )zM


    **EXPERIMENTAL**

    :param image_types: Image types to disable.
    c                 S  rP   r   rQ   rR   r   r   r   rU     rV   z,set_disabled_image_types.<locals>.<listcomp>
imageTypeszEmulation.setDisabledImageTypesrq   Nrs   )r   rr   rf   r   r   r   r   set_disabled_image_types  s   

r   hardware_concurrencyc                 c  rp   )z]


    **EXPERIMENTAL**

    :param hardware_concurrency: Hardware concurrency to report
    hardwareConcurrencyz(Emulation.setHardwareConcurrencyOverriderq   Nrs   )r   rr   rf   r   r   r   r   !set_hardware_concurrency_override  rv   r   
user_agentaccept_languageuser_agent_metadata"typing.Optional[UserAgentMetadata]c                 c  sX    t  }| |d< |dur||d< |dur||d< |dur"| |d< d|d}|V }dS )a  
    Allows overriding user agent with the given string.

    :param user_agent: User agent to use.
    :param accept_language: *(Optional)* Browser langugage to emulate.
    :param platform: *(Optional)* The platform navigator.platform should return.
    :param user_agent_metadata: **(EXPERIMENTAL)** *(Optional)* To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
    	userAgentNacceptLanguagerB   userAgentMetadatazEmulation.setUserAgentOverriderq   r   )r   r   rB   r   rr   rf   r   r   r   r   set_user_agent_override  s   
r   c                 c  rp   )z
    Allows overriding the automation flag.

    **EXPERIMENTAL**

    :param enabled: Whether the override should be enabled.
    ro   zEmulation.setAutomationOverriderq   Nrs   rt   r   r   r   set_automation_override!  rv   r   z"Emulation.virtualTimeBudgetExpiredc                   @  s   e Zd ZdZedddZdS )	VirtualTimeBudgetExpiredz~
    **EXPERIMENTAL**

    Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
    r   r   ra   c                 C  s   |  S r5   r   r   r   r   r   r   >  s   z"VirtualTimeBudgetExpired.from_jsonN)r   r   ra   r   )r   r    r!   r"   r$   r   r   r   r   r   r   4  s    r   )ra   rb   )ra   rh   )ro   rF   ra   rh   r5   )ro   rM   ra   rh   )rz   r{   ra   rh   )r}   r~   ra   rh   )	NNNNNNNNN)r   r   r   r   r   r{   rG   rF   r   r   r   r   r   r   r   r   r   r   r   rM   r   r   r   r   r   r   ra   rh   )r   rF   ra   rh   )r   rF   ra   rh   )ro   rF   r   rJ   ra   rh   )NN)r   rJ   r   r   ra   rh   )r   r   ra   rh   )NNN)r   r   r   r   r   r   ra   rh   )r   rF   r   rF   ra   rh   )rB   r   ra   rh   )r   r{   ra   rh   )r-   rF   ra   rh   )ro   rF   r   r   ra   rh   )
r   r0   r   r   r   r   r   r   ra   r   )r   rJ   ra   rh   )r   r   ra   rh   )r   r   r   r   ra   rh   )r   r   ra   rh   )r   r   ra   rh   )
r   r   r   rJ   rB   rJ   r   r   ra   rh   )3
__future__r   utilr   r   dataclassesr   enumtyping r   r   r	   r
   r%   r+   Enumr0   r>   rA   r\   rg   rj   rl   rm   ru   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   >








@






#




