U
    gh+                     @  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 k	rn| j	
 |d	< | jd k	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%   T/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/devtools/v85/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	|krht|d	 nd d
|k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 k	rn| j	
 |d	< | jd k	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	|krjtj|d	 nd d
|k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 k	r.| j|d< |S )Nc                 S  s   g | ]}|  qS r%   )r!   .0ir%   r%   r&   
<listcomp>   s     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|kr&t |d nd dS )Nc                 S  s   g | ]}t |qS r%   )KeyframeStyler(   rA   r%   r%   r&   rD      s     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 )
rE   z
    Keyframe Style
    r
   offsetr8   c                 C  s   t  }| j|d< | j|d< |S )NrG   r8   )r    rG   r8   r"   r%   r%   r&   r!      s    

zKeyframeStyle.to_jsonc                 C  s   | t |d t |d dS )NrG   r8   )rG   r8   rF   r)   r%   r%   r&   r(      s    

zKeyframeStyle.from_jsonN)r+   r,   r-   r.   r/   r!   r0   r(   r%   r%   r%   r&   rE      s   
rE   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     rL   c                  c  s   ddi} | V }dS )z1
    Enables animation domain notifications.
    rI   zAnimation.enableNr%   rJ   r%   r%   r&   enable   s     rM   r
   z1typing.Generator[T_JSON_DICT, T_JSON_DICT, float])r   rH   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rI   paramsr   )r    r   )r   rO   rK   r$   r%   r%   r&   get_current_time   s    	rP   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.
    rI   zAnimation.getPlaybackRater   )r   rJ   r%   r%   r&   get_playback_rate   s
     rQ   ztyping.List[str])
animationsrH   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     s     z&release_animations.<locals>.<listcomp>rR   zAnimation.releaseAnimationsrN   Nr    )rR   rO   rK   r$   r%   r%   r&   release_animations   s    rT   z@typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject])animation_idrH   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.resolveAnimationrN   ZremoteObject)r    r   ZRemoteObjectr(   )rU   rO   rK   r$   r%   r%   r&   resolve_animation  s    	rW   r   )rR   r   rH   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   -  s     z#seek_animations.<locals>.<listcomp>rR   r   zAnimation.seekAnimationsrN   NrS   )rR   r   rO   rK   r$   r%   r%   r&   seek_animations"  s    
rX   r   )rR   pausedrH   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  s     zset_paused.<locals>.<listcomp>rR   rY   zAnimation.setPausedrN   NrS   )rR   rY   rO   rK   r$   r%   r%   r&   
set_paused6  s    
rZ   )r   rH   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.setPlaybackRaterN   NrS   )r   rO   rK   r$   r%   r%   r&   set_playback_rateJ  s    r[   )rU   r5   r1   rH   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.
    rV   r5   r1   zAnimation.setTimingrN   NrS   )rU   r5   r1   rO   rK   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$   rH   c                 C  s   | t |d dS Nr   )r   rF   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_   rF   r)   r%   r%   r&   r(     s    
zAnimationCreated.from_jsonNr`   r%   r%   r%   r&   ra     s   
ra   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 )Nrc   )rc   )r	   r(   r)   r%   r%   r&   r(     s    zAnimationStarted.from_jsonNr`   r%   r%   r%   r&   rb     s   
rb   )
__future__r   utilr   r   Zdataclassesr   enumtyping r   r   r	   r'   r?   rE   rL   rM   rP   rQ   rT   rW   rX   rZ   r[   r\   r]   ra   rb   r%   r%   r%   r&   <module>   sB   CB

