"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "BasicLayout", {
    enumerable: true,
    get: function() {
        return BasicLayout;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _antd = require("antd");
const _AppContext = require("./AppContext");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const BasicLayout = /*#__PURE__*/ (0, _react.memo)(({ children, configProps: externalConfigProps })=>{
    const { antdConfig, theme } = (0, _AppContext.useAppContext)();
    // 优先使用上下文中的配置，如果没有则使用外部传入的配置
    const finalConfigProps = antdConfig || externalConfigProps;
    // 合并主题配置到 Ant Design 配置
    const mergedConfigProps = _react.default.useMemo(()=>{
        if (!finalConfigProps && !theme.primaryColor) {
            return undefined;
        }
        return {
            ...finalConfigProps,
            theme: {
                ...finalConfigProps?.theme,
                token: {
                    ...finalConfigProps?.theme?.token,
                    ...theme.primaryColor ? {
                        colorPrimary: theme.primaryColor
                    } : {}
                },
                algorithm: finalConfigProps?.theme?.algorithm
            }
        };
    }, [
        finalConfigProps,
        theme.primaryColor
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_antd.ConfigProvider, {
        ...mergedConfigProps,
        children: children
    });
});
BasicLayout.displayName = 'BasicLayout';

//# sourceMappingURL=BasicLayout.js.map