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

This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object
that has an `id`. This `id` can be used to get additional information on the Node, resolve it into
the JavaScript object wrapper, etc. It is important that client receives DOM events only for the
nodes that are known to the client. Backend keeps track of the nodes that were sent to the client
and never sends the same node twice. It is client's responsibility to collect information about
the nodes that were sent to the client. Note that `iframe` owner elements will return
corresponding document elements as their child nodes.
https://chromedevtools.github.io/devtools-protocol/tot/DOM/

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

from typing import Literal

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


class CollectClassNamesFromSubtreeInput(InputModel):

    nodeId: DOM.NodeId


class CollectClassNamesFromSubtreeOutput(OutputModel):

    classNames: list[str]


class CollectClassNamesFromSubtree(CDPMethod[CollectClassNamesFromSubtreeOutput]):  # experimental
    """ Collects class names for the node with given id and all of it's child nodes. """

    INPUT_VALIDATOR = CollectClassNamesFromSubtreeInput
    OUTPUT_VALIDATOR = CollectClassNamesFromSubtreeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class CopyToInput(InputModel):

    nodeId: DOM.NodeId
    targetNodeId: DOM.NodeId
    insertBeforeNodeId: DOM.NodeId | None = None


class CopyToOutput(OutputModel):

    nodeId: DOM.NodeId


class CopyTo(CDPMethod[CopyToOutput]):  # experimental
    """ Creates a deep copy of the specified node and places it into the target container before the
    given anchor. """

    INPUT_VALIDATOR = CopyToInput
    OUTPUT_VALIDATOR = CopyToOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        target_node_id: DOM.NodeId,
        insert_before_node_id: DOM.NodeId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            targetNodeId=target_node_id,
            insertBeforeNodeId=insert_before_node_id
        )


class DescribeNodeInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None
    depth: int | None = None
    pierce: bool | None = None


class DescribeNodeOutput(OutputModel):

    node: DOM.Node


class DescribeNode(CDPMethod[DescribeNodeOutput]):
    """ Describes node given its id, does not require domain to be enabled. Does not start tracking any
    objects, can be used for automation. """

    INPUT_VALIDATOR = DescribeNodeInput
    OUTPUT_VALIDATOR = DescribeNodeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None,
        depth: int | None = None,
        pierce: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id,
            depth=depth,
            pierce=pierce
        )


class ScrollIntoViewIfNeededInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None
    rect: DOM.Rect | None = None


class ScrollIntoViewIfNeeded(CDPMethod[None]):
    """ Scrolls the specified rect of the given node into view if not already visible.
    Note: exactly one between nodeId, backendNodeId and objectId should be passed
    to identify the node. """

    INPUT_VALIDATOR = ScrollIntoViewIfNeededInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None,
        rect: DOM.Rect | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id,
            rect=rect
        )


class Disable(CDPMethod[None]):
    """ Disables DOM agent for the given page. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class DiscardSearchResultsInput(InputModel):

    searchId: str


class DiscardSearchResults(CDPMethod[None]):  # experimental
    """ Discards search results from the session with the given id. `getSearchResults` should no longer
    be called for that search. """

    INPUT_VALIDATOR = DiscardSearchResultsInput
    OUTPUT_VALIDATOR = None

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


class EnableInput(InputModel):

    includeWhitespace: Literal['none', 'all'] | None = None  # experimental


class Enable(CDPMethod[None]):
    """ Enables DOM agent for the given page. """

    INPUT_VALIDATOR = EnableInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        include_whitespace: Literal['none', 'all'] | None = None
    ):
        super().__init__(
            includeWhitespace=include_whitespace
        )


class FocusInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None


class Focus(CDPMethod[None]):
    """ Focuses the given element. """

    INPUT_VALIDATOR = FocusInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id
        )


class GetAttributesInput(InputModel):

    nodeId: DOM.NodeId


class GetAttributesOutput(OutputModel):

    attributes: list[str]


class GetAttributes(CDPMethod[GetAttributesOutput]):
    """ Returns attributes for the specified node. """

    INPUT_VALIDATOR = GetAttributesInput
    OUTPUT_VALIDATOR = GetAttributesOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class GetBoxModelInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None


class GetBoxModelOutput(OutputModel):

    model: DOM.BoxModel


class GetBoxModel(CDPMethod[GetBoxModelOutput]):
    """ Returns boxes for the given node. """

    INPUT_VALIDATOR = GetBoxModelInput
    OUTPUT_VALIDATOR = GetBoxModelOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id
        )


class GetContentQuadsInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None


class GetContentQuadsOutput(OutputModel):

    quads: list[DOM.Quad]


class GetContentQuads(CDPMethod[GetContentQuadsOutput]):  # experimental
    """ Returns quads that describe node position on the page. This method
    might return multiple quads for inline nodes. """

    INPUT_VALIDATOR = GetContentQuadsInput
    OUTPUT_VALIDATOR = GetContentQuadsOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id
        )


class GetDocumentInput(InputModel):

    depth: int | None = None
    pierce: bool | None = None


class GetDocumentOutput(OutputModel):

    root: DOM.Node


class GetDocument(CDPMethod[GetDocumentOutput]):
    """ Returns the root DOM node (and optionally the subtree) to the caller.
    Implicitly enables the DOM domain events for the current target. """

    INPUT_VALIDATOR = GetDocumentInput
    OUTPUT_VALIDATOR = GetDocumentOutput

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


class GetFlattenedDocumentInput(InputModel):

    depth: int | None = None
    pierce: bool | None = None


class GetFlattenedDocumentOutput(OutputModel):

    nodes: list[DOM.Node]


class GetFlattenedDocument(CDPMethod[GetFlattenedDocumentOutput]):  # deprecated
    """ Returns the root DOM node (and optionally the subtree) to the caller.
    Deprecated, as it is not designed to work well with the rest of the DOM agent.
    Use DOMSnapshot.captureSnapshot instead. """

    INPUT_VALIDATOR = GetFlattenedDocumentInput
    OUTPUT_VALIDATOR = GetFlattenedDocumentOutput

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


class GetNodesForSubtreeByStyleInput(InputModel):

    nodeId: DOM.NodeId
    computedStyles: list[DOM.CSSComputedStyleProperty]
    pierce: bool | None = None


class GetNodesForSubtreeByStyleOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class GetNodesForSubtreeByStyle(CDPMethod[GetNodesForSubtreeByStyleOutput]):  # experimental
    """ Finds nodes with a given computed style in a subtree. """

    INPUT_VALIDATOR = GetNodesForSubtreeByStyleInput
    OUTPUT_VALIDATOR = GetNodesForSubtreeByStyleOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        computed_styles: list[DOM.CSSComputedStyleProperty],
        pierce: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            computedStyles=computed_styles,
            pierce=pierce
        )


class GetNodeForLocationInput(InputModel):

    x: int
    y: int
    includeUserAgentShadowDOM: bool | None = None
    ignorePointerEventsNone: bool | None = None


class GetNodeForLocationOutput(OutputModel):

    backendNodeId: DOM.BackendNodeId
    frameId: Page.FrameId
    nodeId: DOM.NodeId | None = None


class GetNodeForLocation(CDPMethod[GetNodeForLocationOutput]):
    """ Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is
    either returned or not. """

    INPUT_VALIDATOR = GetNodeForLocationInput
    OUTPUT_VALIDATOR = GetNodeForLocationOutput

    def __init__(
        self,
        *,
        x: int,
        y: int,
        include_user_agent_shadow_dom: bool | None = None,
        ignore_pointer_events_none: bool | None = None
    ):
        super().__init__(
            x=x,
            y=y,
            includeUserAgentShadowDOM=include_user_agent_shadow_dom,
            ignorePointerEventsNone=ignore_pointer_events_none
        )


class GetOuterHTMLInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None
    includeShadowDOM: bool | None = None  # experimental


class GetOuterHTMLOutput(OutputModel):

    outerHTML: str


class GetOuterHTML(CDPMethod[GetOuterHTMLOutput]):
    """ Returns node's HTML markup. """

    INPUT_VALIDATOR = GetOuterHTMLInput
    OUTPUT_VALIDATOR = GetOuterHTMLOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None,
        include_shadow_dom: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id,
            includeShadowDOM=include_shadow_dom
        )


class GetRelayoutBoundaryInput(InputModel):

    nodeId: DOM.NodeId


class GetRelayoutBoundaryOutput(OutputModel):

    nodeId: DOM.NodeId


class GetRelayoutBoundary(CDPMethod[GetRelayoutBoundaryOutput]):  # experimental
    """ Returns the id of the nearest ancestor that is a relayout boundary. """

    INPUT_VALIDATOR = GetRelayoutBoundaryInput
    OUTPUT_VALIDATOR = GetRelayoutBoundaryOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class GetSearchResultsInput(InputModel):

    searchId: str
    fromIndex: int
    toIndex: int


class GetSearchResultsOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class GetSearchResults(CDPMethod[GetSearchResultsOutput]):  # experimental
    """ Returns search results from given `fromIndex` to given `toIndex` from the search with the given
    identifier. """

    INPUT_VALIDATOR = GetSearchResultsInput
    OUTPUT_VALIDATOR = GetSearchResultsOutput

    def __init__(
        self,
        *,
        search_id: str,
        from_index: int,
        to_index: int
    ):
        super().__init__(
            searchId=search_id,
            fromIndex=from_index,
            toIndex=to_index
        )


class HideHighlight(CDPMethod[None]):
    """ Hides any highlight. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class HighlightNode(CDPMethod[None]):
    """ Highlights DOM node. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class HighlightRect(CDPMethod[None]):
    """ Highlights given rectangle. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class MarkUndoableState(CDPMethod[None]):  # experimental
    """ Marks last undoable state. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class MoveToInput(InputModel):

    nodeId: DOM.NodeId
    targetNodeId: DOM.NodeId
    insertBeforeNodeId: DOM.NodeId | None = None


class MoveToOutput(OutputModel):

    nodeId: DOM.NodeId


class MoveTo(CDPMethod[MoveToOutput]):
    """ Moves node into the new container, places it before the given anchor. """

    INPUT_VALIDATOR = MoveToInput
    OUTPUT_VALIDATOR = MoveToOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        target_node_id: DOM.NodeId,
        insert_before_node_id: DOM.NodeId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            targetNodeId=target_node_id,
            insertBeforeNodeId=insert_before_node_id
        )


class PerformSearchInput(InputModel):

    query: str
    includeUserAgentShadowDOM: bool | None = None


class PerformSearchOutput(OutputModel):

    searchId: str
    resultCount: int


class PerformSearch(CDPMethod[PerformSearchOutput]):  # experimental
    """ Searches for a given string in the DOM tree. Use `getSearchResults` to access search results or
    `cancelSearch` to end this search session. """

    INPUT_VALIDATOR = PerformSearchInput
    OUTPUT_VALIDATOR = PerformSearchOutput

    def __init__(
        self,
        *,
        query: str,
        include_user_agent_shadow_dom: bool | None = None
    ):
        super().__init__(
            query=query,
            includeUserAgentShadowDOM=include_user_agent_shadow_dom
        )


class PushNodeByPathToFrontendInput(InputModel):

    path: str


class PushNodeByPathToFrontendOutput(OutputModel):

    nodeId: DOM.NodeId


class PushNodeByPathToFrontend(CDPMethod[PushNodeByPathToFrontendOutput]):  # experimental
    """ Requests that the node is sent to the caller given its path. // FIXME, use XPath """

    INPUT_VALIDATOR = PushNodeByPathToFrontendInput
    OUTPUT_VALIDATOR = PushNodeByPathToFrontendOutput

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


class PushNodesByBackendIdsToFrontendInput(InputModel):

    backendNodeIds: list[DOM.BackendNodeId]


class PushNodesByBackendIdsToFrontendOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class PushNodesByBackendIdsToFrontend(CDPMethod[PushNodesByBackendIdsToFrontendOutput]):  # experimental
    """ Requests that a batch of nodes is sent to the caller given their backend node ids. """

    INPUT_VALIDATOR = PushNodesByBackendIdsToFrontendInput
    OUTPUT_VALIDATOR = PushNodesByBackendIdsToFrontendOutput

    def __init__(
        self,
        *,
        backend_node_ids: list[DOM.BackendNodeId]
    ):
        super().__init__(
            backendNodeIds=backend_node_ids
        )


class QuerySelectorInput(InputModel):

    nodeId: DOM.NodeId
    selector: str


class QuerySelectorOutput(OutputModel):

    nodeId: DOM.NodeId


class QuerySelector(CDPMethod[QuerySelectorOutput]):
    """ Executes `querySelector` on a given node. """

    INPUT_VALIDATOR = QuerySelectorInput
    OUTPUT_VALIDATOR = QuerySelectorOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        selector: str
    ):
        super().__init__(
            nodeId=node_id,
            selector=selector
        )


class QuerySelectorAllInput(InputModel):

    nodeId: DOM.NodeId
    selector: str


class QuerySelectorAllOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class QuerySelectorAll(CDPMethod[QuerySelectorAllOutput]):
    """ Executes `querySelectorAll` on a given node. """

    INPUT_VALIDATOR = QuerySelectorAllInput
    OUTPUT_VALIDATOR = QuerySelectorAllOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        selector: str
    ):
        super().__init__(
            nodeId=node_id,
            selector=selector
        )


class GetTopLayerElementsOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class GetTopLayerElements(CDPMethod[GetTopLayerElementsOutput]):  # experimental
    """ Returns NodeIds of current top layer elements.
    Top layer is rendered closest to the user within a viewport, therefore its elements always
    appear on top of all other content. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetTopLayerElementsOutput


class GetElementByRelationInput(InputModel):

    nodeId: DOM.NodeId
    relation: Literal['PopoverTarget', 'InterestTarget', 'CommandFor']


class GetElementByRelationOutput(OutputModel):

    nodeId: DOM.NodeId


class GetElementByRelation(CDPMethod[GetElementByRelationOutput]):  # experimental
    """ Returns the NodeId of the matched element according to certain relations. """

    INPUT_VALIDATOR = GetElementByRelationInput
    OUTPUT_VALIDATOR = GetElementByRelationOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        relation: Literal['PopoverTarget', 'InterestTarget', 'CommandFor']
    ):
        super().__init__(
            nodeId=node_id,
            relation=relation
        )


class Redo(CDPMethod[None]):  # experimental
    """ Re-does the last undone action. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class RemoveAttributeInput(InputModel):

    nodeId: DOM.NodeId
    name: str


class RemoveAttribute(CDPMethod[None]):
    """ Removes attribute with given name from an element with given id. """

    INPUT_VALIDATOR = RemoveAttributeInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        name: str
    ):
        super().__init__(
            nodeId=node_id,
            name=name
        )


class RemoveNodeInput(InputModel):

    nodeId: DOM.NodeId


class RemoveNode(CDPMethod[None]):
    """ Removes node with given id. """

    INPUT_VALIDATOR = RemoveNodeInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class RequestChildNodesInput(InputModel):

    nodeId: DOM.NodeId
    depth: int | None = None
    pierce: bool | None = None


class RequestChildNodes(CDPMethod[None]):
    """ Requests that children of the node with given id are returned to the caller in form of
    `setChildNodes` events where not only immediate children are retrieved, but all children down to
    the specified depth. """

    INPUT_VALIDATOR = RequestChildNodesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        depth: int | None = None,
        pierce: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            depth=depth,
            pierce=pierce
        )


class RequestNodeInput(InputModel):

    objectId: Runtime.RemoteObjectId


class RequestNodeOutput(OutputModel):

    nodeId: DOM.NodeId


class RequestNode(CDPMethod[RequestNodeOutput]):
    """ Requests that the node is sent to the caller given the JavaScript node object reference. All
    nodes that form the path from the node to the root are also sent to the client as a series of
    `setChildNodes` notifications. """

    INPUT_VALIDATOR = RequestNodeInput
    OUTPUT_VALIDATOR = RequestNodeOutput

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId
    ):
        super().__init__(
            objectId=object_id
        )


class ResolveNodeInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectGroup: str | None = None
    executionContextId: Runtime.ExecutionContextId | None = None


class ResolveNodeOutput(OutputModel):

    object: Runtime.RemoteObject


class ResolveNode(CDPMethod[ResolveNodeOutput]):
    """ Resolves the JavaScript node object for a given NodeId or BackendNodeId. """

    INPUT_VALIDATOR = ResolveNodeInput
    OUTPUT_VALIDATOR = ResolveNodeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_group: str | None = None,
        execution_context_id: Runtime.ExecutionContextId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectGroup=object_group,
            executionContextId=execution_context_id
        )


class SetAttributeValueInput(InputModel):

    nodeId: DOM.NodeId
    name: str
    value: str


class SetAttributeValue(CDPMethod[None]):
    """ Sets attribute for an element with given id. """

    INPUT_VALIDATOR = SetAttributeValueInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        name: str,
        value: str
    ):
        super().__init__(
            nodeId=node_id,
            name=name,
            value=value
        )


class SetAttributesAsTextInput(InputModel):

    nodeId: DOM.NodeId
    text: str
    name: str | None = None


class SetAttributesAsText(CDPMethod[None]):
    """ Sets attributes on element with given id. This method is useful when user edits some existing
    attribute value and types in several attribute name/value pairs. """

    INPUT_VALIDATOR = SetAttributesAsTextInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        text: str,
        name: str | None = None
    ):
        super().__init__(
            nodeId=node_id,
            text=text,
            name=name
        )


class SetFileInputFilesInput(InputModel):

    files: list[str]
    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None


class SetFileInputFiles(CDPMethod[None]):
    """ Sets files for the given file input element. """

    INPUT_VALIDATOR = SetFileInputFilesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        files: list[str],
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None
    ):
        super().__init__(
            files=files,
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id
        )


class SetNodeStackTracesEnabledInput(InputModel):

    enable: bool


class SetNodeStackTracesEnabled(CDPMethod[None]):  # experimental
    """ Sets if stack traces should be captured for Nodes. See `Node.getNodeStackTraces`. Default is disabled. """

    INPUT_VALIDATOR = SetNodeStackTracesEnabledInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        enable: bool
    ):
        super().__init__(
            enable=enable
        )


class GetNodeStackTracesInput(InputModel):

    nodeId: DOM.NodeId


class GetNodeStackTracesOutput(OutputModel):

    creation: Runtime.StackTrace | None = None


class GetNodeStackTraces(CDPMethod[GetNodeStackTracesOutput]):  # experimental
    """ Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation. """

    INPUT_VALIDATOR = GetNodeStackTracesInput
    OUTPUT_VALIDATOR = GetNodeStackTracesOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class GetFileInfoInput(InputModel):

    objectId: Runtime.RemoteObjectId


class GetFileInfoOutput(OutputModel):

    path: str


class GetFileInfo(CDPMethod[GetFileInfoOutput]):  # experimental
    """ Returns file information for the given
    File wrapper. """

    INPUT_VALIDATOR = GetFileInfoInput
    OUTPUT_VALIDATOR = GetFileInfoOutput

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId
    ):
        super().__init__(
            objectId=object_id
        )


class GetDetachedDomNodesOutput(OutputModel):

    detachedNodes: list[DOM.DetachedElementInfo]


class GetDetachedDomNodes(CDPMethod[GetDetachedDomNodesOutput]):  # experimental
    """ Returns list of detached nodes """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetDetachedDomNodesOutput


class SetInspectedNodeInput(InputModel):

    nodeId: DOM.NodeId


class SetInspectedNode(CDPMethod[None]):  # experimental
    """ Enables console to refer to the node with given id via $x (see Command Line API for more details
    $x functions). """

    INPUT_VALIDATOR = SetInspectedNodeInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class SetNodeNameInput(InputModel):

    nodeId: DOM.NodeId
    name: str


class SetNodeNameOutput(OutputModel):

    nodeId: DOM.NodeId


class SetNodeName(CDPMethod[SetNodeNameOutput]):
    """ Sets node name for a node with given id. """

    INPUT_VALIDATOR = SetNodeNameInput
    OUTPUT_VALIDATOR = SetNodeNameOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        name: str
    ):
        super().__init__(
            nodeId=node_id,
            name=name
        )


class SetNodeValueInput(InputModel):

    nodeId: DOM.NodeId
    value: str


class SetNodeValue(CDPMethod[None]):
    """ Sets node value for a node with given id. """

    INPUT_VALIDATOR = SetNodeValueInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        value: str
    ):
        super().__init__(
            nodeId=node_id,
            value=value
        )


class SetOuterHTMLInput(InputModel):

    nodeId: DOM.NodeId
    outerHTML: str


class SetOuterHTML(CDPMethod[None]):
    """ Sets node HTML markup, returns new node id. """

    INPUT_VALIDATOR = SetOuterHTMLInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        outer_html: str
    ):
        super().__init__(
            nodeId=node_id,
            outerHTML=outer_html
        )


class Undo(CDPMethod[None]):  # experimental
    """ Undoes the last performed action. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class GetFrameOwnerInput(InputModel):

    frameId: Page.FrameId


class GetFrameOwnerOutput(OutputModel):

    backendNodeId: DOM.BackendNodeId
    nodeId: DOM.NodeId | None = None


class GetFrameOwner(CDPMethod[GetFrameOwnerOutput]):  # experimental
    """ Returns iframe node that owns iframe with the given domain. """

    INPUT_VALIDATOR = GetFrameOwnerInput
    OUTPUT_VALIDATOR = GetFrameOwnerOutput

    def __init__(
        self,
        *,
        frame_id: Page.FrameId
    ):
        super().__init__(
            frameId=frame_id
        )


class GetContainerForNodeInput(InputModel):

    nodeId: DOM.NodeId
    containerName: str | None = None
    physicalAxes: DOM.PhysicalAxes | None = None
    logicalAxes: DOM.LogicalAxes | None = None
    queriesScrollState: bool | None = None
    queriesAnchored: bool | None = None


class GetContainerForNodeOutput(OutputModel):

    nodeId: DOM.NodeId | None = None


class GetContainerForNode(CDPMethod[GetContainerForNodeOutput]):  # experimental
    """ Returns the query container of the given node based on container query
    conditions: containerName, physical and logical axes, and whether it queries
    scroll-state or anchored elements. If no axes are provided and
    queriesScrollState is false, the style container is returned, which is the
    direct parent or the closest element with a matching container-name. """

    INPUT_VALIDATOR = GetContainerForNodeInput
    OUTPUT_VALIDATOR = GetContainerForNodeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        container_name: str | None = None,
        physical_axes: DOM.PhysicalAxes | None = None,
        logical_axes: DOM.LogicalAxes | None = None,
        queries_scroll_state: bool | None = None,
        queries_anchored: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            containerName=container_name,
            physicalAxes=physical_axes,
            logicalAxes=logical_axes,
            queriesScrollState=queries_scroll_state,
            queriesAnchored=queries_anchored
        )


class GetQueryingDescendantsForContainerInput(InputModel):

    nodeId: DOM.NodeId


class GetQueryingDescendantsForContainerOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class GetQueryingDescendantsForContainer(CDPMethod[GetQueryingDescendantsForContainerOutput]):  # experimental
    """ Returns the descendants of a container query container that have
    container queries against this container. """

    INPUT_VALIDATOR = GetQueryingDescendantsForContainerInput
    OUTPUT_VALIDATOR = GetQueryingDescendantsForContainerOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId
    ):
        super().__init__(
            nodeId=node_id
        )


class GetAnchorElementInput(InputModel):

    nodeId: DOM.NodeId
    anchorSpecifier: str | None = None


class GetAnchorElementOutput(OutputModel):

    nodeId: DOM.NodeId


class GetAnchorElement(CDPMethod[GetAnchorElementOutput]):  # experimental
    """ Returns the target anchor element of the given anchor query according to
    https://www.w3.org/TR/css-anchor-position-1/#target. """

    INPUT_VALIDATOR = GetAnchorElementInput
    OUTPUT_VALIDATOR = GetAnchorElementOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        anchor_specifier: str | None = None
    ):
        super().__init__(
            nodeId=node_id,
            anchorSpecifier=anchor_specifier
        )


class ForceShowPopoverInput(InputModel):

    nodeId: DOM.NodeId
    enable: bool


class ForceShowPopoverOutput(OutputModel):

    nodeIds: list[DOM.NodeId]


class ForceShowPopover(CDPMethod[ForceShowPopoverOutput]):  # experimental
    """ When enabling, this API force-opens the popover identified by nodeId
    and keeps it open until disabled. """

    INPUT_VALIDATOR = ForceShowPopoverInput
    OUTPUT_VALIDATOR = ForceShowPopoverOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId,
        enable: bool
    ):
        super().__init__(
            nodeId=node_id,
            enable=enable
        )
