function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }

function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }

function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }

function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }

(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["additional-settings-main-additional-network-simulation-additional-network-simulation-module"], {
  /***/
  "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.html":
  /*!**************************************************************************************************************************************************************************!*\
    !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.html ***!
    \**************************************************************************************************************************************************************************/

  /*! exports provided: default */

  /***/
  function _node_modules_rawLoader_dist_cjsJs_src_app_pages_scenario_additionalSettingsMain_additionalNetworkSimulation_additionalNetworkSimulationComponentHtml(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "\n<div class=\"py-10 px-5\">\n    <div class=\"p-grid p-align-center\">\n        <div class=\"ui-g-12\">\n            <p-checkbox name=\"group1\" value=\"0\" [(ngModel)]=\"chkIntSimulation\" [disabled]=\"enableDisKeywordList.WAN_ENV\"\n                binary=\"true\" label=\"Enable Network Simulation\"></p-checkbox>\n        </div>\n    </div>\n    <div class=\"p-grid p-align-center\">\n        <div class=\"ui-g-2\">Network Jitter <strong>Forward</strong></div>\n        <div class=\"p-col-1\">\n            <div class=\"ui-inputgroup\">\n                <input type=\"number\" pInputText min=\"0\" [disabled]=\"!chkIntSimulation ||enableDisKeywordList.WAN_JITTER\"\n                    [(ngModel)]=\"txtFwdJitter\" class=\"w-100-p\" />\n                <span class=\"ui-inputgroup-addon\">%</span>\n            </div>\n        </div>\n        <div class=\"p-col-2 text-right\">Reverse</div>\n        <div class=\"p-col-1\">\n            <div class=\"ui-inputgroup\">\n                <input type=\"number\" pInputText min=\"0\" [disabled]=\"!chkIntSimulation ||enableDisKeywordList.WAN_JITTER\"\n                    [(ngModel)]=\"txtReverseJitter\" class=\"w-100-p\" />\n                <span class=\"ui-inputgroup-addon\">ms</span>\n            </div>\n        </div>\n    </div>\n\n    <div class=\"p-grid p-align-center\">\n        <div class=\"ui-g-2\"> Adverse Factor <strong>Latency</strong></div>\n        <div class=\"p-col-1\">\n            <div class=\"ui-inputgroup\">\n                <input type=\"number\" pInputText min=\"0\"\n                    [disabled]=\"!chkIntSimulation  ||enableDisKeywordList.ADVERSE_FACTOR\" [(ngModel)]=\"txtLatency\"\n                    class=\"w-100-p\" />\n                <span class=\"ui-inputgroup-addon\">%</span>\n            </div>\n        </div>\n\n        <div class=\"p-col-2 text-right\">Loss</div>\n        <div class=\"p-col-1\">\n            <div class=\"ui-inputgroup\">\n                <input type=\"number\" pInputText min=\"0\"\n                    [disabled]=\"!chkIntSimulation ||enableDisKeywordList.ADVERSE_FACTOR\" [(ngModel)]=\"txtLoss\"\n                    class=\"w-100-p\" />\n                <span class=\"ui-inputgroup-addon\">%</span>\n            </div>\n        </div>\n    </div>\n</div>";
    /***/
  },

  /***/
  "./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.scss":
  /*!************************************************************************************************************************************!*\
    !*** ./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.scss ***!
    \************************************************************************************************************************************/

  /*! exports provided: default */

  /***/
  function _src_app_pages_scenario_additionalSettingsMain_additionalNetworkSimulation_additionalNetworkSimulationComponentScss(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "";
    /***/
  },

  /***/
  "./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.ts":
  /*!**********************************************************************************************************************************!*\
    !*** ./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.ts ***!
    \**********************************************************************************************************************************/

  /*! exports provided: AdditionalNetworkSimulationComponent */

  /***/
  function _src_app_pages_scenario_additionalSettingsMain_additionalNetworkSimulation_additionalNetworkSimulationComponentTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "AdditionalNetworkSimulationComponent", function () {
      return AdditionalNetworkSimulationComponent;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var _constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! ../../constants/scen-keyword-constants */
    "./src/app/pages/scenario/constants/scen-keyword-constants.ts");
    /* harmony import */


    var _service_scen_keyword_definition_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! ../../service/scen-keyword-definition.service */
    "./src/app/pages/scenario/service/scen-keyword-definition.service.ts");
    /* harmony import */


    var _service_additional_setting_data_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! ../../service/additional-setting-data-service */
    "./src/app/pages/scenario/service/additional-setting-data-service.ts");
    /* harmony import */


    var _service_scenario_http_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! ../../service/scenario-http.service */
    "./src/app/pages/scenario/service/scenario-http.service.ts");
    /* harmony import */


    var _service_sch_schedule_data_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! ../../service/sch-schedule-data.service */
    "./src/app/pages/scenario/service/sch-schedule-data.service.ts");
    /* harmony import */


    var _service_scenario_utils_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! ../../service/scenario-utils.service */
    "./src/app/pages/scenario/service/scenario-utils.service.ts");
    /* harmony import */


    var _interface_scenario_state__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
    /*! ../../interface/scenario-state */
    "./src/app/pages/scenario/interface/scenario-state.ts");

    var AdditionalNetworkSimulationComponent = /*#__PURE__*/function () {
      function AdditionalNetworkSimulationComponent(keywordDefinition, dataService, scenUtilsService, schData, scenarioHttpService) {
        var _this = this;

        _classCallCheck(this, AdditionalNetworkSimulationComponent);

        this.keywordDefinition = keywordDefinition;
        this.dataService = dataService;
        this.scenUtilsService = scenUtilsService;
        this.schData = schData;
        this.scenarioHttpService = scenarioHttpService;
        this.enableDisKeywordList = {
          "ADVERSE_FACTOR": false,
          "WAN_JITTER": false,
          "WAN_ENV": false
        };
        this.screenKeywordList = Object.keys(this.enableDisKeywordList);
        this.chkIntSimulation = false;
        this.txtFwdJitter = 0;
        this.txtReverseJitter = 0;
        this.txtLatency = 1;
        this.txtLoss = 1;
        this.arrKeywordData = {}; //main obj of screen Keyword data.

        this.saveSubscription = this.scenUtilsService.$saveGroupbasedSetting.subscribe(function (res) {
          if (_this.validateAndSetKeywordArray()) {
            _this.scenUtilsService.saveComponentData(0, {});
          }
        });
      }

      return _createClass(AdditionalNetworkSimulationComponent, [{
        key: "canDeactivate",
        value: function canDeactivate() {
          //insert logic to check if there are pending changes here;
          //returning true will navigate without confirmation
          //returning false will show a confirm alert before navigating away
          try {
            if (this.validateAndSetKeywordArray() == false) {
              return false;
            }
          } catch (e) {
            console.log("can Deactivate in compponents", e);
          }

          return true;
        }
        /**
          * This method is called, when user navigate from one component to another, and want to save data in conf file before navigation.
          */

      }, {
        key: "setDataInConf",
        value: function setDataInConf() {
          return true;
        }
      }, {
        key: "ngOnInit",
        value: function ngOnInit() {
          this.arrKeywordData = this.keywordDefinition.chkAndGetKeywrdDataWithAdditionalKeys(this.screenKeywordList);

          if (this.keywordDefinition.isArrKeywordDataEmpty(this.arrKeywordData, this.screenKeywordList)) {
            this.keywordDefinition.setRequestKeywordListInBody(this.screenKeywordList, "");
            var obj = this.keywordDefinition.getRequestJsonParm();
            this.getKeywordData(obj); //error case

            if (this.arrKeywordData == null) this.arrKeywordData = {};
          } else this.fillDataInComp();
        }
      }, {
        key: "getKeywordData",
        value: function getKeywordData(obj) {
          var _this2 = this;

          this.scenarioHttpService.getDefaultKeywordData(obj).subscribe(function (state) {
            if (state instanceof _interface_scenario_state__WEBPACK_IMPORTED_MODULE_8__["GetDefaultKeywordDataLoadingState"]) {
              return;
            }

            if (state instanceof _interface_scenario_state__WEBPACK_IMPORTED_MODULE_8__["GetDefaultKeywordDataLoadedState"]) {
              _this2.keywordDefinition.setArrKeywordData(_this2.arrKeywordData, state.data, _this2.keywordDefinition.mergeKeywordData);

              _this2.fillDataInComp();

              return;
            }
          }, function (state) {
            console.log(state.error);
            return;
          });
        }
      }, {
        key: "fillDataInComp",
        value: function fillDataInComp() {
          var keys = Object.keys(this.arrKeywordData);

          for (var i = 0; i < keys.length; i++) //keyword iteration
          {
            var strKeyword = keys[i];
            var keyObj = this.arrKeywordData[strKeyword];
            var dataObj = keyObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["KEYWORD_DATA_KEY"].DATA];
            this.enableDisKeywordList[strKeyword] = this.dataService.isCompEnable(this.dataService.getScenMode(), keyObj, strKeyword);
            if (dataObj == undefined) continue;
            if (dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]] == undefined) continue;
            var arrVal = dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]][0];
            if (arrVal == undefined) continue;

            if (strKeyword == 'WAN_ENV') //SSL_CERT_FILE_PATH
              {
                if (arrVal[0] == '0') this.chkIntSimulation = false;else this.chkIntSimulation = true;
              } else if (strKeyword == 'WAN_JITTER') {
              this.txtFwdJitter = arrVal[0] == undefined ? 0 : arrVal[0];
              this.txtReverseJitter = arrVal[1] == undefined ? 0 : arrVal[1];
            } else if (strKeyword == 'ADVERSE_FACTOR') {
              this.txtLatency = arrVal[0] == undefined ? 1 : arrVal[0];
              this.txtLoss = arrVal[1] == undefined ? 1 : arrVal[1];
            }
          }
        }
      }, {
        key: "validateAndSetKeywordArray",
        value: function validateAndSetKeywordArray() {
          /**vallidation  */
          if (this.valAndSetAdvFactor() == false) return false;
          if (this.valAndSetJitter() == false) return false;
          this.setChkBoxData("WAN_ENV", this.chkIntSimulation); //All validation success

          for (var i = 0; i < this.screenKeywordList.length; i++) {
            this.schData.saveKeywordData[this.screenKeywordList[i]] = this.arrKeywordData[this.screenKeywordList[i]].data;
          }

          return true;
        }
      }, {
        key: "valAndSetJitter",
        value: function valAndSetJitter() {
          var tempSumMail = [];

          if (this.chkIntSimulation == true) {
            if (this.txtFwdJitter < 0 || this.txtFwdJitter == null) {
              this.scenUtilsService.errorMessage('Please enter valid forword jitter');
              return false;
            }

            tempSumMail.push(this.txtFwdJitter);

            if (this.txtReverseJitter < 0 || this.txtReverseJitter == null) {
              this.scenUtilsService.errorMessage('Please enter valid reverse factor');
              return false;
            }

            tempSumMail.push(this.txtReverseJitter);
          }

          this.setArrayWithKeyWord('WAN_JITTER', tempSumMail);
          return true;
        }
      }, {
        key: "valAndSetAdvFactor",
        value: function valAndSetAdvFactor() {
          var tempSumMail = [];

          if (this.chkIntSimulation == true) {
            if (this.txtLatency < 0 || this.txtLatency == null) {
              this.scenUtilsService.errorMessage('Please enter valid latency factor');
              return false;
            }

            tempSumMail.push(this.txtLatency);

            if (this.txtLoss < 0 || this.txtLoss == null) {
              this.scenUtilsService.errorMessage('Please enter valid loss factor');
              return false;
            }

            tempSumMail.push(this.txtLoss);
          }

          this.setArrayWithKeyWord('ADVERSE_FACTOR', tempSumMail);
          return true;
        }
      }, {
        key: "setChkBoxData",
        value: function setChkBoxData(keyword, obj) {
          var temObj = [];

          if (obj) {
            temObj.push(1);
          } else temObj.push(0);

          this.setArrayWithKeyWord(keyword, temObj);
        }
      }, {
        key: "setArrayWithKeyWord",
        value: function setArrayWithKeyWord(keyword, temObj) {
          var dataObj = this.arrKeywordData[keyword][_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["KEYWORD_DATA_KEY"].DATA];

          if (dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]] != undefined) {
            dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]] = [];

            dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]].push(temObj);
          } else {
            dataObj[_constants_scen_keyword_constants__WEBPACK_IMPORTED_MODULE_2__["GLOBAL_KEY"]] = [temObj];
          }
        }
      }, {
        key: "ngOnDestroy",
        value: function ngOnDestroy() {
          if (this.saveSubscription) this.saveSubscription.unsubscribe();
        }
      }]);
    }();

    AdditionalNetworkSimulationComponent.ctorParameters = function () {
      return [{
        type: _service_scen_keyword_definition_service__WEBPACK_IMPORTED_MODULE_3__["ScenKeywordDefinitionService"]
      }, {
        type: _service_additional_setting_data_service__WEBPACK_IMPORTED_MODULE_4__["AdditionalSettingsDataService"]
      }, {
        type: _service_scenario_utils_service__WEBPACK_IMPORTED_MODULE_7__["ScenarioUtilsService"]
      }, {
        type: _service_sch_schedule_data_service__WEBPACK_IMPORTED_MODULE_6__["SchScheduleDataService"]
      }, {
        type: _service_scenario_http_service__WEBPACK_IMPORTED_MODULE_5__["ScenarioHttpService"]
      }];
    };

    AdditionalNetworkSimulationComponent = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
      selector: 'app-additional-network-simulation',
      template: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! raw-loader!./additional-network-simulation.component.html */
      "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.html"))["default"],
      styles: [Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! ./additional-network-simulation.component.scss */
      "./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.scss"))["default"]]
    })], AdditionalNetworkSimulationComponent);
    /***/
  },

  /***/
  "./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.module.ts":
  /*!*******************************************************************************************************************************!*\
    !*** ./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.module.ts ***!
    \*******************************************************************************************************************************/

  /*! exports provided: AdditionalNetworkSimulationModule */

  /***/
  function _src_app_pages_scenario_additionalSettingsMain_additionalNetworkSimulation_additionalNetworkSimulationModuleTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "AdditionalNetworkSimulationModule", function () {
      return AdditionalNetworkSimulationModule;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var _angular_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! @angular/common */
    "./node_modules/@angular/common/__ivy_ngcc__/fesm2015/common.js");
    /* harmony import */


    var _additional_network_simulation_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! ./additional-network-simulation.component */
    "./src/app/pages/scenario/additional-settings-main/additional-network-simulation/additional-network-simulation.component.ts");
    /* harmony import */


    var primeng__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! primeng */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng.js");
    /* harmony import */


    var _angular_forms__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! @angular/forms */
    "./node_modules/@angular/forms/__ivy_ngcc__/fesm2015/forms.js");
    /* harmony import */


    var _angular_router__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! @angular/router */
    "./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js");
    /* harmony import */


    var _interface_scenario_routing_guard__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! ../../interface/scenario-routing-guard */
    "./src/app/pages/scenario/interface/scenario-routing-guard.ts");

    var route = [{
      path: '',
      component: _additional_network_simulation_component__WEBPACK_IMPORTED_MODULE_3__["AdditionalNetworkSimulationComponent"],
      canDeactivate: [_interface_scenario_routing_guard__WEBPACK_IMPORTED_MODULE_7__["ScenRoutingGuard"]]
    }];

    var AdditionalNetworkSimulationModule = /*#__PURE__*/_createClass(function AdditionalNetworkSimulationModule() {
      _classCallCheck(this, AdditionalNetworkSimulationModule);
    });

    AdditionalNetworkSimulationModule = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["NgModule"])({
      declarations: [_additional_network_simulation_component__WEBPACK_IMPORTED_MODULE_3__["AdditionalNetworkSimulationComponent"]],
      imports: [_angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["FileUploadModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["DialogModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_5__["FormsModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["DropdownModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["ButtonModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["AccordionModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["BreadcrumbModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["SelectButtonModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["InputTextModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["MultiSelectModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["TableModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["CardModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["CheckboxModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["MessageModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["RadioButtonModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["SpinnerModule"], primeng__WEBPACK_IMPORTED_MODULE_4__["TooltipModule"], _angular_router__WEBPACK_IMPORTED_MODULE_6__["RouterModule"].forChild(route)],
      exports: [_additional_network_simulation_component__WEBPACK_IMPORTED_MODULE_3__["AdditionalNetworkSimulationComponent"]]
    })], AdditionalNetworkSimulationModule);
    /***/
  }
}]);