load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
load("//javascript:defs.bzl", "closure_fragment")

closure_js_binary(
    name = "inputs_bin",
    visibility = [
        "//java/test/org/openqa/selenium/atoms:__pkg__",
        "//javascript/ie-driver:__pkg__",
    ],
    deps = [
        ":inputs_exports",
    ],
)

closure_js_library(
    name = "inputs_exports",
    srcs = ["exports/inputs.js"],
    deps = [":atoms-lib"],
)

closure_js_library(
    name = "atoms-lib",
    srcs = glob([
        "*.js",
        "storage/*.js",
    ]),
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_NULLABLE_RETURN_WITH_NAME",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = ["//javascript:__subpackages__"],
    deps = [
        "//javascript/atoms:action",
        "//javascript/atoms:devices",
        "//javascript/atoms:dom",
        "//javascript/atoms:domcore",
        "//javascript/atoms:html5",
        "//javascript/webdriver:key",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
        "@io_bazel_rules_closure//closure/library/math:coordinate",
        "@io_bazel_rules_closure//closure/library/style",
    ],
)

closure_js_library(
    name = "attribute-only",
    srcs = ["attribute.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_NULLABLE_RETURN_WITH_NAME",
    ],
    visibility = ["//visibility:private"],
    deps = [
        "//javascript/atoms:domcore",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
    ],
)

closure_fragment(
    name = "clear-local-storage",
    function = "webdriver.atoms.storage.local.clear",
    module = "webdriver.atoms.storage.local",
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        "//javascript/webdriver/atoms:atoms-lib",
    ],
)

closure_fragment(
    name = "clear-session-storage",
    function = "webdriver.atoms.storage.session.clear",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        "//javascript/webdriver/atoms:atoms-lib",
    ],
)

closure_fragment(
    name = "get-appcache-status",
    function = "webdriver.atoms.storage.appcache.getStatus",
    module = "webdriver.atoms.storage.appcache",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        "//javascript/webdriver/atoms:atoms-lib",
    ],
)

closure_fragment(
    name = "get-attribute",
    function = "webdriver.atoms.element.attribute.get",
    module = "webdriver.atoms.element.attribute",
    visibility = [
        "//dotnet/src/webdriver:__pkg__",
        "//java/src/org/openqa/selenium/remote:__pkg__",
        "//javascript/chrome-driver:__pkg__",
        "//javascript/ie-driver:__pkg__",
        "//javascript/selenium-webdriver/lib/atoms:__pkg__",
        "//py:__pkg__",
        "//rb/lib/selenium/webdriver/atoms:__pkg__",
    ],
    deps = [
        ":attribute-only",
    ],
)

closure_fragment(
    name = "get-local-storage-item",
    function = "webdriver.atoms.storage.local.getItem",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-local-storage-key",
    function = "webdriver.atoms.storage.local.key",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-local-storage-keys",
    function = "webdriver.atoms.storage.local.keySet",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-local-storage-size",
    function = "webdriver.atoms.storage.local.size",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-session-storage-item",
    function = "webdriver.atoms.storage.session.getItem",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-session-storage-key",
    function = "webdriver.atoms.storage.session.key",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-session-storage-keys",
    function = "webdriver.atoms.storage.session.keySet",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-session-storage-size",
    function = "webdriver.atoms.storage.session.size",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "get-text",
    function = "webdriver.atoms.element.getText",
    module = "webdriver.atoms.element",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
        "//javascript/ie-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "is-selected",
    function = "webdriver.atoms.element.isSelected",
    module = "webdriver.atoms.element",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
        "//javascript/ie-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "remove-local-storage-item",
    function = "webdriver.atoms.storage.local.removeItem",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "remove-session-storage-item",
    function = "webdriver.atoms.storage.session.removeItem",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "set-local-storage-item",
    function = "webdriver.atoms.storage.local.setItem",
    module = "webdriver.atoms.storage.local",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_fragment(
    name = "set-session-storage-item",
    function = "webdriver.atoms.storage.session.setItem",
    module = "webdriver.atoms.storage.session",
    visibility = [
        "//javascript/chrome-driver:__pkg__",
    ],
    deps = [
        ":atoms-lib",
    ],
)

closure_js_library(
    name = "all_js_for_testing",
    testonly = 1,
    srcs = glob(["**/*.js"]),
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = [
        "//javascript:__pkg__",
        "//javascript/chrome-driver:__pkg__",
        "//javascript/webdriver:__pkg__",
    ],
    deps = [
    ],
)
