text: (function(factory){if(typeof define==="function"&&define.amd){define(["jquery","datatables.net"],$=>factory($,window,document))}else if(typeof exports==="object"){module.exports=function(root,$){if(!root){root=window}if(!$||!$.fn.dataTable){$=require("datatables.net")(root,$).$}return factory($,root,root.document)}}else{factory(jQuery,window,document)}})($=>{const DataTable=$.fn.dataTable;const removeNonWord=function(str){return str.replace(/[^0-9a-zA-Z\xC0-\xFF \-]/g,"")};const lowerCase=function(str){return str.toLowerCase()};const upperCase=function(str){return str.toUpperCase()};const camelCase=function(str){str=removeNonWord(str).replace(/\-/g," ").replace(/\s[a-z]/g,upperCase).replace(/\s+/g,"").replace(/^[A-Z]/g,lowerCase);return str};const slugify=function(str,delimeter="_"){str=removeNonWord(str).trim().replace(/ +/g,delimeter).toLowerCase();return str};const YSDataTable=function(options={}){const source=this.data("source");let header={};const ajaxOption={};if(this.prop("rows")!==null&&this.prop("rows")!==undefined){if(source!==undefined&&source!==null){source.type.toLowerCase()!=="get"?header={"X-CSRF-TOKEN":$('meta[name="csrsf-token"]').attr("content")}:"";ajaxOption.ajax={type:source.type,url:source.url,header:header};$.extend(options,ajaxOption);const baseOptions={el:this,options:options};return new Table(baseOptions)}if(options.ajax!==undefined&&options.ajax!==null){const baseOptions={el:this,options:options};return new Table(baseOptions)}options.buttons=Table.Buttons.concat(options.addButtons);if(options.removeButtons!==undefined&&options.removeButtons!==null){options.removeButtons.target.map(target=>delete options.buttons[Table.BMAP[target]])}const columnCase=this.prop("tHead").attributes.case?this.prop("tHead").attributes.case.value:"lower";Table.prototype.setColumnNameCase(columnCase);options.columns=Table.prototype.getColumnsFromTable(this.prop("rows")[0]);return this.DataTable(options)}throw new Error("Not able to found table with given selector","Not Found")};const Table=function({el:el,options:options}){this.el=el;this.exportable=this.getExportable();this.exportUri="ys-datatable/export";this.columnNameCase=el.prop("tHead").attributes.case?el.prop("tHead").attributes.case.value:"lower";this.defaults={columns:this.getColumnsFromTable(el.prop("rows")[0]),buttons:this.getDefaultButtons(),lengthMenu:[[25,50,100,200,500,1e3,1e4,-1],[25,50,100,200,500,1e3,1e4,"All"]],columnDefs:null,dom:'<"row"<"col-sm-2 "l><"col-sm-8"B><"col-sm-2"f>r>t<"row"<"col-sm-12"i>><"row"<"col-sm-12 center-block"p>>',ajax:{},processing:false,serverSide:true};if(options.addButtons!==undefined&&options.addButtons!==null){this.defaults.buttons=this.defaults.buttons.concat(options.addButtons)}if(options.removeButtons!==undefined&&options.removeButtons!==null){this.removeButtons(options.removeButtons.target)}if(options.Export!==undefined&&options.Export!==null){if(options.Export.fun&&options.Export.model&&options.Export.uri){this.exportUri=options.Export.uri+"?model="+options.Export.model+"&fun="+options.Export.fun}else if(options.Export.uri){this.exportUri=options.Export.uri}else if(options.Export.fun){this.exportUri+="?model="+options.Export.model+"&fun="+options.Export.fun}else if(options.Export.model){this.exportUri+="?model="+options.Export.model}this.addServeSiderExportButton()}this.dtOptions=$.extend({},this.defaults,options);const self=this;DataTable.Api.register("api()",()=>self);DataTable.Api.register("class()",()=>Table);this.dTable=el.DataTable(this.dtOptions);return this.dTable};Table.Exportable=[];Table.Buttons=[{extend:"colvis",collectionLayout:"relative three-column",postfixButtons:["colvisRestore"],columns:":gt(0)"},{extend:"copy",exportOptions:{columns:Table.Exportable||[0,":visible"]}},{extend:"excel",exportOptions:{columns:Table.Exportable||[0,":visible"]}},{extend:"csv",exportOptions:{columns:Table.Exportable||[0,":visible"]}},{extend:"print",exportOptions:{columns:Table.Exportable||[0,":visible"]}}];Table.BMAP={colvis:0,copy:1,excel:2,csv:3,print:4};Table.prototype={getColumnsFromTable(tHead){return Array.from(tHead.cells).map((th,index)=>{if(th.attributes.export){if(parseInt(th.attributes.export.value,10)===1||th.attributes.export.value=="true"){Table.Exportable.push(index)}}else{Table.Exportable.push(index)}const columns={seachable:th.attributes.search?!!parseInt(th.attributes.search.value,10):true,sortable:th.attributes.sort?!!parseInt(th.attributes.sort.value,10):true,visible:th.attributes.visible?!!parseInt(th.attributes.visible.value,10):true,class:th.attributes.dtClass?th.attributes.dtClass.value:"",defaultContent:th.attributes.defaultContent?th.attributes.defaultContent.value:null,render:th.dataset.render?eval(th.dataset.render):null};$.extend(columns,{data:th.dataset.name!==undefined&&th.dataset.name!==null?this.slugify(th.dataset.name):this.slugify(th.innerHTML)});return columns})},getColumns(){return this.defaults.columns},getColumnsLength(){return this.defaults.columns.length},getOptions(){return this.dtOptions},getDefaults(){return this.defaults},getDefaultButtons(){return Table.Buttons},getExportable(){return Table.Exportable},setColumnNameCase(columnCase){this.columnNameCase=columnCase},removeButtons(targets){targets.map(target=>delete this.defaults.buttons[Table.BMAP[target]])},slugify(str,delimeter="_"){str=str.trim().replace(/ +/g,delimeter);this.columnNameCase!=="upper"?str=str.toLowerCase():"";return str},addServeSiderExportButton(){let uri=this.exportUri;this.defaults.buttons=this.defaults.buttons.concat([{text:'<span><i class="fa  fa-file fa-lg"></i> Export All To Csv </span>',key:"ctrl+shift+d",action:function(){window.location.href=uri}}])}};$.fn.YSDataTable=YSDataTable;return YSDataTable});