"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.


https://chromedevtools.github.io/devtools-protocol/tot/LayerTree/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    DOM,
    LayerTree,
)
from cdpkit.protocol.base import JSON_DICT, CDPMethod, InputModel, OutputModel


class CompositingReasonsInput(InputModel):

    layerId: LayerTree.LayerId


class CompositingReasonsOutput(OutputModel):

    compositingReasons: list[str]
    compositingReasonIds: list[str]


class CompositingReasons(CDPMethod[CompositingReasonsOutput]):
    """ Provides the reasons why the given layer was composited. """

    INPUT_VALIDATOR = CompositingReasonsInput
    OUTPUT_VALIDATOR = CompositingReasonsOutput

    def __init__(
        self,
        *,
        layer_id: LayerTree.LayerId
    ):
        super().__init__(
            layerId=layer_id
        )


class Disable(CDPMethod[None]):
    """ Disables compositing tree inspection. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):
    """ Enables compositing tree inspection. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class LoadSnapshotInput(InputModel):

    tiles: list[LayerTree.PictureTile]


class LoadSnapshotOutput(OutputModel):

    snapshotId: LayerTree.SnapshotId


class LoadSnapshot(CDPMethod[LoadSnapshotOutput]):
    """ Returns the snapshot identifier. """

    INPUT_VALIDATOR = LoadSnapshotInput
    OUTPUT_VALIDATOR = LoadSnapshotOutput

    def __init__(
        self,
        *,
        tiles: list[LayerTree.PictureTile]
    ):
        super().__init__(
            tiles=tiles
        )


class MakeSnapshotInput(InputModel):

    layerId: LayerTree.LayerId


class MakeSnapshotOutput(OutputModel):

    snapshotId: LayerTree.SnapshotId


class MakeSnapshot(CDPMethod[MakeSnapshotOutput]):
    """ Returns the layer snapshot identifier. """

    INPUT_VALIDATOR = MakeSnapshotInput
    OUTPUT_VALIDATOR = MakeSnapshotOutput

    def __init__(
        self,
        *,
        layer_id: LayerTree.LayerId
    ):
        super().__init__(
            layerId=layer_id
        )


class ProfileSnapshotInput(InputModel):

    snapshotId: LayerTree.SnapshotId
    minRepeatCount: int | None = None
    minDuration: float | None = None
    clipRect: DOM.Rect | None = None


class ProfileSnapshotOutput(OutputModel):

    timings: list[LayerTree.PaintProfile]


class ProfileSnapshot(CDPMethod[ProfileSnapshotOutput]):

    INPUT_VALIDATOR = ProfileSnapshotInput
    OUTPUT_VALIDATOR = ProfileSnapshotOutput

    def __init__(
        self,
        *,
        snapshot_id: LayerTree.SnapshotId,
        min_repeat_count: int | None = None,
        min_duration: float | None = None,
        clip_rect: DOM.Rect | None = None
    ):
        super().__init__(
            snapshotId=snapshot_id,
            minRepeatCount=min_repeat_count,
            minDuration=min_duration,
            clipRect=clip_rect
        )


class ReleaseSnapshotInput(InputModel):

    snapshotId: LayerTree.SnapshotId


class ReleaseSnapshot(CDPMethod[None]):
    """ Releases layer snapshot captured by the back-end. """

    INPUT_VALIDATOR = ReleaseSnapshotInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        snapshot_id: LayerTree.SnapshotId
    ):
        super().__init__(
            snapshotId=snapshot_id
        )


class ReplaySnapshotInput(InputModel):

    snapshotId: LayerTree.SnapshotId
    fromStep: int | None = None
    toStep: int | None = None
    scale: float | None = None


class ReplaySnapshotOutput(OutputModel):

    dataURL: str


class ReplaySnapshot(CDPMethod[ReplaySnapshotOutput]):
    """ Replays the layer snapshot and returns the resulting bitmap. """

    INPUT_VALIDATOR = ReplaySnapshotInput
    OUTPUT_VALIDATOR = ReplaySnapshotOutput

    def __init__(
        self,
        *,
        snapshot_id: LayerTree.SnapshotId,
        from_step: int | None = None,
        to_step: int | None = None,
        scale: float | None = None
    ):
        super().__init__(
            snapshotId=snapshot_id,
            fromStep=from_step,
            toStep=to_step,
            scale=scale
        )


class SnapshotCommandLogInput(InputModel):

    snapshotId: LayerTree.SnapshotId


class SnapshotCommandLogOutput(OutputModel):

    commandLog: list[JSON_DICT]


class SnapshotCommandLog(CDPMethod[SnapshotCommandLogOutput]):
    """ Replays the layer snapshot and returns canvas log. """

    INPUT_VALIDATOR = SnapshotCommandLogInput
    OUTPUT_VALIDATOR = SnapshotCommandLogOutput

    def __init__(
        self,
        *,
        snapshot_id: LayerTree.SnapshotId
    ):
        super().__init__(
            snapshotId=snapshot_id
        )
