module WebDriverPreCore.BiDi.BrowsingContext
  ( Activate (..),
    CaptureScreenshot (..),
    ScreenShotOrigin (..),
    ClipRectangle (..),
    ImageFormat (..),
    Close (..),
    Create (..),
    CreateType (..),
    GetTree (..),
    HandleUserPrompt (..),
    LocateNodes (..),
    Navigate (..),
    Print (..),
    Orientation (..),
    PageRange (..),
    Reload (..),
    SetViewport (..),
    TraverseHistory (..),
    MatchType (..),
    Locator (..),
    ReadinessState (..),
    UserPromptType (..),
    PrintMargin (..),
    PrintPage (..),
    Viewport (..),
    GetTreeResult (..),
    LocateNodesResult (..),
    CaptureScreenshotResult (..),
    PrintResult (..),
    Info (..),
    NavigateResult (..),
    BrowsingContextEvent (..),
    NavigationInfo (..),
    DownloadEnd (..),
    DownloadWillBegin (..),
    HistoryUpdated (..),
    UserPromptClosed (..),
    UserPromptOpened (..),
    Navigation (..),
  )
where

import Data.Aeson (FromJSON (..), GFromJSON, KeyValue (..), Options (..), ToJSON (..), Value (..), Zero, defaultOptions, genericParseJSON, genericToJSON, object, withObject, (.:), (.=))
import Data.Aeson.Types (Parser)
import Data.Functor ((<&>))
import Data.Maybe (catMaybes)
import Data.Text (Text, pack, unpack)
import GHC.Generics ( Generic(Rep) )
import WebDriverPreCore.BiDi.Capabilities (UserPromptHandlerType)
import WebDriverPreCore.BiDi.CoreTypes (BrowsingContext, JSInt, JSUInt, NodeRemoteValue, UserContext, KnownSubscriptionType (..), ClientWindow, URL (..))
import WebDriverPreCore.BiDi.Script (SharedReference)
import AesonUtils (enumCamelCase, fromJSONCamelCase, opt, parseJSONOmitNothing, toJSONOmitNothing)

-- ######### REMOTE #########

-- |  for activate command
newtype Activate = MkActivate
  { Activate -> BrowsingContext
context :: BrowsingContext
  }
  deriving (Int -> Activate -> ShowS
[Activate] -> ShowS
Activate -> String
(Int -> Activate -> ShowS)
-> (Activate -> String) -> ([Activate] -> ShowS) -> Show Activate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Activate -> ShowS
showsPrec :: Int -> Activate -> ShowS
$cshow :: Activate -> String
show :: Activate -> String
$cshowList :: [Activate] -> ShowS
showList :: [Activate] -> ShowS
Show, Activate -> Activate -> Bool
(Activate -> Activate -> Bool)
-> (Activate -> Activate -> Bool) -> Eq Activate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Activate -> Activate -> Bool
== :: Activate -> Activate -> Bool
$c/= :: Activate -> Activate -> Bool
/= :: Activate -> Activate -> Bool
Eq, (forall x. Activate -> Rep Activate x)
-> (forall x. Rep Activate x -> Activate) -> Generic Activate
forall x. Rep Activate x -> Activate
forall x. Activate -> Rep Activate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Activate -> Rep Activate x
from :: forall x. Activate -> Rep Activate x
$cto :: forall x. Rep Activate x -> Activate
to :: forall x. Rep Activate x -> Activate
Generic)

instance ToJSON Activate

-- |  for captureScreenshot command
data CaptureScreenshot = MkCaptureScreenshot
  { CaptureScreenshot -> BrowsingContext
context :: BrowsingContext,
    CaptureScreenshot -> Maybe ScreenShotOrigin
origin :: Maybe ScreenShotOrigin,
    CaptureScreenshot -> Maybe ImageFormat
format :: Maybe ImageFormat,
    CaptureScreenshot -> Maybe ClipRectangle
clip :: Maybe ClipRectangle
  }
  deriving (Int -> CaptureScreenshot -> ShowS
[CaptureScreenshot] -> ShowS
CaptureScreenshot -> String
(Int -> CaptureScreenshot -> ShowS)
-> (CaptureScreenshot -> String)
-> ([CaptureScreenshot] -> ShowS)
-> Show CaptureScreenshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CaptureScreenshot -> ShowS
showsPrec :: Int -> CaptureScreenshot -> ShowS
$cshow :: CaptureScreenshot -> String
show :: CaptureScreenshot -> String
$cshowList :: [CaptureScreenshot] -> ShowS
showList :: [CaptureScreenshot] -> ShowS
Show, CaptureScreenshot -> CaptureScreenshot -> Bool
(CaptureScreenshot -> CaptureScreenshot -> Bool)
-> (CaptureScreenshot -> CaptureScreenshot -> Bool)
-> Eq CaptureScreenshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CaptureScreenshot -> CaptureScreenshot -> Bool
== :: CaptureScreenshot -> CaptureScreenshot -> Bool
$c/= :: CaptureScreenshot -> CaptureScreenshot -> Bool
/= :: CaptureScreenshot -> CaptureScreenshot -> Bool
Eq, (forall x. CaptureScreenshot -> Rep CaptureScreenshot x)
-> (forall x. Rep CaptureScreenshot x -> CaptureScreenshot)
-> Generic CaptureScreenshot
forall x. Rep CaptureScreenshot x -> CaptureScreenshot
forall x. CaptureScreenshot -> Rep CaptureScreenshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CaptureScreenshot -> Rep CaptureScreenshot x
from :: forall x. CaptureScreenshot -> Rep CaptureScreenshot x
$cto :: forall x. Rep CaptureScreenshot x -> CaptureScreenshot
to :: forall x. Rep CaptureScreenshot x -> CaptureScreenshot
Generic)

instance ToJSON CaptureScreenshot where
  toJSON :: CaptureScreenshot -> Value
  toJSON :: CaptureScreenshot -> Value
toJSON (MkCaptureScreenshot {BrowsingContext
context :: CaptureScreenshot -> BrowsingContext
context :: BrowsingContext
context, Maybe ScreenShotOrigin
origin :: CaptureScreenshot -> Maybe ScreenShotOrigin
origin :: Maybe ScreenShotOrigin
origin, Maybe ImageFormat
format :: CaptureScreenshot -> Maybe ImageFormat
format :: Maybe ImageFormat
format, Maybe ClipRectangle
clip :: CaptureScreenshot -> Maybe ClipRectangle
clip :: Maybe ClipRectangle
clip}) =
    [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
      [ Key
"context" Key -> BrowsingContext -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= BrowsingContext
context
      ]
        [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
          [ Key -> Maybe ScreenShotOrigin -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"origin" Maybe ScreenShotOrigin
origin,
            Key -> Maybe ImageFormat -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"format" Maybe ImageFormat
format,
            Key -> Maybe ClipRectangle -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"clip" Maybe ClipRectangle
clip
          ]

data ScreenShotOrigin = Viewport | Document deriving (Int -> ScreenShotOrigin -> ShowS
[ScreenShotOrigin] -> ShowS
ScreenShotOrigin -> String
(Int -> ScreenShotOrigin -> ShowS)
-> (ScreenShotOrigin -> String)
-> ([ScreenShotOrigin] -> ShowS)
-> Show ScreenShotOrigin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScreenShotOrigin -> ShowS
showsPrec :: Int -> ScreenShotOrigin -> ShowS
$cshow :: ScreenShotOrigin -> String
show :: ScreenShotOrigin -> String
$cshowList :: [ScreenShotOrigin] -> ShowS
showList :: [ScreenShotOrigin] -> ShowS
Show, ScreenShotOrigin -> ScreenShotOrigin -> Bool
(ScreenShotOrigin -> ScreenShotOrigin -> Bool)
-> (ScreenShotOrigin -> ScreenShotOrigin -> Bool)
-> Eq ScreenShotOrigin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScreenShotOrigin -> ScreenShotOrigin -> Bool
== :: ScreenShotOrigin -> ScreenShotOrigin -> Bool
$c/= :: ScreenShotOrigin -> ScreenShotOrigin -> Bool
/= :: ScreenShotOrigin -> ScreenShotOrigin -> Bool
Eq, (forall x. ScreenShotOrigin -> Rep ScreenShotOrigin x)
-> (forall x. Rep ScreenShotOrigin x -> ScreenShotOrigin)
-> Generic ScreenShotOrigin
forall x. Rep ScreenShotOrigin x -> ScreenShotOrigin
forall x. ScreenShotOrigin -> Rep ScreenShotOrigin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScreenShotOrigin -> Rep ScreenShotOrigin x
from :: forall x. ScreenShotOrigin -> Rep ScreenShotOrigin x
$cto :: forall x. Rep ScreenShotOrigin x -> ScreenShotOrigin
to :: forall x. Rep ScreenShotOrigin x -> ScreenShotOrigin
Generic)

instance ToJSON ScreenShotOrigin where
  toJSON :: ScreenShotOrigin -> Value
  toJSON :: ScreenShotOrigin -> Value
toJSON = ScreenShotOrigin -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

-- | Clip rectangle for screenshots
data ClipRectangle
  = BoxClipRectangle
      { ClipRectangle -> Float
x :: Float,
        ClipRectangle -> Float
y :: Float,
        ClipRectangle -> Float
width :: Float,
        ClipRectangle -> Float
height :: Float
      }
  | ElementClipRectangle
      { ClipRectangle -> Text
element :: Text -- script.SharedReference
      }
  deriving (Int -> ClipRectangle -> ShowS
[ClipRectangle] -> ShowS
ClipRectangle -> String
(Int -> ClipRectangle -> ShowS)
-> (ClipRectangle -> String)
-> ([ClipRectangle] -> ShowS)
-> Show ClipRectangle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClipRectangle -> ShowS
showsPrec :: Int -> ClipRectangle -> ShowS
$cshow :: ClipRectangle -> String
show :: ClipRectangle -> String
$cshowList :: [ClipRectangle] -> ShowS
showList :: [ClipRectangle] -> ShowS
Show, ClipRectangle -> ClipRectangle -> Bool
(ClipRectangle -> ClipRectangle -> Bool)
-> (ClipRectangle -> ClipRectangle -> Bool) -> Eq ClipRectangle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClipRectangle -> ClipRectangle -> Bool
== :: ClipRectangle -> ClipRectangle -> Bool
$c/= :: ClipRectangle -> ClipRectangle -> Bool
/= :: ClipRectangle -> ClipRectangle -> Bool
Eq, (forall x. ClipRectangle -> Rep ClipRectangle x)
-> (forall x. Rep ClipRectangle x -> ClipRectangle)
-> Generic ClipRectangle
forall x. Rep ClipRectangle x -> ClipRectangle
forall x. ClipRectangle -> Rep ClipRectangle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ClipRectangle -> Rep ClipRectangle x
from :: forall x. ClipRectangle -> Rep ClipRectangle x
$cto :: forall x. Rep ClipRectangle x -> ClipRectangle
to :: forall x. Rep ClipRectangle x -> ClipRectangle
Generic)

instance ToJSON ClipRectangle where
  toJSON :: ClipRectangle -> Value
  toJSON :: ClipRectangle -> Value
toJSON = \case
    BoxClipRectangle {Float
x :: ClipRectangle -> Float
x :: Float
x, Float
y :: ClipRectangle -> Float
y :: Float
y, Float
width :: ClipRectangle -> Float
width :: Float
width, Float
height :: ClipRectangle -> Float
height :: Float
height} ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"box",
          Key
"x" Key -> Float -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Float
x,
          Key
"y" Key -> Float -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Float
y,
          Key
"width" Key -> Float -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Float
width,
          Key
"height" Key -> Float -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Float
height
        ]
    ElementClipRectangle {Text
element :: ClipRectangle -> Text
element :: Text
element} ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"element",
          Key
"element" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
element
        ]

-- | Image format specification
data ImageFormat = MkImageFormat
  { ImageFormat -> Text
imageType :: Text,
    ImageFormat -> Maybe Float
quality :: Maybe Float
  }
  deriving (Int -> ImageFormat -> ShowS
[ImageFormat] -> ShowS
ImageFormat -> String
(Int -> ImageFormat -> ShowS)
-> (ImageFormat -> String)
-> ([ImageFormat] -> ShowS)
-> Show ImageFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImageFormat -> ShowS
showsPrec :: Int -> ImageFormat -> ShowS
$cshow :: ImageFormat -> String
show :: ImageFormat -> String
$cshowList :: [ImageFormat] -> ShowS
showList :: [ImageFormat] -> ShowS
Show, ImageFormat -> ImageFormat -> Bool
(ImageFormat -> ImageFormat -> Bool)
-> (ImageFormat -> ImageFormat -> Bool) -> Eq ImageFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ImageFormat -> ImageFormat -> Bool
== :: ImageFormat -> ImageFormat -> Bool
$c/= :: ImageFormat -> ImageFormat -> Bool
/= :: ImageFormat -> ImageFormat -> Bool
Eq, (forall x. ImageFormat -> Rep ImageFormat x)
-> (forall x. Rep ImageFormat x -> ImageFormat)
-> Generic ImageFormat
forall x. Rep ImageFormat x -> ImageFormat
forall x. ImageFormat -> Rep ImageFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ImageFormat -> Rep ImageFormat x
from :: forall x. ImageFormat -> Rep ImageFormat x
$cto :: forall x. Rep ImageFormat x -> ImageFormat
to :: forall x. Rep ImageFormat x -> ImageFormat
Generic)

instance ToJSON ImageFormat where
  toJSON :: ImageFormat -> Value
  toJSON :: ImageFormat -> Value
toJSON (MkImageFormat {Text
imageType :: ImageFormat -> Text
imageType :: Text
imageType, Maybe Float
quality :: ImageFormat -> Maybe Float
quality :: Maybe Float
quality}) =
    [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
      [ Key
"type" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
imageType
      ]
        [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
          [ Key -> Maybe Float -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"quality" Maybe Float
quality
          ]

-- |  for close command
data Close = MkClose
  { Close -> BrowsingContext
context :: BrowsingContext,
    Close -> Maybe Bool
promptUnload :: Maybe Bool
  }
  deriving (Int -> Close -> ShowS
[Close] -> ShowS
Close -> String
(Int -> Close -> ShowS)
-> (Close -> String) -> ([Close] -> ShowS) -> Show Close
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Close -> ShowS
showsPrec :: Int -> Close -> ShowS
$cshow :: Close -> String
show :: Close -> String
$cshowList :: [Close] -> ShowS
showList :: [Close] -> ShowS
Show, Close -> Close -> Bool
(Close -> Close -> Bool) -> (Close -> Close -> Bool) -> Eq Close
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Close -> Close -> Bool
== :: Close -> Close -> Bool
$c/= :: Close -> Close -> Bool
/= :: Close -> Close -> Bool
Eq, (forall x. Close -> Rep Close x)
-> (forall x. Rep Close x -> Close) -> Generic Close
forall x. Rep Close x -> Close
forall x. Close -> Rep Close x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Close -> Rep Close x
from :: forall x. Close -> Rep Close x
$cto :: forall x. Rep Close x -> Close
to :: forall x. Rep Close x -> Close
Generic)

instance ToJSON Close where
  toJSON :: Close -> Value
  toJSON :: Close -> Value
toJSON (MkClose {BrowsingContext
context :: Close -> BrowsingContext
context :: BrowsingContext
context, Maybe Bool
promptUnload :: Close -> Maybe Bool
promptUnload :: Maybe Bool
promptUnload}) =
    [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
      [ Key
"context" Key -> BrowsingContext -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= BrowsingContext
context
      ]
        [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
          [ Key -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"promptUnload" Maybe Bool
promptUnload
          ]

-- |  for create command
data Create = MkCreate
  { Create -> CreateType
createType :: CreateType,
    Create -> Bool
background :: Bool,
    Create -> Maybe BrowsingContext
referenceContext :: Maybe BrowsingContext,
    Create -> Maybe UserContext
userContext :: Maybe UserContext
  }
  deriving (Int -> Create -> ShowS
[Create] -> ShowS
Create -> String
(Int -> Create -> ShowS)
-> (Create -> String) -> ([Create] -> ShowS) -> Show Create
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Create -> ShowS
showsPrec :: Int -> Create -> ShowS
$cshow :: Create -> String
show :: Create -> String
$cshowList :: [Create] -> ShowS
showList :: [Create] -> ShowS
Show, Create -> Create -> Bool
(Create -> Create -> Bool)
-> (Create -> Create -> Bool) -> Eq Create
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Create -> Create -> Bool
== :: Create -> Create -> Bool
$c/= :: Create -> Create -> Bool
/= :: Create -> Create -> Bool
Eq, (forall x. Create -> Rep Create x)
-> (forall x. Rep Create x -> Create) -> Generic Create
forall x. Rep Create x -> Create
forall x. Create -> Rep Create x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Create -> Rep Create x
from :: forall x. Create -> Rep Create x
$cto :: forall x. Rep Create x -> Create
to :: forall x. Rep Create x -> Create
Generic)

instance ToJSON Create where
  toJSON :: Create -> Value
  toJSON :: Create -> Value
toJSON (MkCreate {CreateType
createType :: Create -> CreateType
createType :: CreateType
createType, Maybe BrowsingContext
referenceContext :: Create -> Maybe BrowsingContext
referenceContext :: Maybe BrowsingContext
referenceContext, Bool
background :: Create -> Bool
background :: Bool
background, Maybe UserContext
userContext :: Create -> Maybe UserContext
userContext :: Maybe UserContext
userContext}) =
    [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
      [ Key
"type" Key -> CreateType -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CreateType
createType,
        Key
"background" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
background
      ]
        [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
          [ Key -> Maybe BrowsingContext -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"referenceContext" Maybe BrowsingContext
referenceContext,
            Key -> Maybe UserContext -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"userContext" Maybe UserContext
userContext
          ]

-- |  for getTree command
data GetTree = MkGetTree
  { GetTree -> Maybe JSUInt
maxDepth :: Maybe JSUInt,
    GetTree -> Maybe BrowsingContext
root :: Maybe BrowsingContext
  }
  deriving (Int -> GetTree -> ShowS
[GetTree] -> ShowS
GetTree -> String
(Int -> GetTree -> ShowS)
-> (GetTree -> String) -> ([GetTree] -> ShowS) -> Show GetTree
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTree -> ShowS
showsPrec :: Int -> GetTree -> ShowS
$cshow :: GetTree -> String
show :: GetTree -> String
$cshowList :: [GetTree] -> ShowS
showList :: [GetTree] -> ShowS
Show, GetTree -> GetTree -> Bool
(GetTree -> GetTree -> Bool)
-> (GetTree -> GetTree -> Bool) -> Eq GetTree
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTree -> GetTree -> Bool
== :: GetTree -> GetTree -> Bool
$c/= :: GetTree -> GetTree -> Bool
/= :: GetTree -> GetTree -> Bool
Eq, (forall x. GetTree -> Rep GetTree x)
-> (forall x. Rep GetTree x -> GetTree) -> Generic GetTree
forall x. Rep GetTree x -> GetTree
forall x. GetTree -> Rep GetTree x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetTree -> Rep GetTree x
from :: forall x. GetTree -> Rep GetTree x
$cto :: forall x. Rep GetTree x -> GetTree
to :: forall x. Rep GetTree x -> GetTree
Generic)

instance ToJSON GetTree where
  toJSON :: GetTree -> Value
  toJSON :: GetTree -> Value
toJSON = GetTree -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- |  for handleUserPrompt command
data HandleUserPrompt = MkHandleUserPrompt
  { HandleUserPrompt -> BrowsingContext
context :: BrowsingContext,
    HandleUserPrompt -> Maybe Bool
accept :: Maybe Bool,
    HandleUserPrompt -> Maybe Text
userText :: Maybe Text
  }
  deriving (Int -> HandleUserPrompt -> ShowS
[HandleUserPrompt] -> ShowS
HandleUserPrompt -> String
(Int -> HandleUserPrompt -> ShowS)
-> (HandleUserPrompt -> String)
-> ([HandleUserPrompt] -> ShowS)
-> Show HandleUserPrompt
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HandleUserPrompt -> ShowS
showsPrec :: Int -> HandleUserPrompt -> ShowS
$cshow :: HandleUserPrompt -> String
show :: HandleUserPrompt -> String
$cshowList :: [HandleUserPrompt] -> ShowS
showList :: [HandleUserPrompt] -> ShowS
Show, HandleUserPrompt -> HandleUserPrompt -> Bool
(HandleUserPrompt -> HandleUserPrompt -> Bool)
-> (HandleUserPrompt -> HandleUserPrompt -> Bool)
-> Eq HandleUserPrompt
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HandleUserPrompt -> HandleUserPrompt -> Bool
== :: HandleUserPrompt -> HandleUserPrompt -> Bool
$c/= :: HandleUserPrompt -> HandleUserPrompt -> Bool
/= :: HandleUserPrompt -> HandleUserPrompt -> Bool
Eq, (forall x. HandleUserPrompt -> Rep HandleUserPrompt x)
-> (forall x. Rep HandleUserPrompt x -> HandleUserPrompt)
-> Generic HandleUserPrompt
forall x. Rep HandleUserPrompt x -> HandleUserPrompt
forall x. HandleUserPrompt -> Rep HandleUserPrompt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HandleUserPrompt -> Rep HandleUserPrompt x
from :: forall x. HandleUserPrompt -> Rep HandleUserPrompt x
$cto :: forall x. Rep HandleUserPrompt x -> HandleUserPrompt
to :: forall x. Rep HandleUserPrompt x -> HandleUserPrompt
Generic)

instance ToJSON HandleUserPrompt where
  toJSON :: HandleUserPrompt -> Value
  toJSON :: HandleUserPrompt -> Value
toJSON = Options -> HandleUserPrompt -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
defaultOptions {omitNothingFields = True}

-- |  for locateNodes command
data LocateNodes = MkLocateNodes
  { LocateNodes -> BrowsingContext
context :: BrowsingContext,
    LocateNodes -> Locator
locator :: Locator,
    LocateNodes -> Maybe JSUInt
maxNodeCount :: Maybe JSUInt,
    LocateNodes -> Maybe Value
serializationOptions :: Maybe Value, -- script.SerializationOptions
    LocateNodes -> Maybe [SharedReference]
startNodes :: Maybe [SharedReference] -- script.SharedReference
  }
  deriving (Int -> LocateNodes -> ShowS
[LocateNodes] -> ShowS
LocateNodes -> String
(Int -> LocateNodes -> ShowS)
-> (LocateNodes -> String)
-> ([LocateNodes] -> ShowS)
-> Show LocateNodes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocateNodes -> ShowS
showsPrec :: Int -> LocateNodes -> ShowS
$cshow :: LocateNodes -> String
show :: LocateNodes -> String
$cshowList :: [LocateNodes] -> ShowS
showList :: [LocateNodes] -> ShowS
Show, LocateNodes -> LocateNodes -> Bool
(LocateNodes -> LocateNodes -> Bool)
-> (LocateNodes -> LocateNodes -> Bool) -> Eq LocateNodes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocateNodes -> LocateNodes -> Bool
== :: LocateNodes -> LocateNodes -> Bool
$c/= :: LocateNodes -> LocateNodes -> Bool
/= :: LocateNodes -> LocateNodes -> Bool
Eq, (forall x. LocateNodes -> Rep LocateNodes x)
-> (forall x. Rep LocateNodes x -> LocateNodes)
-> Generic LocateNodes
forall x. Rep LocateNodes x -> LocateNodes
forall x. LocateNodes -> Rep LocateNodes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LocateNodes -> Rep LocateNodes x
from :: forall x. LocateNodes -> Rep LocateNodes x
$cto :: forall x. Rep LocateNodes x -> LocateNodes
to :: forall x. Rep LocateNodes x -> LocateNodes
Generic)

instance ToJSON LocateNodes where
  toJSON :: LocateNodes -> Value
  toJSON :: LocateNodes -> Value
toJSON = LocateNodes -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- |  for navigate command
data Navigate = MkNavigate
  { Navigate -> BrowsingContext
context :: BrowsingContext,
    Navigate -> URL
url :: URL,
    Navigate -> Maybe ReadinessState
wait :: Maybe ReadinessState
  }
  deriving (Int -> Navigate -> ShowS
[Navigate] -> ShowS
Navigate -> String
(Int -> Navigate -> ShowS)
-> (Navigate -> String) -> ([Navigate] -> ShowS) -> Show Navigate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Navigate -> ShowS
showsPrec :: Int -> Navigate -> ShowS
$cshow :: Navigate -> String
show :: Navigate -> String
$cshowList :: [Navigate] -> ShowS
showList :: [Navigate] -> ShowS
Show, Navigate -> Navigate -> Bool
(Navigate -> Navigate -> Bool)
-> (Navigate -> Navigate -> Bool) -> Eq Navigate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Navigate -> Navigate -> Bool
== :: Navigate -> Navigate -> Bool
$c/= :: Navigate -> Navigate -> Bool
/= :: Navigate -> Navigate -> Bool
Eq, (forall x. Navigate -> Rep Navigate x)
-> (forall x. Rep Navigate x -> Navigate) -> Generic Navigate
forall x. Rep Navigate x -> Navigate
forall x. Navigate -> Rep Navigate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Navigate -> Rep Navigate x
from :: forall x. Navigate -> Rep Navigate x
$cto :: forall x. Rep Navigate x -> Navigate
to :: forall x. Rep Navigate x -> Navigate
Generic)

instance ToJSON Navigate where
  toJSON :: Navigate -> Value
  toJSON :: Navigate -> Value
toJSON = Navigate -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- |  for print command
data Print = MkPrint
  { Print -> BrowsingContext
context :: BrowsingContext,
    Print -> Maybe Bool
background :: Maybe Bool,
    Print -> Maybe PrintMargin
margin :: Maybe PrintMargin,
    Print -> Maybe Orientation
orientation :: Maybe Orientation,
    Print -> Maybe PrintPage
page :: Maybe PrintPage,
    Print -> Maybe [PageRange]
pageRanges :: Maybe [PageRange],
    Print -> Maybe Float
scale :: Maybe Float,
    Print -> Maybe Bool
shrinkToFit :: Maybe Bool
  }
  deriving (Int -> Print -> ShowS
[Print] -> ShowS
Print -> String
(Int -> Print -> ShowS)
-> (Print -> String) -> ([Print] -> ShowS) -> Show Print
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Print -> ShowS
showsPrec :: Int -> Print -> ShowS
$cshow :: Print -> String
show :: Print -> String
$cshowList :: [Print] -> ShowS
showList :: [Print] -> ShowS
Show, Print -> Print -> Bool
(Print -> Print -> Bool) -> (Print -> Print -> Bool) -> Eq Print
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Print -> Print -> Bool
== :: Print -> Print -> Bool
$c/= :: Print -> Print -> Bool
/= :: Print -> Print -> Bool
Eq, (forall x. Print -> Rep Print x)
-> (forall x. Rep Print x -> Print) -> Generic Print
forall x. Rep Print x -> Print
forall x. Print -> Rep Print x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Print -> Rep Print x
from :: forall x. Print -> Rep Print x
$cto :: forall x. Rep Print x -> Print
to :: forall x. Rep Print x -> Print
Generic)

instance ToJSON Print where
  toJSON :: Print -> Value
  toJSON :: Print -> Value
toJSON = Print -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

data Orientation = Portrait | Landscape deriving (Int -> Orientation -> ShowS
[Orientation] -> ShowS
Orientation -> String
(Int -> Orientation -> ShowS)
-> (Orientation -> String)
-> ([Orientation] -> ShowS)
-> Show Orientation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Orientation -> ShowS
showsPrec :: Int -> Orientation -> ShowS
$cshow :: Orientation -> String
show :: Orientation -> String
$cshowList :: [Orientation] -> ShowS
showList :: [Orientation] -> ShowS
Show, Orientation -> Orientation -> Bool
(Orientation -> Orientation -> Bool)
-> (Orientation -> Orientation -> Bool) -> Eq Orientation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Orientation -> Orientation -> Bool
== :: Orientation -> Orientation -> Bool
$c/= :: Orientation -> Orientation -> Bool
/= :: Orientation -> Orientation -> Bool
Eq, (forall x. Orientation -> Rep Orientation x)
-> (forall x. Rep Orientation x -> Orientation)
-> Generic Orientation
forall x. Rep Orientation x -> Orientation
forall x. Orientation -> Rep Orientation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Orientation -> Rep Orientation x
from :: forall x. Orientation -> Rep Orientation x
$cto :: forall x. Rep Orientation x -> Orientation
to :: forall x. Rep Orientation x -> Orientation
Generic)

instance ToJSON Orientation where
  toJSON :: Orientation -> Value
  toJSON :: Orientation -> Value
toJSON = Orientation -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

data PageRange
  = Page Word
  | Range
      { PageRange -> Word
fromPage :: Word,
        PageRange -> Word
toPage :: Word
      }
  deriving (Int -> PageRange -> ShowS
[PageRange] -> ShowS
PageRange -> String
(Int -> PageRange -> ShowS)
-> (PageRange -> String)
-> ([PageRange] -> ShowS)
-> Show PageRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PageRange -> ShowS
showsPrec :: Int -> PageRange -> ShowS
$cshow :: PageRange -> String
show :: PageRange -> String
$cshowList :: [PageRange] -> ShowS
showList :: [PageRange] -> ShowS
Show, PageRange -> PageRange -> Bool
(PageRange -> PageRange -> Bool)
-> (PageRange -> PageRange -> Bool) -> Eq PageRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PageRange -> PageRange -> Bool
== :: PageRange -> PageRange -> Bool
$c/= :: PageRange -> PageRange -> Bool
/= :: PageRange -> PageRange -> Bool
Eq)

instance ToJSON PageRange where
  toJSON :: PageRange -> Value
  toJSON :: PageRange -> Value
toJSON = \case
    Page Word
p -> Scientific -> Value
Number (Scientific -> Value) -> Scientific -> Value
forall a b. (a -> b) -> a -> b
$ Word -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
p
    Range {Word
fromPage :: PageRange -> Word
fromPage :: Word
fromPage, Word
toPage :: PageRange -> Word
toPage :: Word
toPage} -> Text -> Value
String (String -> Text
pack (Word -> String
forall a. Show a => a -> String
show Word
fromPage String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"-" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word -> String
forall a. Show a => a -> String
show Word
toPage))

-- |  for reload command
data Reload = MkReload
  { Reload -> BrowsingContext
context :: BrowsingContext,
    Reload -> Maybe Bool
ignoreCache :: Maybe Bool,
    Reload -> Maybe ReadinessState
wait :: Maybe ReadinessState
  }
  deriving (Int -> Reload -> ShowS
[Reload] -> ShowS
Reload -> String
(Int -> Reload -> ShowS)
-> (Reload -> String) -> ([Reload] -> ShowS) -> Show Reload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Reload -> ShowS
showsPrec :: Int -> Reload -> ShowS
$cshow :: Reload -> String
show :: Reload -> String
$cshowList :: [Reload] -> ShowS
showList :: [Reload] -> ShowS
Show, Reload -> Reload -> Bool
(Reload -> Reload -> Bool)
-> (Reload -> Reload -> Bool) -> Eq Reload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Reload -> Reload -> Bool
== :: Reload -> Reload -> Bool
$c/= :: Reload -> Reload -> Bool
/= :: Reload -> Reload -> Bool
Eq, (forall x. Reload -> Rep Reload x)
-> (forall x. Rep Reload x -> Reload) -> Generic Reload
forall x. Rep Reload x -> Reload
forall x. Reload -> Rep Reload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Reload -> Rep Reload x
from :: forall x. Reload -> Rep Reload x
$cto :: forall x. Rep Reload x -> Reload
to :: forall x. Rep Reload x -> Reload
Generic)

instance ToJSON Reload where
  toJSON :: Reload -> Value
  toJSON :: Reload -> Value
toJSON = Reload -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- |  for setViewport command
data SetViewport = MkSetViewport
  { SetViewport -> Maybe BrowsingContext
context :: Maybe BrowsingContext,
    SetViewport -> Maybe (Maybe Viewport)
viewport :: Maybe (Maybe Viewport), -- Viewport or null
    SetViewport -> Maybe (Maybe Float)
devicePixelRatio :: Maybe (Maybe Float), -- Float or null
    SetViewport -> Maybe [Text]
userContexts :: Maybe [Text] -- browser.UserContext
  }
  deriving (Int -> SetViewport -> ShowS
[SetViewport] -> ShowS
SetViewport -> String
(Int -> SetViewport -> ShowS)
-> (SetViewport -> String)
-> ([SetViewport] -> ShowS)
-> Show SetViewport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetViewport -> ShowS
showsPrec :: Int -> SetViewport -> ShowS
$cshow :: SetViewport -> String
show :: SetViewport -> String
$cshowList :: [SetViewport] -> ShowS
showList :: [SetViewport] -> ShowS
Show, SetViewport -> SetViewport -> Bool
(SetViewport -> SetViewport -> Bool)
-> (SetViewport -> SetViewport -> Bool) -> Eq SetViewport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetViewport -> SetViewport -> Bool
== :: SetViewport -> SetViewport -> Bool
$c/= :: SetViewport -> SetViewport -> Bool
/= :: SetViewport -> SetViewport -> Bool
Eq, (forall x. SetViewport -> Rep SetViewport x)
-> (forall x. Rep SetViewport x -> SetViewport)
-> Generic SetViewport
forall x. Rep SetViewport x -> SetViewport
forall x. SetViewport -> Rep SetViewport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetViewport -> Rep SetViewport x
from :: forall x. SetViewport -> Rep SetViewport x
$cto :: forall x. Rep SetViewport x -> SetViewport
to :: forall x. Rep SetViewport x -> SetViewport
Generic)

instance ToJSON SetViewport where
  toJSON :: SetViewport -> Value
  toJSON :: SetViewport -> Value
toJSON = SetViewport -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- |  for traverseHistory command
data TraverseHistory = MkTraverseHistory
  { TraverseHistory -> BrowsingContext
context :: BrowsingContext,
    TraverseHistory -> JSInt
delta :: JSInt
  }
  deriving (Int -> TraverseHistory -> ShowS
[TraverseHistory] -> ShowS
TraverseHistory -> String
(Int -> TraverseHistory -> ShowS)
-> (TraverseHistory -> String)
-> ([TraverseHistory] -> ShowS)
-> Show TraverseHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TraverseHistory -> ShowS
showsPrec :: Int -> TraverseHistory -> ShowS
$cshow :: TraverseHistory -> String
show :: TraverseHistory -> String
$cshowList :: [TraverseHistory] -> ShowS
showList :: [TraverseHistory] -> ShowS
Show, TraverseHistory -> TraverseHistory -> Bool
(TraverseHistory -> TraverseHistory -> Bool)
-> (TraverseHistory -> TraverseHistory -> Bool)
-> Eq TraverseHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TraverseHistory -> TraverseHistory -> Bool
== :: TraverseHistory -> TraverseHistory -> Bool
$c/= :: TraverseHistory -> TraverseHistory -> Bool
/= :: TraverseHistory -> TraverseHistory -> Bool
Eq, (forall x. TraverseHistory -> Rep TraverseHistory x)
-> (forall x. Rep TraverseHistory x -> TraverseHistory)
-> Generic TraverseHistory
forall x. Rep TraverseHistory x -> TraverseHistory
forall x. TraverseHistory -> Rep TraverseHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TraverseHistory -> Rep TraverseHistory x
from :: forall x. TraverseHistory -> Rep TraverseHistory x
$cto :: forall x. Rep TraverseHistory x -> TraverseHistory
to :: forall x. Rep TraverseHistory x -> TraverseHistory
Generic)

-- | Text matching type for InnerText locator
data MatchType = Full | Partial
  deriving (Int -> MatchType -> ShowS
[MatchType] -> ShowS
MatchType -> String
(Int -> MatchType -> ShowS)
-> (MatchType -> String)
-> ([MatchType] -> ShowS)
-> Show MatchType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MatchType -> ShowS
showsPrec :: Int -> MatchType -> ShowS
$cshow :: MatchType -> String
show :: MatchType -> String
$cshowList :: [MatchType] -> ShowS
showList :: [MatchType] -> ShowS
Show, MatchType -> MatchType -> Bool
(MatchType -> MatchType -> Bool)
-> (MatchType -> MatchType -> Bool) -> Eq MatchType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MatchType -> MatchType -> Bool
== :: MatchType -> MatchType -> Bool
$c/= :: MatchType -> MatchType -> Bool
/= :: MatchType -> MatchType -> Bool
Eq, (forall x. MatchType -> Rep MatchType x)
-> (forall x. Rep MatchType x -> MatchType) -> Generic MatchType
forall x. Rep MatchType x -> MatchType
forall x. MatchType -> Rep MatchType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MatchType -> Rep MatchType x
from :: forall x. MatchType -> Rep MatchType x
$cto :: forall x. Rep MatchType x -> MatchType
to :: forall x. Rep MatchType x -> MatchType
Generic)

instance ToJSON MatchType where
  toJSON :: MatchType -> Value
  toJSON :: MatchType -> Value
toJSON = MatchType -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

-- | Different types of locators for elements
data Locator
  = Accessibility
      { Locator -> Maybe Text
name :: Maybe Text,
        Locator -> Maybe Text
role :: Maybe Text
      }
  | CSS
      { Locator -> Text
value :: Text
      }
  | Context
      { Locator -> BrowsingContext
context :: BrowsingContext
      }
  | InnerText
      { value :: Text,
        Locator -> Maybe Bool
ignoreCase :: Maybe Bool,
        Locator -> Maybe MatchType
matchType :: Maybe MatchType,
        Locator -> Maybe JSUInt
maxDepth :: Maybe JSUInt
      }
  | XPath
      { value :: Text
      }
  deriving (Int -> Locator -> ShowS
[Locator] -> ShowS
Locator -> String
(Int -> Locator -> ShowS)
-> (Locator -> String) -> ([Locator] -> ShowS) -> Show Locator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Locator -> ShowS
showsPrec :: Int -> Locator -> ShowS
$cshow :: Locator -> String
show :: Locator -> String
$cshowList :: [Locator] -> ShowS
showList :: [Locator] -> ShowS
Show, Locator -> Locator -> Bool
(Locator -> Locator -> Bool)
-> (Locator -> Locator -> Bool) -> Eq Locator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Locator -> Locator -> Bool
== :: Locator -> Locator -> Bool
$c/= :: Locator -> Locator -> Bool
/= :: Locator -> Locator -> Bool
Eq)

instance ToJSON Locator where
  toJSON :: Locator -> Value
  toJSON :: Locator -> Value
toJSON = \case
    Accessibility {Maybe Text
name :: Locator -> Maybe Text
name :: Maybe Text
name, Maybe Text
role :: Locator -> Maybe Text
role :: Maybe Text
role} ->
      [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"accessibility",
          Key
"value"
            Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ( [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
                   [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
                     [ Key -> Maybe Text -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"name" Maybe Text
name,
                       Key -> Maybe Text -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"role" Maybe Text
role
                     ]
               )
        ]
    CSS {Text
value :: Locator -> Text
value :: Text
value} ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"css",
          Key
"value" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
value
        ]
    Context {BrowsingContext
context :: Locator -> BrowsingContext
context :: BrowsingContext
context} ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"context",
          Key
"value" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [Key
"context" Key -> BrowsingContext -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= BrowsingContext
context]
        ]
    InnerText {Text
value :: Locator -> Text
value :: Text
value, Maybe Bool
ignoreCase :: Locator -> Maybe Bool
ignoreCase :: Maybe Bool
ignoreCase, Maybe MatchType
matchType :: Locator -> Maybe MatchType
matchType :: Maybe MatchType
matchType, Maybe JSUInt
maxDepth :: Locator -> Maybe JSUInt
maxDepth :: Maybe JSUInt
maxDepth} ->
      [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"innerText",
          Key
"value" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
value
        ]
          [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
            [ Key -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"ignoreCase" Maybe Bool
ignoreCase,
              Key -> Maybe MatchType -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"matchType" Maybe MatchType
matchType,
              Key -> Maybe JSUInt -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"maxDepth" Maybe JSUInt
maxDepth
            ]
    XPath {Text
value :: Locator -> Text
value :: Text
value} ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"xpath",
          Key
"value" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
value
        ]

-- | Readiness state of a browsing context
data ReadinessState = None | Interactive | Complete
  deriving (Int -> ReadinessState -> ShowS
[ReadinessState] -> ShowS
ReadinessState -> String
(Int -> ReadinessState -> ShowS)
-> (ReadinessState -> String)
-> ([ReadinessState] -> ShowS)
-> Show ReadinessState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadinessState -> ShowS
showsPrec :: Int -> ReadinessState -> ShowS
$cshow :: ReadinessState -> String
show :: ReadinessState -> String
$cshowList :: [ReadinessState] -> ShowS
showList :: [ReadinessState] -> ShowS
Show, ReadinessState -> ReadinessState -> Bool
(ReadinessState -> ReadinessState -> Bool)
-> (ReadinessState -> ReadinessState -> Bool) -> Eq ReadinessState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReadinessState -> ReadinessState -> Bool
== :: ReadinessState -> ReadinessState -> Bool
$c/= :: ReadinessState -> ReadinessState -> Bool
/= :: ReadinessState -> ReadinessState -> Bool
Eq, (forall x. ReadinessState -> Rep ReadinessState x)
-> (forall x. Rep ReadinessState x -> ReadinessState)
-> Generic ReadinessState
forall x. Rep ReadinessState x -> ReadinessState
forall x. ReadinessState -> Rep ReadinessState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReadinessState -> Rep ReadinessState x
from :: forall x. ReadinessState -> Rep ReadinessState x
$cto :: forall x. Rep ReadinessState x -> ReadinessState
to :: forall x. Rep ReadinessState x -> ReadinessState
Generic)

instance ToJSON ReadinessState where
  toJSON :: ReadinessState -> Value
  toJSON :: ReadinessState -> Value
toJSON = ReadinessState -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

-- | User prompt types
data UserPromptType = Alert | BeforeUnload | Confirm | Prompt
  deriving (Int -> UserPromptType -> ShowS
[UserPromptType] -> ShowS
UserPromptType -> String
(Int -> UserPromptType -> ShowS)
-> (UserPromptType -> String)
-> ([UserPromptType] -> ShowS)
-> Show UserPromptType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPromptType -> ShowS
showsPrec :: Int -> UserPromptType -> ShowS
$cshow :: UserPromptType -> String
show :: UserPromptType -> String
$cshowList :: [UserPromptType] -> ShowS
showList :: [UserPromptType] -> ShowS
Show, UserPromptType -> UserPromptType -> Bool
(UserPromptType -> UserPromptType -> Bool)
-> (UserPromptType -> UserPromptType -> Bool) -> Eq UserPromptType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPromptType -> UserPromptType -> Bool
== :: UserPromptType -> UserPromptType -> Bool
$c/= :: UserPromptType -> UserPromptType -> Bool
/= :: UserPromptType -> UserPromptType -> Bool
Eq, (forall x. UserPromptType -> Rep UserPromptType x)
-> (forall x. Rep UserPromptType x -> UserPromptType)
-> Generic UserPromptType
forall x. Rep UserPromptType x -> UserPromptType
forall x. UserPromptType -> Rep UserPromptType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserPromptType -> Rep UserPromptType x
from :: forall x. UserPromptType -> Rep UserPromptType x
$cto :: forall x. Rep UserPromptType x -> UserPromptType
to :: forall x. Rep UserPromptType x -> UserPromptType
Generic)

instance ToJSON UserPromptType where
  toJSON :: UserPromptType -> Value
  toJSON :: UserPromptType -> Value
toJSON = UserPromptType -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

instance FromJSON UserPromptType where
  parseJSON :: Value -> Parser UserPromptType
  parseJSON :: Value -> Parser UserPromptType
parseJSON = Value -> Parser UserPromptType
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
fromJSONCamelCase

-- | Type of browsing context to create
data CreateType = Tab | Window
  deriving (Int -> CreateType -> ShowS
[CreateType] -> ShowS
CreateType -> String
(Int -> CreateType -> ShowS)
-> (CreateType -> String)
-> ([CreateType] -> ShowS)
-> Show CreateType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateType -> ShowS
showsPrec :: Int -> CreateType -> ShowS
$cshow :: CreateType -> String
show :: CreateType -> String
$cshowList :: [CreateType] -> ShowS
showList :: [CreateType] -> ShowS
Show, CreateType -> CreateType -> Bool
(CreateType -> CreateType -> Bool)
-> (CreateType -> CreateType -> Bool) -> Eq CreateType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateType -> CreateType -> Bool
== :: CreateType -> CreateType -> Bool
$c/= :: CreateType -> CreateType -> Bool
/= :: CreateType -> CreateType -> Bool
Eq, (forall x. CreateType -> Rep CreateType x)
-> (forall x. Rep CreateType x -> CreateType) -> Generic CreateType
forall x. Rep CreateType x -> CreateType
forall x. CreateType -> Rep CreateType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CreateType -> Rep CreateType x
from :: forall x. CreateType -> Rep CreateType x
$cto :: forall x. Rep CreateType x -> CreateType
to :: forall x. Rep CreateType x -> CreateType
Generic)

instance ToJSON CreateType where
  toJSON :: CreateType -> Value
  toJSON :: CreateType -> Value
toJSON = CreateType -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

-- | Print margin
data PrintMargin = MkPrintMargin
  { PrintMargin -> Maybe Float
bottom :: Maybe Float,
    PrintMargin -> Maybe Float
left :: Maybe Float,
    PrintMargin -> Maybe Float
right :: Maybe Float,
    PrintMargin -> Maybe Float
top :: Maybe Float
  }
  deriving (Int -> PrintMargin -> ShowS
[PrintMargin] -> ShowS
PrintMargin -> String
(Int -> PrintMargin -> ShowS)
-> (PrintMargin -> String)
-> ([PrintMargin] -> ShowS)
-> Show PrintMargin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PrintMargin -> ShowS
showsPrec :: Int -> PrintMargin -> ShowS
$cshow :: PrintMargin -> String
show :: PrintMargin -> String
$cshowList :: [PrintMargin] -> ShowS
showList :: [PrintMargin] -> ShowS
Show, PrintMargin -> PrintMargin -> Bool
(PrintMargin -> PrintMargin -> Bool)
-> (PrintMargin -> PrintMargin -> Bool) -> Eq PrintMargin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PrintMargin -> PrintMargin -> Bool
== :: PrintMargin -> PrintMargin -> Bool
$c/= :: PrintMargin -> PrintMargin -> Bool
/= :: PrintMargin -> PrintMargin -> Bool
Eq, (forall x. PrintMargin -> Rep PrintMargin x)
-> (forall x. Rep PrintMargin x -> PrintMargin)
-> Generic PrintMargin
forall x. Rep PrintMargin x -> PrintMargin
forall x. PrintMargin -> Rep PrintMargin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PrintMargin -> Rep PrintMargin x
from :: forall x. PrintMargin -> Rep PrintMargin x
$cto :: forall x. Rep PrintMargin x -> PrintMargin
to :: forall x. Rep PrintMargin x -> PrintMargin
Generic)

-- | Print page
data PrintPage = MkPrintPage
  { PrintPage -> Maybe Float
height :: Maybe Float,
    PrintPage -> Maybe Float
width :: Maybe Float
  }
  deriving (Int -> PrintPage -> ShowS
[PrintPage] -> ShowS
PrintPage -> String
(Int -> PrintPage -> ShowS)
-> (PrintPage -> String)
-> ([PrintPage] -> ShowS)
-> Show PrintPage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PrintPage -> ShowS
showsPrec :: Int -> PrintPage -> ShowS
$cshow :: PrintPage -> String
show :: PrintPage -> String
$cshowList :: [PrintPage] -> ShowS
showList :: [PrintPage] -> ShowS
Show, PrintPage -> PrintPage -> Bool
(PrintPage -> PrintPage -> Bool)
-> (PrintPage -> PrintPage -> Bool) -> Eq PrintPage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PrintPage -> PrintPage -> Bool
== :: PrintPage -> PrintPage -> Bool
$c/= :: PrintPage -> PrintPage -> Bool
/= :: PrintPage -> PrintPage -> Bool
Eq, (forall x. PrintPage -> Rep PrintPage x)
-> (forall x. Rep PrintPage x -> PrintPage) -> Generic PrintPage
forall x. Rep PrintPage x -> PrintPage
forall x. PrintPage -> Rep PrintPage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PrintPage -> Rep PrintPage x
from :: forall x. PrintPage -> Rep PrintPage x
$cto :: forall x. Rep PrintPage x -> PrintPage
to :: forall x. Rep PrintPage x -> PrintPage
Generic)

-- | Viewport dimensions
data Viewport = MkViewport
  { Viewport -> JSUInt
width :: JSUInt,
    Viewport -> JSUInt
height :: JSUInt
  }
  deriving (Int -> Viewport -> ShowS
[Viewport] -> ShowS
Viewport -> String
(Int -> Viewport -> ShowS)
-> (Viewport -> String) -> ([Viewport] -> ShowS) -> Show Viewport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Viewport -> ShowS
showsPrec :: Int -> Viewport -> ShowS
$cshow :: Viewport -> String
show :: Viewport -> String
$cshowList :: [Viewport] -> ShowS
showList :: [Viewport] -> ShowS
Show, Viewport -> Viewport -> Bool
(Viewport -> Viewport -> Bool)
-> (Viewport -> Viewport -> Bool) -> Eq Viewport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Viewport -> Viewport -> Bool
== :: Viewport -> Viewport -> Bool
$c/= :: Viewport -> Viewport -> Bool
/= :: Viewport -> Viewport -> Bool
Eq, (forall x. Viewport -> Rep Viewport x)
-> (forall x. Rep Viewport x -> Viewport) -> Generic Viewport
forall x. Rep Viewport x -> Viewport
forall x. Viewport -> Rep Viewport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Viewport -> Rep Viewport x
from :: forall x. Viewport -> Rep Viewport x
$cto :: forall x. Rep Viewport x -> Viewport
to :: forall x. Rep Viewport x -> Viewport
Generic)

-- ######### Local #########

instance FromJSON NavigateResult

newtype GetTreeResult = MkGetTreeResult
  { GetTreeResult -> [Info]
contexts :: [Info]
  }
  deriving stock (Int -> GetTreeResult -> ShowS
[GetTreeResult] -> ShowS
GetTreeResult -> String
(Int -> GetTreeResult -> ShowS)
-> (GetTreeResult -> String)
-> ([GetTreeResult] -> ShowS)
-> Show GetTreeResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTreeResult -> ShowS
showsPrec :: Int -> GetTreeResult -> ShowS
$cshow :: GetTreeResult -> String
show :: GetTreeResult -> String
$cshowList :: [GetTreeResult] -> ShowS
showList :: [GetTreeResult] -> ShowS
Show, GetTreeResult -> GetTreeResult -> Bool
(GetTreeResult -> GetTreeResult -> Bool)
-> (GetTreeResult -> GetTreeResult -> Bool) -> Eq GetTreeResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTreeResult -> GetTreeResult -> Bool
== :: GetTreeResult -> GetTreeResult -> Bool
$c/= :: GetTreeResult -> GetTreeResult -> Bool
/= :: GetTreeResult -> GetTreeResult -> Bool
Eq, (forall x. GetTreeResult -> Rep GetTreeResult x)
-> (forall x. Rep GetTreeResult x -> GetTreeResult)
-> Generic GetTreeResult
forall x. Rep GetTreeResult x -> GetTreeResult
forall x. GetTreeResult -> Rep GetTreeResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetTreeResult -> Rep GetTreeResult x
from :: forall x. GetTreeResult -> Rep GetTreeResult x
$cto :: forall x. Rep GetTreeResult x -> GetTreeResult
to :: forall x. Rep GetTreeResult x -> GetTreeResult
Generic)

instance FromJSON GetTreeResult

newtype LocateNodesResult = MkLocateNodesResult
  { LocateNodesResult -> [NodeRemoteValue]
nodes :: [NodeRemoteValue]
  }
  deriving newtype (Int -> LocateNodesResult -> ShowS
[LocateNodesResult] -> ShowS
LocateNodesResult -> String
(Int -> LocateNodesResult -> ShowS)
-> (LocateNodesResult -> String)
-> ([LocateNodesResult] -> ShowS)
-> Show LocateNodesResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocateNodesResult -> ShowS
showsPrec :: Int -> LocateNodesResult -> ShowS
$cshow :: LocateNodesResult -> String
show :: LocateNodesResult -> String
$cshowList :: [LocateNodesResult] -> ShowS
showList :: [LocateNodesResult] -> ShowS
Show, LocateNodesResult -> LocateNodesResult -> Bool
(LocateNodesResult -> LocateNodesResult -> Bool)
-> (LocateNodesResult -> LocateNodesResult -> Bool)
-> Eq LocateNodesResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocateNodesResult -> LocateNodesResult -> Bool
== :: LocateNodesResult -> LocateNodesResult -> Bool
$c/= :: LocateNodesResult -> LocateNodesResult -> Bool
/= :: LocateNodesResult -> LocateNodesResult -> Bool
Eq)
  deriving stock ((forall x. LocateNodesResult -> Rep LocateNodesResult x)
-> (forall x. Rep LocateNodesResult x -> LocateNodesResult)
-> Generic LocateNodesResult
forall x. Rep LocateNodesResult x -> LocateNodesResult
forall x. LocateNodesResult -> Rep LocateNodesResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LocateNodesResult -> Rep LocateNodesResult x
from :: forall x. LocateNodesResult -> Rep LocateNodesResult x
$cto :: forall x. Rep LocateNodesResult x -> LocateNodesResult
to :: forall x. Rep LocateNodesResult x -> LocateNodesResult
Generic)

instance FromJSON LocateNodesResult

newtype CaptureScreenshotResult = MkCaptureScreenshotResult
  { CaptureScreenshotResult -> Text
base64Text :: Text
  }
  deriving newtype (Int -> CaptureScreenshotResult -> ShowS
[CaptureScreenshotResult] -> ShowS
CaptureScreenshotResult -> String
(Int -> CaptureScreenshotResult -> ShowS)
-> (CaptureScreenshotResult -> String)
-> ([CaptureScreenshotResult] -> ShowS)
-> Show CaptureScreenshotResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CaptureScreenshotResult -> ShowS
showsPrec :: Int -> CaptureScreenshotResult -> ShowS
$cshow :: CaptureScreenshotResult -> String
show :: CaptureScreenshotResult -> String
$cshowList :: [CaptureScreenshotResult] -> ShowS
showList :: [CaptureScreenshotResult] -> ShowS
Show, CaptureScreenshotResult -> CaptureScreenshotResult -> Bool
(CaptureScreenshotResult -> CaptureScreenshotResult -> Bool)
-> (CaptureScreenshotResult -> CaptureScreenshotResult -> Bool)
-> Eq CaptureScreenshotResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CaptureScreenshotResult -> CaptureScreenshotResult -> Bool
== :: CaptureScreenshotResult -> CaptureScreenshotResult -> Bool
$c/= :: CaptureScreenshotResult -> CaptureScreenshotResult -> Bool
/= :: CaptureScreenshotResult -> CaptureScreenshotResult -> Bool
Eq)

parseTextData :: Text -> Value -> Parser Text
parseTextData :: Text -> Value -> Parser Text
parseTextData Text
description = String -> (Object -> Parser Text) -> Value -> Parser Text
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject (Text -> String
unpack Text
description) ((Object -> Parser Text) -> Value -> Parser Text)
-> (Object -> Parser Text) -> Value -> Parser Text
forall a b. (a -> b) -> a -> b
$ (Object -> Key -> Parser Text) -> Key -> Object -> Parser Text
forall a b c. (a -> b -> c) -> b -> a -> c
flip Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
(.:) Key
"data"

instance FromJSON CaptureScreenshotResult where
  parseJSON :: Value -> Parser CaptureScreenshotResult
  parseJSON :: Value -> Parser CaptureScreenshotResult
parseJSON = (Text -> CaptureScreenshotResult)
-> Parser Text -> Parser CaptureScreenshotResult
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> CaptureScreenshotResult
MkCaptureScreenshotResult (Parser Text -> Parser CaptureScreenshotResult)
-> (Value -> Parser Text)
-> Value
-> Parser CaptureScreenshotResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Value -> Parser Text
parseTextData Text
"CaptureScreenshotResult"

newtype PrintResult = MkPrintResult
  { PrintResult -> Text
base64Text :: Text
  }
  deriving newtype (Int -> PrintResult -> ShowS
[PrintResult] -> ShowS
PrintResult -> String
(Int -> PrintResult -> ShowS)
-> (PrintResult -> String)
-> ([PrintResult] -> ShowS)
-> Show PrintResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PrintResult -> ShowS
showsPrec :: Int -> PrintResult -> ShowS
$cshow :: PrintResult -> String
show :: PrintResult -> String
$cshowList :: [PrintResult] -> ShowS
showList :: [PrintResult] -> ShowS
Show, PrintResult -> PrintResult -> Bool
(PrintResult -> PrintResult -> Bool)
-> (PrintResult -> PrintResult -> Bool) -> Eq PrintResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PrintResult -> PrintResult -> Bool
== :: PrintResult -> PrintResult -> Bool
$c/= :: PrintResult -> PrintResult -> Bool
/= :: PrintResult -> PrintResult -> Bool
Eq)

instance FromJSON PrintResult where
  parseJSON :: Value -> Parser PrintResult
  parseJSON :: Value -> Parser PrintResult
parseJSON = (Text -> PrintResult) -> Parser Text -> Parser PrintResult
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> PrintResult
MkPrintResult (Parser Text -> Parser PrintResult)
-> (Value -> Parser Text) -> Value -> Parser PrintResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Value -> Parser Text
parseTextData Text
"PrintResult"

data Info = MkInfo
  { Info -> Maybe [Info]
children :: Maybe [Info],
    Info -> ClientWindow
clientWindow :: ClientWindow, 
    Info -> BrowsingContext
context :: BrowsingContext,
    Info -> Maybe BrowsingContext
originalOpener :: Maybe BrowsingContext,
    Info -> URL
url :: URL,
    Info -> UserContext
userContext :: UserContext, 
    Info -> Maybe BrowsingContext
parent :: Maybe BrowsingContext
  }
  deriving (Int -> Info -> ShowS
[Info] -> ShowS
Info -> String
(Int -> Info -> ShowS)
-> (Info -> String) -> ([Info] -> ShowS) -> Show Info
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Info -> ShowS
showsPrec :: Int -> Info -> ShowS
$cshow :: Info -> String
show :: Info -> String
$cshowList :: [Info] -> ShowS
showList :: [Info] -> ShowS
Show, Info -> Info -> Bool
(Info -> Info -> Bool) -> (Info -> Info -> Bool) -> Eq Info
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Info -> Info -> Bool
== :: Info -> Info -> Bool
$c/= :: Info -> Info -> Bool
/= :: Info -> Info -> Bool
Eq, (forall x. Info -> Rep Info x)
-> (forall x. Rep Info x -> Info) -> Generic Info
forall x. Rep Info x -> Info
forall x. Info -> Rep Info x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Info -> Rep Info x
from :: forall x. Info -> Rep Info x
$cto :: forall x. Rep Info x -> Info
to :: forall x. Rep Info x -> Info
Generic)

instance FromJSON Info where
  parseJSON :: Value -> Parser Info
  parseJSON :: Value -> Parser Info
parseJSON = Value -> Parser Info
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

data NavigateResult = MkNavigateResult
  { NavigateResult -> Maybe Text
navigation :: Maybe Text,
    NavigateResult -> URL
url :: URL
  }
  deriving (Int -> NavigateResult -> ShowS
[NavigateResult] -> ShowS
NavigateResult -> String
(Int -> NavigateResult -> ShowS)
-> (NavigateResult -> String)
-> ([NavigateResult] -> ShowS)
-> Show NavigateResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NavigateResult -> ShowS
showsPrec :: Int -> NavigateResult -> ShowS
$cshow :: NavigateResult -> String
show :: NavigateResult -> String
$cshowList :: [NavigateResult] -> ShowS
showList :: [NavigateResult] -> ShowS
Show, NavigateResult -> NavigateResult -> Bool
(NavigateResult -> NavigateResult -> Bool)
-> (NavigateResult -> NavigateResult -> Bool) -> Eq NavigateResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NavigateResult -> NavigateResult -> Bool
== :: NavigateResult -> NavigateResult -> Bool
$c/= :: NavigateResult -> NavigateResult -> Bool
/= :: NavigateResult -> NavigateResult -> Bool
Eq, (forall x. NavigateResult -> Rep NavigateResult x)
-> (forall x. Rep NavigateResult x -> NavigateResult)
-> Generic NavigateResult
forall x. Rep NavigateResult x -> NavigateResult
forall x. NavigateResult -> Rep NavigateResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NavigateResult -> Rep NavigateResult x
from :: forall x. NavigateResult -> Rep NavigateResult x
$cto :: forall x. Rep NavigateResult x -> NavigateResult
to :: forall x. Rep NavigateResult x -> NavigateResult
Generic)

-- | Event from a browsing context
data BrowsingContextEvent
  = ContextCreated Info
  | ContextDestroyed Info
  | DomContentLoaded NavigationInfo
  | DownloadEnd
  | DownloadWillBegin DownloadWillBegin
  | FragmentNavigated NavigationInfo
  | HistoryUpdated HistoryUpdated
  | Load NavigationInfo
  | NavigationAborted NavigationInfo
  | NavigationCommitted NavigationInfo
  | NavigationFailed NavigationInfo
  | NavigationStarted NavigationInfo
  | UserPromptClosed UserPromptClosed
  | UserPromptOpened UserPromptOpened
  deriving (Int -> BrowsingContextEvent -> ShowS
[BrowsingContextEvent] -> ShowS
BrowsingContextEvent -> String
(Int -> BrowsingContextEvent -> ShowS)
-> (BrowsingContextEvent -> String)
-> ([BrowsingContextEvent] -> ShowS)
-> Show BrowsingContextEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BrowsingContextEvent -> ShowS
showsPrec :: Int -> BrowsingContextEvent -> ShowS
$cshow :: BrowsingContextEvent -> String
show :: BrowsingContextEvent -> String
$cshowList :: [BrowsingContextEvent] -> ShowS
showList :: [BrowsingContextEvent] -> ShowS
Show, BrowsingContextEvent -> BrowsingContextEvent -> Bool
(BrowsingContextEvent -> BrowsingContextEvent -> Bool)
-> (BrowsingContextEvent -> BrowsingContextEvent -> Bool)
-> Eq BrowsingContextEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BrowsingContextEvent -> BrowsingContextEvent -> Bool
== :: BrowsingContextEvent -> BrowsingContextEvent -> Bool
$c/= :: BrowsingContextEvent -> BrowsingContextEvent -> Bool
/= :: BrowsingContextEvent -> BrowsingContextEvent -> Bool
Eq, (forall x. BrowsingContextEvent -> Rep BrowsingContextEvent x)
-> (forall x. Rep BrowsingContextEvent x -> BrowsingContextEvent)
-> Generic BrowsingContextEvent
forall x. Rep BrowsingContextEvent x -> BrowsingContextEvent
forall x. BrowsingContextEvent -> Rep BrowsingContextEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BrowsingContextEvent -> Rep BrowsingContextEvent x
from :: forall x. BrowsingContextEvent -> Rep BrowsingContextEvent x
$cto :: forall x. Rep BrowsingContextEvent x -> BrowsingContextEvent
to :: forall x. Rep BrowsingContextEvent x -> BrowsingContextEvent
Generic)

instance FromJSON BrowsingContextEvent where
  parseJSON :: Value -> Parser BrowsingContextEvent
  parseJSON :: Value -> Parser BrowsingContextEvent
parseJSON = String
-> (Object -> Parser BrowsingContextEvent)
-> Value
-> Parser BrowsingContextEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"BrowsingContextEvent" ((Object -> Parser BrowsingContextEvent)
 -> Value -> Parser BrowsingContextEvent)
-> (Object -> Parser BrowsingContextEvent)
-> Value
-> Parser BrowsingContextEvent
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
    typ <- Object
o Object -> Key -> Parser KnownSubscriptionType
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"method"
    params <- o .: "params"
    let parsedPrms :: forall a b. (FromJSON a) => (a -> b) -> Parser b
        parsedPrms = Parser a -> (a -> b) -> Parser b
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
(<&>) (Value -> Parser a
forall a. FromJSON a => Value -> Parser a
parseJSON Value
params)
    case typ of
      KnownSubscriptionType
BrowsingContextContextCreated -> (Info -> BrowsingContextEvent) -> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms Info -> BrowsingContextEvent
ContextCreated
      KnownSubscriptionType
BrowsingContextContextDestroyed -> (Info -> BrowsingContextEvent) -> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms Info -> BrowsingContextEvent
ContextDestroyed
      KnownSubscriptionType
BrowsingContextDomContentLoaded -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
DomContentLoaded
      KnownSubscriptionType
BrowsingContextDownloadEnd -> BrowsingContextEvent -> Parser BrowsingContextEvent
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BrowsingContextEvent
DownloadEnd
      KnownSubscriptionType
BrowsingContextDownloadWillBegin -> (DownloadWillBegin -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms DownloadWillBegin -> BrowsingContextEvent
DownloadWillBegin
      KnownSubscriptionType
BrowsingContextFragmentNavigated -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
FragmentNavigated
      KnownSubscriptionType
BrowsingContextHistoryUpdated -> (HistoryUpdated -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms HistoryUpdated -> BrowsingContextEvent
HistoryUpdated
      KnownSubscriptionType
BrowsingContextLoad -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
Load
      KnownSubscriptionType
BrowsingContextNavigationAborted -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
NavigationAborted
      KnownSubscriptionType
BrowsingContextNavigationCommitted -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
NavigationCommitted
      KnownSubscriptionType
BrowsingContextNavigationFailed -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
NavigationFailed
      KnownSubscriptionType
BrowsingContextNavigationStarted -> (NavigationInfo -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms NavigationInfo -> BrowsingContextEvent
NavigationStarted
      KnownSubscriptionType
BrowsingContextUserPromptClosed -> (UserPromptClosed -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms UserPromptClosed -> BrowsingContextEvent
UserPromptClosed
      KnownSubscriptionType
BrowsingContextUserPromptOpened -> (UserPromptOpened -> BrowsingContextEvent)
-> Parser BrowsingContextEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parsedPrms UserPromptOpened -> BrowsingContextEvent
UserPromptOpened
      KnownSubscriptionType
_ -> String -> Parser BrowsingContextEvent
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser BrowsingContextEvent)
-> String -> Parser BrowsingContextEvent
forall a b. (a -> b) -> a -> b
$ String
"Unknown BrowsingContextEvent type: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> KnownSubscriptionType -> String
forall a. Show a => a -> String
show KnownSubscriptionType
typ

data NavigationInfo = MkNavigationInfo
  { NavigationInfo -> BrowsingContext
context :: BrowsingContext,
    NavigationInfo -> Maybe Navigation
navigation :: Maybe Navigation,
    NavigationInfo -> JSUInt
timestamp :: JSUInt,
    NavigationInfo -> URL
url :: URL
  }
  deriving (Int -> NavigationInfo -> ShowS
[NavigationInfo] -> ShowS
NavigationInfo -> String
(Int -> NavigationInfo -> ShowS)
-> (NavigationInfo -> String)
-> ([NavigationInfo] -> ShowS)
-> Show NavigationInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NavigationInfo -> ShowS
showsPrec :: Int -> NavigationInfo -> ShowS
$cshow :: NavigationInfo -> String
show :: NavigationInfo -> String
$cshowList :: [NavigationInfo] -> ShowS
showList :: [NavigationInfo] -> ShowS
Show, NavigationInfo -> NavigationInfo -> Bool
(NavigationInfo -> NavigationInfo -> Bool)
-> (NavigationInfo -> NavigationInfo -> Bool) -> Eq NavigationInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NavigationInfo -> NavigationInfo -> Bool
== :: NavigationInfo -> NavigationInfo -> Bool
$c/= :: NavigationInfo -> NavigationInfo -> Bool
/= :: NavigationInfo -> NavigationInfo -> Bool
Eq, (forall x. NavigationInfo -> Rep NavigationInfo x)
-> (forall x. Rep NavigationInfo x -> NavigationInfo)
-> Generic NavigationInfo
forall x. Rep NavigationInfo x -> NavigationInfo
forall x. NavigationInfo -> Rep NavigationInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NavigationInfo -> Rep NavigationInfo x
from :: forall x. NavigationInfo -> Rep NavigationInfo x
$cto :: forall x. Rep NavigationInfo x -> NavigationInfo
to :: forall x. Rep NavigationInfo x -> NavigationInfo
Generic)

instance FromJSON NavigationInfo where
  parseJSON :: Value -> Parser NavigationInfo
  parseJSON :: Value -> Parser NavigationInfo
parseJSON = Value -> Parser NavigationInfo
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

data DownloadEnd
  = DownloadCompleted
      { DownloadEnd -> Maybe Text
filePath :: Maybe Text,
        DownloadEnd -> NavigationInfo
navigationInfo :: NavigationInfo
      }
  | DownloadCanceled {navigationInfo :: NavigationInfo}
  deriving (Int -> DownloadEnd -> ShowS
[DownloadEnd] -> ShowS
DownloadEnd -> String
(Int -> DownloadEnd -> ShowS)
-> (DownloadEnd -> String)
-> ([DownloadEnd] -> ShowS)
-> Show DownloadEnd
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DownloadEnd -> ShowS
showsPrec :: Int -> DownloadEnd -> ShowS
$cshow :: DownloadEnd -> String
show :: DownloadEnd -> String
$cshowList :: [DownloadEnd] -> ShowS
showList :: [DownloadEnd] -> ShowS
Show, DownloadEnd -> DownloadEnd -> Bool
(DownloadEnd -> DownloadEnd -> Bool)
-> (DownloadEnd -> DownloadEnd -> Bool) -> Eq DownloadEnd
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DownloadEnd -> DownloadEnd -> Bool
== :: DownloadEnd -> DownloadEnd -> Bool
$c/= :: DownloadEnd -> DownloadEnd -> Bool
/= :: DownloadEnd -> DownloadEnd -> Bool
Eq, (forall x. DownloadEnd -> Rep DownloadEnd x)
-> (forall x. Rep DownloadEnd x -> DownloadEnd)
-> Generic DownloadEnd
forall x. Rep DownloadEnd x -> DownloadEnd
forall x. DownloadEnd -> Rep DownloadEnd x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DownloadEnd -> Rep DownloadEnd x
from :: forall x. DownloadEnd -> Rep DownloadEnd x
$cto :: forall x. Rep DownloadEnd x -> DownloadEnd
to :: forall x. Rep DownloadEnd x -> DownloadEnd
Generic)

instance FromJSON DownloadEnd where
  parseJSON :: Value -> Parser DownloadEnd
  parseJSON :: Value -> Parser DownloadEnd
parseJSON = String
-> (Object -> Parser DownloadEnd) -> Value -> Parser DownloadEnd
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"DownloadEnd" ((Object -> Parser DownloadEnd) -> Value -> Parser DownloadEnd)
-> (Object -> Parser DownloadEnd) -> Value -> Parser DownloadEnd
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
    status <- Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"status"
    case status of
      Text
"complete" -> do
        filePath <- Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"filepath"
        context <- v .: "context"
        navigation <- v .: "navigation"
        timestamp <- v .: "timestamp"
        url <- v .: "url"
        let navigationInfo = MkNavigationInfo {BrowsingContext
context :: BrowsingContext
context :: BrowsingContext
context, Maybe Navigation
navigation :: Maybe Navigation
navigation :: Maybe Navigation
navigation, JSUInt
timestamp :: JSUInt
timestamp :: JSUInt
timestamp, URL
url :: URL
url :: URL
url}
        pure $ DownloadCompleted {filePath, navigationInfo}
      Text
"canceled" -> do
        context <- Object
v Object -> Key -> Parser BrowsingContext
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"context"
        navigation <- v .: "navigation"
        timestamp <- v .: "timestamp"
        url <- v .: "url"
        let navigationInfo = MkNavigationInfo {BrowsingContext
context :: BrowsingContext
context :: BrowsingContext
context, Maybe Navigation
navigation :: Maybe Navigation
navigation :: Maybe Navigation
navigation, JSUInt
timestamp :: JSUInt
timestamp :: JSUInt
timestamp, URL
url :: URL
url :: URL
url}
        pure $ DownloadCanceled {navigationInfo}
      Text
_ -> String -> Parser DownloadEnd
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser DownloadEnd) -> String -> Parser DownloadEnd
forall a b. (a -> b) -> a -> b
$ String
"Unknown DownloadEnd status: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
status

data DownloadWillBegin = MkDownloadWillBegin
  { DownloadWillBegin -> Text
suggestedFilename :: Text,
    DownloadWillBegin -> BrowsingContext
context :: BrowsingContext,
    DownloadWillBegin -> Maybe Navigation
navigation :: Maybe Navigation,
    DownloadWillBegin -> JSUInt
timestamp :: JSUInt,
    DownloadWillBegin -> URL
url :: URL
  }
  deriving (Int -> DownloadWillBegin -> ShowS
[DownloadWillBegin] -> ShowS
DownloadWillBegin -> String
(Int -> DownloadWillBegin -> ShowS)
-> (DownloadWillBegin -> String)
-> ([DownloadWillBegin] -> ShowS)
-> Show DownloadWillBegin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DownloadWillBegin -> ShowS
showsPrec :: Int -> DownloadWillBegin -> ShowS
$cshow :: DownloadWillBegin -> String
show :: DownloadWillBegin -> String
$cshowList :: [DownloadWillBegin] -> ShowS
showList :: [DownloadWillBegin] -> ShowS
Show, DownloadWillBegin -> DownloadWillBegin -> Bool
(DownloadWillBegin -> DownloadWillBegin -> Bool)
-> (DownloadWillBegin -> DownloadWillBegin -> Bool)
-> Eq DownloadWillBegin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DownloadWillBegin -> DownloadWillBegin -> Bool
== :: DownloadWillBegin -> DownloadWillBegin -> Bool
$c/= :: DownloadWillBegin -> DownloadWillBegin -> Bool
/= :: DownloadWillBegin -> DownloadWillBegin -> Bool
Eq, (forall x. DownloadWillBegin -> Rep DownloadWillBegin x)
-> (forall x. Rep DownloadWillBegin x -> DownloadWillBegin)
-> Generic DownloadWillBegin
forall x. Rep DownloadWillBegin x -> DownloadWillBegin
forall x. DownloadWillBegin -> Rep DownloadWillBegin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DownloadWillBegin -> Rep DownloadWillBegin x
from :: forall x. DownloadWillBegin -> Rep DownloadWillBegin x
$cto :: forall x. Rep DownloadWillBegin x -> DownloadWillBegin
to :: forall x. Rep DownloadWillBegin x -> DownloadWillBegin
Generic)

instance FromJSON DownloadWillBegin where
  parseJSON :: Value -> Parser DownloadWillBegin
  parseJSON :: Value -> Parser DownloadWillBegin
parseJSON = Value -> Parser DownloadWillBegin
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

data HistoryUpdated = MkHistoryUpdated
  { HistoryUpdated -> BrowsingContext
context :: BrowsingContext,
    HistoryUpdated -> JSUInt
timestamp :: JSUInt,
    HistoryUpdated -> URL
url :: URL
  }
  deriving (Int -> HistoryUpdated -> ShowS
[HistoryUpdated] -> ShowS
HistoryUpdated -> String
(Int -> HistoryUpdated -> ShowS)
-> (HistoryUpdated -> String)
-> ([HistoryUpdated] -> ShowS)
-> Show HistoryUpdated
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HistoryUpdated -> ShowS
showsPrec :: Int -> HistoryUpdated -> ShowS
$cshow :: HistoryUpdated -> String
show :: HistoryUpdated -> String
$cshowList :: [HistoryUpdated] -> ShowS
showList :: [HistoryUpdated] -> ShowS
Show, HistoryUpdated -> HistoryUpdated -> Bool
(HistoryUpdated -> HistoryUpdated -> Bool)
-> (HistoryUpdated -> HistoryUpdated -> Bool) -> Eq HistoryUpdated
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HistoryUpdated -> HistoryUpdated -> Bool
== :: HistoryUpdated -> HistoryUpdated -> Bool
$c/= :: HistoryUpdated -> HistoryUpdated -> Bool
/= :: HistoryUpdated -> HistoryUpdated -> Bool
Eq, (forall x. HistoryUpdated -> Rep HistoryUpdated x)
-> (forall x. Rep HistoryUpdated x -> HistoryUpdated)
-> Generic HistoryUpdated
forall x. Rep HistoryUpdated x -> HistoryUpdated
forall x. HistoryUpdated -> Rep HistoryUpdated x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HistoryUpdated -> Rep HistoryUpdated x
from :: forall x. HistoryUpdated -> Rep HistoryUpdated x
$cto :: forall x. Rep HistoryUpdated x -> HistoryUpdated
to :: forall x. Rep HistoryUpdated x -> HistoryUpdated
Generic)

instance FromJSON HistoryUpdated

data UserPromptClosed = MkUserPromptClosed
  { UserPromptClosed -> BrowsingContext
context :: BrowsingContext,
    UserPromptClosed -> Bool
accepted :: Bool,
    UserPromptClosed -> UserPromptType
promptType :: UserPromptType,
    UserPromptClosed -> Maybe Text
userText :: Maybe Text
  }
  deriving (Int -> UserPromptClosed -> ShowS
[UserPromptClosed] -> ShowS
UserPromptClosed -> String
(Int -> UserPromptClosed -> ShowS)
-> (UserPromptClosed -> String)
-> ([UserPromptClosed] -> ShowS)
-> Show UserPromptClosed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPromptClosed -> ShowS
showsPrec :: Int -> UserPromptClosed -> ShowS
$cshow :: UserPromptClosed -> String
show :: UserPromptClosed -> String
$cshowList :: [UserPromptClosed] -> ShowS
showList :: [UserPromptClosed] -> ShowS
Show, UserPromptClosed -> UserPromptClosed -> Bool
(UserPromptClosed -> UserPromptClosed -> Bool)
-> (UserPromptClosed -> UserPromptClosed -> Bool)
-> Eq UserPromptClosed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPromptClosed -> UserPromptClosed -> Bool
== :: UserPromptClosed -> UserPromptClosed -> Bool
$c/= :: UserPromptClosed -> UserPromptClosed -> Bool
/= :: UserPromptClosed -> UserPromptClosed -> Bool
Eq, (forall x. UserPromptClosed -> Rep UserPromptClosed x)
-> (forall x. Rep UserPromptClosed x -> UserPromptClosed)
-> Generic UserPromptClosed
forall x. Rep UserPromptClosed x -> UserPromptClosed
forall x. UserPromptClosed -> Rep UserPromptClosed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserPromptClosed -> Rep UserPromptClosed x
from :: forall x. UserPromptClosed -> Rep UserPromptClosed x
$cto :: forall x. Rep UserPromptClosed x -> UserPromptClosed
to :: forall x. Rep UserPromptClosed x -> UserPromptClosed
Generic)

promptParser :: forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
promptParser :: forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
promptParser =
  Options -> Value -> Parser a
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON
    Options
defaultOptions
      { fieldLabelModifier = \case
          String
"promptType" -> String
"type"
          String
other -> String
other,
        omitNothingFields = True
      }

instance FromJSON UserPromptClosed where
  parseJSON :: Value -> Parser UserPromptClosed
  parseJSON :: Value -> Parser UserPromptClosed
parseJSON = Value -> Parser UserPromptClosed
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
promptParser

data UserPromptOpened = MkUserPromptOpened
  { UserPromptOpened -> BrowsingContext
context :: BrowsingContext,
    UserPromptOpened -> UserPromptHandlerType
handler :: UserPromptHandlerType,
    UserPromptOpened -> Text
message :: Text,
    UserPromptOpened -> UserPromptType
promptType :: UserPromptType,
    UserPromptOpened -> Maybe Text
defaultValue :: Maybe Text
  }
  deriving (Int -> UserPromptOpened -> ShowS
[UserPromptOpened] -> ShowS
UserPromptOpened -> String
(Int -> UserPromptOpened -> ShowS)
-> (UserPromptOpened -> String)
-> ([UserPromptOpened] -> ShowS)
-> Show UserPromptOpened
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPromptOpened -> ShowS
showsPrec :: Int -> UserPromptOpened -> ShowS
$cshow :: UserPromptOpened -> String
show :: UserPromptOpened -> String
$cshowList :: [UserPromptOpened] -> ShowS
showList :: [UserPromptOpened] -> ShowS
Show, UserPromptOpened -> UserPromptOpened -> Bool
(UserPromptOpened -> UserPromptOpened -> Bool)
-> (UserPromptOpened -> UserPromptOpened -> Bool)
-> Eq UserPromptOpened
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPromptOpened -> UserPromptOpened -> Bool
== :: UserPromptOpened -> UserPromptOpened -> Bool
$c/= :: UserPromptOpened -> UserPromptOpened -> Bool
/= :: UserPromptOpened -> UserPromptOpened -> Bool
Eq, (forall x. UserPromptOpened -> Rep UserPromptOpened x)
-> (forall x. Rep UserPromptOpened x -> UserPromptOpened)
-> Generic UserPromptOpened
forall x. Rep UserPromptOpened x -> UserPromptOpened
forall x. UserPromptOpened -> Rep UserPromptOpened x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserPromptOpened -> Rep UserPromptOpened x
from :: forall x. UserPromptOpened -> Rep UserPromptOpened x
$cto :: forall x. Rep UserPromptOpened x -> UserPromptOpened
to :: forall x. Rep UserPromptOpened x -> UserPromptOpened
Generic)

instance FromJSON UserPromptOpened where
  parseJSON :: Value -> Parser UserPromptOpened
  parseJSON :: Value -> Parser UserPromptOpened
parseJSON = Value -> Parser UserPromptOpened
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
promptParser

newtype Navigation = MkNavigation
  { Navigation -> Text
navigationId :: Text
  }
  deriving (Int -> Navigation -> ShowS
[Navigation] -> ShowS
Navigation -> String
(Int -> Navigation -> ShowS)
-> (Navigation -> String)
-> ([Navigation] -> ShowS)
-> Show Navigation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Navigation -> ShowS
showsPrec :: Int -> Navigation -> ShowS
$cshow :: Navigation -> String
show :: Navigation -> String
$cshowList :: [Navigation] -> ShowS
showList :: [Navigation] -> ShowS
Show, Navigation -> Navigation -> Bool
(Navigation -> Navigation -> Bool)
-> (Navigation -> Navigation -> Bool) -> Eq Navigation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Navigation -> Navigation -> Bool
== :: Navigation -> Navigation -> Bool
$c/= :: Navigation -> Navigation -> Bool
/= :: Navigation -> Navigation -> Bool
Eq, (forall x. Navigation -> Rep Navigation x)
-> (forall x. Rep Navigation x -> Navigation) -> Generic Navigation
forall x. Rep Navigation x -> Navigation
forall x. Navigation -> Rep Navigation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Navigation -> Rep Navigation x
from :: forall x. Navigation -> Rep Navigation x
$cto :: forall x. Rep Navigation x -> Navigation
to :: forall x. Rep Navigation x -> Navigation
Generic)
  deriving newtype (Maybe Navigation
Value -> Parser [Navigation]
Value -> Parser Navigation
(Value -> Parser Navigation)
-> (Value -> Parser [Navigation])
-> Maybe Navigation
-> FromJSON Navigation
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Navigation
parseJSON :: Value -> Parser Navigation
$cparseJSONList :: Value -> Parser [Navigation]
parseJSONList :: Value -> Parser [Navigation]
$comittedField :: Maybe Navigation
omittedField :: Maybe Navigation
FromJSON)

instance ToJSON TraverseHistory

instance ToJSON PrintMargin

instance ToJSON PrintPage

instance ToJSON Viewport