/**
 * amis-ui v6.12.0-beta.0
 * Copyright 2018-2025 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var isFunction = require('lodash/isFunction');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

var useSetState = function (initialState) {
    if (initialState === void 0) { initialState = {}; }
    var _a = tslib.__read(React.useState(initialState), 2), state = _a[0], setState = _a[1];
    var setMergeState = React.useCallback(function (patch) {
        setState(function (prevState) { return (tslib.__assign(tslib.__assign({}, prevState), (isFunction__default["default"](patch) ? patch(prevState) : patch))); });
    }, []);
    return [state, setMergeState];
};

exports["default"] = useSetState;
