"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.E2EButtonTest = void 0;
const React = __importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_2 = require("@fluentui/react-native");
const e2e_testing_1 = require("@fluentui-react-native/e2e-testing");
const stack_1 = require("@fluentui-react-native/stack");
const styles_1 = require("../Common/styles");
const TestProps_1 = require("../Common/TestProps");
function keyEvent(key) {
    return {
        key,
        capsLockKey: false,
        shiftKey: false,
        ctrlKey: false,
        altKey: false,
        metaKey: false,
        numericPadKey: false,
        helpKey: false,
        functionKey: false,
        ArrowLeft: false,
        ArrowRight: false,
        ArrowUp: false,
        ArrowDown: false,
    };
}
const E2EButtonTest = () => {
    const [buttonPressed, setButtonPressed] = React.useState(false);
    const [keyDetected, setKeyDetected] = React.useState('');
    const onClick = React.useCallback(() => {
        setButtonPressed(!buttonPressed);
        setKeyDetected('');
    }, [buttonPressed]);
    const keyPressProps = {
        keyDownEvents: [keyEvent('a')],
        onKeyDown: (args) => {
            if (args.nativeEvent.key === 'a') {
                setKeyDetected('a (down)');
                args.stopPropagation();
            }
        },
        keyUpEvents: [keyEvent('b')],
        onKeyUp: (args) => {
            if (args.nativeEvent.key === 'b') {
                setKeyDetected('b (up)');
                args.stopPropagation();
            }
        },
    };
    return (React.createElement(react_native_1.View, null,
        React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
            React.createElement(react_native_2.ButtonV1, { onClick: onClick, accessibilityLabel: e2e_testing_1.BUTTON_ACCESSIBILITY_LABEL, ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_TEST_COMPONENT) }, "This is a button for E2E testing"),
            React.createElement(react_native_2.ButtonV1, { onClick: onClick, accessibilityRole: "menuitem", ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_NO_A11Y_LABEL_COMPONENT) }, e2e_testing_1.BUTTON_TEST_COMPONENT_LABEL),
            React.createElement(react_native_2.ButtonV1, { onClick: onClick, accessibilityLabel: e2e_testing_1.BUTTON_PRESS_TEST_COMPONENT_LABEL, ...keyPressProps, ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_PRESS_TEST_COMPONENT) }, "Press \"a\" or \"b\" after focusing this button"),
            React.createElement(react_native_2.ButtonV1, { onClick: onClick, accessibilityLabel: e2e_testing_1.BUTTON_FOCUSABLE_TEST_COMPONENT_LABEL, focusable: false, ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_FOCUSABLE_TEST_COMPONENT) }, "This button isn't focusable (but isn't disabled or indeterminate either)"),
            buttonPressed ? (React.createElement(react_native_2.Text
            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
            , { ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_ON_PRESS) }, "Button Pressed")) : null,
            keyDetected ? (React.createElement(react_native_2.Text /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, { ...(0, TestProps_1.testProps)(e2e_testing_1.BUTTON_ON_KEY) },
                "Button Key Press detected: ",
                keyDetected)) : null)));
};
exports.E2EButtonTest = E2EButtonTest;
//# sourceMappingURL=E2EButtonTest.js.map