import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { memo, forwardRef } from 'react';
import { FastField } from 'formik';
import { noop } from '@bigbinary/neeto-cist';
import { path, pluck } from 'ramda';
import Editor from './Editor.js';
import { jsx } from 'react/jsx-runtime';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';
import './chunk-bVrG7VPz.js';
import './chunk-DmrvuTKK.js';
import 'i18next';
import '@bigbinary/neeto-icons/TextH1';
import '@bigbinary/neeto-icons/TextH2';
import '@bigbinary/neeto-icons/TextH3';
import '@bigbinary/neeto-icons/TextH4';
import '@bigbinary/neeto-icons/TextH5';
import '@bigbinary/neeto-icons/TextP';
import './chunk-Bu-cg5p1.js';
import './chunk-Dg3CF2Q2.js';
import './chunk-DmB-qAHJ.js';
import 'yup';
import 'tippy.js';
import 'react-dom';
import 'classnames';
import 'tippy.js/dist/svg-arrow.css';
import '@bigbinary/neeto-icons/Link';
import '@bigbinary/neeto-icons/Column';
import '@bigbinary/neeto-icons/Down';
import '@bigbinary/neetoui/Dropdown';
import 'react-i18next';
import '@bigbinary/neeto-icons/Close';
import '@bigbinary/neetoui/Button';
import '@bigbinary/neeto-commons-frontend/utils';
import '@bigbinary/neeto-icons/Check';
import '@bigbinary/neetoui/Label';
import '@bigbinary/neeto-icons/Quote';
import '@bigbinary/neeto-icons/Attachment';
import '@bigbinary/neeto-icons/CodeBlock';
import '@bigbinary/neeto-icons/Code';
import '@bigbinary/neeto-icons/Highlight';
import '@bigbinary/neeto-icons/TextBold';
import '@bigbinary/neeto-icons/TextCross';
import '@bigbinary/neeto-icons/TextItalic';
import '@bigbinary/neeto-icons/Underline';
import '@bigbinary/neeto-icons/ListDot';
import '@bigbinary/neeto-icons/ListNumber';
import '@bigbinary/neeto-icons/ImageUpload';
import '@bigbinary/neeto-icons/Video';
import '@bigbinary/neeto-icons/Undo';
import '@bigbinary/neeto-icons/Redo';
import '@bigbinary/neeto-icons/Email';
import '@bigbinary/neetoui/Avatar';
import '@bigbinary/neetoui/Typography';
import '@bigbinary/neeto-icons/Smiley';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/possibleConstructorReturn';
import '@babel/runtime/helpers/getPrototypeOf';
import '@babel/runtime/helpers/inherits';
import '@babel/runtime/regenerator';
import 'emoji-mart';
import 'axios';
import '@bigbinary/neeto-commons-frontend/react-utils';
import '@bigbinary/neeto-icons/Customize';
import '@bigbinary/neeto-icons/Refresh';
import '@bigbinary/neetoui/Input';
import 'react-colorful';
import '@bigbinary/neeto-molecules/DynamicVariables';
import '@bigbinary/neeto-image-uploader-frontend';
import '@bigbinary/neetoui/Modal';
import '@bigbinary/neetoui/Tab';
import './chunk-BBnDX9fA.js';
import 'zustand/shallow';
import '@bigbinary/neetoui/Toastr';
import 'zustand';
import './chunk-E-ZsRS8r.js';
import '@bigbinary/neeto-icons/LeftAlign';
import '@bigbinary/neeto-icons/CenterAlign';
import '@bigbinary/neeto-icons/RightAlign';
import '@bigbinary/neeto-icons/Delete';
import '@bigbinary/neeto-commons-frontend/initializers';
import '@bigbinary/neetoui/Tooltip';
import '@bigbinary/neetoui/formik/Form';
import '@bigbinary/neetoui/formik/Input';
import '@bigbinary/neetoui/formik/ActionBlock';
import '@bigbinary/neetoui/Checkbox';
import '@bigbinary/neeto-icons/Checkbox';
import '@bigbinary/neeto-icons/Flag';
import '@bigbinary/neeto-icons/misc/Info';
import '@bigbinary/neeto-icons/misc/Warning';
import '@bigbinary/neeto-icons/misc/Danger';
import '@bigbinary/neeto-icons/misc/Megaphone';
import '@bigbinary/neeto-icons/misc/Success';
import '@bigbinary/neeto-icons/MenuHorizontal';
import '@tippyjs/react';
import '@bigbinary/neeto-icons/File';
import 'react-dom/server';
import './chunk-BCoBS5ED.js';
import 'yjs';
import '@bigbinary/neeto-molecules/CopyToClipboardButton';
import '@bigbinary/neetoui/Spinner';
import '@bigbinary/neeto-icons/Blockquote';
import '@bigbinary/neeto-icons/Minus';
import '@bigbinary/neeto-icons/Notes';
import '@bigbinary/neeto-icons/MessageSquare';
import '@bigbinary/neeto-icons/DeleteRow';
import '@bigbinary/neeto-icons/DeleteColumn';
import '@bigbinary/neeto-icons/DeleteTable';
import '@bigbinary/neeto-icons/InsertRow';
import '@bigbinary/neeto-icons/InsertColumn';
import '@bigbinary/neeto-icons/MergeSplit';
import '@bigbinary/neeto-icons/ToggleHeaderRow';
import './chunk-CBb1JIyY.js';
import '@bigbinary/neeto-icons/MenuVertical';
import '@bigbinary/neetoui/Alert';

var _excluded = ["name", "onChange", "shouldUpdate", "attachments", "mentions", "variables"];
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), !0).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 FormikEditor = function FormikEditor(_ref, ref) {
  var name = _ref.name,
    _ref$onChange = _ref.onChange,
    _onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
    shouldUpdate = _ref.shouldUpdate,
    _ref$attachments = _ref.attachments,
    attachments = _ref$attachments === void 0 ? [] : _ref$attachments,
    _ref$mentions = _ref.mentions,
    mentions = _ref$mentions === void 0 ? [] : _ref$mentions,
    _ref$variables = _ref.variables,
    variables = _ref$variables === void 0 ? [] : _ref$variables,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  // Similar to the `shouldComponentUpdate` logic of FastField component.
  // https://github.com/jaredpalmer/formik/blob/main/packages/formik/src/FastField.tsx#L75-L93
  // Additionally calls the shouldUpdate function passed from the host application and compares to
  // the rest of the values.
  var internalShouldUpdate = function internalShouldUpdate(prevProps, nextProps) {
    var prevFormikProps = prevProps.formik;
    var nextFormikProps = nextProps.formik;
    var pathParts = name.split(".");
    var prevError = path(pathParts, prevFormikProps.errors);
    var nextError = path(pathParts, nextFormikProps.errors);
    var prevTouched = path(pathParts, prevFormikProps.touched);
    var nextTouched = path(pathParts, nextFormikProps.touched);
    var prevAttachments = pluck("signedId", prevProps.attachments).join("|");
    var nextAttachments = pluck("signedId", nextProps.attachments).join("|");
    return prevError !== nextError || prevTouched !== nextTouched || Object.keys(nextProps).length !== Object.keys(prevProps).length || prevFormikProps.isSubmitting !== nextFormikProps.isSubmitting || prevAttachments !== nextAttachments || Boolean(shouldUpdate === null || shouldUpdate === void 0 ? void 0 : shouldUpdate(prevProps, nextProps));
  };
  return /*#__PURE__*/jsx(FastField, {
    attachments: attachments,
    mentions: mentions,
    name: name,
    variables: variables,
    shouldUpdate: internalShouldUpdate,
    children: function children(_ref2) {
      var field = _ref2.field,
        form = _ref2.form,
        meta = _ref2.meta;
      return /*#__PURE__*/jsx(Editor, _objectSpread({
        attachments: attachments,
        mentions: mentions,
        name: name,
        ref: ref,
        variables: variables,
        error: meta.touched ? meta.error : "",
        initialValue: field.value,
        onBlur: function onBlur() {
          form.setFieldTouched(name, true);
        },
        onChange: function onChange(value) {
          form.setFieldValue(name, value);
          _onChange === null || _onChange === void 0 || _onChange(value);
        }
      }, otherProps));
    }
  });
};
FormikEditor.displayName = "FormikNeetoEditor";
var FormikEditor$1 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(FormikEditor));

export { FormikEditor$1 as default };
//# sourceMappingURL=FormikEditor.js.map
