import React from 'react';
import isEmpty from 'lodash/fp/isEmpty';
import PropTypes from 'prop-types';
import DisciplineCTA from '../../../molecule/discipline-cta';
import DisciplineHeader from '../../../molecule/discipline-header';
import DisciplinePartners from '../../../molecule/discipline-partners';
import DisciplineScope from '../../../molecule/discipline-scope';
import DisciplineAssociatedSkills from '../../../molecule/discipline-associated-skills';
import Share, { ShareFeedback, ShareStatusProvider } from '../../../molecule/share';
import AddToMyList, { AddToMyListFeedback, AddToMyListStatusProvider } from '../../../molecule/add-to-my-list';
import ScopeContent from '../../../molecule/scope-content';
import style from './style.css';
const Discipline = (props, context) => {
  const {
    selected = 0,
    level,
    levels,
    changeLevel,
    image,
    title = '',
    video,
    authors = [],
    description = '',
    content = null,
    start,
    buy,
    startLabel,
    skills = [],
    onSkillClick,
    buyLabel,
    shareWording,
    shareText,
    shareSuccessWording,
    shareErrorWording,
    addToMyListButton,
    favorite,
    onFavoriteClick,
    addToMyListText,
    removeFromMyListText,
    disableShare = false,
    disableAddToMyList = false,
    lastUpdated
  } = props;
  const authorSection = isEmpty(authors) ? null : /*#__PURE__*/React.createElement("div", {
    className: style.partners
  }, /*#__PURE__*/React.createElement(DisciplinePartners, {
    authors: authors
  }));
  const disciplineCTA = /*#__PURE__*/React.createElement(DisciplineCTA, {
    type: 'discipline',
    start: start,
    buy: buy,
    startLabel: startLabel,
    buyLabel: buyLabel
  });
  const disciplineContent = content || !isEmpty(levels) ? /*#__PURE__*/React.createElement("div", {
    className: style.content
  }, content ? /*#__PURE__*/React.createElement(ScopeContent, {
    content: content
  }) : null, !isEmpty(levels) ? /*#__PURE__*/React.createElement(DisciplineScope, {
    content: level,
    levels: levels,
    selected: selected,
    onClick: changeLevel
  }) : null) : null;
  const disciplineHeader = /*#__PURE__*/React.createElement("div", {
    className: style.header
  }, /*#__PURE__*/React.createElement(DisciplineHeader, {
    image: image,
    video: video,
    title: title,
    description: description,
    lastUpdated: lastUpdated
  }));
  const discipline = /*#__PURE__*/React.createElement("div", {
    "data-name": "discipline",
    className: style.container,
    key: "discipline"
  }, /*#__PURE__*/React.createElement("div", {
    className: style.leftSection
  }, disciplineHeader, /*#__PURE__*/React.createElement("div", {
    className: style.mobileAuthorCtaSection
  }, /*#__PURE__*/React.createElement("div", {
    className: style.columnReverse
  }, /*#__PURE__*/React.createElement("div", {
    className: style.cta
  }, disciplineCTA), disableAddToMyList ? null : /*#__PURE__*/React.createElement(AddToMyList, {
    style: style.addToMyListBtn,
    addToMyListButton: addToMyListButton,
    favorite: favorite,
    onFavoriteClick: onFavoriteClick,
    key: 'addToMyListTablet'
  }), disableShare ? null : /*#__PURE__*/React.createElement(Share, {
    style: style.shareBtn,
    wording: shareWording,
    text: shareText,
    key: 'shareTablet'
  })), /*#__PURE__*/React.createElement(DisciplineAssociatedSkills, {
    skills: skills,
    onSkillClick: onSkillClick
  }), authorSection), disciplineContent), /*#__PURE__*/React.createElement("div", {
    className: style.rightSection
  }, /*#__PURE__*/React.createElement("div", {
    className: style.stickySection
  }, /*#__PURE__*/React.createElement("div", {
    className: style.cta
  }, disciplineCTA, disableShare && disableAddToMyList ? null : /*#__PURE__*/React.createElement("div", {
    className: style.buttons
  }, disableShare ? null : /*#__PURE__*/React.createElement(Share, {
    style: style.shareBtn,
    wording: shareWording,
    text: shareText,
    key: 'shareDesktop'
  }), disableAddToMyList ? null : /*#__PURE__*/React.createElement(AddToMyList, {
    style: style.addToMyListBtn,
    addToMyListButton: addToMyListButton,
    favorite: favorite,
    onFavoriteClick: onFavoriteClick,
    key: 'addToMyListDesktop'
  }))), /*#__PURE__*/React.createElement(DisciplineAssociatedSkills, {
    skills: skills,
    onSkillClick: onSkillClick
  }), authorSection)));
  const shareFeedBack = disableShare ? null : /*#__PURE__*/React.createElement(ShareFeedback, {
    errorWording: shareErrorWording,
    successWording: shareSuccessWording,
    key: "shareFeedBack"
  });
  const addToMyListFeedback = disableAddToMyList ? null : /*#__PURE__*/React.createElement(AddToMyListFeedback, {
    addToMyListText: addToMyListText,
    removeFromMyListText: removeFromMyListText,
    favorite: favorite
  });
  const addToMyListProviderWrap = disableAddToMyList ? /*#__PURE__*/React.createElement(React.Fragment, null, shareFeedBack, discipline) : /*#__PURE__*/React.createElement(AddToMyListStatusProvider, null, shareFeedBack, addToMyListFeedback, discipline);
  const shareProviderWrap = disableShare ? addToMyListProviderWrap : /*#__PURE__*/React.createElement(ShareStatusProvider, null, addToMyListProviderWrap);
  return shareProviderWrap;
};
Discipline.propTypes = process.env.NODE_ENV !== "production" ? {
  image: DisciplineHeader.propTypes.image,
  video: DisciplineHeader.propTypes.video,
  title: DisciplineHeader.propTypes.title,
  description: DisciplineHeader.propTypes.description,
  start: DisciplineCTA.propTypes.start,
  buy: DisciplineCTA.propTypes.buy,
  startLabel: DisciplineCTA.propTypes.startLabel,
  buyLabel: DisciplineCTA.propTypes.buyLabel,
  authors: DisciplinePartners.propTypes.authors,
  level: DisciplineScope.propTypes.content,
  levels: DisciplineScope.propTypes.levels,
  selected: DisciplineScope.propTypes.selected,
  changeLevel: DisciplineScope.propTypes.onClick,
  content: ScopeContent.propTypes.content,
  shareWording: Share.propTypes.wording,
  shareText: Share.propTypes.text,
  shareSuccessWording: ShareFeedback.propTypes.successWording,
  shareErrorWording: ShareFeedback.propTypes.errorWording,
  skills: PropTypes.arrayOf(PropTypes.shape({
    ref: PropTypes.string,
    locale: PropTypes.string,
    focused: PropTypes.bool
  })),
  onSkillClick: PropTypes.func,
  addToMyListText: AddToMyListFeedback.propTypes.addToMyListText,
  removeFromMyListText: AddToMyListFeedback.propTypes.removeFromMyListText,
  addToMyListButton: AddToMyList.propTypes.addToMyListButton,
  onFavoriteClick: AddToMyList.propTypes.onFavoriteClick,
  favorite: AddToMyList.propTypes.favorite,
  disableShare: PropTypes.bool,
  disableAddToMyList: PropTypes.bool
} : {};
Discipline.contextTypes = {
  translate: PropTypes.func
};
export default Discipline;
//# sourceMappingURL=index.js.map