import _defineProperty from '@babel/runtime/helpers/defineProperty';
import 'react';
import classnames from 'classnames';
import { useFormikContext } from 'formik';
import { useTranslation } from 'react-i18next';
import Button from '../Button.js';
import { a as getLocale } from '../index-QWVp_Xt6.js';
import FormikButton from './Button.js';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'react-router-dom';
import '../Spinner.js';
import '../Tooltip.js';
import '@babel/runtime/helpers/slicedToArray';
import '@tippyjs/react';
import 'tippy.js';
import '@bigbinary/neeto-hotkeys';
import '../overlayManager.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'qs';
import 'ramda';
import '../index-DyUNP5G9.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'i18next';
import '../usePrefersReducedMotion-n4ZJtExQ.js';
import '../en-Dmu3B4Vs.js';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var POSITIONS = {
  left: "left",
  right: "right"
};
var ActionBlock = function ActionBlock(_ref) {
  var className = _ref.className,
    submitButtonProps = _ref.submitButtonProps,
    cancelButtonProps = _ref.cancelButtonProps,
    isFormSubmitting = _ref.isSubmitting,
    _ref$position = _ref.position,
    position = _ref$position === void 0 ? POSITIONS.left : _ref$position;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t,
    i18n = _useTranslation.i18n;
  var _useFormikContext = useFormikContext(),
    handleReset = _useFormikContext.handleReset,
    isFormikSubmitting = _useFormikContext.isSubmitting,
    dirty = _useFormikContext.dirty;
  var isSubmitting = isFormSubmitting !== null && isFormSubmitting !== void 0 ? isFormSubmitting : isFormikSubmitting;
  var isButtonPositionRight = position === POSITIONS.right;
  var cancelButton = /*#__PURE__*/jsx(Button, _objectSpread({
    "data-testid": "cancel-button",
    disabled: isSubmitting,
    label: getLocale(i18n, t, "neetoui.actionBlock.cancel"),
    style: "text",
    onClick: handleReset,
    onMouseDown: function onMouseDown(e) {
      return e.preventDefault();
    }
  }, cancelButtonProps));
  var submitButton = /*#__PURE__*/jsx(FormikButton, _objectSpread({
    "data-testid": "save-changes-button",
    disabled: isSubmitting || !dirty,
    label: getLocale(i18n, t, "neetoui.actionBlock.saveChanges"),
    loading: isSubmitting,
    style: "primary",
    type: "submit"
  }, submitButtonProps));
  return /*#__PURE__*/jsx("div", {
    className: classnames(["neeto-ui-action-block__wrapper", {
      "justify-end": isButtonPositionRight
    }, className]),
    children: isButtonPositionRight ? /*#__PURE__*/jsxs(Fragment, {
      children: [cancelButton, submitButton]
    }) : /*#__PURE__*/jsxs(Fragment, {
      children: [submitButton, cancelButton]
    })
  });
};

export { ActionBlock as default };
//# sourceMappingURL=ActionBlock.js.map
