"""
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/

***************************************************
                    Events
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    DOM,
)
from cdpkit.protocol.base import CDPEvent


class AttributeModified(CDPEvent):
    """ Fired when `Element`'s attribute is modified. """

    nodeId: DOM.NodeId
    name: str
    value: str


class AdoptedStyleSheetsModified(CDPEvent):
    """ Fired when `Element`'s adoptedStyleSheets are modified. """

    nodeId: DOM.NodeId
    adoptedStyleSheets: list[DOM.StyleSheetId] | None = None  # experimental


class AttributeRemoved(CDPEvent):
    """ Fired when `Element`'s attribute is removed. """

    nodeId: DOM.NodeId
    name: str


class CharacterDataModified(CDPEvent):
    """ Mirrors `DOMCharacterDataModified` event. """

    nodeId: DOM.NodeId
    characterData: str


class ChildNodeCountUpdated(CDPEvent):
    """ Fired when `Container`'s child node count has changed. """

    nodeId: DOM.NodeId
    childNodeCount: int


class ChildNodeInserted(CDPEvent):
    """ Mirrors `DOMNodeInserted` event. """

    parentNodeId: DOM.NodeId
    previousNodeId: DOM.NodeId
    node: DOM.Node


class ChildNodeRemoved(CDPEvent):
    """ Mirrors `DOMNodeRemoved` event. """

    parentNodeId: DOM.NodeId
    nodeId: DOM.NodeId


class DistributedNodesUpdated(CDPEvent):
    """ Called when distribution is changed. """

    insertionPointId: DOM.NodeId
    distributedNodes: list[DOM.BackendNode]


class DocumentUpdated(CDPEvent):
    """ Fired when `Document` has been totally updated. Node ids are no longer valid. """

    ...


class InlineStyleInvalidated(CDPEvent):
    """ Fired when `Element`'s inline style is modified via a CSS property modification. """

    nodeIds: list[DOM.NodeId]


class PseudoElementAdded(CDPEvent):
    """ Called when a pseudo element is added to an element. """

    parentId: DOM.NodeId
    pseudoElement: DOM.Node


class TopLayerElementsUpdated(CDPEvent):
    """ Called when top layer elements are changed. """

    ...


class ScrollableFlagUpdated(CDPEvent):
    """ Fired when a node's scrollability state changes. """

    nodeId: DOM.NodeId
    isScrollable: bool


class AffectedByStartingStylesFlagUpdated(CDPEvent):
    """ Fired when a node's starting styles changes. """

    nodeId: DOM.NodeId
    affectedByStartingStyles: bool


class PseudoElementRemoved(CDPEvent):
    """ Called when a pseudo element is removed from an element. """

    parentId: DOM.NodeId
    pseudoElementId: DOM.NodeId


class SetChildNodes(CDPEvent):
    """ Fired when backend wants to provide client with the missing DOM structure. This happens upon
    most of the calls requesting node ids. """

    parentId: DOM.NodeId
    nodes: list[DOM.Node]


class ShadowRootPopped(CDPEvent):
    """ Called when shadow root is popped from the element. """

    hostId: DOM.NodeId
    rootId: DOM.NodeId


class ShadowRootPushed(CDPEvent):
    """ Called when shadow root is pushed into the element. """

    hostId: DOM.NodeId
    root: DOM.Node
