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

DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript
execution will stop on these operations as if there was a regular breakpoint set.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/

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

from cdpkit.protocol._types import (
    DOM,
    DOMDebugger,
    Runtime,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class GetEventListenersInput(InputModel):

    objectId: Runtime.RemoteObjectId
    depth: int | None = None
    pierce: bool | None = None


class GetEventListenersOutput(OutputModel):

    listeners: list[DOMDebugger.EventListener]


class GetEventListeners(CDPMethod[GetEventListenersOutput]):
    """ Returns event listeners of the given object. """

    INPUT_VALIDATOR = GetEventListenersInput
    OUTPUT_VALIDATOR = GetEventListenersOutput

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId,
        depth: int | None = None,
        pierce: bool | None = None
    ):
        super().__init__(
            objectId=object_id,
            depth=depth,
            pierce=pierce
        )


class RemoveDOMBreakpointInput(InputModel):

    nodeId: DOM.NodeId
    type: DOMDebugger.DOMBreakpointType


class RemoveDOMBreakpoint(CDPMethod[None]):
    """ Removes DOM breakpoint that was set using `setDOMBreakpoint`. """

    INPUT_VALIDATOR = RemoveDOMBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        type_: DOMDebugger.DOMBreakpointType
    ):
        super().__init__(
            nodeId=node_id,
            type=type_
        )


class RemoveEventListenerBreakpointInput(InputModel):

    eventName: str
    targetName: str | None = None  # experimental


class RemoveEventListenerBreakpoint(CDPMethod[None]):
    """ Removes breakpoint on particular DOM event. """

    INPUT_VALIDATOR = RemoveEventListenerBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        event_name: str,
        target_name: str | None = None
    ):
        super().__init__(
            eventName=event_name,
            targetName=target_name
        )


class RemoveInstrumentationBreakpointInput(InputModel):

    eventName: str


class RemoveInstrumentationBreakpoint(CDPMethod[None]):  # experimental deprecated
    """ Removes breakpoint on particular native event. """

    INPUT_VALIDATOR = RemoveInstrumentationBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        event_name: str
    ):
        super().__init__(
            eventName=event_name
        )


class RemoveXHRBreakpointInput(InputModel):

    url: str


class RemoveXHRBreakpoint(CDPMethod[None]):
    """ Removes breakpoint from XMLHttpRequest. """

    INPUT_VALIDATOR = RemoveXHRBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        url: str
    ):
        super().__init__(
            url=url
        )


class SetBreakOnCSPViolationInput(InputModel):

    violationTypes: list[DOMDebugger.CSPViolationType]


class SetBreakOnCSPViolation(CDPMethod[None]):  # experimental
    """ Sets breakpoint on particular CSP violations. """

    INPUT_VALIDATOR = SetBreakOnCSPViolationInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        violation_types: list[DOMDebugger.CSPViolationType]
    ):
        super().__init__(
            violationTypes=violation_types
        )


class SetDOMBreakpointInput(InputModel):

    nodeId: DOM.NodeId
    type: DOMDebugger.DOMBreakpointType


class SetDOMBreakpoint(CDPMethod[None]):
    """ Sets breakpoint on particular operation with DOM. """

    INPUT_VALIDATOR = SetDOMBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        type_: DOMDebugger.DOMBreakpointType
    ):
        super().__init__(
            nodeId=node_id,
            type=type_
        )


class SetEventListenerBreakpointInput(InputModel):

    eventName: str
    targetName: str | None = None  # experimental


class SetEventListenerBreakpoint(CDPMethod[None]):
    """ Sets breakpoint on particular DOM event. """

    INPUT_VALIDATOR = SetEventListenerBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        event_name: str,
        target_name: str | None = None
    ):
        super().__init__(
            eventName=event_name,
            targetName=target_name
        )


class SetInstrumentationBreakpointInput(InputModel):

    eventName: str


class SetInstrumentationBreakpoint(CDPMethod[None]):  # experimental deprecated
    """ Sets breakpoint on particular native event. """

    INPUT_VALIDATOR = SetInstrumentationBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        event_name: str
    ):
        super().__init__(
            eventName=event_name
        )


class SetXHRBreakpointInput(InputModel):

    url: str


class SetXHRBreakpoint(CDPMethod[None]):
    """ Sets breakpoint on XMLHttpRequest. """

    INPUT_VALIDATOR = SetXHRBreakpointInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        url: str
    ):
        super().__init__(
            url=url
        )
