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


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

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

from typing import Literal

from cdpkit.protocol._types import (
    Input,
)
from cdpkit.protocol.base import CDPMethod, InputModel


class DispatchDragEventInput(InputModel):

    type: Literal['dragEnter', 'dragOver', 'drop', 'dragCancel']
    x: float
    y: float
    data: Input.DragData
    modifiers: int | None = None


class DispatchDragEvent(CDPMethod[None]):  # experimental
    """ Dispatches a drag event into the page. """

    INPUT_VALIDATOR = DispatchDragEventInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        type_: Literal['dragEnter', 'dragOver', 'drop', 'dragCancel'],
        x: float,
        y: float,
        data: Input.DragData,
        modifiers: int | None = None
    ):
        super().__init__(
            type=type_,
            x=x,
            y=y,
            data=data,
            modifiers=modifiers
        )


class DispatchKeyEventInput(InputModel):

    type: Literal['keyDown', 'keyUp', 'rawKeyDown', 'char']
    modifiers: int | None = None
    timestamp: Input.TimeSinceEpoch | None = None
    text: str | None = None
    unmodifiedText: str | None = None
    keyIdentifier: str | None = None
    code: str | None = None
    key: str | None = None
    windowsVirtualKeyCode: int | None = None
    nativeVirtualKeyCode: int | None = None
    autoRepeat: bool | None = None
    isKeypad: bool | None = None
    isSystemKey: bool | None = None
    location: int | None = None
    commands: list[str] | None = None  # experimental


class DispatchKeyEvent(CDPMethod[None]):
    """ Dispatches a key event to the page. """

    INPUT_VALIDATOR = DispatchKeyEventInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        type_: Literal['keyDown', 'keyUp', 'rawKeyDown', 'char'],
        modifiers: int | None = None,
        timestamp: Input.TimeSinceEpoch | None = None,
        text: str | None = None,
        unmodified_text: str | None = None,
        key_identifier: str | None = None,
        code: str | None = None,
        key: str | None = None,
        windows_virtual_key_code: int | None = None,
        native_virtual_key_code: int | None = None,
        auto_repeat: bool | None = None,
        is_keypad: bool | None = None,
        is_system_key: bool | None = None,
        location: int | None = None,
        commands: list[str] | None = None
    ):
        super().__init__(
            type=type_,
            modifiers=modifiers,
            timestamp=timestamp,
            text=text,
            unmodifiedText=unmodified_text,
            keyIdentifier=key_identifier,
            code=code,
            key=key,
            windowsVirtualKeyCode=windows_virtual_key_code,
            nativeVirtualKeyCode=native_virtual_key_code,
            autoRepeat=auto_repeat,
            isKeypad=is_keypad,
            isSystemKey=is_system_key,
            location=location,
            commands=commands
        )


class InsertTextInput(InputModel):

    text: str


class InsertText(CDPMethod[None]):  # experimental
    """ This method emulates inserting text that doesn't come from a key press,
    for example an emoji keyboard or an IME. """

    INPUT_VALIDATOR = InsertTextInput
    OUTPUT_VALIDATOR = None

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


class ImeSetCompositionInput(InputModel):

    text: str
    selectionStart: int
    selectionEnd: int
    replacementStart: int | None = None
    replacementEnd: int | None = None


class ImeSetComposition(CDPMethod[None]):  # experimental
    """ This method sets the current candidate text for IME.
    Use imeCommitComposition to commit the final text.
    Use imeSetComposition with empty string as text to cancel composition. """

    INPUT_VALIDATOR = ImeSetCompositionInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        text: str,
        selection_start: int,
        selection_end: int,
        replacement_start: int | None = None,
        replacement_end: int | None = None
    ):
        super().__init__(
            text=text,
            selectionStart=selection_start,
            selectionEnd=selection_end,
            replacementStart=replacement_start,
            replacementEnd=replacement_end
        )


class DispatchMouseEventInput(InputModel):

    type: Literal['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel']
    x: float
    y: float
    modifiers: int | None = None
    timestamp: Input.TimeSinceEpoch | None = None
    button: Input.MouseButton | None = None
    buttons: int | None = None
    clickCount: int | None = None
    force: float | None = None  # experimental
    tangentialPressure: float | None = None  # experimental
    tiltX: float | None = None
    tiltY: float | None = None
    twist: int | None = None  # experimental
    deltaX: float | None = None
    deltaY: float | None = None
    pointerType: Literal['mouse', 'pen'] | None = None


class DispatchMouseEvent(CDPMethod[None]):
    """ Dispatches a mouse event to the page. """

    INPUT_VALIDATOR = DispatchMouseEventInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        type_: Literal['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel'],
        x: float,
        y: float,
        modifiers: int | None = None,
        timestamp: Input.TimeSinceEpoch | None = None,
        button: Input.MouseButton | None = None,
        buttons: int | None = None,
        click_count: int | None = None,
        force: float | None = None,
        tangential_pressure: float | None = None,
        tilt_x: float | None = None,
        tilt_y: float | None = None,
        twist: int | None = None,
        delta_x: float | None = None,
        delta_y: float | None = None,
        pointer_type: Literal['mouse', 'pen'] | None = None
    ):
        super().__init__(
            type=type_,
            x=x,
            y=y,
            modifiers=modifiers,
            timestamp=timestamp,
            button=button,
            buttons=buttons,
            clickCount=click_count,
            force=force,
            tangentialPressure=tangential_pressure,
            tiltX=tilt_x,
            tiltY=tilt_y,
            twist=twist,
            deltaX=delta_x,
            deltaY=delta_y,
            pointerType=pointer_type
        )


class DispatchTouchEventInput(InputModel):

    type: Literal['touchStart', 'touchEnd', 'touchMove', 'touchCancel']
    touchPoints: list[Input.TouchPoint]
    modifiers: int | None = None
    timestamp: Input.TimeSinceEpoch | None = None


class DispatchTouchEvent(CDPMethod[None]):
    """ Dispatches a touch event to the page. """

    INPUT_VALIDATOR = DispatchTouchEventInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        type_: Literal['touchStart', 'touchEnd', 'touchMove', 'touchCancel'],
        touch_points: list[Input.TouchPoint],
        modifiers: int | None = None,
        timestamp: Input.TimeSinceEpoch | None = None
    ):
        super().__init__(
            type=type_,
            touchPoints=touch_points,
            modifiers=modifiers,
            timestamp=timestamp
        )


class CancelDragging(CDPMethod[None]):
    """ Cancels any active dragging in the page. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class EmulateTouchFromMouseEventInput(InputModel):

    type: Literal['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel']
    x: int
    y: int
    button: Input.MouseButton
    timestamp: Input.TimeSinceEpoch | None = None
    deltaX: float | None = None
    deltaY: float | None = None
    modifiers: int | None = None
    clickCount: int | None = None


class EmulateTouchFromMouseEvent(CDPMethod[None]):  # experimental
    """ Emulates touch event from the mouse event parameters. """

    INPUT_VALIDATOR = EmulateTouchFromMouseEventInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        type_: Literal['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel'],
        x: int,
        y: int,
        button: Input.MouseButton,
        timestamp: Input.TimeSinceEpoch | None = None,
        delta_x: float | None = None,
        delta_y: float | None = None,
        modifiers: int | None = None,
        click_count: int | None = None
    ):
        super().__init__(
            type=type_,
            x=x,
            y=y,
            button=button,
            timestamp=timestamp,
            deltaX=delta_x,
            deltaY=delta_y,
            modifiers=modifiers,
            clickCount=click_count
        )


class SetIgnoreInputEventsInput(InputModel):

    ignore: bool


class SetIgnoreInputEvents(CDPMethod[None]):
    """ Ignores input events (useful while auditing page). """

    INPUT_VALIDATOR = SetIgnoreInputEventsInput
    OUTPUT_VALIDATOR = None

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


class SetInterceptDragsInput(InputModel):

    enabled: bool


class SetInterceptDrags(CDPMethod[None]):  # experimental
    """ Prevents default drag and drop behavior and instead emits `Input.dragIntercepted` events.
    Drag and drop behavior can be directly controlled via `Input.dispatchDragEvent`. """

    INPUT_VALIDATOR = SetInterceptDragsInput
    OUTPUT_VALIDATOR = None

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


class SynthesizePinchGestureInput(InputModel):

    x: float
    y: float
    scaleFactor: float
    relativeSpeed: int | None = None
    gestureSourceType: Input.GestureSourceType | None = None


class SynthesizePinchGesture(CDPMethod[None]):  # experimental
    """ Synthesizes a pinch gesture over a time period by issuing appropriate touch events. """

    INPUT_VALIDATOR = SynthesizePinchGestureInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        x: float,
        y: float,
        scale_factor: float,
        relative_speed: int | None = None,
        gesture_source_type: Input.GestureSourceType | None = None
    ):
        super().__init__(
            x=x,
            y=y,
            scaleFactor=scale_factor,
            relativeSpeed=relative_speed,
            gestureSourceType=gesture_source_type
        )


class SynthesizeScrollGestureInput(InputModel):

    x: float
    y: float
    xDistance: float | None = None
    yDistance: float | None = None
    xOverscroll: float | None = None
    yOverscroll: float | None = None
    preventFling: bool | None = None
    speed: int | None = None
    gestureSourceType: Input.GestureSourceType | None = None
    repeatCount: int | None = None
    repeatDelayMs: int | None = None
    interactionMarkerName: str | None = None


class SynthesizeScrollGesture(CDPMethod[None]):  # experimental
    """ Synthesizes a scroll gesture over a time period by issuing appropriate touch events. """

    INPUT_VALIDATOR = SynthesizeScrollGestureInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        x: float,
        y: float,
        x_distance: float | None = None,
        y_distance: float | None = None,
        x_overscroll: float | None = None,
        y_overscroll: float | None = None,
        prevent_fling: bool | None = None,
        speed: int | None = None,
        gesture_source_type: Input.GestureSourceType | None = None,
        repeat_count: int | None = None,
        repeat_delay_ms: int | None = None,
        interaction_marker_name: str | None = None
    ):
        super().__init__(
            x=x,
            y=y,
            xDistance=x_distance,
            yDistance=y_distance,
            xOverscroll=x_overscroll,
            yOverscroll=y_overscroll,
            preventFling=prevent_fling,
            speed=speed,
            gestureSourceType=gesture_source_type,
            repeatCount=repeat_count,
            repeatDelayMs=repeat_delay_ms,
            interactionMarkerName=interaction_marker_name
        )


class SynthesizeTapGestureInput(InputModel):

    x: float
    y: float
    duration: int | None = None
    tapCount: int | None = None
    gestureSourceType: Input.GestureSourceType | None = None


class SynthesizeTapGesture(CDPMethod[None]):  # experimental
    """ Synthesizes a tap gesture over a time period by issuing appropriate touch events. """

    INPUT_VALIDATOR = SynthesizeTapGestureInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        x: float,
        y: float,
        duration: int | None = None,
        tap_count: int | None = None,
        gesture_source_type: Input.GestureSourceType | None = None
    ):
        super().__init__(
            x=x,
            y=y,
            duration=duration,
            tapCount=tap_count,
            gestureSourceType=gesture_source_type
        )
