"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _proptypes = require("../../util/proptypes");
var _forumComment = _interopRequireDefault(require("../../molecule/forum/forum-comment"));
var _forumThread = _interopRequireDefault(require("../../molecule/forum/forum-thread"));
var _postConditions = _interopRequireDefault(require("../../molecule/forum/post-conditions"));
var _loader = _interopRequireDefault(require("../../atom/loader"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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); }
function Discussion(props) {
  const {
    threads = [],
    title,
    avatar,
    value,
    loading,
    onPost,
    onChange,
    hideComments,
    textareaDisabled,
    postDisabled,
    className,
    profileAvatarAlt
  } = props;
  const threadsView = threads.map(thread => /*#__PURE__*/_react.default.createElement(_forumThread.default, _extends({}, thread, {
    key: thread.id,
    mainPost: true
  })));
  const commentView = !hideComments ? /*#__PURE__*/_react.default.createElement(_forumComment.default, {
    avatar: avatar,
    value: value,
    profileAvatarAlt: profileAvatarAlt,
    newPost: true,
    onPost: onPost,
    onChange: onChange,
    textareaDisabled: textareaDisabled,
    postDisabled: postDisabled
  }) : null;
  const loader = loading ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.loader
  }, /*#__PURE__*/_react.default.createElement(_loader.default, null)) : null;
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "discussion",
    className: (0, _classnames.default)(_style.default.thread, className)
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.header
  }, /*#__PURE__*/_react.default.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: _proptypes.SrcPropType,
  loading: _propTypes.default.bool,
  value: _propTypes.default.string,
  profileAvatarAlt: _propTypes.default.string,
  title: _propTypes.default.string,
  onPost: _propTypes.default.func,
  onChange: _propTypes.default.func,
  threads: _propTypes.default.arrayOf(_propTypes.default.shape(_postConditions.default)),
  textareaDisabled: _propTypes.default.bool,
  postDisabled: _propTypes.default.bool,
  className: _propTypes.default.string,
  hideComments: _propTypes.default.bool
} : {};
var _default = exports.default = Discussion;
//# sourceMappingURL=index.js.map