/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/js/view/advanced-data-table.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/js/view/advanced-data-table.js":
/*!********************************************!*\
  !*** ./src/js/view/advanced-data-table.js ***!
  \********************************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nvar advancedDataTable = /*#__PURE__*/function () {\n  function advancedDataTable() {\n    _classCallCheck(this, advancedDataTable);\n    // register hooks\n    elementorFrontend.hooks.addAction(\"frontend/element_ready/eael-advanced-data-table.default\", this.initFrontend.bind(this));\n  }\n\n  // init frontend features\n  return _createClass(advancedDataTable, [{\n    key: \"initFrontend\",\n    value: function initFrontend($scope, $) {\n      var table = $scope[0].querySelector(\".ea-advanced-data-table\");\n      var search = $scope[0].querySelector(\".ea-advanced-data-table-search\");\n      var pagination = $scope[0].querySelector(\".ea-advanced-data-table-pagination\");\n      var classCollection = {};\n      if (!eael.isEditMode && table !== null) {\n        // search\n        this.initTableSearch(table, search, pagination);\n\n        // sort\n        this.initTableSort(table, pagination, classCollection);\n\n        // paginated table\n        this.initTablePagination(table, pagination, classCollection);\n\n        // woocommerce\n        this.initWooFeatures(table);\n        var isEscapedHtmlString = function isEscapedHtmlString(str) {\n            return /&[a-zA-Z]+;/.test(str);\n          },\n          decodeEscapedHtmlString = function decodeEscapedHtmlString(str) {\n            var textarea = document.createElement('textarea');\n            textarea.innerHTML = str;\n            return textarea.value;\n          };\n        if ($(table).hasClass('ea-advanced-data-table-static')) {\n          var DOM_config = {\n            ALLOWED_ATTR: ['class', 'id', 'style', 'title', 'lang', 'dir', 'data-*', 'accesskey', 'tabindex', 'contenteditable',\n            // Global\n            'href', 'target', 'rel', 'download', 'type',\n            // <a>, <button>, <input>, <source>\n            'src', 'alt', 'width', 'height', 'loading',\n            // <img>, <audio>, <video>, <iframe>, <source>, <table>\n            'action', 'method', 'enctype', 'novalidate',\n            // <form>\n            'name', 'value', 'placeholder', 'checked', 'disabled', 'readonly', 'required', 'maxlength', 'min', 'max', 'step',\n            // <input>, <form>, <li>\n            'border', 'cellpadding', 'cellspacing', 'colspan', 'rowspan', 'scope',\n            // <table>, <td>, <th>\n            'controls', 'autoplay', 'loop', 'muted', 'preload', 'poster',\n            // <audio>, <video>\n            'fill', 'stroke', 'viewBox', 'xmlns', 'd', 'cx', 'cy', 'r',\n            // <svg>, <path>, <circle>\n            'allow', 'allowfullscreen', 'sandbox',\n            // <iframe>\n            'content', 'http-equiv', 'charset',\n            // <meta>\n            'aria-label', 'aria-hidden', 'role',\n            // Accessibility (Global)\n            // Common for form elements\n            'pattern', 'multiple', 'autocomplete',\n            // <input>, <textarea>, <select>\n            'accept-charset',\n            // <form>\n            'rows', 'cols', 'wrap',\n            // <textarea>\n            'size', 'multiple',\n            // <select>\n            'for' // <label>\n            ]\n          };\n          $(table).find('th, td').each(function () {\n            var text = $(this)[0].innerHTML;\n            if (isEscapedHtmlString(text)) {\n              text = decodeEscapedHtmlString(text);\n              $(this).html(DOMPurify.sanitize(text, DOM_config));\n            }\n          });\n        }\n      }\n    }\n\n    // frontend - search\n  }, {\n    key: \"initTableSearch\",\n    value: function initTableSearch(table, search, pagination) {\n      if (search) {\n        search.addEventListener(\"input\", function (e) {\n          var input = e.target.value.toLowerCase();\n          var hasSort = table.classList.contains(\"ea-advanced-data-table-sortable\");\n          var offset = table.rows[0].parentNode.tagName.toLowerCase() == \"thead\" ? 1 : 0;\n          if (table.rows.length > 1) {\n            if (input.length > 0) {\n              if (hasSort) {\n                table.classList.add(\"ea-advanced-data-table-unsortable\");\n              }\n              if (pagination && pagination.innerHTML.length > 0) {\n                pagination.style.display = \"none\";\n              }\n              for (var i = offset; i < table.rows.length; i++) {\n                var matchFound = false;\n                if (table.rows[i].cells.length > 0) {\n                  for (var j = 0; j < table.rows[i].cells.length; j++) {\n                    if (table.rows[i].cells[j].textContent.toLowerCase().indexOf(input) > -1) {\n                      matchFound = true;\n                      break;\n                    }\n                  }\n                }\n                if (matchFound) {\n                  table.rows[i].style.display = \"table-row\";\n                } else {\n                  table.rows[i].style.display = \"none\";\n                }\n              }\n            } else {\n              if (hasSort) {\n                table.classList.remove(\"ea-advanced-data-table-unsortable\");\n              }\n              if (pagination && pagination.innerHTML.length > 0) {\n                pagination.style.display = \"\";\n                var paginationType = pagination.classList.contains(\"ea-advanced-data-table-pagination-button\") ? \"button\" : \"select\";\n                var currentPage = paginationType == \"button\" ? pagination.querySelector(\".ea-adtp-current\").dataset.page : pagination.querySelector(\"select\").value;\n                var _startIndex = (currentPage - 1) * table.dataset.itemsPerPage + 1;\n                var endIndex = currentPage * table.dataset.itemsPerPage;\n                for (var _i = 1; _i <= table.rows.length - 1; _i++) {\n                  if (_i >= _startIndex && _i <= endIndex) {\n                    table.rows[_i].style.display = \"table-row\";\n                  } else {\n                    table.rows[_i].style.display = \"none\";\n                  }\n                }\n              } else {\n                for (var _i2 = 1; _i2 <= table.rows.length - 1; _i2++) {\n                  table.rows[_i2].style.display = \"table-row\";\n                }\n              }\n            }\n          }\n        });\n      }\n    }\n\n    // frontend - sort\n  }, {\n    key: \"initTableSort\",\n    value: function initTableSort(table, pagination, classCollection) {\n      if (jQuery(table).hasClass('ea-advanced-data-table-sortable')) {\n        jQuery(table).click(function (e) {\n          var th = jQuery(e.target).closest(\"th\");\n          if (!th.length) return; // click wasn't on a table header\n\n          var _table = th.closest(\"table\");\n          var tbody = _table.find(\"tbody\");\n          var rows = tbody.find(\"tr\");\n          var sortOrder = 1;\n          if (th.hasClass(\"asc\")) {\n            sortOrder = -1;\n            th.removeClass(\"asc\").addClass(\"desc\");\n          } else {\n            th.removeClass(\"desc\").addClass(\"asc\");\n          }\n          var dateRegexes = [/^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/,\n          // MM/DD/YYYY\n          /^\\d{4}-\\d{1,2}-\\d{1,2}$/,\n          // YYYY-MM-DD\n          /^\\d{1,2}-\\d{1,2}-\\d{4}$/,\n          // DD-MM-YYYY (common in Europe)\n          /^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$/,\n          // YYYY/MM/DD\n          /^([a-zA-Z]{3,}) (\\d{1,2}), (\\d{4})$/,\n          // Month Day, Year (e.g., Feb 14, 2024)\n          /^(\\d{1,2}) ([a-zA-Z]{3,}) (\\d{4})$/,\n          // Day Month Year (e.g., 14 Feb 2024)\n          /^([a-zA-Z]{3,}) (\\d{1,2})st, (\\d{4})$/,\n          // Month Dayst, Year\n          /^([a-zA-Z]{3,}) (\\d{1,2})nd, (\\d{4})$/,\n          // Month Daynd, Year\n          /^([a-zA-Z]{3,}) (\\d{1,2})rd, (\\d{4})$/,\n          // Month Dayrd, Year\n          /^([a-zA-Z]{3,}) (\\d{1,2})th, (\\d{4})$/ // Month Dayth, Year\n          ];\n          function isLikelyDate(value) {\n            // Apply regular expressions first\n            for (var i = 0; i < dateRegexes.length; i++) {\n              if (dateRegexes[i].test(value)) {\n                return true;\n              }\n            }\n\n            // Heuristic checks (if regular expressions don't match)\n            var parts = value.split(/[^\\d]+/); // Split by non-digits\n            if (parts.length >= 3) {\n              var year = parseInt(parts.pop());\n              if (year >= 1000 && year <= 9999) {\n                // Basic year range check\n                var month = parseInt(parts.pop());\n                var day = parseInt(parts.pop());\n                if (month >= 1 && month <= 12 && day >= 1 && day <= 31) {\n                  return true;\n                }\n              }\n            }\n            return false;\n          }\n          rows.sort(function (a, b) {\n            var colIndex = th.index();\n            var valueA = jQuery(a).children().eq(colIndex).text().toUpperCase().replace(/[^A-Za-z0-9\\s]/g, '');\n            var valueB = jQuery(b).children().eq(colIndex).text().toUpperCase().replace(/[^A-Za-z0-9\\s]/g, '');\n            if (isLikelyDate(valueA) && isLikelyDate(valueB)) {\n              // Both are likely dates, sort by parsed date\n              var dateA = new Date(valueA);\n              var dateB = new Date(valueB);\n              return (dateA - dateB) * sortOrder;\n            } else if (isLikelyDate(valueA)) {\n              // Only A is a likely date, sort A before B\n              return -1 * sortOrder;\n            } else if (isLikelyDate(valueB)) {\n              // Only B is a likely date, sort B before A\n              return 1 * sortOrder;\n            } else {\n              // Handle numeric sorting\n              var isNumericA = !isNaN(valueA);\n              var isNumericB = !isNaN(valueB);\n              if (isNumericA && isNumericB) {\n                return (valueA - valueB) * sortOrder;\n              }\n            }\n\n            // Handle case-insensitive text sorting\n            return valueA < valueB ? -1 * sortOrder : valueA > valueB ? sortOrder : 0;\n          });\n          if (pagination && pagination.innerHTML.length > 0) {\n            var itemsPerPage = jQuery(table).data('items-per-page'),\n              paginationType = jQuery(pagination).hasClass(\"ea-advanced-data-table-pagination-button\") ? \"button\" : \"select\",\n              currentPage = startIndex = 1,\n              endIndex = rows.length;\n            currentPage = paginationType == \"button\" ? $('.ea-adtp-current', pagination).data('page') : $(\"select\", pagination).val();\n            startIndex = (currentPage - 1) * itemsPerPage;\n            endIndex = endIndex - (currentPage - 1) * itemsPerPage >= itemsPerPage ? currentPage * itemsPerPage : endIndex;\n            jQuery(rows).removeAttr('style');\n            for (var i = startIndex; i < endIndex; i++) {\n              jQuery(rows[i]).attr('style', 'display: table-row;');\n            }\n          }\n          tbody.empty().append(rows);\n        });\n      }\n    }\n\n    // frontend - pagination\n  }, {\n    key: \"initTablePagination\",\n    value: function initTablePagination(table, pagination, classCollection) {\n      if (table.classList.contains(\"ea-advanced-data-table-paginated\")) {\n        var paginationHTML = \"\";\n        var paginationType = pagination.classList.contains(\"ea-advanced-data-table-pagination-button\") ? \"button\" : \"select\";\n        var currentPage = 1;\n        var _startIndex2 = table.rows[0].parentNode.tagName.toLowerCase() === \"thead\" ? 1 : 0;\n        var endIndex = currentPage * table.dataset.itemsPerPage;\n        var maxPages = Math.ceil((table.rows.length - 1) / table.dataset.itemsPerPage);\n        if (!_startIndex2) {\n          endIndex -= 1;\n        }\n        pagination.insertAdjacentHTML(\"beforeend\", ''); // insert pagination\n        if (maxPages > 1) {\n          if (paginationType === \"button\") {\n            paginationHTML += \"<a href=\\\"#\\\" data-page=\\\"1\\\" class=\\\"ea-adtp-current ea-adtp-show\\\">1</a><a class=\\\"dots-1st ea-adtp-hide\\\">...</a>\";\n            for (var i = 2; i < maxPages; i++) {\n              var _cssClass = i <= 6 || i === maxPages ? 'ea-adtp-show' : 'ea-adtp-hide';\n              paginationHTML += \"<a href=\\\"#\\\" data-page=\\\"\".concat(i, \"\\\" class=\\\"\").concat(_cssClass, \"\\\">\").concat(i, \"</a>\");\n            }\n            var dots2 = '',\n              cssClass = 'ea-adtp-show';\n            if (maxPages > 7) {\n              dots2 = \"<a class=\\\"dots-last\\\">...</a>\";\n              cssClass = 'ea-adtp-hide';\n            }\n            paginationHTML += dots2 + \"<a href=\\\"#\\\" data-page=\\\"\".concat(maxPages, \"\\\" class=\\\"\").concat(cssClass, \"\\\">\").concat(maxPages, \"</a>\");\n            pagination.insertAdjacentHTML(\"beforeend\", \"<a href=\\\"#\\\" data-page=\\\"1\\\" class=\\\"ea-adtp-1st\\\">&laquo;</a>\".concat(paginationHTML, \"<a href=\\\"#\\\" data-page=\\\"\").concat(maxPages, \"\\\" class=\\\"ea-adtp-last\\\">&raquo;</a>\"));\n          } else {\n            for (var _i3 = 1; _i3 <= maxPages; _i3++) {\n              paginationHTML += \"<option value=\\\"\".concat(_i3, \"\\\">\").concat(_i3, \"</option>\");\n            }\n            pagination.insertAdjacentHTML(\"beforeend\", \"<select>\".concat(paginationHTML, \"</select>\"));\n          }\n        }\n\n        // make initial item visible\n        for (var _i4 = 0; _i4 <= endIndex; _i4++) {\n          if (_i4 >= table.rows.length) {\n            break;\n          }\n          table.rows[_i4].style.display = \"table-row\";\n        }\n\n        // paginate on click\n        if (paginationType === \"button\") {\n          var _$ = jQuery;\n          _$('a:not(.dots-1st, .dots-last)', pagination).on(\"click\", function (e) {\n            e.preventDefault();\n            if (e.target.tagName.toLowerCase() === \"a\") {\n              currentPage = e.target.dataset.page;\n              var _offset = table.rows[0].parentNode.tagName.toLowerCase() === \"thead\" ? 1 : 0;\n              _startIndex2 = (currentPage - 1) * table.dataset.itemsPerPage + _offset;\n              endIndex = currentPage * table.dataset.itemsPerPage;\n              if (!_offset) {\n                endIndex -= 1;\n              }\n              if (maxPages > 7) {\n                var countFrom = 1,\n                  countTo = 6;\n                _$('a.ea-adtp-current', pagination).removeClass('ea-adtp-current');\n                if (currentPage > maxPages - 5) {\n                  countFrom = maxPages - 5;\n                  countTo = maxPages;\n                } else if (currentPage > 5) {\n                  countFrom = currentPage - 2;\n                  countTo = parseInt(currentPage) + 2;\n                }\n                _$('a.ea-adtp-show', pagination).removeClass('ea-adtp-show').addClass('ea-adtp-hide');\n                for (var page = countFrom; page <= countTo; page++) {\n                  _$(\"a[data-page=\\\"\".concat(page, \"\\\"]:not(.ea-adtp-1st,.ea-adtp-last)\"), pagination).removeClass('ea-adtp-hide').addClass('ea-adtp-show');\n                }\n                _$(\"a[data-page=\\\"\".concat(currentPage, \"\\\"]\"), pagination).addClass('ea-adtp-current');\n                if (_$(\"a[data-page=\\\"2\\\"]\", pagination).hasClass('ea-adtp-hide')) {\n                  _$(\"a.dots-1st\", pagination).removeClass('ea-adtp-hide').addClass('ea-adtp-show');\n                } else {\n                  _$(\"a.dots-1st\", pagination).removeClass('ea-adtp-show').addClass('ea-adtp-hide');\n                }\n                if (_$(\"a[data-page=\\\"\".concat(maxPages - 1, \"\\\"]\"), pagination).hasClass('ea-adtp-hide')) {\n                  _$(\"a.dots-last\", pagination).removeClass('ea-adtp-hide').addClass('ea-adtp-show');\n                } else {\n                  _$(\"a.dots-last\", pagination).removeClass('ea-adtp-show').addClass('ea-adtp-hide');\n                }\n              } else {\n                _$('a.ea-adtp-current', pagination).removeClass('ea-adtp-current');\n                _$(\"a[data-page=\\\"\".concat(currentPage, \"\\\"]\"), pagination).addClass('ea-adtp-current');\n              }\n              for (var _i5 = _offset; _i5 <= table.rows.length - 1; _i5++) {\n                if (_i5 >= _startIndex2 && _i5 <= endIndex) {\n                  table.rows[_i5].style.display = \"table-row\";\n                } else {\n                  table.rows[_i5].style.display = \"none\";\n                }\n              }\n              table.querySelectorAll(\"th\").forEach(function (el, index) {\n                el.classList.remove(\"asc\", \"desc\");\n                if (typeof classCollection[currentPage] != \"undefined\") {\n                  if (classCollection[currentPage][index]) {\n                    el.classList.add(classCollection[currentPage][index]);\n                  }\n                }\n              });\n            }\n          });\n        } else {\n          if (pagination.hasChildNodes()) {\n            pagination.querySelector(\"select\").addEventListener(\"input\", function (e) {\n              e.preventDefault();\n              currentPage = e.target.value;\n              offset = table.rows[0].parentNode.tagName.toLowerCase() == \"thead\" ? 1 : 0;\n              _startIndex2 = (currentPage - 1) * table.dataset.itemsPerPage + offset;\n              endIndex = currentPage * table.dataset.itemsPerPage;\n              for (var _i6 = offset; _i6 <= table.rows.length - 1; _i6++) {\n                if (_i6 >= _startIndex2 && _i6 <= endIndex) {\n                  table.rows[_i6].style.display = \"table-row\";\n                } else {\n                  table.rows[_i6].style.display = \"none\";\n                }\n              }\n              table.querySelectorAll(\"th\").forEach(function (el, index) {\n                el.classList.remove(\"asc\", \"desc\");\n                if (typeof classCollection[currentPage] != \"undefined\") {\n                  if (classCollection[currentPage][index]) {\n                    el.classList.add(classCollection[currentPage][index]);\n                  }\n                }\n              });\n            });\n          }\n        }\n      }\n    }\n\n    // woocommerce features\n  }, {\n    key: \"initWooFeatures\",\n    value: function initWooFeatures(table) {\n      table.querySelectorAll(\".nt_button_woo\").forEach(function (el) {\n        el.classList.add(\"add_to_cart_button\", \"ajax_add_to_cart\");\n      });\n      table.querySelectorAll(\".nt_woo_quantity\").forEach(function (el) {\n        el.addEventListener(\"input\", function (e) {\n          var product_id = e.target.dataset.product_id;\n          var quantity = e.target.value;\n          $(\".nt_add_to_cart_\".concat(product_id), $(table)).data(\"quantity\", quantity);\n        });\n      });\n    }\n  }]);\n}();\neael.hooks.addAction(\"init\", \"ea\", function () {\n  if (eael.elementStatusCheck('eaelAdvancedDataTable')) {\n    return false;\n  }\n  new advancedDataTable();\n});\n\n//# sourceURL=webpack:///./src/js/view/advanced-data-table.js?");

/***/ })

/******/ });