a
    xdh+                     @  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 eG dd	 d	ZeG d
d dZeG dd dZeG dd dZddddZddddZdddddZddddZddddd Zdd!d"d#d$Zdd%dd&d'd(Zdd)dd*d+d,Zd%dd-d.d/Zdd%d%dd0d1d2Zed3eG d4d5 d5Zed6eG d7d8 d8Zed9eG d:d; d;ZdS )<    )annotations   )event_classT_JSON_DICT)	dataclassN)dom)runtimec                   @  s~   e Zd ZU dZded< ded< ded< 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d Zedd Z	dS )	Animationz
    Animation instance.
    strid_nameboolpaused_state
play_statefloatplayback_rate
start_timecurrent_timetype_Nz typing.Optional[AnimationEffect]sourcetyping.Optional[str]css_idc                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	d urn| j	
 |d	< | jd ur| j|d
< |S )Nidr   pausedState	playStateplaybackRate	startTimecurrentTimetyper   cssId)dictr   r   r   r   r   r   r   r   r   to_jsonr   selfjson r%   i/var/www/html/Ranjet/env/lib/python3.9/site-packages/selenium/webdriver/common/devtools/v113/animation.pyr!   4   s    










zAnimation.to_jsonc                 C  s   | t |d t |d t|d t |d t|d t|d t|d t |d d	|v rht|d	 nd d
|v r~t |d
 nd d
S )Nr   r   r   r   r   r   r   r   r   r   )
r   r   r   r   r   r   r   r   r   r   )r
   r   r   AnimationEffect	from_jsonclsr$   r%   r%   r&   r(   D   s    







zAnimation.from_json)
__name__
__module____qualname____doc____annotations__r   r   r!   classmethodr(   r%   r%   r%   r&   r	      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ed	< ded
< ded< dZded< dZded< dd Zedd Z	dS )r'   z"
    AnimationEffect instance
    r   delay	end_delayiteration_start
iterationsdurationr
   	directionfilleasingNz"typing.Optional[dom.BackendNodeId]backend_node_idztyping.Optional[KeyframesRule]keyframes_rulec                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	d urn| j	
 |d	< | jd ur| j
 |d
< |S )Nr1   endDelayiterationStartr4   r5   r6   r7   r8   backendNodeIdkeyframesRule)r    r1   r2   r3   r4   r5   r6   r7   r8   r9   r!   r:   r"   r%   r%   r&   r!   w   s    









zAnimationEffect.to_jsonc                 C  s   | t |d t |d t |d t |d t |d t|d t|d t|d d	|v rjtj|d	 nd d
|v rt|d
 nd d
S )Nr1   r;   r<   r4   r5   r6   r7   r8   r=   r>   )
r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   )r   r
   r   ZBackendNodeIdr(   KeyframesRuler)   r%   r%   r&   r(      s    







zAnimationEffect.from_json)
r+   r,   r-   r.   r/   r9   r:   r!   r0   r(   r%   r%   r%   r&   r'   T   s   
r'   c                   @  s:   e Zd ZU dZded< dZded< dd Zed	d
 ZdS )r?   z
    Keyframes Rule
    ztyping.List[KeyframeStyle]	keyframesNr   r   c                 C  s2   t  }dd | jD |d< | jd ur.| j|d< |S )Nc                 S  s   g | ]}|  qS r%   )r!   .0ir%   r%   r&   
<listcomp>       z)KeyframesRule.to_json.<locals>.<listcomp>r@   r   )r    r@   r   r"   r%   r%   r&   r!      s
    

zKeyframesRule.to_jsonc                 C  s.   | dd |d D d|v r&t |d nd dS )Nc                 S  s   g | ]}t |qS r%   )KeyframeStyler(   rA   r%   r%   r&   rD      rE   z+KeyframesRule.from_json.<locals>.<listcomp>r@   r   )r@   r   r
   r)   r%   r%   r&   r(      s    zKeyframesRule.from_json)	r+   r,   r-   r.   r/   r   r!   r0   r(   r%   r%   r%   r&   r?      s   
r?   c                   @  s6   e Zd ZU dZded< ded< dd Zedd Zd	S )
rF   z
    Keyframe Style
    r
   offsetr8   c                 C  s   t  }| j|d< | j|d< |S )NrH   r8   )r    rH   r8   r"   r%   r%   r&   r!      s    

zKeyframeStyle.to_jsonc                 C  s   | t |d t |d dS )NrH   r8   )rH   r8   rG   r)   r%   r%   r&   r(      s    

zKeyframeStyle.from_jsonN)r+   r,   r-   r.   r/   r!   r0   r(   r%   r%   r%   r&   rF      s   
rF   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])returnc                  c  s   ddi} | V }dS )z2
    Disables animation domain notifications.
    methodzAnimation.disableNr%   cmd_dictr$   r%   r%   r&   disable   s    rM   c                  c  s   ddi} | V }dS )z1
    Enables animation domain notifications.
    rJ   zAnimation.enableNr%   rK   r%   r%   r&   enable   s    rN   r
   z1typing.Generator[T_JSON_DICT, T_JSON_DICT, float])r   rI   c                 c  s*   t  }| |d< d|d}|V }t|d S )z
    Returns the current time of the an animation.

    :param id_: Id of animation.
    :returns: Current time of the page.
    r   zAnimation.getCurrentTimerJ   paramsr   )r    r   )r   rP   rL   r$   r%   r%   r&   get_current_time   s    	rQ   c                  c  s   ddi} | V }t |d S )zo
    Gets the playback rate of the document timeline.

    :returns: Playback rate for animations on page.
    rJ   zAnimation.getPlaybackRater   )r   rK   r%   r%   r&   get_playback_rate   s    rR   ztyping.List[str])
animationsrI   c                 c  s,   t  }dd | D |d< d|d}|V }dS )zz
    Releases a set of animations to no longer be manipulated.

    :param animations: List of animation ids to seek.
    c                 S  s   g | ]}|qS r%   r%   rA   r%   r%   r&   rD     rE   z&release_animations.<locals>.<listcomp>rS   zAnimation.releaseAnimationsrO   Nr    )rS   rP   rL   r$   r%   r%   r&   release_animations   s    rU   z@typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject])animation_idrI   c                 c  s.   t  }| |d< d|d}|V }tj|d S )z
    Gets the remote object of the Animation.

    :param animation_id: Animation id.
    :returns: Corresponding remote object.
    animationIdzAnimation.resolveAnimationrO   ZremoteObject)r    r   ZRemoteObjectr(   )rV   rP   rL   r$   r%   r%   r&   resolve_animation  s    	rX   r   )rS   r   rI   c                 c  s4   t  }dd | D |d< ||d< d|d}|V }dS )z
    Seek a set of animations to a particular time within each animation.

    :param animations: List of animation ids to seek.
    :param current_time: Set the current time of each animation.
    c                 S  s   g | ]}|qS r%   r%   rA   r%   r%   r&   rD   -  rE   z#seek_animations.<locals>.<listcomp>rS   r   zAnimation.seekAnimationsrO   NrT   )rS   r   rP   rL   r$   r%   r%   r&   seek_animations"  s    
rY   r   )rS   pausedrI   c                 c  s4   t  }dd | D |d< ||d< d|d}|V }dS )z
    Sets the paused state of a set of animations.

    :param animations: Animations to set the pause state of.
    :param paused: Paused state to set to.
    c                 S  s   g | ]}|qS r%   r%   rA   r%   r%   r&   rD   A  rE   zset_paused.<locals>.<listcomp>rS   rZ   zAnimation.setPausedrO   NrT   )rS   rZ   rP   rL   r$   r%   r%   r&   
set_paused6  s    
r[   )r   rI   c                 c  s"   t  }| |d< d|d}|V }dS )zz
    Sets the playback rate of the document timeline.

    :param playback_rate: Playback rate for animations on page
    r   zAnimation.setPlaybackRaterO   NrT   )r   rP   rL   r$   r%   r%   r&   set_playback_rateJ  s    r\   )rV   r5   r1   rI   c                 c  s2   t  }| |d< ||d< ||d< d|d}|V }dS )z
    Sets the timing of an animation node.

    :param animation_id: Animation id.
    :param duration: Duration of the animation.
    :param delay: Delay of the animation.
    rW   r5   r1   zAnimation.setTimingrO   NrT   )rV   r5   r1   rP   rL   r$   r%   r%   r&   
set_timing[  s    r]   zAnimation.animationCanceledc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationCanceledz9
    Event for when an animation has been cancelled.
    r
   r   r   r$   rI   c                 C  s   | t |d dS Nr   )r   rG   r)   r%   r%   r&   r(   {  s    
zAnimationCanceled.from_jsonNr+   r,   r-   r.   r/   r0   r(   r%   r%   r%   r&   r^   r  s   
r^   zAnimation.animationCreatedc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationCreatedz9
    Event for each animation that has been created.
    r
   r   r   r_   c                 C  s   | t |d dS r`   rG   r)   r%   r%   r&   r(     s    
zAnimationCreated.from_jsonNra   r%   r%   r%   r&   rb     s   
rb   zAnimation.animationStartedc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationStartedz4
    Event for animation that has been started.
    r	   	animationr   r_   c                 C  s   | t |d dS )Nrd   )rd   )r	   r(   r)   r%   r%   r&   r(     s    zAnimationStarted.from_jsonNra   r%   r%   r%   r&   rc     s   
rc   )
__future__r   utilr   r   Zdataclassesr   enumtyping r   r   r	   r'   r?   rF   rM   rN   rQ   rR   rU   rX   rY   r[   r\   r]   r^   rb   rc   r%   r%   r%   r&   <module>   sB   CB

