import _keys from "lodash/fp/keys";
import _get from "lodash/fp/get";
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { NovaSolidVoteRewardsVoteHeart as HeartIcon, NovaCompositionCoorpacademyBrokenHeart as HeartBrokenIcon, NovaCompositionCoorpacademyVoteHeartOutline as HeartIconOutline } from '@coorpacademy/nova-icons';
import Provider from '../provider';
import cssStyle from './style.css';
const MODES = {
  default: cssStyle.defaultStyle,
  small: cssStyle.small
};
const BOUNCES = {
  bounce: cssStyle.bounce,
  bounceTwice: cssStyle.bounceTwice,
  bounceAndPause: cssStyle.bounceAndPause
};
const Life = (props, context) => {
  const {
    skin
  } = context;
  const {
    bounce = null,
    heartOnRight = false,
    animated = false,
    count = 3,
    failed = false,
    mode = 'default',
    operator = 'x',
    revival,
    className,
    style: customStyle
  } = props;
  const negativeColor = _get('common.negative', skin);
  const white = _get('common.white', skin);
  if (count === null) {
    return null;
  }
  const pickStyle = (successStyle, failedStyle, animatedFailedStyle, revivalStyle) => {
    if (revival) return revivalStyle;
    if (failed && animated) return animatedFailedStyle;
    if (failed) return failedStyle;
    return successStyle;
  };
  const heartWrapper = failed && animated ? cssStyle.heartWrapperFailed : cssStyle.heartWrapperDefault;
  const bounceClass = bounce ? BOUNCES[bounce.type] : null;
  const heartCustomStyle = {
    animationDelay: bounce && bounce.delay,
    animationDuration: bounce && bounce.duration,
    left: heartOnRight && '70px'
  };
  const countStyle = failed ? cssStyle.livesCounterFailed : cssStyle.livesCounterDefault;
  return /*#__PURE__*/React.createElement("div", {
    "data-name": "life",
    className: classnames(MODES[mode], className),
    style: customStyle
  }, /*#__PURE__*/React.createElement("div", {
    className: cssStyle.livesCounterWrapper
  }, /*#__PURE__*/React.createElement("div", {
    className: pickStyle(cssStyle.previousLivesCounterDefault, cssStyle.previousLivesCounterDefault, cssStyle.previousLivesCounterFailed, cssStyle.previousLivesRevival)
  }, count + 1), /*#__PURE__*/React.createElement("div", {
    "data-name": "counter",
    className: countStyle
  }, count)), /*#__PURE__*/React.createElement("div", {
    className: cssStyle.operatorWrapper
  }, /*#__PURE__*/React.createElement("span", {
    className: cssStyle.operator
  }, operator)), /*#__PURE__*/React.createElement("div", {
    className: classnames(heartWrapper, bounceClass),
    style: heartCustomStyle
  }, /*#__PURE__*/React.createElement(HeartIconOutline, {
    className: cssStyle.heartOutline,
    style: {
      color: white
    }
  }), /*#__PURE__*/React.createElement(HeartIcon, {
    className: pickStyle(cssStyle.heartNormalDefault, cssStyle.heartNormalFailed, cssStyle.heartNormalAnimatedFailed, cssStyle.heartNormalRevival),
    style: {
      color: negativeColor
    }
  }), /*#__PURE__*/React.createElement(HeartBrokenIcon, {
    className: pickStyle(cssStyle.heartBrokenDefault, cssStyle.heartBrokenFailed, cssStyle.heartBrokenAnimatedFailed, cssStyle.heartBrokenRevival),
    style: {
      color: negativeColor
    }
  })));
};
Life.contextTypes = {
  skin: Provider.childContextTypes.skin
};
Life.propTypes = process.env.NODE_ENV !== "production" ? {
  revival: PropTypes.bool,
  animated: PropTypes.bool,
  bounce: PropTypes.shape({
    type: PropTypes.oneOf(['bounce', 'bounceTwice', 'bounceAndPause']),
    delay: PropTypes.string
  }),
  heartOnRight: PropTypes.bool,
  mode: PropTypes.oneOf(_keys(MODES)),
  count: PropTypes.number,
  failed: PropTypes.bool,
  className: PropTypes.string,
  operator: PropTypes.string,
  style: PropTypes.shape({})
} : {};
export default Life;
//# sourceMappingURL=index.js.map