"use strict";

exports.__esModule = true;
exports.default = void 0;
var _uniqueId2 = _interopRequireDefault(require("lodash/fp/uniqueId"));
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _icon = _interopRequireDefault(require("../../atom/icon"));
var _tooltip = _interopRequireDefault(require("../../atom/tooltip"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _catalogSection = _interopRequireDefault(require("../../atom/catalog-section"));
var _style = _interopRequireDefault(require("./style.css"));
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; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const DisciplineAssociatedSkills = (props, context) => {
  const {
    translate
  } = context;
  const {
    skills = [],
    onSkillClick
  } = props;
  const AnchorElement = (0, _react.useCallback)(skill => /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.chipFocusedContent
  }, skill.focused ? /*#__PURE__*/_react.default.createElement(_icon.default, {
    iconName: "bullseye-arrow",
    size: {
      faSize: 12,
      wrapperSize: 12
    }
  }) : null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.chipFocusedContentText
  }, skill.locale)), []);
  const TooltipContentElement = (0, _react.useCallback)(skill => /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.tooltipContentWrapper
  }, skill.focused ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("b", null, translate('skill_focused_chip_tooltip'))) : null, /*#__PURE__*/_react.default.createElement("div", null, skill.locale)), [translate]);
  return !(0, _isEmpty2.default)(skills) ? /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "discipline-associated-skills",
    className: _style.default.associatedSkillsWrapper
  }, /*#__PURE__*/_react.default.createElement(_catalogSection.default, {
    title: translate('associated_skills')
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.chipsWrapper
  }, skills.map(skill => {
    function handleSkillClick() {
      onSkillClick(skill.ref);
    }
    function handleAnchorElement() {
      return AnchorElement(skill);
    }
    function handleTooltipContentElement() {
      return TooltipContentElement(skill);
    }
    return /*#__PURE__*/_react.default.createElement("div", {
      key: (0, _uniqueId2.default)(),
      className: (0, _classnames.default)(_style.default.chipWrapper, skill.focused && _style.default.chipWrapperFocused),
      onClick: handleSkillClick
    }, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
      AnchorElement: handleAnchorElement,
      fontSize: 12,
      delayHide: 0,
      iconContainerClassName: _style.default.infoIconTooltip,
      tooltipClassName: skill.focused ? _style.default.tooltipSkillFocused : _style.default.tooltip,
      TooltipContent: handleTooltipContentElement,
      closeToolTipInformationTextAriaLabel: translate('close_tooltip_information')
    }));
  })))) : null;
};
DisciplineAssociatedSkills.contextTypes = {
  translate: _provider.default.childContextTypes.translate
};
DisciplineAssociatedSkills.propTypes = process.env.NODE_ENV !== "production" ? {
  skills: _propTypes.default.arrayOf(_propTypes.default.shape({
    ref: _propTypes.default.string,
    locale: _propTypes.default.string,
    focused: _propTypes.default.bool
  })),
  onSkillClick: _propTypes.default.func
} : {};
var _default = exports.default = DisciplineAssociatedSkills;
//# sourceMappingURL=index.js.map