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 '@bigbinary/neeto-atoms';
import '../chunk-ChNzXvhJ.js';
import 'axios';
import '../chunk-C5svTfyQ.js';
import 'react-dom';
import '@bigbinary/neeto-commons-frontend/react-utils';
import 'zustand';
import 'classnames';
import '@bigbinary/neeto-commons-frontend/v2/react-utils';
import '../chunk-Be5ikGpm.js';
import '../chunk-Qg4uQqj3.js';
import '../chunk-BFTU3MAI.js';
import '@bigbinary/neeto-commons-frontend/initializers';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import '@tanstack/react-query';
import 'yjs';
import '../chunk-DDwycKmK.js';
import '../chunk-CF5f8-fy.js';
import 'i18next';
import 'yup';
import 'react-dom/server';
import '../chunk-COgPAsPy.js';
import 'lucide-react';
import '@bigbinary/neeto-atoms/primitives/Popover';
import 'react-i18next';
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 'emoji-mart';
import '@bigbinary/neeto-commons-frontend/v2/utils';
import 'react-colorful';
import '@bigbinary/neeto-image-uploader-frontend/v2/ImageUploader';
import '../chunk-BFKmIsWV.js';
import '../chunk-KiXJWA8i.js';
import 'zustand/shallow';
import '@bigbinary/neeto-commons-frontend/v2/initializers';
import '@bigbinary/neeto-icons/LeftAlign';
import '@bigbinary/neeto-icons/CenterAlign';
import '@bigbinary/neeto-icons/RightAlign';
import '@bigbinary/neeto-icons/Delete';
import '@bigbinary/neeto-icons/CustomSize';
import '@bigbinary/neeto-icons/BorderDisable';
import '@bigbinary/neeto-icons/BorderEnable';
import '@bigbinary/neeto-icons/AspectRatio11';
import '@bigbinary/neeto-icons/AspectRatio169';
import '@bigbinary/neeto-icons/AspectRatio916';
import '@bigbinary/neeto-icons/AspectRatio43';
import '@bigbinary/neeto-icons/AspectRatio32';
import '@bigbinary/neeto-atoms/formik';
import '@bigbinary/neeto-molecules/v2/DynamicVariables';
import '@tippyjs/react';
import '@bigbinary/neeto-icons/misc/Megaphone';
import '@bigbinary/neeto-molecules/v2/CopyToClipboardButton';
import 'tippy.js';
import '@bigbinary/neeto-icons/TextP';
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/ListDot';
import '@bigbinary/neeto-icons/ListNumber';
import '@bigbinary/neeto-icons/Checkbox';
import '@bigbinary/neeto-icons/Blockquote';
import '@bigbinary/neeto-icons/ImageUpload';
import '@bigbinary/neeto-icons/CodeBlock';
import '@bigbinary/neeto-icons/Smiley';
import '@bigbinary/neeto-icons/Minus';
import '@bigbinary/neeto-icons/Video';
import '@bigbinary/neeto-icons/Notes';
import '@bigbinary/neeto-icons/Column';
import '@bigbinary/neeto-icons/TextBold';
import '@bigbinary/neeto-icons/TextItalic';
import '@bigbinary/neeto-icons/Underline';
import '@bigbinary/neeto-icons/Link';
import '@bigbinary/neeto-icons/Attachment';
import '@bigbinary/neeto-icons/MessageSquare';
import '@bigbinary/neeto-icons/File';
import '@babel/runtime/helpers/typeof';
import '@bigbinary/neeto-molecules/v2/Search';
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--BjpQHaY.js';
import '@bigbinary/neeto-commons-frontend/v2/react-utils/useOnClickOutside';

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), 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 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);
  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_default = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(FormikEditor));

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