Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/process-metrics/ProcessMetricsContainer.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/layout', 'frontend-js-react-web$react', 'portal-workflow-metrics-web$react-router-dom', '../../shared/components/header/HeaderKebab.es', '../../shared/components/navbar-tabs/NavbarTabs.es', '../../shared/components/router/queryString.es', '../../shared/components/router/routerUtil.es', '../../shared/hooks/useProcessTitle.es', '../AppContext.es', '../filter/hooks/useTimeRangeFetch.es', './SLAInfo.es', './completion-velocity/CompletionVelocityCard.es', './performance-by-assignee-card/PerformanceByAssigneeCard.es', './performance-by-step-card/PerformanceByStepCard.es', './process-items/CompletedItemsCard.es', './process-items/PendingItemsCard.es', './workload-by-assignee-card/WorkloadByAssigneeCard.es', './workload-by-step-card/WorkloadByStepCard.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

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

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

    var _reactRouterDom = require("portal-workflow-metrics-web$react-router-dom");

    var _HeaderKebab = _interopRequireDefault(require("../../shared/components/header/HeaderKebab.es"));

    var _NavbarTabs = _interopRequireDefault(require("../../shared/components/navbar-tabs/NavbarTabs.es"));

    var _queryString = require("../../shared/components/router/queryString.es");

    var _routerUtil = require("../../shared/components/router/routerUtil.es");

    var _useProcessTitle = require("../../shared/hooks/useProcessTitle.es");

    var _AppContext = require("../AppContext.es");

    var _useTimeRangeFetch = require("../filter/hooks/useTimeRangeFetch.es");

    var _SLAInfo = _interopRequireDefault(require("./SLAInfo.es"));

    var _CompletionVelocityCard = _interopRequireDefault(require("./completion-velocity/CompletionVelocityCard.es"));

    var _PerformanceByAssigneeCard = _interopRequireDefault(require("./performance-by-assignee-card/PerformanceByAssigneeCard.es"));

    var _PerformanceByStepCard = _interopRequireDefault(require("./performance-by-step-card/PerformanceByStepCard.es"));

    var _CompletedItemsCard = _interopRequireDefault(require("./process-items/CompletedItemsCard.es"));

    var _PendingItemsCard = _interopRequireDefault(require("./process-items/PendingItemsCard.es"));

    var _WorkloadByAssigneeCard = _interopRequireDefault(require("./workload-by-assignee-card/WorkloadByAssigneeCard.es"));

    var _WorkloadByStepCard = _interopRequireDefault(require("./workload-by-step-card/WorkloadByStepCard.es"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    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;
    }

    var DashboardTab = function DashboardTab(props) {
      return (/*#__PURE__*/_react.default.createElement(_layout.default.ContainerFluid, null, /*#__PURE__*/_react.default.createElement(_layout.default.Row, null, /*#__PURE__*/_react.default.createElement(_layout.default.Col, {
          className: "p-0",
          md: "9"
        }, /*#__PURE__*/_react.default.createElement(_PendingItemsCard.default, props), /*#__PURE__*/_react.default.createElement(_WorkloadByStepCard.default, props)), /*#__PURE__*/_react.default.createElement(_layout.default.Col, {
          className: "p-0",
          md: "3"
        }, /*#__PURE__*/_react.default.createElement(_WorkloadByAssigneeCard.default, props))))
      );
    };

    var PerformanceTab = function PerformanceTab(props) {
      (0, _useTimeRangeFetch.useTimeRangeFetch)();
      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CompletedItemsCard.default, props), /*#__PURE__*/_react.default.createElement(_CompletionVelocityCard.default, props), /*#__PURE__*/_react.default.createElement(_PerformanceByStepCard.default, props), /*#__PURE__*/_react.default.createElement(_PerformanceByAssigneeCard.default, props))
      );
    };

    var ProcessMetricsContainer = function ProcessMetricsContainer(_ref) {
      var history = _ref.history,
          processId = _ref.processId,
          query = _ref.query;

      var _useContext = (0, _react.useContext)(_AppContext.AppContext),
          defaultDelta = _useContext.defaultDelta;

      (0, _useProcessTitle.useProcessTitle)(processId);
      var dashboardTab = (0, _react.useMemo)(function () {
        return {
          key: 'dashboard',
          name: Liferay.Language.get('dashboard'),
          params: {
            page: 1,
            pageSize: defaultDelta,
            processId: processId,
            sort: 'overdueInstanceCount:asc'
          },
          path: '/metrics/:processId/dashboard/:pageSize/:page/:sort'
        };
      }, // eslint-disable-next-line react-hooks/exhaustive-deps
      [processId]);
      var performanceTab = (0, _react.useMemo)(function () {
        return {
          key: 'performance',
          name: Liferay.Language.get('performance'),
          params: {
            processId: processId
          },
          path: '/metrics/:processId/performance'
        };
      }, [processId]);

      if (history.location.pathname === "/metrics/".concat(processId)) {
        var pathname = (0, _routerUtil.getPathname)(dashboardTab.params, dashboardTab.path);
        var search = (0, _queryString.stringify)(_objectSpread(_objectSpread({}, (0, _queryString.parse)(query)), {}, {
          filters: {
            taskNames: ['allSteps']
          }
        }));
        history.replace({
          pathname: pathname,
          search: search
        });
      }

      return (/*#__PURE__*/_react.default.createElement("div", {
          className: "workflow-process-dashboard"
        }, /*#__PURE__*/_react.default.createElement(_HeaderKebab.default, {
          kebabItems: [{
            label: Liferay.Language.get('sla-settings'),
            link: "/sla/".concat(processId, "/list/").concat(defaultDelta, "/1")
          }]
        }), /*#__PURE__*/_react.default.createElement(_NavbarTabs.default, {
          tabs: [dashboardTab, performanceTab]
        }), /*#__PURE__*/_react.default.createElement(_SLAInfo.default, {
          processId: processId
        }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Switch, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
          exact: true,
          path: dashboardTab.path,
          render: (0, _routerUtil.withParams)(DashboardTab)
        }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
          exact: true,
          path: performanceTab.path,
          render: (0, _routerUtil.withParams)(PerformanceTab)
        })))
      );
    };

    var _default = ProcessMetricsContainer;
    exports.default = _default;
    //# sourceMappingURL=ProcessMetricsContainer.es.js.map
  }
});
//# sourceMappingURL=ProcessMetricsContainer.es.js.map