text: import t from"jquery";import"datatables.net/js/jquery.dataTables";import"datatables.net-bs4/js/dataTables.bootstrap4";import"datatables.net-buttons/js/dataTables.buttons";import"datatables.net-buttons-bs4/js/buttons.bootstrap4";import"datatables.net-buttons/js/buttons.colVis";import"datatables.net-buttons/js/buttons.html5";import"datatables.net-buttons/js/buttons.print";import"datatables.net-responsive/js/dataTables.responsive";import"datatables.net-responsive-bs4/js/responsive.bootstrap4";"undefined"!=typeof module&&module.exports&&(module.exports=class{constructor(e,s,o,i){this.version="3.0.1",this.table=e,this.userOptions=s,this.eventOptions=o,this.translations=i,this.elements={columnRowSelector:".js-table-columns",filterRowSelector:".js-table-filters",filterSelectColumn:".js-select-filter",filterInputColumn:".js-input-filter"},this.prefix={throw:"w2wDataTables: "},this.defaultOptions={language:"en",stateSaving:!0,dom:'<"row"<"col-md-4"f><"col-md-4 col-md-offset-4 text-right">>trlip<"clear">',buttons:[],showAlertForXhrInactivity:!0,handleXhrInactivity:()=>{},showAlertForErrors:!0,handleErrors:()=>{}},this.globals={options:{},source:e.data("source"),columnFilter:e.data("column-filter"),autoReload:e.data("auto-reload"),perPage:e.data("per-page"),tableID:e.attr("id"),serverSide:!0,table:!1,state:!1,translations:{},debounceDelay:250},this.events={"draw.dt":[this.recalc.bind(this)],"init.dt":[],initComplete:[],"xhr.dt":[this.onXhr.bind(this)],"error.dt":[this.onError.bind(this)]},t.fn.dataTable.ext.errMode="none"}onXhr(t,e,s,o){if(4===o.readyState&&200!==o.status){if(403!==o.status||"CSRF token validation failed"!==o.responseJSON.error)throw e.oInit.showAlertForErrors&&alert("Something went wrong. The administrator has been notified. Please try again later."),e.oInit.handleErrors(),this.prefix.throw+"Ajax call returned a "+o.status+" status code";e.oInit.showAlertForXhrInactivity&&alert("You need to refresh the page due to an extended period of inactivity"),e.oInit.handleXhrInactivity()}}onError(t,e,s,o){if(7!==s)throw e.oInit.showAlertForErrors&&alert("Something went wrong. The administrator has been notified. Please try again later."),e.oInit.handleErrors(),this.prefix.throw+o}init(){this.globals.options=this.getOptions(),this.globals.translations=this.getTranslations(),this.globals.options.buttons=this.getFilters(),this.hasRequirementsOrThrow(),this.getEventOptions(),this.makeTable()}getOptions(){return t.extend(this.defaultOptions,this.userOptions)}getTranslations(){return this.translations.get(this.globals.options.language)}getEventOptions(){t.each(this.eventOptions,function(e,s){this.events[e]=t.extend({},this.events[e],s||{})})}hasRequirementsOrThrow(){let t=this.table.find(this.elements.columnRowSelector);if(void 0!==this.globals.source&&""!==this.globals.source||(this.globals.serverSide=!1),void 0===this.globals.tableID||""===this.globals.tableID)throw this.prefix.throw+"missing id attribute!";if(0===t.length)throw this.prefix.throw+"missing column row ("+this.elements.columnRowSelector+")!";if(void 0!==this.globals.autoReload&&!this.globals.autoReload>0)throw this.prefix.throw+"invalid reload interval!";if(void 0!==this.globals.perPage&&!this.globals.perPage>0)throw this.prefix.throw+"invalid amount per page!"}makeTable(){let e={autoWidth:!1,columns:this.getColumns(),initComplete:function(){e.component.table.find(e.component.elements.filterRowSelector).length>0&&e.component.filterColumn(),e.component.triggerEvent("initComplete")},order:this.getOrder(),orderCellsTop:!0,processing:!0,responsive:!0,serverSide:this.globals.serverSide,stateSave:this.globals.options.stateSaving,component:this},s=this;if(t.extend(e,this.globals.options),e.language=this.globals.translations,1==this.globals.serverSide&&(e.ajax={method:"POST",url:this.globals.source}),!this.table)throw"Unknown element for the datatable!";this.globals.table=this.table.DataTable(e),this.globals.state=this.globals.table.state.loaded(),this.setFilterValues(),void 0!==this.globals.autoReload&&this.bindReload(this.globals.autoReload),void 0!==this.globals.perPage&&(this.globals.options.perPage=this.globals.perPage),void 0!==this.globals.options.perPage&&this.setPageLength(),this.globals.table.on("init.dt",function(){s.triggerEvent("init.dt")}),t.each(this.events,this.listenToEvent.bind(this)),1!=this.globals.serverSide&&this.filterColumn()}addEvent(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}listenToEvent(t){let e=this;this.globals.table.on(t,function(){e.triggerEvent(t,arguments)})}triggerEvent(e,s){this.events[e]&&t.each(this.events[e],function(t,e){e.apply(this,s)})}setPageLength(){this.globals.table.page.len(this.globals.options.perPage).draw()}getColumns(){let e=this.table.find(this.elements.columnRowSelector+" th"),s=[];return e.each(function(){let e=[!0,!1],o=t(this),i=o.data("name"),l=o.data("data"),a=o.data("orderable"),n=o.data("searchable");void 0===l&&(l=i),void 0!==a&&e.indexOf(a)||(a=!0),void 0!==n&&e.indexOf(n)||(n=!0),s.push({data:l,name:i,orderable:a,searchable:n})}),s}getOrder(){let t=this.table.find('[data-default-sort="true"]'),e=t.data("default-sort-order");if(0===t.length)return[[0,"desc"]];if(void 0===e)throw this.prefix.throw+'You must add a sorting order (default-sort-order="asc/desc") if you are filtering on a custom column!';if(-1==["asc","desc"].indexOf(e))throw this.prefix.throw+"You must add a valid sorting order (asc/desc) if you are filtering on a custom column!";return[[t.index(),e]]}filterColumn(){let t=this;t.globals.table&&t.globals.table.columns().eq(0).each(function(e){let s=t.table.find(t.elements.filterRowSelector+" th:eq("+e+")");t.initFilterSelect(e,s),t.initFilterInput(e,s)})}initFilterInput(e,s){let o=this,i=o.debounce(function(s,i){const l=t(this).val();i&&!l||o.globals.table.column(e).search(l).draw()},o.globals.debounceDelay);s.find(o.elements.filterInputColumn).on("input",i),s.find(o.elements.filterInputColumn).on("change",i),s.find(o.elements.filterInputColumn).each(i)}initFilterSelect(e,s){let o=this,i=o.debounce(function(s,i){let l=t(this).val();i&&!l||o.globals.table.column(e).search(o.searchString(l),!0,!1).draw()},o.globals.debounceDelay);s.find(o.elements.filterSelectColumn).on("change",i),s.find(o.elements.filterSelectColumn).each(i)}searchString(t,e="|"){let s=t;return!s||Array.isArray(s)&&s.length<1?"":(Array.isArray(s)&&s.length>0&&(s=s.join(e)),"^"+s+"$")}bindReload(t){setInterval(function(){this.globals.table.ajax.reload()},t)}debounce(t,e,s){let o;return function(){let i=this,l=arguments;clearTimeout(o),o=setTimeout(function(){o=null,s||t.apply(i,l)},e),s&&!o&&t.apply(i,l)}}recalc(){this.globals.table&&this.globals.table.responsive.recalc()}setFilterValues(){let e=this;e.globals.state&&e.globals.state.columns&&t.each(e.globals.state.columns,function(t,s){let o=s.search.search;o&&(s.search.regex&&(o=o.slice(1,-1)),e.table.find(e.elements.filterRowSelector+" th").eq(t).find(".form-control").val(o))})}getFilters(){let e=this.table.find(this.elements.columnRowSelector+" th"),s={},o=[],i=[],l=this;return l.globals.options.buttons&&(o=this.globals.options.buttons),e.each(function(){let e=t(l),o=e.data("name"),a=e.data("filter");a?(t.each(a.split("|"),function(t,e){s[e]||(s[e]=[]),s[e].indexOf(o+":name")<0&&s[e].push(o+":name")}),i.push(o+":name")):i.push(o+":name")}),t.each(s,function(t,e){let s=i.filter(function(t){return e.indexOf(t)<0});o.push({extend:"colvisGroup",text:t,show:e,hide:s})}),!jQuery.isEmptyObject(s)&&o.length>0&&o.push({extend:"colvisGroup",text:l.globals.translations.all,show:i,hide:[]}),1==l.globals.columnFilter&&o.push({extend:"colvis",text:'<i class="fa fa-columns"></i> '+l.globals.translations.columns}),o}getTable(){return this.globals.table}});
  //# sourceMappingURL=datatables.modern.js.map
  