'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var formik = require('formik');
var neetoCist = require('@bigbinary/neeto-cist');
var ramda = require('ramda');
var v2_Editor = require('./Editor.cjs.js');
var jsxRuntime = require('react/jsx-runtime');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/slicedToArray');
require('@bigbinary/neeto-atoms');
require('../chunk-Cv0ocaVh.cjs.js');
require('../chunk-eyfbjfPH.cjs.js');
require('tippy.js');
require('react-dom');
require('axios');
require('@bigbinary/neeto-commons-frontend/react-utils');
require('zustand');
require('classnames');
require('@bigbinary/neeto-commons-frontend/v2/react-utils');
require('../chunk-DOxH3Agq.cjs.js');
require('../chunk-De3nCFAF.cjs.js');
require('../chunk-BJu3ubxk.cjs.js');
require('@bigbinary/neeto-commons-frontend/initializers');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('@tanstack/react-query');
require('yjs');
require('../chunk-2HrSPdAV.cjs.js');
require('../chunk-BGy3NmZC.cjs.js');
require('i18next');
require('yup');
require('react-dom/server');
require('../chunk-BzPTK6pP.cjs.js');
require('lucide-react');
require('tippy.js/dist/svg-arrow.css');
require('@bigbinary/neeto-atoms/primitives/Popover');
require('react-i18next');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@babel/runtime/helpers/possibleConstructorReturn');
require('@babel/runtime/helpers/getPrototypeOf');
require('@babel/runtime/helpers/inherits');
require('emoji-mart');
require('@bigbinary/neeto-commons-frontend/v2/utils');
require('react-colorful');
require('@bigbinary/neeto-image-uploader-frontend/v2/ImageUploader');
require('../chunk-D3Unocnm.cjs.js');
require('../chunk-CDAiAyof.cjs.js');
require('zustand/shallow');
require('@bigbinary/neeto-commons-frontend/v2/initializers');
require('@bigbinary/neeto-icons/LeftAlign');
require('@bigbinary/neeto-icons/CenterAlign');
require('@bigbinary/neeto-icons/RightAlign');
require('@bigbinary/neeto-icons/Delete');
require('@bigbinary/neeto-icons/CustomSize');
require('@bigbinary/neeto-icons/BorderDisable');
require('@bigbinary/neeto-icons/BorderEnable');
require('@bigbinary/neeto-icons/AspectRatio11');
require('@bigbinary/neeto-icons/AspectRatio169');
require('@bigbinary/neeto-icons/AspectRatio916');
require('@bigbinary/neeto-icons/AspectRatio43');
require('@bigbinary/neeto-icons/AspectRatio32');
require('@bigbinary/neeto-atoms/formik');
require('@bigbinary/neeto-molecules/DynamicVariables');
require('@tippyjs/react');
require('@bigbinary/neeto-icons/misc/Megaphone');
require('@bigbinary/neeto-molecules/v2/CopyToClipboardButton');
require('@bigbinary/neeto-icons/TextP');
require('@bigbinary/neeto-icons/TextH1');
require('@bigbinary/neeto-icons/TextH2');
require('@bigbinary/neeto-icons/TextH3');
require('@bigbinary/neeto-icons/TextH4');
require('@bigbinary/neeto-icons/TextH5');
require('@bigbinary/neeto-icons/ListDot');
require('@bigbinary/neeto-icons/ListNumber');
require('@bigbinary/neeto-icons/Checkbox');
require('@bigbinary/neeto-icons/Blockquote');
require('@bigbinary/neeto-icons/ImageUpload');
require('@bigbinary/neeto-icons/CodeBlock');
require('@bigbinary/neeto-icons/Smiley');
require('@bigbinary/neeto-icons/Minus');
require('@bigbinary/neeto-icons/Video');
require('@bigbinary/neeto-icons/Notes');
require('@bigbinary/neeto-icons/Column');
require('@bigbinary/neeto-icons/TextBold');
require('@bigbinary/neeto-icons/TextItalic');
require('@bigbinary/neeto-icons/Underline');
require('@bigbinary/neeto-icons/Link');
require('@bigbinary/neeto-icons/Attachment');
require('@bigbinary/neeto-icons/MessageSquare');
require('@bigbinary/neeto-icons/File');
require('@babel/runtime/helpers/typeof');
require('@bigbinary/neeto-molecules/v2/Search');
require('@bigbinary/neeto-icons/DeleteRow');
require('@bigbinary/neeto-icons/DeleteColumn');
require('@bigbinary/neeto-icons/DeleteTable');
require('@bigbinary/neeto-icons/InsertRow');
require('@bigbinary/neeto-icons/InsertColumn');
require('@bigbinary/neeto-icons/MergeSplit');
require('@bigbinary/neeto-icons/ToggleHeaderRow');
require('../chunk-Cvxaj__T.cjs.js');
require('@bigbinary/neeto-commons-frontend/v2/react-utils/useOnClickOutside');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

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__default.default(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 ? neetoCist.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__default.default(_ref, _excluded);
  var internalShouldUpdate = function internalShouldUpdate(prevProps, nextProps) {
    var prevFormikProps = prevProps.formik;
    var nextFormikProps = nextProps.formik;
    var pathParts = name.split(".");
    var prevError = ramda.path(pathParts, prevFormikProps.errors);
    var nextError = ramda.path(pathParts, nextFormikProps.errors);
    var prevTouched = ramda.path(pathParts, prevFormikProps.touched);
    var nextTouched = ramda.path(pathParts, nextFormikProps.touched);
    var prevAttachments = ramda.pluck("signedId", prevProps.attachments).join("|");
    var nextAttachments = ramda.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__*/jsxRuntime.jsx(formik.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__*/jsxRuntime.jsx(v2_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__*/React.memo(/*#__PURE__*/React.forwardRef(FormikEditor));

module.exports = FormikEditor_default;
//# sourceMappingURL=FormikEditor.cjs.js.map
