import _getOr from "lodash/fp/getOr";
import _get from "lodash/fp/get";
import _keys from "lodash/fp/keys";
import _noop from "lodash/fp/noop";
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { NovaSolidLightsLightbulb4 as LightBulbIcon, NovaCompositionNavigationArrowDown as ArrowIcon, NovaCompositionCoorpacademyOpenInNewTab as OpenInNewTabIcon, NovaCompositionCoorpacademyDashboard as DashboardIcon, NovaCompositionCoorpacademyAnalytics as AnalyticsIcon, NovaCompositionCoorpacademyAnimation as AnimationIcon, NovaCompositionCoorpacademyAdministration as AdministrationIcon, NovaCompositionCoorpacademyContentCreation as ContentCreationIcon, NovaCompositionCoorpacademyEditorialization as EditorializationIcon } from '@coorpacademy/nova-icons';
import Link from '../../../../atom/link';
import Provider from '../../../../atom/provider';
import { COLORS } from '../../../../variables/colors';
import style from './style.css';
const ICON_TYPES = {
  arrow: LightBulbIcon,
  dashboard: DashboardIcon,
  analytics: AnalyticsIcon,
  administration: AdministrationIcon,
  animation: AnimationIcon,
  contentCreation: ContentCreationIcon,
  editorialization: EditorializationIcon
};
const defaultStyle = {
  titleIcon: style.titleIcon,
  label: style.titleLabel,
  selectedLabel: style.titleLabel,
  title: style.setupTitle,
  container: style.container,
  openHeader: style.openHeader,
  closedHeader: style.closedHeader,
  default: null
};
const setupThemeStyle = {
  titleIcon: style.titleIcon,
  titleActivatedIcon: style.setupTitleActivatedIcon,
  label: style.setupTitleLabel,
  selectedLabel: style.setupSelectedTitleLabel,
  setupSelectedTitle: style.setupSelectedTitle,
  selectedTitle: style.selectedTitle,
  title: style.setupTitle,
  container: style.setupContainer,
  openHeader: style.coorpManagerOpenHeader,
  closedHeader: style.coorpManagerClosedHeader
};
const MoreLessIcons = ({
  type,
  moreClassName,
  lessClassName,
  darkColor,
  mediumColor
}) => {
  return type !== 'iconLink' ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ArrowIcon, {
    className: moreClassName,
    style: {
      color: darkColor
    }
  }), /*#__PURE__*/React.createElement(ArrowIcon, {
    className: lessClassName,
    style: {
      color: mediumColor
    }
  })) : /*#__PURE__*/React.createElement(OpenInNewTabIcon, {
    className: style.newTabIcon
  });
};
const Part = ({
  skin,
  selected,
  iconType,
  onParentClick,
  onClick,
  isOpen,
  title,
  type,
  children,
  theme
}) => {
  const darkColor = _get('common.dark', skin);
  const mediumColor = _get('common.medium', skin);
  const lessClassName = isOpen ? style.openIconActivated : style.openIcon;
  const moreClassName = !isOpen ? style.closeIconActivated : style.closeIcon;
  const iconColor = selected ? style.iconBlue : style.iconGrey;
  const hoverIconColor = selected && style.blueTitleIcon;
  const selectedBlackLabel = selected && style.labelBlack;
  const Icon = ICON_TYPES[iconType];
  const isLink = type === 'iconLink';
  const isCollapsible = type === 'collapsibleTab';
  return /*#__PURE__*/React.createElement("div", {
    className: style.wrapper
  }, theme === 'setup' ? /*#__PURE__*/React.createElement("div", {
    className: classnames(style.border, selected ? style.borderBgBlue : style.borderBgNone)
  }) : null, /*#__PURE__*/React.createElement("div", {
    "data-type": iconType,
    onClick: onParentClick,
    style: {
      flex: 1
    }
  }, /*#__PURE__*/React.createElement("div", {
    "data-name": "accordionPart",
    className: style.setupPart
  }, /*#__PURE__*/React.createElement("div", {
    className: style.header,
    "data-type": iconType,
    onClick: onClick
  }, /*#__PURE__*/React.createElement("div", {
    "data-name": "title",
    className: style.title
  }, Icon ? /*#__PURE__*/React.createElement(Icon, {
    className: classnames(style.titleIcon, iconColor, hoverIconColor)
  }) : null, /*#__PURE__*/React.createElement("h3", {
    className: classnames(style.titleLabel, selectedBlackLabel)
  }, title, isLink ? /*#__PURE__*/React.createElement(OpenInNewTabIcon, {
    className: style.newTabIcon
  }) : null)), isCollapsible ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ArrowIcon, {
    className: moreClassName,
    style: {
      color: darkColor
    }
  }), /*#__PURE__*/React.createElement(ArrowIcon, {
    className: lessClassName,
    style: {
      color: mediumColor
    }
  })) : null), isCollapsible ? children : null)));
};
const AccordionPart = (props, context) => {
  const {
    skin
  } = context;
  const {
    title,
    content,
    iconType,
    theme,
    onClick = _noop,
    selected = false,
    type,
    href,
    isOpen,
    onUpdateOpenedTab
  } = props;
  const themeStyle = theme === 'setup' ? setupThemeStyle : defaultStyle;
  function handleParentClick() {
    onUpdateOpenedTab();
    onClick();
  }
  const isCollapsibleTab = type === 'collapsibleTab';
  return /*#__PURE__*/React.createElement("div", {
    "data-name": "accordionPart",
    className: themeStyle[theme]
  }, !isCollapsibleTab ? /*#__PURE__*/React.createElement(Link, {
    onClick: handleParentClick,
    hoverColor: _getOr(COLORS.brand, 'common.primary', skin),
    href: href,
    "data-name": `link-item`,
    target: '_blank',
    style: {
      textDecoration: 'none'
    }
  }, /*#__PURE__*/React.createElement(Part, {
    skin: skin,
    title: title,
    content: content,
    iconType: iconType,
    theme: theme,
    onParentClick: handleParentClick,
    onClick: onClick,
    isOpen: isOpen,
    selected: selected,
    type: type
  })) : /*#__PURE__*/React.createElement(Part, {
    skin: skin,
    title: title,
    content: content,
    iconType: iconType,
    theme: theme,
    onParentClick: handleParentClick,
    onClick: onClick,
    selected: selected,
    isOpen: isOpen,
    type: type
  }), isCollapsibleTab && isOpen ? /*#__PURE__*/React.createElement("div", {
    className: themeStyle.container
  }, content) : null);
};
AccordionPart.contextTypes = {
  skin: Provider.childContextTypes.skin
};
AccordionPart.propTypes = process.env.NODE_ENV !== "production" ? {
  iconType: PropTypes.oneOf(_keys(ICON_TYPES)),
  type: PropTypes.oneOf(['simpleTab', 'collapsibleTab', 'iconLink']),
  title: PropTypes.string,
  content: PropTypes.node,
  onClick: PropTypes.func,
  selected: PropTypes.bool,
  theme: PropTypes.string,
  href: PropTypes.string,
  isOpen: PropTypes.bool,
  onUpdateOpenedTab: PropTypes.func
} : {};
MoreLessIcons.propTypes = process.env.NODE_ENV !== "production" ? {
  type: PropTypes.string,
  moreClassName: PropTypes.string,
  lessClassName: PropTypes.string,
  darkColor: PropTypes.string,
  mediumColor: PropTypes.string
} : {};
Part.propTypes = process.env.NODE_ENV !== "production" ? {
  ...AccordionPart.propTypes
} : {};
export default AccordionPart;
//# sourceMappingURL=index.js.map