"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdaptableLoadingScreen = AdaptableLoadingScreen;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Dialog_1 = tslib_1.__importDefault(require("../../../components/Dialog"));
const Flex_1 = require("../../../components/Flex");
function AdaptableLoadingScreen(props) {
    const { showLoadingScreen, loadingScreenDelay, loadingScreenTitle, loadingScreenText } = props;
    const [delayElapsed, setDelayElapsed] = React.useState(typeof loadingScreenDelay === 'number' ? false : showLoadingScreen);
    React.useEffect(() => {
        if (typeof loadingScreenDelay === 'number') {
            const timeoutId = setTimeout(() => {
                setDelayElapsed(true);
            }, loadingScreenDelay);
            return () => {
                clearTimeout(timeoutId);
            };
        }
    }, [loadingScreenDelay]);
    return (React.createElement(Dialog_1.default, { modal: true, isOpen: delayElapsed ? showLoadingScreen : false, onDismiss: props.onClose, showCloseButton: false, className: "ab-LoadingScreen twa:min-h-auto" },
        React.createElement(Flex_1.Box, { className: "twa:p-3" },
            React.createElement("h4", null, loadingScreenTitle ?? 'Initialising Grid'),
            React.createElement("p", null, loadingScreenText ?? 'Retrieving your settings and setting up the grid...'))));
}
