import { useCallback as h, useEffect as p, useState as V } from "react";
import { u as x } from "./FormClearHelper-7XVCWEDh.js";
import { m as C } from "./index-CsBCemCF.js";
function U({
  getStateFromWidgetMgr: n,
  getDefaultState: a,
  updateWidgetMgrState: o,
  element: s,
  widgetMgr: u,
  fragmentId: l,
  onFormCleared: f
}) {
  const [i, e] = V(() => n(u, s) ?? a(u, s)), [c, r] = V({
    value: i,
    fromUi: !1
  });
  p(() => {
    C(c) || (r(null), e(c.value), o(s, u, c, l));
  }, [c, o, s, u, l]);
  const t = h(() => {
    r({
      value: a(u, s),
      fromUi: !0
    }), f?.();
  }, [r, s, a, u, f]);
  return x({
    widgetMgr: u,
    element: s,
    onFormCleared: t
  }), [i, r];
}
function S({
  getStateFromWidgetMgr: n,
  getDefaultStateFromProto: a,
  getCurrStateFromProto: o,
  updateWidgetMgrState: s,
  element: u,
  widgetMgr: l,
  fragmentId: f,
  onFormCleared: i
}) {
  const e = h((t, v) => a(v), [a]), [c, r] = U({
    getStateFromWidgetMgr: n,
    getDefaultState: e,
    updateWidgetMgrState: s,
    element: u,
    widgetMgr: l,
    fragmentId: f,
    onFormCleared: i
  });
  return p(() => {
    u.setValue && (u.setValue = !1, r({
      value: o(u),
      fromUi: !1
    }));
  }, [u, o, r]), [c, r];
}
export {
  U as a,
  S as u
};
//# sourceMappingURL=useBasicWidgetState-KOlq_goV.js.map
