"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StepperItem = StepperItem;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _faCheck = require("@fortawesome/free-solid-svg-icons/faCheck");
var _faXmark = require("@fortawesome/free-solid-svg-icons/faXmark");
var _fontAwesomeIcon = require("../font-awesome-icon");
var _truncateWithTooltip = require("../truncate-with-tooltip");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function StepperItem({
  icon,
  isCompleted,
  isRectHidden,
  label,
  helperText,
  isActive,
  onClick,
  stepKey,
  testId,
  isVisited,
  isDisabled,
  hasErrored
}) {
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
    className: "stepper-item",
    "test-id": `${testId}-${stepKey}`,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
      className: "button",
      onClick: () => onClick(stepKey),
      disabled: isDisabled,
      "test-id": `${testId}-${stepKey}-item`,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: (0, _classnames.default)('stepper-item-icon', {
          active: isActive,
          completed: isCompleted,
          visited: isVisited,
          disabled: isDisabled,
          errored: hasErrored
        }),
        "test-id": `${testId}-${stepKey}-icon-btn`,
        children: hasErrored ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
          icon: _faXmark.faXmark
        }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
          icon: isCompleted || isVisited ? _faCheck.faCheck : icon
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
        className: "stepper-item-text-wrapper",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
          className: "stepper-item-label",
          "test-id": `${testId}-${stepKey}-item-label`,
          children: label
        }), helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
          className: (0, _classnames.default)('stepper-item-helper-text', {
            errored: hasErrored
          }),
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
            "test-id": `${testId}-${stepKey}-helper-text`,
            children: helperText
          })
        })]
      })]
    }), !isRectHidden && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "stepper-item-rect",
      "test-id": `${testId}-${stepKey}-rect`
    })]
  });
}