o
    衡iK                     @  s   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 er$d dl
mZ G dd deZG dd	 d	eZed
eeZdddZG dd dZG dd dZG dd dZG dd dZdS )    )annotations)Enum)TYPE_CHECKINGAnyTypeVar)command_builder)WebSocketConnectionc                   @  s   e Zd ZdZdZdZdS )ScreenOrientationNaturalzNatural screen orientation.portrait	landscapeN)__name__
__module____qualname____doc__PORTRAIT	LANDSCAPE r   r   y/var/www/html/asbeauty/laura_geller_scraping/env/lib/python3.10/site-packages/selenium/webdriver/common/bidi/emulation.pyr	      s    r	   c                   @  s    e Zd ZdZdZdZdZdZdS )ScreenOrientationTypezScreen orientation type.zportrait-primaryzportrait-secondaryzlandscape-primaryzlandscape-secondaryN)r   r   r   r   PORTRAIT_PRIMARYPORTRAIT_SECONDARYLANDSCAPE_PRIMARYLANDSCAPE_SECONDARYr   r   r   r   r   #   s    r   EvalueE | str
enum_classtype[E]returnc                 C  sH   t | |r| S t | tsJ z||  W S  ty#   td|  w )NzInvalid orientation: )
isinstancestrlower
ValueError)r   r   r   r   r   _convert_to_enum/   s   
r#   c                   @  s$   e Zd ZdZdddZdd
dZdS )ScreenOrientationz,Represents screen orientation configuration.naturalScreenOrientationNatural | strtypeScreenOrientationType | strc                 C  s   t |t| _t |t| _dS )ag  Initialize ScreenOrientation.

        Args:
            natural: Natural screen orientation ("portrait" or "landscape").
            type: Screen orientation type ("portrait-primary", "portrait-secondary",
                "landscape-primary", or "landscape-secondary").

        Raises:
            ValueError: If natural or type values are invalid.
        N)r#   r	   r%   r   r'   )selfr%   r'   r   r   r   __init__<   s   zScreenOrientation.__init__r   dict[str, str]c                 C  s   | j j| jjdS )N)r%   r'   )r%   r   r'   r)   r   r   r   to_dictO   s   zScreenOrientation.to_dictN)r%   r&   r'   r(   r   r+   )r   r   r   r   r*   r-   r   r   r   r   r$   9   s    
r$   c                   @  s  e Zd ZdZ					d*d+ddZed,ddZejd-ddZed,ddZejd-ddZed,ddZ	e	jd-ddZ	ed.ddZ
e
jd/ddZ
ed.ddZejd/d dZed.d!d"Zejd/d#d"Zed.d$d%Zejd/d&d%Zd0d(d)ZdS )1GeolocationCoordinatesz#Represents geolocation coordinates.      ?Nlatitudefloat	longitudeaccuracyaltitudefloat | Nonealtitude_accuracyheadingspeedc                 C  s.   || _ || _|| _|| _|| _|| _|| _dS )a  Initialize GeolocationCoordinates.

        Args:
            latitude: Latitude coordinate (-90.0 to 90.0).
            longitude: Longitude coordinate (-180.0 to 180.0).
            accuracy: Accuracy in meters (>= 0.0), defaults to 1.0.
            altitude: Altitude in meters or None, defaults to None.
            altitude_accuracy: Altitude accuracy in meters (>= 0.0) or None, defaults to None.
            heading: Heading in degrees (0.0 to 360.0) or None, defaults to None.
            speed: Speed in meters per second (>= 0.0) or None, defaults to None.

        Raises:
            ValueError: If coordinates are out of valid range or if altitude_accuracy is provided without altitude.
        Nr1   r3   r4   r5   r7   r8   r9   )r)   r1   r3   r4   r5   r7   r8   r9   r   r   r   r*   Y   s   
zGeolocationCoordinates.__init__r   c                 C     | j S N)	_latituder,   r   r   r   r1   y      zGeolocationCoordinates.latituder   Nonec                 C  .   d|  krdkst d t d|| _d S )Ng     Vg     V@z'latitude must be between -90.0 and 90.0)r"   r=   r)   r   r   r   r   r1   }   
   
c                 C  r;   r<   )
_longituder,   r   r   r   r3      r>   z GeolocationCoordinates.longitudec                 C  r@   )Ng     fg     f@z*longitude must be between -180.0 and 180.0)r"   rC   rA   r   r   r   r3      rB   c                 C  r;   r<   )	_accuracyr,   r   r   r   r4      r>   zGeolocationCoordinates.accuracyc                 C  s   |dk rt d|| _d S )N        zaccuracy must be >= 0.0)r"   rD   rA   r   r   r   r4      s   
c                 C  r;   r<   	_altituder,   r   r   r   r5      r>   zGeolocationCoordinates.altitudec                 C  
   || _ d S r<   rF   rA   r   r   r   r5      s   
c                 C  r;   r<   )_altitude_accuracyr,   r   r   r   r7      r>   z(GeolocationCoordinates.altitude_accuracyc                 C  s<   |d ur| j d u rtd|d ur|dk rtd|| _d S )Nz0altitude_accuracy cannot be set without altituderE   z altitude_accuracy must be >= 0.0)r5   r"   rI   rA   r   r   r   r7      s
   
c                 C  r;   r<   )_headingr,   r   r   r   r8      r>   zGeolocationCoordinates.headingc                 C  s6   |d urd|  krdk st d t d|| _d S )NrE   g     v@z%heading must be between 0.0 and 360.0)r"   rJ   rA   r   r   r   r8      s
   
c                 C  r;   r<   )_speedr,   r   r   r   r9      r>   zGeolocationCoordinates.speedc                 C  s"   |d ur|dk rt d|| _d S )NrE   zspeed must be >= 0.0)r"   rK   rA   r   r   r   r9      s   
dict[str, float | None]c                 C  sf   | j | j| jd}| jd ur| j|d< | jd ur| j|d< | jd ur'| j|d< | jd ur1| j|d< |S )N)r1   r3   r4   r5   altitudeAccuracyr8   r9   r:   )r)   resultr   r   r   r-      s   







zGeolocationCoordinates.to_dict)r0   NNNN)r1   r2   r3   r2   r4   r2   r5   r6   r7   r6   r8   r6   r9   r6   )r   r2   )r   r2   r   r?   )r   r6   )r   r6   r   r?   )r   rL   )r   r   r   r   r*   propertyr1   setterr3   r4   r5   r7   r8   r9   r-   r   r   r   r   r/   V   sJ     r/   c                   @  s,   e Zd ZdZdZefdddZdd	d
ZdS )GeolocationPositionErrorz(Represents a geolocation position error.positionUnavailabler'   r    c                 C  s&   || j krtd| j  d|| _d S )Nztype must be "")TYPE_POSITION_UNAVAILABLEr"   r'   )r)   r'   r   r   r   r*      s   

z!GeolocationPositionError.__init__r   r+   c                 C  s
   d| j iS )Nr'   )r'   r,   r   r   r   r-         
z GeolocationPositionError.to_dictN)r'   r    r.   )r   r   r   r   rT   r*   r-   r   r   r   r   rQ      s
    rQ   c                   @  s   e Zd ZdZd.ddZ				d/d0ddZ			d1d2ddZ			d1d3ddZ			d4d5ddZ			d1d6d d!Z				d1d7d#d$Z
			d4d8d'd(Z				d/d9d,d-ZdS ):	Emulationz,BiDi implementation of the emulation module.connr   r   r?   c                 C  rH   r<   )rW   )r)   rW   r   r   r   r*      rU   zEmulation.__init__NcoordinatesGeolocationCoordinates | NoneerrorGeolocationPositionError | Nonecontextslist[str] | Noneuser_contextsc                 C  s   |dur|durt d|dur|durt d|du r$|du r$t di }|dur1| |d< n
|dur;| |d< |durD||d< n|durL||d< | jtd	| dS )
aT  Set geolocation override for the given contexts or user contexts.

        Args:
            coordinates: Geolocation coordinates to emulate, or None.
            error: Geolocation error to emulate, or None.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both coordinates and error are provided, or if both contexts
                and user_contexts are provided, or if neither contexts nor
                user_contexts are provided.
        Nz)Cannot specify both coordinates and error-Cannot specify both contexts and userContexts,Must specify either contexts or userContextsrX   rZ   r\   userContextsz emulation.setGeolocationOverrider"   r-   rW   executer   )r)   rX   rZ   r\   r^   paramsr   r   r   set_geolocation_override   s    
z"Emulation.set_geolocation_overridetimezone
str | Nonec                 C  p   |dur|durt d|du r|du rt dd|i}|dur%||d< n|dur-||d< | jtd| dS )a   Set timezone override for the given contexts or user contexts.

        Args:
            timezone: Timezone identifier (IANA timezone name or offset string like '+01:00'),
                or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        N.Cannot specify both contexts and user_contexts-Must specify either contexts or user_contextsrf   r\   ra   zemulation.setTimezoneOverrider"   rW   rc   r   )r)   rf   r\   r^   rd   r   r   r   set_timezone_override  s   
zEmulation.set_timezone_overridelocalec                 C  rh   )a  Set locale override for the given contexts or user contexts.

        Args:
            locale: Locale string as per BCP 47, or None to clear override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided, or if locale is invalid.
        Nr_   r`   rm   r\   ra   zemulation.setLocaleOverriderk   )r)   rm   r\   r^   rd   r   r   r   set_locale_override5     
zEmulation.set_locale_overrideFenabledbool | Nonec                 C  s|   |rt d|dur|durt d|du r|du rt dd|i}|dur+||d< n|dur3||d< | jtd| dS )	aI  Set scripting enabled override for the given contexts or user contexts.

        Args:
            enabled: False to disable scripting, None to clear the override.
                Note: Only emulation of disabled JavaScript is supported.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided, or if enabled is True.
        zROnly emulation of disabled JavaScript is supported (enabled must be False or None)Nr_   r`   rp   r\   ra   zemulation.setScriptingEnabledrk   )r)   rp   r\   r^   rd   r   r   r   set_scripting_enabledU  s   
zEmulation.set_scripting_enabledscreen_orientationScreenOrientation | Nonec                 C  s   |dur|durt d|du r|du rt dd|dur!| ndi}|dur-||d< n|dur5||d< | jtd| dS )a   Set screen orientation override for the given contexts or user contexts.

        Args:
            screen_orientation: ScreenOrientation object to emulate, or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nr_   r`   screenOrientationr\   ra   z&emulation.setScreenOrientationOverriderb   )r)   rs   r\   r^   rd   r   r   r   set_screen_orientation_overridey  s   
z)Emulation.set_screen_orientation_override
user_agentc                 C  rh   )a  Set user agent override for the given contexts or user contexts.

        Args:
            user_agent: User agent string to emulate, or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nri   rj   	userAgentr\   ra   zemulation.setUserAgentOverriderk   )r)   rw   r\   r^   rd   r   r   r   set_user_agent_override  ro   z!Emulation.set_user_agent_overrideofflineboolc                 C  s   |dur|durt d|du r|du rt di }|r#ddi|d< nd|d< |dur0||d< n|dur8||d< | jtd	| dS )
a  Set network conditions for the given contexts or user contexts.

        Args:
            offline: True to emulate offline network conditions, False to clear the override.
            contexts: List of browsing context IDs to apply the conditions to.
            user_contexts: List of user context IDs to apply the conditions to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nri   rj   r'   rz   networkConditionsr\   ra   zemulation.setNetworkConditionsrk   )r)   rz   r\   r^   rd   r   r   r   set_network_conditions  s   
z Emulation.set_network_conditionswidth
int | Noneheightc                 C  s   |du |du krt d|dur|durt d|du r$|du r$t dd}|durM|durMt|tr8t|ts<t d|dk sD|dk rHt d||d}d	|i}|durZ||d
< n|durb||d< | jtd| dS )aG  Set screen settings override for the given contexts or user contexts.

        Args:
            width: Screen width in pixels (>= 0). None to clear the override.
            height: Screen height in pixels (>= 0). None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If only one of width/height is provided, or if both contexts
                and user_contexts are provided, or if neither is provided.
        NzDMust provide both width and height, or neither to clear the overrideri   rj   z!width and height must be integersr   zwidth and height must be >= 0)r~   r   
screenArear\   ra   z#emulation.setScreenSettingsOverride)r"   r   intrW   rc   r   )r)   r~   r   r\   r^   screen_areard   r   r   r   set_screen_settings_override  s&   

z&Emulation.set_screen_settings_override)rW   r   r   r?   )NNNN)
rX   rY   rZ   r[   r\   r]   r^   r]   r   r?   )NNN)rf   rg   r\   r]   r^   r]   r   r?   )rm   rg   r\   r]   r^   r]   r   r?   )FNN)rp   rq   r\   r]   r^   r]   r   r?   )rs   rt   r\   r]   r^   r]   r   r?   )rw   rg   r\   r]   r^   r]   r   r?   )rz   r{   r\   r]   r^   r]   r   r?   )
r~   r   r   r   r\   r]   r^   r]   r   r?   )r   r   r   r   r*   re   rl   rn   rr   rv   ry   r}   r   r   r   r   r   rV      sJ    
-#"&$"(rV   N)r   r   r   r   r   r   )
__future__r   enumr   typingr   r   r   %selenium.webdriver.common.bidi.commonr   .selenium.webdriver.remote.websocket_connectionr   r	   r   r   r#   r$   r/   rQ   rV   r   r   r   r   <module>   s   	

