"use strict";

exports.__esModule = true;
exports.default = void 0;
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../../../atom/provider"));
var _cardsGrid = _interopRequireDefault(require("../../../organism/cards-grid"));
var _socialLink = _interopRequireDefault(require("../../../atom/social-link"));
var _link = _interopRequireDefault(require("../../../atom/link"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
class Authors extends _react.default.Component {
  static contextTypes = {
    translate: _provider.default.childContextTypes.translate,
    skin: _provider.default.childContextTypes.skin
  };
  constructor(props, context) {
    super(props);
    this.state = {
      fullDisplay: false
    };
    this.handleToggleDisplay = this.handleToggleDisplay.bind(this);
  }
  handleToggleDisplay() {
    this.setState(prevState => ({
      fullDisplay: !prevState.fullDisplay
    }));
  }
  render() {
    const {
      image,
      title,
      description,
      cards,
      cardsTitle,
      socialTitle,
      sociallinks,
      website,
      urlwebsite,
      urlcontent
    } = this.props;
    const {
      fullDisplay
    } = this.state;
    const {
      translate,
      skin
    } = this.context;
    const defaultColor = (0, _getOr2.default)('#00B0FF', 'common.primary', skin);
    const toggleLabel = fullDisplay ? translate('See less') : translate('Show more');
    const socialView = _map2.default.convert({
      cap: false
    })((sociallink, i) => /*#__PURE__*/_react.default.createElement("div", {
      key: i,
      "data-name": "link",
      className: _style.default.link
    }, /*#__PURE__*/_react.default.createElement(_socialLink.default, sociallink)), sociallinks);
    const authorSocial = socialView.length > 0 ? /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.links
    }, /*#__PURE__*/_react.default.createElement("span", null, socialTitle), socialView) : null;
    return /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "authors",
      className: _style.default.wrapper
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.authorsWrapper
    }, /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "header",
      className: _style.default.header
    }, /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "image",
      className: _style.default.imgWrapper
    }, /*#__PURE__*/_react.default.createElement("img", {
      src: image
    })), /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.descWrapper
    }, /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "title",
      className: _style.default.title
    }, title), /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.linksWrapper
    }, /*#__PURE__*/_react.default.createElement("span", null, website), /*#__PURE__*/_react.default.createElement(_link.default, {
      "data-name": "linkSite",
      className: _style.default.linksite,
      style: {
        color: defaultColor
      },
      href: urlwebsite,
      target: '_blank'
    }, urlcontent), authorSocial), /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "description",
      className: fullDisplay ? _style.default.desc : _style.default.shortDesc
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.innerHTML
      // eslint-disable-next-line react/no-danger
      ,
      dangerouslySetInnerHTML: {
        __html: description
      }
    })), /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "more",
      className: _style.default.toggle,
      onClick: this.handleToggleDisplay
    }, toggleLabel))), /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.cardsTitle
    }, cardsTitle), /*#__PURE__*/_react.default.createElement(_cardsGrid.default, cards)));
  }
}
Authors.propTypes = process.env.NODE_ENV !== "production" ? {
  cards: _propTypes.default.shape(_cardsGrid.default.propTypes),
  cardsTitle: _propTypes.default.string,
  image: _propTypes.default.string,
  title: _propTypes.default.string,
  website: _propTypes.default.string,
  urlcontent: _propTypes.default.string,
  urlwebsite: _propTypes.default.string,
  description: _propTypes.default.string,
  socialTitle: _propTypes.default.string,
  sociallinks: _propTypes.default.arrayOf(_propTypes.default.shape({
    type: _propTypes.default.string,
    link: _propTypes.default.string
  }))
} : {};
var _default = exports.default = Authors;
//# sourceMappingURL=index.js.map