import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.

/* eslint-disable react/no-danger */
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import marked from 'marked';
import { CLS_PREFIX } from '../../constants';

/**
 * `Markdown` component is used for creating content with rich text formatting.
 * @since 0.0.42
 */
const Markdown = ({
  baseClassName,
  className,
  compact = false,
  children,
  ...props
}) => /*#__PURE__*/React.createElement("div", _extends({
  className: classNames(baseClassName, {
    ["".concat(baseClassName, "--compact")]: compact
  }, className),
  dangerouslySetInnerHTML: {
    __html: marked(children, {
      sanitize: true
    })
  }
}, props));

Markdown.propTypes = {
  /**
   * Content of the Markdown
   * @since 0.0.42
   */
  children: PropTypes.string.isRequired,

  /**
   * Compact mode
   * @since 0.0.42
   */
  compact: PropTypes.bool,

  /**
   * @ignore
   */
  className: PropTypes.string,

  /**
   * @ignore
   */
  baseClassName: PropTypes.string
};
Markdown.defaultProps = {
  compact: false,
  className: null,
  baseClassName: "".concat(CLS_PREFIX, "markdown")
};
export default Markdown;