"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Test = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_2 = require("@fluentui/react-native");
const button_1 = require("@fluentui-react-native/button");
const e2e_testing_1 = require("@fluentui-react-native/e2e-testing");
const stack_1 = require("@fluentui-react-native/stack");
const theme_types_1 = require("@fluentui-react-native/theme-types");
const react_native_svg_1 = tslib_1.__importStar(require("react-native-svg"));
const styles_1 = require("./Common/styles");
const TestProps_1 = require("./Common/TestProps");
const definitions = {
    Production: 'Control is ready for broad partner use and to be used in production-ready scenarios.',
    Beta: 'Control is ready for partner consumption, but not ready for production release (e.g. fixing bugs).',
    Experimental: 'Control code checked into repo, but not ready for partner use.',
    Backlog: 'Control is in plan and on our backlog to deliver.',
    'N/A': 'Control is not in current plan.',
    Deprecated: 'Control is being deprecated.',
};
const styles = react_native_1.StyleSheet.create({
    name: {
        marginTop: 4,
        flex: react_native_1.Platform.select({ ios: 0, android: 0, default: 1 }),
    },
    definitionHeader: {
        marginTop: 12,
        marginBottom: 6,
    },
    description: {
        alignItems: 'flex-start',
        flexWrap: 'wrap',
    },
    header: {
        alignItems: 'center',
        flexDirection: 'row',
        justifyContent: 'space-between',
        flexWrap: 'wrap',
    },
    section: {
        marginTop: 12,
    },
    statusView: {
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
    },
    statusLabel: {
        marginTop: 2,
        marginStart: 4,
    },
    status: {
        fontWeight: 'normal',
    },
    // This button is only for our E2E testing framework. We want to be able to put keyboard focus in any test page if we need it.
    // This button will be at the top of every test page and allows us to do that. But we don't want partners to see it.
    e2eFocusButton: {
        opacity: 0,
    },
    e2eSection: {
        marginBottom: 4,
    },
    e2eSwitch: {
        display: 'flex',
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'center',
    },
    e2eSwitchLabel: {
        marginRight: 4,
        textAlignVertical: 'center',
    },
});
const Test = (props) => {
    const [showStatus, setShowStatus] = React.useState(false);
    const [showE2E, setShowE2E] = React.useState(false);
    const toggleSvg = () => {
        const plusPath = 'M6.5 1.75C6.5 1.33579 6.16421 1 5.75 1C5.33579 1 5 1.33579 5 1.75V5H1.75C1.33579 5 1 5.33579 1 5.75C1 6.16421 1.33579 6.5 1.75 6.5H5V9.75C5 10.1642 5.33579 10.5 5.75 10.5C6.16421 10.5 6.5 10.1642 6.5 9.75V6.5H9.75C10.1642 6.5 10.5 6.16421 10.5 5.75C10.5 5.33579 10.1642 5 9.75 5H6.5V1.75Z';
        const minusPath = 'M2.75 5.25h6.5s0.75 0 0.75 0.75v0s0 0.75 -0.75 0.75h-6.5s-0.75 0 -0.75 -0.75v0s0 -0.75 0.75 -0.75';
        const path = showStatus ? minusPath : plusPath;
        return (React.createElement(react_native_svg_1.default, null,
            React.createElement(react_native_svg_1.G, null,
                React.createElement(react_native_svg_1.Path, { d: path, fill: "black" }))));
    };
    const svgProps = {
        src: toggleSvg,
    };
    const theme = (0, theme_types_1.useTheme)();
    const fontFamily = theme.typography.families.primary;
    const plusCodepoint = 0x2795;
    const minusCodepoint = 0x2796;
    const fontIconProps = {
        fontFamily: fontFamily,
        codepoint: showStatus ? minusCodepoint : plusCodepoint,
        fontSize: 10,
    };
    const toggleIconProps = react_native_1.Platform.OS === 'windows' ? { fontSource: fontIconProps } : { svgSource: svgProps, width: 12, height: 12 };
    const { e2eSections } = props;
    const isMobile = react_native_1.Platform.OS === 'ios' || react_native_1.Platform.OS === 'android';
    return (React.createElement(react_native_1.View, null,
        React.createElement(react_native_1.View, { style: styles.header },
            React.createElement(react_native_2.Text, { style: styles.name, variant: "heroSemibold" }, props.name),
            !isMobile && (React.createElement(button_1.ButtonV1
            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
            , { ...(0, TestProps_1.testProps)('Focus_Button'), style: styles.e2eFocusButton }, "E2E Button")),
            props.e2eSections && (React.createElement(react_native_1.View, { style: styles.e2eSwitch },
                React.createElement(react_native_2.Text, { style: styles.e2eSwitchLabel, ...(isMobile ? {} : { variant: 'body1Strong' }) }, "E2E Mode"),
                React.createElement(react_native_1.Switch, { onValueChange: setShowE2E, value: showE2E, ...(0, TestProps_1.testProps)(e2e_testing_1.E2E_MODE_SWITCH) }))),
            props.spec && React.createElement(react_native_2.Link, { url: props.spec, content: "SPEC" })),
        React.createElement(react_native_2.Separator, null),
        e2eSections && showE2E && (
        // We can check if the E2E section renders by checking if the "E2E Tests" header has rendered for each spec
        React.createElement(React.Fragment, null,
            React.createElement(react_native_2.Text, { variant: "headerSemibold", ...(0, TestProps_1.testProps)(e2e_testing_1.E2E_TEST_SECTION) }, "E2E Tests"),
            e2eSections.map((section, i) => {
                if (section === null) {
                    return null;
                }
                const { component: E2EComponent } = section;
                return React.createElement(E2EComponent, { key: i });
            }))),
        React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
            React.createElement(react_native_2.Text, { style: styles.description }, props.description)),
        React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
            React.createElement(react_native_1.View, { style: styles.statusView },
                React.createElement(react_native_2.Text, { variant: "headerStandard" }, "Platform Status"),
                React.createElement(react_native_2.ToggleButton, { iconOnly: true, icon: toggleIconProps, onClick: () => setShowStatus(!showStatus) })),
            showStatus && (React.createElement(React.Fragment, null,
                React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold" },
                    "Win32: ",
                    React.createElement(react_native_2.Text, { style: styles.status }, props.status.win32Status)),
                React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold" },
                    "UWP: ",
                    React.createElement(react_native_2.Text, { style: styles.status }, props.status.uwpStatus)),
                React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold" },
                    "iOS: ",
                    React.createElement(react_native_2.Text, { style: styles.status }, props.status.iosStatus)),
                React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold" },
                    "macOS: ",
                    React.createElement(react_native_2.Text, { style: styles.status }, props.status.macosStatus)),
                React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold" },
                    "Android: ",
                    React.createElement(react_native_2.Text, { style: styles.status }, props.status.androidStatus)),
                React.createElement(react_native_2.Text, { style: styles.definitionHeader, variant: "headerStandard" }, "Status Definitions"),
                Object.entries(definitions).map(([key, value]) => {
                    return (React.createElement(react_native_2.Text, { style: styles.statusLabel, variant: "bodySemibold", key: key },
                        key,
                        ": ",
                        React.createElement(react_native_2.Text, { style: styles.status }, value)));
                })))),
        props.sections.map((section, index) => {
            if (section == null) {
                return React.createElement(React.Fragment, null);
            }
            const TestComponent = section.component;
            return (React.createElement(react_native_1.View, { key: index },
                React.createElement(react_native_2.Text, { style: styles.section, variant: "headerSemibold", ...(0, TestProps_1.testProps)(section.testID) }, section.name),
                React.createElement(react_native_2.Separator, null),
                React.createElement(TestComponent, null)));
        })));
};
exports.Test = Test;
//# sourceMappingURL=Test.js.map