Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/sla/form-page/sections/TimeFrameSection.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/layout', 'frontend-js-react-web$react', '../../../../shared/components/autocomplete/AutocompleteMultiSelect.es', '../../../../shared/components/form/FieldLabel.es', '../../../../shared/components/form/FormGroupWithStatus.es', '../SLAFormConstants.es', '../SLAFormPageProvider.es', '../util/slaFormUtil.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.TimeFrameSection = void 0;

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

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

    var _AutocompleteMultiSelect = require("../../../../shared/components/autocomplete/AutocompleteMultiSelect.es");

    var _FieldLabel = _interopRequireDefault(require("../../../../shared/components/form/FieldLabel.es"));

    var _FormGroupWithStatus = _interopRequireDefault(require("../../../../shared/components/form/FormGroupWithStatus.es"));

    var _SLAFormConstants = require("../SLAFormConstants.es");

    var _SLAFormPageProvider = require("../SLAFormPageProvider.es");

    var _slaFormUtil = require("../util/slaFormUtil.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 TimeFrameSection = function TimeFrameSection() {
      var _useContext = (0, _react.useContext)(_SLAFormPageProvider.SLAFormContext),
          changeNodesKeys = _useContext.changeNodesKeys,
          changePauseNodes = _useContext.changePauseNodes,
          errors = _useContext.errors,
          getNodeTags = _useContext.getNodeTags,
          getPauseNodeTags = _useContext.getPauseNodeTags,
          getPauseNodes = _useContext.getPauseNodes,
          getStartNodes = _useContext.getStartNodes,
          getStopNodes = _useContext.getStopNodes,
          nodes = _useContext.nodes,
          setErrors = _useContext.setErrors,
          _useContext$sla = _useContext.sla,
          pauseNodeKeys = _useContext$sla.pauseNodeKeys.nodeKeys,
          startNodeKeys = _useContext$sla.startNodeKeys.nodeKeys,
          stopNodeKeys = _useContext$sla.stopNodeKeys.nodeKeys;

      var checkNodeErrors = function checkNodeErrors(type) {
        return function (filteredNodeKeys) {
          if (type !== _SLAFormConstants.PAUSE_NODE_KEYS) {
            errors[type] = (0, _slaFormUtil.validateNodeKeys)(filteredNodeKeys);
          }

          setErrors(_objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, _SLAFormConstants.ALERT_MESSAGE, '')));
        };
      };

      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h3", {
          className: "sheet-subtitle"
        }, /*#__PURE__*/_react.default.createElement(_FieldLabel.default, {
          htmlFor: "slaTimeStart",
          text: Liferay.Language.get('time-frame').toUpperCase()
        })), /*#__PURE__*/_react.default.createElement("div", {
          className: "sheet-text"
        }, Liferay.Language.get('define-when-time-should-be-tracked-based-on-workflow-steps')), /*#__PURE__*/_react.default.createElement(_layout.default.Row, null, /*#__PURE__*/_react.default.createElement(_layout.default.Col, null, /*#__PURE__*/_react.default.createElement(_FormGroupWithStatus.default, {
          className: "form-group",
          error: errors[_SLAFormConstants.START_NODE_KEYS],
          htmlFor: "slaTimeStart",
          label: Liferay.Language.get('start'),
          requiredLabel: true
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "form-text"
        }, Liferay.Language.get('time-will-begin-counting-when')), /*#__PURE__*/_react.default.createElement(_AutocompleteMultiSelect.AutocompleteMultiSelect, {
          fieldId: "compositeId",
          fieldName: "desc",
          id: "start",
          items: getStartNodes(pauseNodeKeys, stopNodeKeys),
          onChange: changeNodesKeys(_SLAFormConstants.START_NODE_KEYS, nodes, checkNodeErrors(_SLAFormConstants.START_NODE_KEYS)),
          selectedItems: getNodeTags(getStartNodes(pauseNodeKeys, stopNodeKeys), startNodeKeys)
        })))), /*#__PURE__*/_react.default.createElement(_layout.default.Row, null, /*#__PURE__*/_react.default.createElement(_layout.default.Col, null, /*#__PURE__*/_react.default.createElement(_FormGroupWithStatus.default, {
          className: "form-group",
          htmlFor: "slaTimePause",
          label: Liferay.Language.get('pause')
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "form-text"
        }, Liferay.Language.get('time-wont-be-considered-when')), /*#__PURE__*/_react.default.createElement(_AutocompleteMultiSelect.AutocompleteMultiSelect, {
          fieldId: "compositeId",
          fieldName: "desc",
          id: "pause",
          items: getPauseNodes(startNodeKeys, stopNodeKeys),
          onChange: changePauseNodes(getPauseNodes(startNodeKeys, stopNodeKeys), checkNodeErrors(_SLAFormConstants.PAUSE_NODE_KEYS)),
          selectedItems: getPauseNodeTags(getPauseNodes(startNodeKeys, stopNodeKeys), pauseNodeKeys)
        })))), /*#__PURE__*/_react.default.createElement(_layout.default.Row, null, /*#__PURE__*/_react.default.createElement(_layout.default.Col, null, /*#__PURE__*/_react.default.createElement(_FormGroupWithStatus.default, {
          className: "form-group",
          error: errors[_SLAFormConstants.STOP_NODE_KEYS],
          htmlFor: "slaTimeStop",
          label: Liferay.Language.get('stop'),
          requiredLabel: true
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "form-text"
        }, Liferay.Language.get('time-will-stop-counting-when')), /*#__PURE__*/_react.default.createElement(_AutocompleteMultiSelect.AutocompleteMultiSelect, {
          fieldId: "compositeId",
          fieldName: "desc",
          id: "stop",
          items: getStopNodes(pauseNodeKeys, startNodeKeys),
          onChange: changeNodesKeys(_SLAFormConstants.STOP_NODE_KEYS, nodes, checkNodeErrors(_SLAFormConstants.STOP_NODE_KEYS)),
          selectedItems: getNodeTags(getStopNodes(pauseNodeKeys, startNodeKeys), stopNodeKeys)
        })))))
      );
    };

    exports.TimeFrameSection = TimeFrameSection;
    //# sourceMappingURL=TimeFrameSection.es.js.map
  }
});
//# sourceMappingURL=TimeFrameSection.es.js.map