"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardContextProvider = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const DashboardContext_1 = require("../DashboardContext");
const DashboardContextProvider = ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, desktopViewMode, }) => {
    const [alertElement, setAlertElement] = (0, react_1.useState)(null);
    const [alertHeight, setAlertHeight] = (0, react_1.useState)(0);
    const [isFocusedModeInternal, setFocusedMode] = (0, react_1.useState)(isFocusedMode);
    const hasMenuOrganizationRef = (0, react_1.useRef)(false);
    const hasProfileRef = (0, react_1.useRef)(false);
    (0, react_1.useEffect)(() => {
        if (isFocusedMode !== isFocusedModeInternal) {
            setFocusedMode(isFocusedMode);
        }
    }, [isFocusedMode]);
    (0, react_1.useEffect)(() => {
        if (!alertElement) {
            setAlertHeight(0);
            return;
        }
        setAlertHeight(alertElement.getBoundingClientRect().height);
        const resizeObserver = new ResizeObserver((entries) => {
            for (const e of entries) {
                setAlertHeight(e.contentRect.height);
            }
        });
        resizeObserver.observe(alertElement);
        return () => resizeObserver.disconnect();
    }, [alertElement]);
    return ((0, jsx_runtime_1.jsx)(DashboardContext_1.DashboardContext.Provider, { value: {
            isFocusedMode: isFocusedModeInternal,
            mobileHeaderPriorityFeature,
            desktopViewMode,
            setAlertElement,
            alertHeight,
            isLoading,
            hasProfileRef,
            hasMenuOrganizationRef,
            setFocusedMode,
        }, children: children }));
};
exports.DashboardContextProvider = DashboardContextProvider;
