import classnames from 'classnames';
import customizable from "../../../../../utils/css/customizable.js";
import getTagFromType from '../../getTagFromType';
const Leaf = function Leaf(props) {
  const {
    data,
    context
  } = props;
  const {
    text,
    marks
  } = data;
  const {
    classes,
    components
  } = context;
  const hasMarks = !!marks && marks.length > 0;
  if (!hasMarks && !text) {
    return null;
  }
  if (!hasMarks) {
    return text;
  }
  const [mark, ...restMarks] = marks;
  const {
    Tag,
    name,
    nodeToProps
  } = getTagFromType(mark.type, components);
  return <Tag className={classnames(customizable(`RenderedContent__${name}`), classes[name])} {...nodeToProps(data, context)}>
      <Leaf data={{
      text,
      marks: restMarks
    }} context={context} />
    </Tag>;
};
export default Leaf;