"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _cssColorFunction = require("css-color-function");
var _novaIcons = require("@coorpacademy/nova-icons");
var _getOr = _interopRequireDefault(require("lodash/fp/getOr"));
var _buttonLink = _interopRequireDefault(require("../../atom/button-link"));
var _style = _interopRequireDefault(require("./style.css"));
var _propTypes = _interopRequireDefault(require("./prop-types"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const getGradientBackground = baseColor => {
  const gradients = [(0, _cssColorFunction.convert)(`color(${baseColor} lightness(30%))`), (0, _cssColorFunction.convert)(`color(${baseColor} lightness(47%))`), (0, _cssColorFunction.convert)(`color(${baseColor} lightness(55%))`)];
  return `radial-gradient(62.12% 56.45% at 0% 77.29%, ${gradients[0]} 0%, ${(0, _cssColorFunction.convert)(`color(${gradients[0]} a(0))`)} 100%), radial-gradient(113.85% 103.46% at 93.27% 7.88%, ${gradients[1]} 0%, ${(0, _cssColorFunction.convert)(`color(${gradients[1]} a(0))`)} 100%), radial-gradient(49.66% 49.63% at 78.65% 86.26%, ${gradients[2]} 0%, ${(0, _cssColorFunction.convert)(`color(${gradients[2]} a(0))`)} 100%), ${baseColor}`;
};
const SkillCard = (props, context) => {
  const {
    'aria-label': ariaLabel,
    skillTitle,
    skillAriaLabel,
    buttonLabel,
    buttonAriaLabel,
    reviseLabel,
    reviseAriaLabel,
    onClick,
    isCustom = false
  } = props;
  const {
    skin
  } = context;
  const primarySkinColor = (0, _getOr.default)('#00B0FF', 'common.primary', skin);
  const buttonProps = {
    customStyle: {
      backgroundColor: (0, _cssColorFunction.convert)(`color(${primarySkinColor} a(0.07))`),
      color: primarySkinColor,
      transition: 'background-color 0.15s ease-in-out, color 0.15s ease-in-out'
    },
    hoverBackgroundColor: primarySkinColor,
    hoverColor: '#FFFFFF',
    onClick,
    'aria-label': buttonAriaLabel ? `${skillTitle}, ${buttonAriaLabel}` : skillTitle,
    label: buttonLabel,
    'data-name': 'skill-card-button'
  };
  const titleBackgroundColor = (0, _react.useMemo)(() => isCustom ? '#128C72' : primarySkinColor, [isCustom, primarySkinColor]);
  const titleBackground = (0, _react.useMemo)(() => getGradientBackground(titleBackgroundColor), [titleBackgroundColor]);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.skillCardWrapper,
    "data-name": "skill-card-wrapper",
    "aria-label": ariaLabel
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "skill-title",
    className: _style.default.skillTitle,
    "aria-label": skillAriaLabel || skillTitle,
    style: {
      background: titleBackground
    }
  }, skillTitle), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "card-content-wrapper"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.questionReviseText,
    "data-name": "questions-to-revise-label",
    "aria-label": reviseAriaLabel || reviseLabel
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidInterfaceFeedbackInterfaceQuestionMark, {
    className: _style.default.questionReviseIcon,
    width: 16,
    height: 16
  }), reviseLabel), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.buttonWrapper,
    "data-name": "button-wrapper"
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, buttonProps))));
};
SkillCard.propTypes = process.env.NODE_ENV !== "production" ? _propTypes.default : {};
var _default = exports.default = SkillCard;
//# sourceMappingURL=index.js.map