"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > 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__, {
    useStorageState: ()=>useStorageState
});
const external_react_namespaceObject = require("react");
const Storage_cjs_namespaceObject = require("../utils/Storage.cjs");
const useStorageState = (key, initialValue, storageType = 'localStorage', prefix = 'ui')=>{
    const getValue = (0, external_react_namespaceObject.useCallback)(()=>{
        const storedValue = (0, Storage_cjs_namespaceObject.getStoredValue)(key, storageType, prefix);
        const result = void 0 !== storedValue ? storedValue : initialValue;
        return result;
    }, [
        initialValue,
        key,
        storageType,
        prefix
    ]);
    const [value, setValue] = (0, external_react_namespaceObject.useState)(getValue);
    const isInitialMount = (0, external_react_namespaceObject.useRef)(true);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (isInitialMount.current) {
            isInitialMount.current = false;
            return;
        }
        (0, Storage_cjs_namespaceObject.setStoredValue)(key, value, storageType, prefix);
    }, [
        value,
        key,
        storageType,
        prefix
    ]);
    const setStoredValueCallback = (0, external_react_namespaceObject.useCallback)((newValue)=>{
        setValue((prevValue)=>{
            const valueToStore = newValue instanceof Function ? newValue(prevValue) : newValue;
            (0, Storage_cjs_namespaceObject.setStoredValue)(key, valueToStore, storageType, prefix);
            return valueToStore;
        });
    }, [
        key,
        storageType,
        prefix
    ]);
    return [
        value,
        setStoredValueCallback
    ];
};
exports.useStorageState = __webpack_exports__.useStorageState;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useStorageState"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
