import * as React from 'react';
import { CaretToolbar } from 'nice-ui/lib/4-card/Toolbar/ToolbarMenu/CaretToolbar';
import { useToolbarPlugin } from '../../context';
import { useSyncStore, useTimeout } from '../../../../web/react/hooks';
import { AfterTimeout } from '../../../../web/react/util/AfterTimeout';
export const CaretTopOverlay = () => {
    const { toolbar } = useToolbarPlugin();
    const showInlineToolbar = toolbar.showInlineToolbar;
    const [, toolbarVisibilityChangeTime] = useSyncStore(showInlineToolbar);
    const doHideForCoolDown = toolbarVisibilityChangeTime + 500 > Date.now();
    const enableAfterCoolDown = useTimeout(500, [doHideForCoolDown]);
    // biome-ignore lint/correctness/useExhaustiveDependencies: showInlineToolbar.next do not need to memoize
    const handleClose = React.useCallback(() => {
        setTimeout(() => {
            if (showInlineToolbar.value)
                showInlineToolbar.next([false, Date.now()]);
        }, 5);
    }, []);
    let element = (React.createElement(CaretToolbar, { disabled: !enableAfterCoolDown, menu: toolbar.getCaretMenu(), onPopupClose: handleClose }));
    if (doHideForCoolDown) {
        element = React.createElement(AfterTimeout, { ms: 500 }, element);
    }
    element = null;
    return element;
};
//# sourceMappingURL=CaretTopOverlay.js.map