"use strict";
const React = require("react");
const context = require("./context.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var FormProviderComponent = function(props, _) {
  var formsRef = React.useRef({});
  var register = React.useCallback(function(name, form) {
    if (name) {
      formsRef.current[name] = form;
    }
    return function() {
      delete formsRef.current[name];
    };
  }, []);
  var onFormSubmit = React.useCallback(function(name, changedValues) {
    props.onFormSubmit && props.onFormSubmit(name, changedValues, {
      forms: formsRef.current
    });
  }, [props.onFormSubmit]);
  var onFormValuesChange = React.useCallback(function(name, values) {
    props.onFormValuesChange && props.onFormValuesChange(name, values, {
      forms: formsRef.current
    });
  }, [props.onFormValuesChange]);
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(context.FormProviderContext.Provider, {
    value: {
      onFormValuesChange,
      onFormSubmit,
      register
    },
    children: props.children
  });
};
var FormProvider = React.forwardRef(FormProviderComponent);
FormProvider.displayName = "FormProvider";
const FormProvider$1 = FormProvider;
module.exports = FormProvider$1;
//# sourceMappingURL=form-provider.js.map
