"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _immer = _interopRequireDefault(require("immer"));

var _lodash = require("lodash");

var autocomplete = _interopRequireWildcard(require("./autocomplete"));

var formGroupList = _interopRequireWildcard(require("./formGroupList"));

var showCharacterCounter = _interopRequireWildcard(require("./showCharacterCounter"));

var selectAutocomplete = _interopRequireWildcard(require("./selectAutocomplete"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

// Order of plugins
var typePlugins = [autocomplete, selectAutocomplete, showCharacterCounter, formGroupList];

var _default = function _default(props) {
  var _props$extraTypePlugi = props.extraTypePlugins,
      extraTypePlugins = _props$extraTypePlugi === void 0 ? [] : _props$extraTypePlugi,
      config = props.config; // Run plugins in the given order

  return (0, _lodash.flow)([].concat(typePlugins, (0, _toConsumableArray2["default"])(extraTypePlugins)) // Plugin type must match with the config type
  .filter(function (_ref) {
    var types = _ref.types;
    return types.includes(config.type);
  }).map(function (_ref2) {
    var _ref3, _props;

    var converter = _ref2.converter;
    return _ref3 = (_props = props, converter(_props)), (0, _immer["default"])(_ref3);
  }));
};

exports["default"] = _default;
//# sourceMappingURL=index.cjs.map