"use strict";

exports.__esModule = true;
exports.default = void 0;
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _link = _interopRequireDefault(require("../../../../../atom/link"));
var _provider = _interopRequireDefault(require("../../../../../atom/provider"));
var _learner = _interopRequireDefault(require("./learner.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 LearnerHeaderWrapper = props => {
  const {
    children,
    mode,
    onClick
  } = props;
  if (mode === 'scorm') return /*#__PURE__*/_react.default.createElement("div", {
    className: _learner.default.contentWrapperScorm
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _learner.default.backIcon
  }), children);
  return /*#__PURE__*/_react.default.createElement(_link.default, {
    onClick: onClick,
    className: _learner.default.contentWrapper
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionNavigationArrowLeft, {
    className: _learner.default.backIcon
  }), children);
};
LearnerHeaderWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
  onClick: _link.default.propTypes.onClick,
  mode: _propTypes.default.string,
  children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired
} : {};
const Content = ({
  onClick,
  title,
  details,
  mode
}, context) => {
  const {
    skin
  } = context;
  const primarySkinColor = (0, _get2.default)('common.primary', skin);
  return /*#__PURE__*/_react.default.createElement(LearnerHeaderWrapper, {
    mode: mode,
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _learner.default.content
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _learner.default.contentDetails,
    style: {
      color: primarySkinColor
    }
  }, details), /*#__PURE__*/_react.default.createElement("span", {
    "data-name": "contentTitle",
    className: (0, _classnames.default)(_learner.default.contentTitle, _learner.default.innerHTML)
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: title
    }
  })));
};
Content.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
Content.propTypes = process.env.NODE_ENV !== "production" ? {
  onClick: _link.default.propTypes.onClick,
  title: _propTypes.default.string.isRequired,
  details: _propTypes.default.string,
  mode: _propTypes.default.string
} : {};
const Subcontent = ({
  title,
  details
}, context) => /*#__PURE__*/_react.default.createElement("div", {
  className: _learner.default.subcontent
}, /*#__PURE__*/_react.default.createElement("div", {
  className: _learner.default.subcontentDetails
}, details), /*#__PURE__*/_react.default.createElement("div", {
  className: (0, _classnames.default)(_learner.default.subcontentTitle, _learner.default.innerHTML)
  // eslint-disable-next-line react/no-danger
  ,
  dangerouslySetInnerHTML: {
    __html: title
  }
}));
Subcontent.propTypes = process.env.NODE_ENV !== "production" ? {
  title: _propTypes.default.string.isRequired,
  details: _propTypes.default.string
} : {};
const LearnerHeader = (props, context) => {
  const {
    content,
    subcontent,
    mode
  } = props;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _learner.default.wrapper
  }, /*#__PURE__*/_react.default.createElement(Content, _extends({}, content, {
    mode: mode
  })), /*#__PURE__*/_react.default.createElement(Subcontent, subcontent));
};
LearnerHeader.propTypes = process.env.NODE_ENV !== "production" ? {
  content: _propTypes.default.shape(Content.propTypes).isRequired,
  subcontent: _propTypes.default.shape(Subcontent.propTypes).isRequired,
  mode: _propTypes.default.string
} : {};
var _default = exports.default = LearnerHeader;
//# sourceMappingURL=learner.js.map