o
    ҷh:                     @  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
 G dd deZG d	d
 d
e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G dd deZdAddZdBddZdBddZdCd"d#ZdDd$d%Z			dEdFd.d/ZdGd0d1Z			dEdHd6d7ZdId9d:Zed;eG d<d= d=Zed>eG d?d@ d@ZdS )J    )annotations   )event_classT_JSON_DICT)	dataclassN)domc                      8   e Zd ZdZdddZedddZ fd	d
Z  ZS )LayerIdz"
    Unique Layer identifier.
    returnstrc                 C     | S N selfr   r   e/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v118/layer_tree.pyto_json      zLayerId.to_jsonjsonc                 C     | |S r   r   clsr   r   r   r   	from_json      zLayerId.from_jsonc                      d t  S )NzLayerId({})formatsuper__repr__r   	__class__r   r   r         zLayerId.__repr__r
   r   )r   r   r
   r	   	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r   r   r   r   r	          
r	   c                      r   )
SnapshotIdz%
    Unique snapshot identifier.
    r
   r   c                 C  r   r   r   r   r   r   r   r   "   r   zSnapshotId.to_jsonr   c                 C  r   r   r   r   r   r   r   r   %   r   zSnapshotId.from_jsonc                   r   )NzSnapshotId({})r   r   r   r   r   r   )   r!   zSnapshotId.__repr__r"   )r   r   r
   r+   r#   r   r   r   r   r+      r*   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 )
ScrollRectz?
    Rectangle where scrolling happens on the main thread.
    dom.Rectrectr   type_c                 C  s"   t  }| j |d< | j|d< |S )Nr.   type)dictr.   r   r/   r   r   r   r   r   r   8   s   
zScrollRect.to_jsonc                 C  s    | t j|d t|d dS )Nr.   r0   )r.   r/   )r   Rectr   r   r   r   r   r   r   >   s   
zScrollRect.from_jsonNr$   r%   r&   r'   __annotations__r   r(   r   r   r   r   r   r,   -   s   
 r,   c                   @  sN   e Zd ZU dZ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 )StickyPositionConstraintz&
    Sticky position constraints.
    r-   sticky_box_rectcontaining_block_rectNtyping.Optional[LayerId]!nearest_layer_shifting_sticky_box'nearest_layer_shifting_containing_blockc                 C  sV   t  }| j |d< | j |d< | jd ur| j |d< | jd ur)| j |d< |S )NstickyBoxRectcontainingBlockRectnearestLayerShiftingStickyBox#nearestLayerShiftingContainingBlock)r1   r7   r   r8   r:   r;   r2   r   r   r   r   W   s   

z StickyPositionConstraint.to_jsonc                 C  sX   | t j|d t j|d d|v rt|d nd d|v r(t|d dS d dS )Nr<   r=   r>   r?   )r7   r8   r:   r;   )r   r3   r   r	   r   r   r   r   r   a   s   z"StickyPositionConstraint.from_json)
r$   r%   r&   r'   r5   r:   r;   r   r(   r   r   r   r   r   r6   F   s   
 
r6   c                   @  s>   e Zd ZU dZded< ded< ded< dd Zed	d
 ZdS )PictureTilezV
    Serialized fragment of layer picture along with its offset within the layer.
    floatxyr   picturec                 C  s(   t  }| j|d< | j|d< | j|d< |S )NrB   rC   rD   )r1   rB   rC   rD   r2   r   r   r   r   y   s
   


zPictureTile.to_jsonc                 C  s&   | t |d t |d t|d dS )NrB   rC   rD   )rB   rC   rD   )rA   r   r   r   r   r   r      s
   


zPictureTile.from_jsonNr4   r   r   r   r   r@   k   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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
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 )"Layerz0
    Information about a compositing layer.
    r	   layer_idrA   offset_xoffset_ywidthheightintpaint_countbooldraws_contentNr9   parent_layer_idz"typing.Optional[dom.BackendNodeId]backend_node_idz#typing.Optional[typing.List[float]]	transformtyping.Optional[float]anchor_xanchor_yanchor_zztyping.Optional[bool]	invisiblez(typing.Optional[typing.List[ScrollRect]]scroll_rectsz)typing.Optional[StickyPositionConstraint]sticky_position_constraintc                 C  s(  t  }| j |d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	d ur4| j	 |d< | j
d ur@| j
 |d	< | jd urOd
d | jD |d< | jd urY| j|d< | jd urc| j|d< | jd urm| j|d< | jd urw| j|d< | jd urdd | jD |d< | jd ur| j |d< |S )NlayerIdoffsetXoffsetYrI   rJ   
paintCountdrawsContentparentLayerIdbackendNodeIdc                 S  s   g | ]}|qS r   r   .0ir   r   r   
<listcomp>   s    z!Layer.to_json.<locals>.<listcomp>rQ   anchorXanchorYanchorZrV   c                 S     g | ]}|  qS r   r   r`   r   r   r   rc          scrollRectsstickyPositionConstraint)r1   rF   r   rG   rH   rI   rJ   rL   rN   rO   rP   rQ   rS   rT   rU   rV   rW   rX   r2   r   r   r   r      s6   


















zLayer.to_jsonc                 C  sp  | d i dt |d dt|d dt|d dt|d dt|d d	t|d
 dt|d dd|v rAt |d nd dd|v rPtj|d nd dd|v r`dd |d D nd dd|v rmt|d nd dd|v rzt|d nd dd|v rt|d nd dd|v rt|d nd dd|v rdd |d D nd dd|v rt|d S d S )!NrF   rY   rG   rZ   rH   r[   rI   rJ   rL   r\   rN   r]   rO   r^   rP   r_   rQ   c                 S     g | ]}t |qS r   )rA   r`   r   r   r   rc      ri   z#Layer.from_json.<locals>.<listcomp>rS   rd   rT   re   rU   rf   rV   rW   rj   c                 S     g | ]}t |qS r   )r,   r   r`   r   r   r   rc          rX   rk   r   )r	   r   rA   rK   rM   r   BackendNodeIdr6   r   r   r   r   r      sV   	
zLayer.from_json)r$   r%   r&   r'   r5   rO   rP   rQ   rS   rT   rU   rV   rW   rX   r   r(   r   r   r   r   r   rE      s*   
 rE   c                      r   )PaintProfilez/
    Array of timings, one per paint step.
    r
   typing.List[float]c                 C  r   r   r   r   r   r   r   r      r   zPaintProfile.to_jsonr   c                 C  r   r   r   r   r   r   r   r      r   zPaintProfile.from_jsonc                   r   )NzPaintProfile({})r   r   r   r   r   r      r!   zPaintProfile.__repr__)r
   rq   )r   rq   r
   rp   r#   r   r   r   r   rp      r*   rp   rF   r
   \typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[typing.List[str], typing.List[str]]]c                 c  sH    t  }|  |d< d|d}|V }dd |d D dd |d D fS )	a  
    Provides the reasons why the given layer was composited.

    :param layer_id: The id of the layer for which we want to get the reasons it was composited.
    :returns: A tuple with the following items:

        0. **compositingReasons** - A list of strings specifying reasons for the given layer to become composited.
        1. **compositingReasonIds** - A list of strings specifying reason IDs for the given layer to become composited.
    rY   zLayerTree.compositingReasonsmethodparamsc                 S  rl   r   r   r`   r   r   r   rc     ri   z'compositing_reasons.<locals>.<listcomp>compositingReasonsc                 S  rl   r   rv   r`   r   r   r   rc     ri   compositingReasonIdsr1   r   rF   ru   cmd_dictr   r   r   r   compositing_reasons  s   r|   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c      ddi} | V }dS )z/
    Disables compositing tree inspection.
    rt   zLayerTree.disableNr   r{   r   r   r   r   disable     
r   c                  c  r~   )z.
    Enables compositing tree inspection.
    rt   zLayerTree.enableNr   r   r   r   r   enable$  r   r   tilestyping.List[PictureTile]6typing.Generator[T_JSON_DICT, T_JSON_DICT, SnapshotId]c                 c  s8    t  }dd | D |d< d|d}|V }t|d S )z
    Returns the snapshot identifier.

    :param tiles: An array of tiles composing the snapshot.
    :returns: The id of the snapshot.
    c                 S  rg   r   rh   r`   r   r   r   rc   8  ri   z!load_snapshot.<locals>.<listcomp>r   zLayerTree.loadSnapshotrs   
snapshotId)r1   r+   r   )r   ru   r{   r   r   r   r   load_snapshot.  s   	r   c                 c  s2    t  }|  |d< d|d}|V }t|d S )z
    Returns the layer snapshot identifier.

    :param layer_id: The id of the layer.
    :returns: The id of the layer snapshot.
    rY   zLayerTree.makeSnapshotrs   r   )r1   r   r+   r   rz   r   r   r   make_snapshotA  s   	r   snapshot_idmin_repeat_counttyping.Optional[int]min_durationrR   	clip_recttyping.Optional[dom.Rect]Etyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[PaintProfile]]c                 c  sj    t  }|  |d< |dur||d< |dur||d< |dur$| |d< d|d}|V }dd	 |d
 D S )a  
    :param snapshot_id: The id of the layer snapshot.
    :param min_repeat_count: *(Optional)* The maximum number of times to replay the snapshot (1, if not specified).
    :param min_duration: *(Optional)* The minimum duration (in seconds) to replay the snapshot.
    :param clip_rect: *(Optional)* The clip rectangle to apply when replaying the snapshot.
    :returns: The array of paint profiles, one per run.
    r   NminRepeatCountminDurationclipRectzLayerTree.profileSnapshotrs   c                 S  rm   r   )rp   r   r`   r   r   r   rc   n  rn   z$profile_snapshot.<locals>.<listcomp>timingsry   )r   r   r   r   ru   r{   r   r   r   r   profile_snapshotT  s   r   c                 c  s(    t  }|  |d< d|d}|V }dS )zr
    Releases layer snapshot captured by the back-end.

    :param snapshot_id: The id of the layer snapshot.
    r   zLayerTree.releaseSnapshotrs   Nry   r   ru   r{   r   r   r   r   release_snapshotq  s   
r   	from_stepto_stepscale/typing.Generator[T_JSON_DICT, T_JSON_DICT, str]c                 c  s`    t  }|  |d< |dur||d< |dur||d< |dur"||d< d|d}|V }t|d S )	a  
    Replays the layer snapshot and returns the resulting bitmap.

    :param snapshot_id: The id of the layer snapshot.
    :param from_step: *(Optional)* The first step to replay from (replay from the very start if not specified).
    :param to_step: *(Optional)* The last step to replay to (replay till the end if not specified).
    :param scale: *(Optional)* The scale to apply while replaying (defaults to 1).
    :returns: A data: URL for resulting image.
    r   NfromSteptoStepr   zLayerTree.replaySnapshotrs   dataURL)r1   r   r   )r   r   r   r   ru   r{   r   r   r   r   replay_snapshot  s   r   =typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[dict]]c                 c  s6    t  }|  |d< d|d}|V }dd |d D S )z
    Replays the layer snapshot and returns canvas log.

    :param snapshot_id: The id of the layer snapshot.
    :returns: The array of canvas function calls.
    r   zLayerTree.snapshotCommandLogrs   c                 S  rl   r   )r1   r`   r   r   r   rc     ri   z(snapshot_command_log.<locals>.<listcomp>
commandLogry   r   r   r   r   snapshot_command_log  s   	r   zLayerTree.layerPaintedc                   @  s,   e Zd ZU ded< ded< eddd	Zd
S )LayerPaintedr	   rF   r-   clipr   r   r
   c                 C  s"   | t |d tj|d dS )NrY   r   )rF   r   )r	   r   r   r3   r   r   r   r   r     s   zLayerPainted.from_jsonN)r   r   r
   r   r$   r%   r&   r5   r(   r   r   r   r   r   r     s
   
 r   zLayerTree.layerTreeDidChangec                   @  s$   e Zd ZU ded< ed	ddZdS )
LayerTreeDidChangez#typing.Optional[typing.List[Layer]]layersr   r   r
   c                 C  s(   | d|v rdd |d D dS d dS )Nr   c                 S  rm   r   )rE   r   r`   r   r   r   rc     rn   z0LayerTreeDidChange.from_json.<locals>.<listcomp>)r   r   r   r   r   r   r     s
   zLayerTreeDidChange.from_jsonN)r   r   r
   r   r   r   r   r   r   r     s   
 r   )rF   r	   r
   rr   )r
   r}   )r   r   r
   r   )rF   r	   r
   r   )NNN)
r   r+   r   r   r   rR   r   r   r
   r   )r   r+   r
   r}   )
r   r+   r   r   r   r   r   rR   r
   r   )r   r+   r
   r   )
__future__r   utilr   r   dataclassesr   enumtyping r   r   r	   r+   r,   r6   r@   rE   listrp   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sL   $h








