(window["webpackJsonpLIS"] = window["webpackJsonpLIS"] || []).push([["vendors~toubiz-events"],{

/***/ "./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js":
/*!**************************************************************************************************!*\
  !*** ./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js ***!
  \**************************************************************************************************/
/*! exports provided: EventsResultsListController */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EventsResultsListController\", function() { return EventsResultsListController; });\n/* harmony import */ var _common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../common/selector-utilities */ \"./node_modules/@newland/assets-neos/Scripts/common/selector-utilities.js\");\n/* harmony import */ var _common_results_list_controller_class__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/results-list-controller.class */ \"./node_modules/@newland/assets-neos/Scripts/common/results-list-controller.class.js\");\n/* harmony import */ var _common_date_formatting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/date-formatting */ \"./node_modules/@newland/assets-neos/Scripts/common/date-formatting.js\");\n/* harmony import */ var _nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nimius/event-utility */ \"./node_modules/@nimius/event-utility/index.js\");\nfunction _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); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _createForOfIteratorHelper(o) { if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\nvar ATTRIBUTE = Object.freeze({\n  DATE_PICKER: 'data-toubiz-date-picker',\n  DATE_PICKER_BUTTON: 'data-toubiz-date-picker-button',\n  DATE_LINK: 'data-toubiz-events-date',\n  FROM_DATE: 'data-toubiz-events-from-date',\n  TO_DATE: 'data-toubiz-events-to-date',\n  ACTIVE_CLASSES: 'data-toubiz-events-date.active-classes',\n  INACTIVE_CLASSES: 'data-toubiz-events-date.inactive-classes'\n});\nvar EventsResultsListController = /*#__PURE__*/function (_ResultsListControlle) {\n  _inherits(EventsResultsListController, _ResultsListControlle);\n\n  var _super = _createSuper(EventsResultsListController);\n\n  function EventsResultsListController() {\n    _classCallCheck(this, EventsResultsListController);\n\n    return _super.apply(this, arguments);\n  }\n\n  _createClass(EventsResultsListController, [{\n    key: \"onInitialize\",\n\n    /** @protected */\n    value: function onInitialize() {\n      this.initializeEventSpecificBehaviour();\n    }\n    /** @protected */\n\n  }, {\n    key: \"onReinitialize\",\n    value: function onReinitialize() {\n      this.initializeEventSpecificBehaviour();\n    }\n    /** @private */\n\n  }, {\n    key: \"initializeEventSpecificBehaviour\",\n    value: function initializeEventSpecificBehaviour() {\n      this.initializeDateLinks();\n      this.initializeDatePicker();\n      this.updateDateFields();\n      this.isDateSelection = true;\n    }\n    /** @private */\n\n  }, {\n    key: \"updateDateFields\",\n    value: function updateDateFields() {\n      this.fromDate = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.FROM_DATE));\n      this.toDate = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.TO_DATE));\n    }\n    /** @private */\n\n  }, {\n    key: \"initializeDateLinks\",\n    value: function initializeDateLinks() {\n      var _this = this;\n\n      this.dateLinks = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_LINK), true);\n\n      var _iterator = _createForOfIteratorHelper(this.dateLinks),\n          _step;\n\n      try {\n        var _loop = function _loop() {\n          var link = _step.value;\n          link.addEventListener('click', function (event) {\n            event.preventDefault();\n\n            _this.updateDates(link.getAttribute(ATTRIBUTE.DATE_LINK), link.getAttribute(ATTRIBUTE.DATE_LINK), [link]);\n          });\n        };\n\n        for (_iterator.s(); !(_step = _iterator.n()).done;) {\n          _loop();\n        }\n      } catch (err) {\n        _iterator.e(err);\n      } finally {\n        _iterator.f();\n      }\n    }\n    /** @private */\n\n  }, {\n    key: \"initializeDatePicker\",\n    value: function initializeDatePicker() {\n      var _this2 = this;\n\n      this.picker = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER));\n\n      if (!this.picker) {\n        return;\n      }\n\n      this.pickerButton = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER_BUTTON));\n      this.picker.addEventListener('toubiz-date-picker.change', function (event) {\n        return _this2.updateDates(event.detail.range.start, event.detail.range.end, [_this2.picker, _this2.pickerButton]);\n      });\n    }\n  }, {\n    key: \"resetDateSelection\",\n    value: function resetDateSelection() {\n      this.fromDate.value = '';\n      this.toDate.value = '';\n      Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(this.picker, 'toubiz-date-picker.set', {\n        start: null,\n        end: null\n      });\n      this.toggleSelection();\n    }\n    /**\n     * @private\n     * @param {Date|string} fromDate\n     * @param {Date|string} toDate\n     * @param {HTMLElement} element\n     */\n\n  }, {\n    key: \"updateDates\",\n    value: function updateDates(fromDate, toDate) {\n      var elementsToActivate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n      var fromBefore = this.fromDate.value;\n      var toBefore = this.toDate.value;\n      Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(this.toggleButton, 'target-enhancement.close');\n      var from = fromDate instanceof Date ? fromDate : this.parseDateString(fromDate);\n      var to = toDate instanceof Date ? toDate : this.parseDateString(toDate);\n      this.fromDate.value = Object(_common_date_formatting__WEBPACK_IMPORTED_MODULE_2__[\"dateToShortIsoString\"])(from);\n      this.toDate.value = Object(_common_date_formatting__WEBPACK_IMPORTED_MODULE_2__[\"dateToShortIsoString\"])(to);\n\n      if (fromBefore !== this.fromDate.value || toBefore !== this.toDate.value) {\n        var picker = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER));\n        Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(picker, 'toubiz-date-picker.set', {\n          start: from,\n          end: to\n        });\n        this.formReload.reload();\n        this.toggleSelection(elementsToActivate, true);\n      }\n    }\n    /**\n     * @private\n     * @param {string} string\n     * @returns {Date}\n     */\n\n  }, {\n    key: \"parseDateString\",\n    value: function parseDateString(string) {\n      var date = new Date();\n\n      switch (string) {\n        case 'today':\n          return date;\n\n        case 'tomorrow':\n          date.setDate(date.getDate() + 1);\n          return date;\n\n        default:\n          return new Date(string);\n      }\n    }\n  }, {\n    key: \"toggleSelection\",\n    value: function toggleSelection() {\n      var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n      var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n      this.toggleElementClasses([].concat(_toConsumableArray(this.dateLinks), [this.picker, this.pickerButton]), false);\n\n      if (elements.length > 0) {\n        this.toggleElementClasses(elements, state);\n      }\n    }\n  }]);\n\n  return EventsResultsListController;\n}(_common_results_list_controller_class__WEBPACK_IMPORTED_MODULE_1__[\"ResultsListController\"]);\n\n//# sourceURL=webpack://LIS/./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js?");

/***/ })

}]);