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

The Browser domain defines methods and events for browser managing.
https://chromedevtools.github.io/devtools-protocol/tot/Browser/

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

from typing import Literal

from cdpkit.protocol._types import (
    Browser,
    Target,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class SetPermissionInput(InputModel):

    permission: Browser.PermissionDescriptor
    setting: Browser.PermissionSetting
    origin: str | None = None
    embeddedOrigin: str | None = None
    browserContextId: Browser.BrowserContextID | None = None


class SetPermission(CDPMethod[None]):  # experimental
    """ Set permission settings for given embedding and embedded origins. """

    INPUT_VALIDATOR = SetPermissionInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        permission: Browser.PermissionDescriptor,
        setting: Browser.PermissionSetting,
        origin: str | None = None,
        embedded_origin: str | None = None,
        browser_context_id: Browser.BrowserContextID | None = None
    ):
        super().__init__(
            permission=permission,
            setting=setting,
            origin=origin,
            embeddedOrigin=embedded_origin,
            browserContextId=browser_context_id
        )


class GrantPermissionsInput(InputModel):

    permissions: list[Browser.PermissionType]
    origin: str | None = None
    browserContextId: Browser.BrowserContextID | None = None


class GrantPermissions(CDPMethod[None]):  # experimental deprecated
    """ Grant specific permissions to the given origin and reject all others. Deprecated. Use
    setPermission instead. """

    INPUT_VALIDATOR = GrantPermissionsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        permissions: list[Browser.PermissionType],
        origin: str | None = None,
        browser_context_id: Browser.BrowserContextID | None = None
    ):
        super().__init__(
            permissions=permissions,
            origin=origin,
            browserContextId=browser_context_id
        )


class ResetPermissionsInput(InputModel):

    browserContextId: Browser.BrowserContextID | None = None


class ResetPermissions(CDPMethod[None]):
    """ Reset all permission management for all origins. """

    INPUT_VALIDATOR = ResetPermissionsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        browser_context_id: Browser.BrowserContextID | None = None
    ):
        super().__init__(
            browserContextId=browser_context_id
        )


class SetDownloadBehaviorInput(InputModel):

    behavior: Literal['deny', 'allow', 'allowAndName', 'default']
    browserContextId: Browser.BrowserContextID | None = None
    downloadPath: str | None = None
    eventsEnabled: bool | None = None


class SetDownloadBehavior(CDPMethod[None]):  # experimental
    """ Set the behavior when downloading a file. """

    INPUT_VALIDATOR = SetDownloadBehaviorInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        behavior: Literal['deny', 'allow', 'allowAndName', 'default'],
        browser_context_id: Browser.BrowserContextID | None = None,
        download_path: str | None = None,
        events_enabled: bool | None = None
    ):
        super().__init__(
            behavior=behavior,
            browserContextId=browser_context_id,
            downloadPath=download_path,
            eventsEnabled=events_enabled
        )


class CancelDownloadInput(InputModel):

    guid: str
    browserContextId: Browser.BrowserContextID | None = None


class CancelDownload(CDPMethod[None]):  # experimental
    """ Cancel a download if in progress """

    INPUT_VALIDATOR = CancelDownloadInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        guid: str,
        browser_context_id: Browser.BrowserContextID | None = None
    ):
        super().__init__(
            guid=guid,
            browserContextId=browser_context_id
        )


class Close(CDPMethod[None]):
    """ Close browser gracefully. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Crash(CDPMethod[None]):  # experimental
    """ Crashes browser on the main thread. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class CrashGpuProcess(CDPMethod[None]):  # experimental
    """ Crashes GPU process. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class GetVersionOutput(OutputModel):

    protocolVersion: str
    product: str
    revision: str
    userAgent: str
    jsVersion: str


class GetVersion(CDPMethod[GetVersionOutput]):
    """ Returns version information. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetVersionOutput


class GetBrowserCommandLineOutput(OutputModel):

    arguments: list[str]


class GetBrowserCommandLine(CDPMethod[GetBrowserCommandLineOutput]):  # experimental
    """ Returns the command line switches for the browser process if, and only if
    --enable-automation is on the commandline. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetBrowserCommandLineOutput


class GetHistogramsInput(InputModel):

    query: str | None = None
    delta: bool | None = None


class GetHistogramsOutput(OutputModel):

    histograms: list[Browser.Histogram]


class GetHistograms(CDPMethod[GetHistogramsOutput]):  # experimental
    """ Get Chrome histograms. """

    INPUT_VALIDATOR = GetHistogramsInput
    OUTPUT_VALIDATOR = GetHistogramsOutput

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


class GetHistogramInput(InputModel):

    name: str
    delta: bool | None = None


class GetHistogramOutput(OutputModel):

    histogram: Browser.Histogram


class GetHistogram(CDPMethod[GetHistogramOutput]):  # experimental
    """ Get a Chrome histogram by name. """

    INPUT_VALIDATOR = GetHistogramInput
    OUTPUT_VALIDATOR = GetHistogramOutput

    def __init__(
        self,
        *,
        name: str,
        delta: bool | None = None
    ):
        super().__init__(
            name=name,
            delta=delta
        )


class GetWindowBoundsInput(InputModel):

    windowId: Browser.WindowID


class GetWindowBoundsOutput(OutputModel):

    bounds: Browser.Bounds


class GetWindowBounds(CDPMethod[GetWindowBoundsOutput]):  # experimental
    """ Get position and size of the browser window. """

    INPUT_VALIDATOR = GetWindowBoundsInput
    OUTPUT_VALIDATOR = GetWindowBoundsOutput

    def __init__(
        self,
        *,
        window_id: Browser.WindowID
    ):
        super().__init__(
            windowId=window_id
        )


class GetWindowForTargetInput(InputModel):

    targetId: Target.TargetID | None = None


class GetWindowForTargetOutput(OutputModel):

    windowId: Browser.WindowID
    bounds: Browser.Bounds


class GetWindowForTarget(CDPMethod[GetWindowForTargetOutput]):  # experimental
    """ Get the browser window that contains the devtools target. """

    INPUT_VALIDATOR = GetWindowForTargetInput
    OUTPUT_VALIDATOR = GetWindowForTargetOutput

    def __init__(
        self,
        *,
        target_id: Target.TargetID | None = None
    ):
        super().__init__(
            targetId=target_id
        )


class SetWindowBoundsInput(InputModel):

    windowId: Browser.WindowID
    bounds: Browser.Bounds


class SetWindowBounds(CDPMethod[None]):  # experimental
    """ Set position and/or size of the browser window. """

    INPUT_VALIDATOR = SetWindowBoundsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        window_id: Browser.WindowID,
        bounds: Browser.Bounds
    ):
        super().__init__(
            windowId=window_id,
            bounds=bounds
        )


class SetContentsSizeInput(InputModel):

    windowId: Browser.WindowID
    width: int | None = None
    height: int | None = None


class SetContentsSize(CDPMethod[None]):  # experimental
    """ Set size of the browser contents resizing browser window as necessary. """

    INPUT_VALIDATOR = SetContentsSizeInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        window_id: Browser.WindowID,
        width: int | None = None,
        height: int | None = None
    ):
        super().__init__(
            windowId=window_id,
            width=width,
            height=height
        )


class SetDockTileInput(InputModel):

    badgeLabel: str | None = None
    image: str | None = None


class SetDockTile(CDPMethod[None]):  # experimental
    """ Set dock tile details, platform-specific. """

    INPUT_VALIDATOR = SetDockTileInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        badge_label: str | None = None,
        image: str | None = None
    ):
        super().__init__(
            badgeLabel=badge_label,
            image=image
        )


class ExecuteBrowserCommandInput(InputModel):

    commandId: Browser.BrowserCommandId


class ExecuteBrowserCommand(CDPMethod[None]):  # experimental
    """ Invoke custom browser commands used by telemetry. """

    INPUT_VALIDATOR = ExecuteBrowserCommandInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        command_id: Browser.BrowserCommandId
    ):
        super().__init__(
            commandId=command_id
        )


class AddPrivacySandboxEnrollmentOverrideInput(InputModel):

    url: str


class AddPrivacySandboxEnrollmentOverride(CDPMethod[None]):
    """ Allows a site to use privacy sandbox features that require enrollment
    without the site actually being enrolled. Only supported on page targets. """

    INPUT_VALIDATOR = AddPrivacySandboxEnrollmentOverrideInput
    OUTPUT_VALIDATOR = None

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


class AddPrivacySandboxCoordinatorKeyConfigInput(InputModel):

    api: Browser.PrivacySandboxAPI
    coordinatorOrigin: str
    keyConfig: str
    browserContextId: Browser.BrowserContextID | None = None


class AddPrivacySandboxCoordinatorKeyConfig(CDPMethod[None]):
    """ Configures encryption keys used with a given privacy sandbox API to talk
    to a trusted coordinator.  Since this is intended for test automation only,
    coordinatorOrigin must be a .test domain. No existing coordinator
    configuration for the origin may exist. """

    INPUT_VALIDATOR = AddPrivacySandboxCoordinatorKeyConfigInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        api: Browser.PrivacySandboxAPI,
        coordinator_origin: str,
        key_config: str,
        browser_context_id: Browser.BrowserContextID | None = None
    ):
        super().__init__(
            api=api,
            coordinatorOrigin=coordinator_origin,
            keyConfig=key_config,
            browserContextId=browser_context_id
        )
