/* eslint-disable react/jsx-props-no-spreading, no-param-reassign */
import React from 'react';
import PropTypes from 'prop-types';

const withMarks = (content, leaf) => {
  if (leaf.bold) {
    if (leaf.italic) {
      return /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement("em", null, content));
    }

    return /*#__PURE__*/React.createElement("strong", null, content);
  }

  if (leaf.italic) {
    return /*#__PURE__*/React.createElement("em", null, content);
  }

  return content;
};

const Leaf = ({
  attributes,
  children,
  leaf
}) => /*#__PURE__*/React.createElement("span", attributes, withMarks(children, leaf));

Leaf.propTypes = {
  attributes: PropTypes.object,
  children: PropTypes.node,
  leaf: PropTypes.shape({
    bold: PropTypes.bool,
    italic: PropTypes.bool,
    underline: PropTypes.bool
  }).isRequired
};
Leaf.defaultProps = {
  attributes: {},
  children: null
};
export default Leaf;