"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    LayoutContext: function() {
        return LayoutContext;
    },
    LayoutProvider: function() {
        return LayoutProvider;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const KEY = "MARIN_MODULE_PLACE";
const LayoutContext = /*#__PURE__*/ (0, _react.createContext)({});
const LayoutProvider = (props)=>{
    const context = (0, _react.useContext)(LayoutContext);
    const [position, setPosition] = (0, _react.useState)(()=>{
        const oldPlace = localStorage.getItem(KEY);
        if (!oldPlace) {
            return "top";
        }
        if (![
            "top",
            "bottom"
        ].includes(oldPlace)) {
            localStorage.setItem(KEY, "top");
            return "top";
        }
        return oldPlace;
    });
    const isTopLevel = (0, _react.useMemo)(()=>!context.isTopLevel, []);
    const [siderWidth, setSiderWidth] = (0, _react.useState)(0);
    const [headerHeight, setHeaderHeight] = (0, _react.useState)(0);
    const [footerHeight, setFooterHeight] = (0, _react.useState)(0);
    const [pageHeaderHeight, setPageHeaderHeight] = (0, _react.useState)(0);
    const [pageFooterHeight, setPageFooterHeight] = (0, _react.useState)(0);
    const changePosition = (0, _react.useCallback)((newPosition)=>{
        localStorage.setItem(KEY, newPosition);
        setPosition(newPosition);
    }, [
        setPosition
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(LayoutContext.Provider, {
        value: {
            siderWidth,
            headerHeight: isTopLevel ? headerHeight : context.headerHeight,
            footerHeight: isTopLevel ? footerHeight : context.footerHeight,
            setSiderWidth,
            setHeaderHeight,
            setFooterHeight,
            pageHeaderHeight,
            pageFooterHeight,
            setPageHeaderHeight,
            setPageFooterHeight,
            isTopLevel,
            marginModulePosition: position,
            setMarginModulePosition: changePosition
        },
        children: props.children
    });
};

//# sourceMappingURL=layoutContext.js.map