Liferay.Loader.define("app-builder-workflow-web@1.0.40/js/components/workflow-info-bar/WorkflowInfoBar.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/label', '@frontend-taglib-clay$clayui/tooltip', 'app-builder-web/js/utils/utils.es', 'frontend-js-react-web$classnames', 'frontend-js-react-web$react', '../../../css/WorkflowInfoBar.scss'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = WorkflowInfo;

    var _label = _interopRequireDefault(require("@frontend-taglib-clay$clayui/label"));

    var _tooltip = require("@frontend-taglib-clay$clayui/tooltip");

    var _utils = require("app-builder-web/js/utils/utils.es");

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

    require("../../../css/WorkflowInfoBar.scss");

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    function WorkflowInfo(_ref) {
      var _assignees$, _assignees$2;

      var _ref$assignees = _ref.assignees,
          assignees = _ref$assignees === void 0 ? [] : _ref$assignees,
          appVersion = _ref.appVersion,
          className = _ref.className,
          completed = _ref.completed,
          _ref$hideColumns = _ref.hideColumns,
          hideColumns = _ref$hideColumns === void 0 ? [] : _ref$hideColumns,
          _ref$taskNames = _ref.taskNames,
          taskNames = _ref$taskNames === void 0 ? [] : _ref$taskNames,
          _ref$tasks = _ref.tasks,
          tasks = _ref$tasks === void 0 ? [] : _ref$tasks;
      var emptyValue = '--';
      var assignee = ((_assignees$ = assignees[0]) === null || _assignees$ === void 0 ? void 0 : _assignees$.name) || emptyValue;
      var status = completed ? /*#__PURE__*/_react.default.createElement(_label.default, {
        displayType: "success"
      }, Liferay.Language.get('completed')) : /*#__PURE__*/_react.default.createElement(_label.default, {
        displayType: "info"
      }, Liferay.Language.get('pending'));
      var stepName = taskNames[0] || emptyValue;

      if (((_assignees$2 = assignees[0]) === null || _assignees$2 === void 0 ? void 0 : _assignees$2.id) === -1) {
        var _ref2 = tasks.find(function (_ref3) {
          var name = _ref3.name;
          return name === stepName;
        }) || {},
            _ref2$appWorkflowRole = _ref2.appWorkflowRoleAssignments,
            roles = _ref2$appWorkflowRole === void 0 ? [] : _ref2$appWorkflowRole;

        var roleNames = roles.map(function (_ref4) {
          var roleName = _ref4.roleName;
          return roleName;
        });
        assignee = roleNames.length ? (0, _utils.concatValues)(roleNames) : emptyValue;
      }

      var tooltipProps = {
        'data-tooltip-align': 'bottom',
        'data-tooltip-delay': '0'
      };
      var items = [{
        label: Liferay.Language.get('status'),
        show: !hideColumns.includes('status'),
        value: status
      }, {
        label: Liferay.Language.get('step'),
        show: !hideColumns.includes('step'),
        value: stepName
      }, {
        label: Liferay.Language.get('assignee'),
        show: !hideColumns.includes('assignee'),
        tooltip: _objectSpread({
          title: assignee
        }, tooltipProps),
        value: assignee
      }, {
        label: Liferay.Language.get('version'),
        show: !hideColumns.includes('status'),
        tooltip: _objectSpread({
          title: Liferay.Language.get('app-version')
        }, tooltipProps),
        value: appVersion !== null && appVersion !== void 0 ? appVersion : '1.0'
      }];
      return (/*#__PURE__*/_react.default.createElement(_tooltip.ClayTooltipProvider, null, /*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('workflow-info-bar', className)
        }, items.map(function (_ref5, index) {
          var label = _ref5.label,
              show = _ref5.show,
              _ref5$tooltip = _ref5.tooltip,
              tooltip = _ref5$tooltip === void 0 ? {} : _ref5$tooltip,
              value = _ref5.value;
          return show && /*#__PURE__*/_react.default.createElement("div", _extends({
            className: "info-item",
            key: index
          }, tooltip), /*#__PURE__*/_react.default.createElement("span", {
            className: "font-weight-bold text-secondary"
          }, "".concat(label, ": ")), value);
        })))
      );
    }
    //# sourceMappingURL=WorkflowInfoBar.es.js.map
  }
});
//# sourceMappingURL=WorkflowInfoBar.es.js.map