'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var formik = require('formik');
var utils = require('../utils-BhM0B89p.js');
var formik_Button = require('./Button.js');
var Button = require('../Button-BlNtYr1w.js');
require('ramda');
require('react-router-dom');
require('../renderIcon-BRrpZu9a.js');
require('../primitives/Button.js');
require('../button-CMl9rLXi.js');
require('../index-vioSzJOw.js');
require('../index-DuNgWCXZ.js');
require('../index-D-iDn9RI.js');
require('../primitives/Spinner.js');
require('react-i18next');
require('../loader-circle-Bw7zP2Gn.js');
require('../createLucideIcon-D0tRgV6l.js');
require('../primitives/Tooltip.js');
require('../tooltip-BYCcUMZn.js');
require('../index-COPkC3I5.js');
require('../index-CGUGhyIp.js');
require('../index-Bvu9MiFi.js');
require('../index-DMbj7vXd.js');
require('react-dom');
require('../index-lWVw05cs.js');
require('../index-BwAq9ba8.js');
require('../index-CCdG4z4E.js');
require('../index-C9ICrOhM.js');
require('../floating-ui.react-dom-B4Aw6O7R.js');
require('../index-Bf0WsHta.js');
require('../index-Df-Ffa3s.js');
require('../index-DcCSSgb7.js');
require('../index-CyrAgb4H.js');
require('../index-CB9xFokC.js');

const FormikActionBlock = React.forwardRef(
  ({
    className,
    submitButtonProps,
    cancelButtonProps,
    isSubmitting: isSubmittingProp,
    position = "left"
  }, ref) => {
    const { handleReset, isSubmitting: isFormikSubmitting } = formik.useFormikContext();
    const isSubmitting = isSubmittingProp ?? isFormikSubmitting;
    const cancelButton = /* @__PURE__ */ jsxRuntime.jsx(
      Button.Button,
      {
        "data-testid": "cancel-button",
        disabled: isSubmitting,
        label: "Cancel",
        variant: "ghost",
        onClick: handleReset,
        onMouseDown: (e) => e.preventDefault(),
        ...cancelButtonProps
      }
    );
    const submitButton = /* @__PURE__ */ jsxRuntime.jsx(
      formik_Button.FormikButton,
      {
        "data-testid": "save-changes-button",
        label: "Save changes",
        type: "submit",
        ...submitButtonProps
      }
    );
    return /* @__PURE__ */ jsxRuntime.jsx(
      "div",
      {
        ref,
        className: utils.cn(
          "flex items-center gap-2",
          position === "right" && "justify-end",
          className
        ),
        children: position === "right" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
          cancelButton,
          submitButton
        ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
          submitButton,
          cancelButton
        ] })
      }
    );
  }
);
FormikActionBlock.displayName = "FormikActionBlock";

exports.FormikActionBlock = FormikActionBlock;
//# sourceMappingURL=ActionBlock.js.map
