import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { useEffect } from 'react';
import Icon from '../Icon';
import './NetworkErrorBoundary.scss';
import { useOnlineStatus } from '../../utils/OnlineStatus/useOnlineStatus';
export const NetworkErrorBoundary = ({ children, offlineContent, hasError = false, onNetworkStatusChange, overlayClassName, overlayZIndex = 99998, iconWidth = 300, iconHeight = 300, }) => {
    const isOnline = useOnlineStatus();
    useEffect(() => {
        if (onNetworkStatusChange) {
            onNetworkStatusChange(isOnline);
        }
    }, [isOnline, onNetworkStatusChange]);
    if (hasError || !isOnline) {
        return (_jsx("div", { className: `offlineOverlay ${overlayClassName ?? ''}`, style: { zIndex: overlayZIndex }, children: offlineContent || (_jsx(Icon, { name: "offline_404_icon", height: iconHeight, width: iconWidth })) }));
    }
    return _jsx(_Fragment, { children: children });
};
export default NetworkErrorBoundary;
//# sourceMappingURL=NetworkErrorBoundary.js.map