"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);t=r.call(e,t||"default");if("object"!=_typeof(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}var ContactTable=function(){return _createClass(function e(t,r){_classCallCheck(this,e),this.table=document.querySelector(t),this.table&&(this.searchInput=document.querySelector(r),this.headerCheckbox=this.table.querySelector('thead input[type="checkbox"]'),this.rows=Array.from(this.table.querySelectorAll("tbody tr")),this.initCheckboxLogic(),this.initSearchLogic())},[{key:"initCheckboxLogic",value:function(){var r,o=this;this.headerCheckbox&&(r=function(){return Array.from(o.table.querySelectorAll('tbody input[type="checkbox"]'))},this.headerCheckbox.addEventListener("change",function(){var t=o.headerCheckbox.checked;r().forEach(function(e){e.checked=t})}),this.table.addEventListener("change",function(e){e.target.matches('tbody input[type="checkbox"]')&&(e=r(),o.headerCheckbox.checked=e.every(function(e){return e.checked}))}))}},{key:"initSearchLogic",value:function(){var e=this;this.searchInput&&this.searchInput.addEventListener("input",function(){var r=e.searchInput.value.trim().toLowerCase();e.rows.forEach(function(e){var t=e.innerText.toLowerCase();e.style.display=t.includes(r)?"":"none"}),e.headerCheckbox.checked=!1})}}])}();document.addEventListener("DOMContentLoaded",function(){new ContactTable(".table-contactlist","#contact-search-input")});