import { __spreadArray as y, __read as N } from "../../../tslib/tslib.es6.mjs";
import { useMemo as _, useRef as C } from "react";
import { isFunction as b } from "../utils/index.mjs";
import w from "../useMemoizedFn/index.mjs";
import F from "../useUpdate/index.mjs";
function A(e, r) {
  e === void 0 && (e = {}), r === void 0 && (r = {});
  var V = r.defaultValue, f = r.defaultValuePropName, n = f === void 0 ? "defaultValue" : f, i = r.valuePropName, m = i === void 0 ? "value" : i, d = r.trigger, o = d === void 0 ? "onChange" : d, v = e[m], t = e.hasOwnProperty(m), P = _(function() {
    return t ? v : e.hasOwnProperty(n) ? e[n] : V;
  }, []), a = C(P);
  t && (a.current = v);
  var h = F();
  function s(l) {
    for (var c = [], u = 1; u < arguments.length; u++)
      c[u - 1] = arguments[u];
    var g = b(l) ? l(a.current) : l;
    t || (a.current = g, h()), e[o] && e[o].apply(e, y([g], N(c), !1));
  }
  return [a.current, w(s)];
}
export {
  A as default
};
