"use strict";
var __webpack_modules__ = {
    "./AntdAppProvider": function(module) {
        module.exports = require("./AntdAppProvider.js");
    },
    "./defaultTheme": function(module) {
        module.exports = require("./defaultTheme.js");
    },
    "./type": function(module) {
        module.exports = require("./type.js");
    },
    antd: function(module) {
        module.exports = require("antd");
    },
    lodash: function(module) {
        module.exports = require("lodash");
    },
    react: function(module) {
        module.exports = require("react");
    },
    "react/jsx-runtime": function(module) {
        module.exports = require("react/jsx-runtime");
    }
};
var __webpack_module_cache__ = {};
function __webpack_require__(moduleId) {
    var cachedModule = __webpack_module_cache__[moduleId];
    if (void 0 !== cachedModule) return cachedModule.exports;
    var module = __webpack_module_cache__[moduleId] = {
        exports: {}
    };
    __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
    return module.exports;
}
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AntdAppProvider: function() {
        return _AntdAppProvider__WEBPACK_IMPORTED_MODULE_5___default.a;
    },
    GlobalThemeProvider: function() {
        return GlobalThemeProvider;
    },
    defaultTheme: function() {
        return _defaultTheme__WEBPACK_IMPORTED_MODULE_4___default.a;
    },
    useGlobalTheme: function() {
        return useGlobalTheme;
    }
});
var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react/jsx-runtime");
var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("react");
var antd__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("antd");
var lodash__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("lodash");
var lodash__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_3__);
var _defaultTheme__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./defaultTheme");
var _defaultTheme__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/ __webpack_require__.n(_defaultTheme__WEBPACK_IMPORTED_MODULE_4__);
var _AntdAppProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./AntdAppProvider");
var _AntdAppProvider__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(_AntdAppProvider__WEBPACK_IMPORTED_MODULE_5__);
var _type__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./type");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _type__WEBPACK_IMPORTED_MODULE_6__)if ([
    "defaultTheme",
    "default",
    "AntdAppProvider",
    "useGlobalTheme",
    "GlobalThemeProvider"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
    return _type__WEBPACK_IMPORTED_MODULE_6__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
const GlobalThemeContext = /*#__PURE__*/ (0, react__WEBPACK_IMPORTED_MODULE_1__.createContext)(null);
GlobalThemeContext.displayName = 'GlobalThemeContext';
const useGlobalTheme = ()=>(0, react__WEBPACK_IMPORTED_MODULE_1__.useContext)(GlobalThemeContext) || {
        theme: {},
        isDarkTheme: false
    };
const GlobalThemeProvider = (param)=>{
    let { children, theme: themeFromProps } = param;
    const [theme, setTheme] = (0, react__WEBPACK_IMPORTED_MODULE_1__.useState)(themeFromProps || _defaultTheme__WEBPACK_IMPORTED_MODULE_4___default());
    const currentSettingThemeRef = (0, react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
    const currentEditingThemeRef = (0, react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
    const isDarkTheme = (0, react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(()=>{
        const algorithm = null == theme ? void 0 : theme.algorithm;
        if (Array.isArray(algorithm)) return algorithm.includes(antd__WEBPACK_IMPORTED_MODULE_2__.theme.darkAlgorithm);
        return algorithm === antd__WEBPACK_IMPORTED_MODULE_2__.theme.darkAlgorithm;
    }, [
        null == theme ? void 0 : theme.algorithm
    ]);
    const setCurrentEditingTheme = (0, react__WEBPACK_IMPORTED_MODULE_1__.useCallback)((themeItem)=>{
        currentEditingThemeRef.current = themeItem ? lodash__WEBPACK_IMPORTED_MODULE_3___default().cloneDeep(themeItem) : themeItem;
    }, []);
    const getCurrentEditingTheme = (0, react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(()=>currentEditingThemeRef.current, []);
    const setCurrentSettingTheme = (0, react__WEBPACK_IMPORTED_MODULE_1__.useCallback)((theme)=>{
        currentSettingThemeRef.current = theme ? lodash__WEBPACK_IMPORTED_MODULE_3___default().cloneDeep(theme) : theme;
    }, []);
    const getCurrentSettingTheme = (0, react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(()=>currentSettingThemeRef.current, []);
    const value = (0, react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(()=>({
            theme,
            setTheme,
            setCurrentSettingTheme,
            getCurrentSettingTheme,
            setCurrentEditingTheme,
            getCurrentEditingTheme,
            isDarkTheme
        }), [
        getCurrentEditingTheme,
        getCurrentSettingTheme,
        isDarkTheme,
        setCurrentEditingTheme,
        setCurrentSettingTheme,
        theme
    ]);
    return /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(GlobalThemeContext.Provider, {
        value: value,
        children: /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(antd__WEBPACK_IMPORTED_MODULE_2__.ConfigProvider, {
            theme: _defaultTheme__WEBPACK_IMPORTED_MODULE_4___default(),
            children: /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(antd__WEBPACK_IMPORTED_MODULE_2__.ConfigProvider, {
                theme: theme,
                children: children
            })
        })
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
