"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useObjectState = void 0;
const react_1 = require("react");
const hash_1 = require("@saulx/hash");
const utils_1 = require("@saulx/utils");
const useObjectState = (initialObject) => {
    const ref = (0, react_1.useRef)(initialObject ?? {});
    const [, setHash] = (0, react_1.useState)(initialObject ? (0, react_1.useMemo)(() => (0, hash_1.hash)(initialObject), []) : null);
    const update = (0, react_1.useCallback)((value) => {
        (0, utils_1.deepMerge)(ref.current, value);
        setHash((0, hash_1.hash)(ref.current));
    }, []);
    return [ref.current, update];
};
exports.useObjectState = useObjectState;
//# sourceMappingURL=useObjectState.js.map