"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _button = _interopRequireDefault(require("../../atom/button"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _discussion = _interopRequireDefault(require("../../organism/discussion"));
var _resourceBrowser = _interopRequireDefault(require("../../organism/resource-browser"));
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); }
const ScopeContent = (props, context) => {
  const {
    translate,
    skin
  } = context;
  const {
    content
  } = props;
  const lstitle = translate('At the end of this level, you will be able to_');
  const _chaptersTitle = translate('chapters');
  const time = (0, _getOr2.default)('', 'time', content);
  const title = (0, _getOr2.default)('', 'title', content);
  const _skills = (0, _getOr2.default)([], 'skills', content);
  const _chapters = (0, _getOr2.default)([], 'chapters', content);
  const _resources = (0, _getOr2.default)([], 'resources', content);
  const skillsTitle = (0, _getOr2.default)(lstitle, 'skillsTitle', content);
  const chaptersTitle = (0, _getOr2.default)(_chaptersTitle, 'chaptersTitle', content);
  const onClick = (0, _get2.default)('onClick', content);
  const buttonLabel = (0, _get2.default)('buttonLabel', content);
  const discussion = (0, _get2.default)('discussion', content);
  const skills = _skills.map((skill, index) => /*#__PURE__*/_react.default.createElement("li", {
    key: index
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: skill
    }
  }));
  const chapters = _chapters.map((chapter, index) => /*#__PURE__*/_react.default.createElement("li", {
    key: index
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: chapter.name
    }
  }));
  const ctaView = onClick ? /*#__PURE__*/_react.default.createElement(_button.default, {
    "data-name": "cta",
    type: "link",
    className: _style.default.cta,
    onClick: onClick,
    submitValue: buttonLabel,
    style: {
      backgroundColor: (0, _get2.default)('common.primary', skin)
    }
  }) : null;
  return content && title ? /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "scopeContent",
    className: _style.default.scopeContent
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "description",
    className: _style.default.desc
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.infos
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.title
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.innerHTML
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: title
    }
  }), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("span", {
    "data-name": "duration",
    className: _style.default.time
  }, time))), ctaView), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.columnLayout
  }, (0, _isEmpty2.default)(skills) ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.skills
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.coltitle
  }, skillsTitle), /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.dottedlist
  }, skills)), (0, _isEmpty2.default)(chapters) ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.column
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.coltitle
  }, chaptersTitle), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.roundedlist
  }, chapters))))), !(0, _isEmpty2.default)(_resources) ? /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "description",
    className: _style.default.bordered
  }, /*#__PURE__*/_react.default.createElement(_resourceBrowser.default, {
    resources: _resources
  })) : null, discussion ? /*#__PURE__*/_react.default.createElement(_discussion.default, _extends({}, discussion, {
    className: _style.default.discussion
  })) : null) : /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "discussion"
  }, discussion ? /*#__PURE__*/_react.default.createElement(_discussion.default, _extends({}, discussion, {
    className: _style.default.discussion
  })) : null);
};
ScopeContent.contextTypes = {
  skin: _provider.default.childContextTypes.skin,
  translate: _provider.default.childContextTypes.translate
};
ScopeContent.propTypes = process.env.NODE_ENV !== "production" ? {
  content: _propTypes.default.shape({
    title: _propTypes.default.string,
    skillsTitle: _propTypes.default.string,
    chaptersTitle: _propTypes.default.string,
    time: _propTypes.default.string,
    onClick: _propTypes.default.func,
    buttonLabel: _propTypes.default.string,
    skills: _propTypes.default.arrayOf(_propTypes.default.string),
    chapters: _propTypes.default.arrayOf(_propTypes.default.object),
    course_scope: _propTypes.default.arrayOf(_propTypes.default.string),
    resources: _resourceBrowser.default.propTypes.resources,
    discussion: _propTypes.default.shape(_discussion.default.propTypes)
  })
} : {};
var _default = exports.default = ScopeContent;
//# sourceMappingURL=index.js.map