"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _slateReact = require("slate-react");
var ElementType = _interopRequireWildcard(require("../constants/element-types"));
var _plugins = require("../plugins");
const SlateElement = _ref => {
  let {
    element,
    options,
    ...params
  } = _ref;
  const option = options ? options[element.type] : null;
  const props = {
    ...params,
    option,
    element
  };
  const editor = (0, _slateReact.useSlateStatic)();
  switch (element.type) {
    case ElementType.BLOCKQUOTE:
      {
        const [renderBlockquote] = _plugins.BlockquotePlugin.renderElements;
        return renderBlockquote(props);
      }
    case ElementType.HEADER1:
    case ElementType.HEADER2:
    case ElementType.HEADER3:
    case ElementType.HEADER4:
    case ElementType.HEADER5:
    case ElementType.HEADER6:
      {
        const [renderHeader] = _plugins.HeaderPlugin.renderElements;
        return renderHeader(props, editor);
      }
    case ElementType.IMAGE:
      {
        const [renderImage] = _plugins.ImagePlugin.renderElements;
        return renderImage(props, editor);
      }
    case ElementType.LINK:
      {
        const [renderLink] = _plugins.LinkPlugin.renderElements;
        return renderLink(props, editor);
      }
    case ElementType.LINK_REFERENCE:
      {
        const [renderLinkReferencePlugin] = _plugins.LinkReferencePlugin.renderElements;
        return renderLinkReferencePlugin(props, editor);
      }
    case ElementType.DEFINITION:
      {
        const [renderDefinition] = _plugins.DefinitionPlugin.renderElements;
        return renderDefinition(props, editor);
      }
    case ElementType.CODE_BLOCK:
      {
        const [renderCodeBlock] = _plugins.CodeBlockPlugin.renderElements;
        return renderCodeBlock(props, editor);
      }
    case ElementType.CODE_LINE:
      {
        const [, renderCodeLine] = _plugins.CodeBlockPlugin.renderElements;
        return renderCodeLine(props, editor);
      }
    case ElementType.CHECK_LIST_ITEM:
      {
        const [renderCheckListItem] = _plugins.CheckListPlugin.renderElements;
        return renderCheckListItem(props, editor);
      }
    case ElementType.ORDERED_LIST:
    case ElementType.UNORDERED_LIST:
      {
        const [renderList] = _plugins.ListPlugin.renderElements;
        return renderList(props, editor);
      }
    case ElementType.LIST_ITEM:
      {
        const [, renderListItem] = _plugins.ListPlugin.renderElements;
        return renderListItem(props, editor);
      }
    case ElementType.TABLE_CELL:
      {
        const [renderTableCell] = _plugins.TablePlugin.renderElements;
        return renderTableCell(props);
      }
    case ElementType.TABLE_ROW:
      {
        const [, renderTableRow] = _plugins.TablePlugin.renderElements;
        return renderTableRow(props);
      }
    case ElementType.TABLE:
      {
        const [,, renderTable] = _plugins.TablePlugin.renderElements;
        return renderTable(props, editor);
      }
    case ElementType.FORMULA:
      {
        const [renderFormula] = _plugins.FormulaPlugin.renderElements;
        return renderFormula(props, editor);
      }
    case ElementType.COLUMN:
      {
        const [renderColumn] = _plugins.ColumnPlugin.renderElements;
        return renderColumn(props);
      }
    default:
      {
        const [renderParagraph] = _plugins.ParagraphPlugin.renderElements;
        return renderParagraph(props);
      }
  }
};
const renderElement = props => {
  return /*#__PURE__*/_react.default.createElement(SlateElement, props);
};
var _default = exports.default = renderElement;