function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { SrcPropType } from '../../util/proptypes';
import ForumComment from '../../molecule/forum/forum-comment';
import ForumThread from '../../molecule/forum/forum-thread';
import postConditions from '../../molecule/forum/post-conditions';
import Loader from '../../atom/loader';
import style from './style.css';
function Discussion(props) {
  const {
    threads = [],
    title,
    avatar,
    value,
    loading,
    onPost,
    onChange,
    hideComments,
    textareaDisabled,
    postDisabled,
    className,
    profileAvatarAlt
  } = props;
  const threadsView = threads.map(thread => /*#__PURE__*/React.createElement(ForumThread, _extends({}, thread, {
    key: thread.id,
    mainPost: true
  })));
  const commentView = !hideComments ? /*#__PURE__*/React.createElement(ForumComment, {
    avatar: avatar,
    value: value,
    profileAvatarAlt: profileAvatarAlt,
    newPost: true,
    onPost: onPost,
    onChange: onChange,
    textareaDisabled: textareaDisabled,
    postDisabled: postDisabled
  }) : null;
  const loader = loading ? /*#__PURE__*/React.createElement("div", {
    className: style.loader
  }, /*#__PURE__*/React.createElement(Loader, null)) : null;
  return /*#__PURE__*/React.createElement("div", {
    "data-name": "discussion",
    className: classnames(style.thread, className)
  }, /*#__PURE__*/React.createElement("div", {
    className: style.header
  }, /*#__PURE__*/React.createElement("h1", {
    id: "forum-discussion"
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: title
    }
  }), commentView), threadsView, loader);
}
Discussion.propTypes = process.env.NODE_ENV !== "production" ? {
  avatar: SrcPropType,
  loading: PropTypes.bool,
  value: PropTypes.string,
  profileAvatarAlt: PropTypes.string,
  title: PropTypes.string,
  onPost: PropTypes.func,
  onChange: PropTypes.func,
  threads: PropTypes.arrayOf(PropTypes.shape(postConditions)),
  textareaDisabled: PropTypes.bool,
  postDisabled: PropTypes.bool,
  className: PropTypes.string,
  hideComments: PropTypes.bool
} : {};
export default Discussion;
//# sourceMappingURL=index.js.map