import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import classNames from 'classnames';
import { useEffect, useState } from 'react';
import { CheckBlackIcon } from '../../../lib/icons/CheckBlack.js';
import { Spinner } from '../../../lib/ui/Spinner/Spinner.js';
export function LoadingToast({ isLoading = true, label, top, left, }) {
    const [hidden, setHidden] = useState(false);
    const [showToast, setShowToast] = useState(isLoading);
    useEffect(() => {
        if (isLoading) {
            setHidden(false);
            setShowToast(true);
            return () => { };
        }
        const hideTimeout = globalThis.setTimeout(() => {
            setHidden(true);
        }, 1000);
        const removeTimeout = globalThis.setTimeout(() => {
            setShowToast(false);
        }, 1500);
        return () => {
            globalThis.clearTimeout(hideTimeout);
            globalThis.clearTimeout(removeTimeout);
        };
    }, [isLoading]);
    if (!showToast)
        return _jsx(_Fragment, {});
    return (_jsxs("div", { className: classNames('seam-loading-toast', {
            'seam-loading-toast-hide': hidden,
        }), style: { top, left }, children: [_jsx("div", { className: 'seam-loading-toast-icon-wrap', children: isLoading ? _jsx(Spinner, { size: 'small' }) : _jsx(CheckBlackIcon, {}) }), _jsx("p", { className: 'seam-loading-toast-text', children: label })] }));
}
//# sourceMappingURL=LoadingToast.js.map