"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _tag = _interopRequireDefault(require("../../atom/tag"));
var _buttonLink = _interopRequireDefault(require("../../atom/button-link"));
var _style = _interopRequireDefault(require("./style.css"));
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 LearningPrioritySetupItem = (props, context) => {
  const {
    priorityRef,
    id,
    title,
    courses = null,
    type,
    'aria-label': ariaLabel,
    onRemove
  } = props;
  const {
    translate
  } = context;
  const handleRemovePriority = (0, _react.useCallback)(() => onRemove(priorityRef, type), [priorityRef, type, onRemove]);
  const handleTypeTranslate = itemType => {
    switch (itemType) {
      case 'skill':
        return translate('skill');
      case 'playlist':
        return translate('playlist');
      case 'certificate':
        return translate('certificate');
    }
  };
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.container,
    "aria-label": ariaLabel,
    "data-name": `learning-priority-setup-item-${id}`
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.containerInfos
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.titleWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.title,
    "data-name": "learning-priority-setup-item-title"
  }, title), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_tag.default, {
    label: handleTypeTranslate(type),
    size: 'S'
  }))), courses !== null ? /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.courses
  }, `${courses} ${translate('courses')}`) : null), /*#__PURE__*/_react.default.createElement(_buttonLink.default, {
    type: "primary",
    customStyle: {
      width: 'fit-content',
      backgroundColor: 'transparent'
    },
    hoverBackgroundColor: "#EAEAEB",
    icon: {
      position: 'left',
      faIcon: {
        name: 'trash',
        color: '#515161',
        size: 16
      }
    },
    onClick: handleRemovePriority,
    "data-testid": `button-link-trash-${priorityRef}`
  }));
};
LearningPrioritySetupItem.contextTypes = {
  translate: _provider.default.childContextTypes.translate
};
LearningPrioritySetupItem.propTypes = process.env.NODE_ENV !== "production" ? {
  'aria-label': _propTypes.default.string,
  id: _propTypes.default.string,
  priorityRef: _propTypes.default.string,
  title: _propTypes.default.string,
  courses: _propTypes.default.number,
  type: _propTypes.default.oneOf(['skill', 'playlist', 'certificate']),
  onRemove: _propTypes.default.func
} : {};
var _default = exports.default = LearningPrioritySetupItem;
//# sourceMappingURL=index.js.map