You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
138 KiB

(function(){var __webpack_exports__={},global,factory;global=window,factory=function(){"use strict";var Version=(info={title:"Jspreadsheet",version:"4.13.3",type:"CE",host:"https://bossanova.uk/jspreadsheet",license:"MIT",print:function(){return[this.title+" "+this.type+" "+this.version,this.host,this.license].join("\r\n")}},function(){return info}),info,isFormula=function(e){var o=(""+e)[0];return"="==o||"#"==o},getMask=function(e){if(e.format||e.mask||e.locale){var o={};return e.mask?o.mask=e.mask:e.format?o.mask=e.format:(o.locale=e.locale,o.options=e.options),e.decimal&&(o.options||(o.options={}),o.options={decimal:e.decimal}),o}return null},jexcel=function(el,options){var obj={options:{}};if(!(el instanceof Element||el instanceof HTMLDocument))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;if("TABLE"==el.tagName){if(!(options=jexcel.createFromTable(el,options)))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;var div=document.createElement("div");el.parentNode.insertBefore(div,el),el.remove(),el=div}var defaults={url:null,method:"GET",requestVariables:null,data:null,sorting:null,copyCompatibility:!1,root:null,rows:[],columns:[],colHeaders:[],colWidths:[],colAlignments:[],nestedHeaders:null,defaultColWidth:50,defaultColAlign:"center",defaultRowHeight:null,minSpareRows:0,minSpareCols:0,minDimensions:[0,0],allowExport:!0,includeHeadersOnDownload:!1,includeHeadersOnCopy:!1,columnSorting:!0,columnDrag:!1,columnResize:!0,rowResize:!1,rowDrag:!0,editable:!0,allowInsertRow:!0,allowManualInsertRow:!0,allowInsertColumn:!0,allowManualInsertColumn:!0,allowDeleteRow:!0,allowDeletingAllRows:!1,allowDeleteColumn:!0,allowRenameColumn:!0,allowComments:!1,wordWrap:!1,imageOptions:null,csv:null,csvFileName:"jspreadsheet",csvHeaders:!0,csvDelimiter:",",parseTableFirstRowAsHeader:!1,parseTableAutoCellType:!1,selectionCopy:!0,mergeCells:{},toolbar:null,search:!1,pagination:!1,paginationOptions:null,fullscreen:!1,lazyLoading:!1,loadingSpin:!1,tableOverflow:!1,tableHeight:"300px",tableWidth:null,textOverflow:!1,meta:null,style:null,classes:null,parseFormulas:!0,autoIncrement:!0,autoCasting:!0,secureFormulas:!0,stripHTML:!0,stripHTMLOnCopy:!1,filters:!1,footers:null,onundo:null,onredo:null,onload:null,onchange:null,oncomments:null,onbeforechange:null,onafterchanges:null,onbeforeinsertrow:null,oninsertrow:null,onbeforeinsertcolumn:null,oninsertcolumn:null,onbeforedeleterow:null,ondeleterow:null,onbeforedeletecolumn:null,ondeletecolumn:null,onmoverow:null,onmovecolumn:null,onresizerow:null,onresizecolumn:null,onsort:null,onselection:null,oncopy:null,onpaste:null,onbeforepaste:null,onmerge:null,onfocus:null,onblur:null,onchangeheader:null,oncreateeditor:null,oneditionstart:null,oneditionend:null,onchangestyle:null,onchangemeta:null,onchangepage:null,onbeforesave:null,onsave:null,onevent:null,persistance:!1,updateTable:null,detachForUpdates:!1,freezeColumns:null,text:{noRecordsFound:"No records found",showingPage:"Showing page {0} of {1} entries",show:"Show ",search:"Search",entries:" entries",columnName:"Column name",insertANewColumnBefore:"Insert a new column before",insertANewColumnAfter:"Insert a new column after",deleteSelectedColumns:"Delete selected columns",renameThisColumn:"Rename this column",orderAscending:"Order ascending",orderDescending:"Order descending",insertANewRowBefore:"Insert a new row before",insertANewRowAfter:"Insert a new row after",deleteSelectedRows:"Delete selected rows",editComments:"Edit comments",addComments:"Add comments",comments:"Comments",clearComments:"Clear comments",copy:"Copy...",paste:"Paste...",saveAs:"Save as...",about:"About",areYouSureToDeleteTheSelectedRows:"Are you sure to delete the selected rows?",areYouSureToDeleteTheSelectedColumns:"Are you sure to delete the selected columns?",thisActionWillDestroyAnyExistingMergedCellsAreYouSure:"This action will destroy any existing merged cells. Are you sure?",thisActionWillClearYourSearchResultsAreYouSure:"This action will clear your search results. Are you sure?",thereIsAConflictWithAnotherMergedCell:"There is a conflict with another merged cell",invalidMergeProperties:"Invalid merged properties",cellAlreadyMerged:"Cell already merged",noCellsSelected:"No cells selected"},about:!0};for(var property in defaults)if(options&&options.hasOwnProperty(property))if("text"===property)for(var textKey in obj.options[property]=defaults[property],options[property])options[property].hasOwnProperty(textKey)&&(obj.options[property][textKey]=options[property][textKey]);else obj.options[property]=options[property];else obj.options[property]=defaults[property];obj.el=el,obj.corner=null,obj.contextMenu=null,obj.textarea=null,obj.ads=null,obj.content=null,obj.table=null,obj.thead=null,obj.tbody=null,obj.rows=[],obj.results=null,obj.searchInput=null,obj.toolbar=null,obj.pagination=null,obj.pageNumber=null,obj.headerContainer=null,obj.colgroupContainer=null,obj.headers=[],obj.records=[],obj.history=[],obj.formula=[],obj.colgroup=[],obj.selection=[],obj.highlighted=[],obj.selectedCell=null,obj.selectedContainer=null,obj.style=[],obj.data=null,obj.filter=null,obj.filters=[],obj.cursor=null,obj.historyIndex=-1,obj.ignoreEvents=!1,obj.ignoreHistory=!1,obj.edition=null,obj.hashString=null,obj.resizing=null,obj.dragging=null,1==obj.options.lazyLoading&&0==obj.options.tableOverflow&&0==obj.options.fullscreen&&(console.error("Jspreadsheet: The lazyloading only works when tableOverflow = yes or fullscreen = yes"),obj.options.lazyLoading=!1),obj.fullscreen=function(e){null==e&&(e=!obj.options.fullscreen),obj.options.fullscreen!=e&&(obj.options.fullscreen=e,1==e?el.classList.add("fullscreen"):el.classList.remove("fullscreen"))},obj.dispatch=function(e){if(!obj.ignoreEvents){if("function"==typeof obj.options.onevent)var o=obj.options.onevent.apply(this,arguments);"function"==typeof obj.options[e]&&(o=obj.options[e].apply(this,Array.prototype.slice.call(arguments,1)))}if("onafterchanges"==e&&obj.options.persistance){var t=1==obj.options.persistance?obj.options.url:obj.options.persistance,n=obj.prepareJson(arguments[2]);obj.save(t,n)}return o},obj.prepareTable=function(){var e=obj.options.columns.length;if(obj.options.data&&void 0!==obj.options.data[0]){var o=Object.keys(obj.options.data[0]);o.length>e&&(e=o.length)}obj.options.minDimensions[0]>e&&(e=obj.options.minDimensions[0]);for(var t=[],n=0;n<e;n++)obj.options.colHeaders[n]||(obj.options.colHeaders[n]=""),obj.options.colWidths[n]||(obj.options.colWidths[n]=obj.options.defaultColWidth),obj.options.colAlignments[n]||(obj.options.colAlignments[n]=obj.options.defaultColAlign),obj.options.columns[n]?obj.options.columns[n].type||(obj.options.columns[n].type="text"):obj.options.columns[n]={type:"text"},obj.options.columns[n].name||(obj.options.columns[n].name=o&&o[n]?o[n]:n),obj.options.columns[n].source||(obj.options.columns[n].source=[]),obj.options.columns[n].options||(obj.options.columns[n].options=[]),obj.options.columns[n].editor||(obj.options.columns[n].editor=null),obj.options.columns[n].allowEmpty||(obj.options.columns[n].allowEmpty=!1),obj.options.columns[n].title||(obj.options.columns[n].title=obj.options.colHeaders[n]?obj.options.colHeaders[n]:""),obj.options.columns[n].width||(obj.options.columns[n].width=obj.options.colWidths[n]?obj.options.colWidths[n]:obj.options.defaultColWidth),obj.options.columns[n].align||(obj.options.columns[n].align=obj.options.colAlignments[n]?obj.options.colAlignments[n]:"center"),"autocomplete"==obj.options.columns[n].type||"dropdown"==obj.options.columns[n].type?obj.options.columns[n].url&&t.push({url:obj.options.columns[n].url,index:n,method:"GET",dataType:"json",success:function(e){for(var o=0;o<e.length;o++)obj.options.columns[this.index].source.push(e[o])}}):"calendar"==obj.options.columns[n].type&&(obj.options.columns[n].options.format||(obj.options.columns[n].options.format="DD/MM/YYYY"));t.length?jSuites.ajax(t,(function(){obj.createTable()})):obj.createTable()},obj.createTable=function(){obj.table=document.createElement("table"),obj.thead=document.createElement("thead"),obj.tbody=document.createElement("tbody"),obj.headers=[],obj.colgroup=[],obj.content=document.createElement("div"),obj.content.classList.add("jexcel_content"),obj.content.onscroll=function(e){obj.scrollControls(e)},obj.content.onwheel=function(e){obj.wheelControls(e)},obj.toolbar=document.createElement("div"),obj.toolbar.classList.add("jexcel_toolbar");var e=document.createElement("div"),o=document.createTextNode(obj.options.text.search+": ");obj.searchInput=document.createElement("input"),obj.searchInput.classList.add("jexcel_search"),e.appendChild(o),e.appendChild(obj.searchInput),obj.searchInput.onfocus=function(){obj.resetSelection()};var t=document.createElement("div");if(obj.options.pagination>0&&obj.options.paginationOptions&&obj.options.paginationOptions.length>0){obj.paginationDropdown=document.createElement("select"),obj.paginationDropdown.classList.add("jexcel_pagination_dropdown"),obj.paginationDropdown.onchange=function(){obj.options.pagination=parseInt(this.value),obj.page(0)};for(var n=0;n<obj.options.paginationOptions.length;n++){var r=document.createElement("option");r.value=obj.options.paginationOptions[n],r.innerHTML=obj.options.paginationOptions[n],obj.paginationDropdown.appendChild(r)}obj.paginationDropdown.value=obj.options.pagination,t.appendChild(document.createTextNode(obj.options.text.show)),t.appendChild(obj.paginationDropdown),t.appendChild(document.createTextNode(obj.options.text.entries))}var l,s=document.createElement("div");if(s.classList.add("jexcel_filter"),s.appendChild(t),s.appendChild(e),obj.colgroupContainer=document.createElement("colgroup"),(l=document.createElement("col")).setAttribute("width","50"),obj.colgroupContainer.appendChild(l),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var i=0;i<obj.options.nestedHeaders.length;i++)obj.thead.appendChild(obj.createNestedHeader(obj.options.nestedHeaders[i]));else obj.thead.appendChild(obj.createNestedHeader(obj.options.nestedHeaders));for(obj.headerContainer=document.createElement("tr"),(l=document.createElement("td")).classList.add("jexcel_selectall"),obj.headerContainer.appendChild(l),n=0;n<obj.options.columns.length;n++)obj.createCellHeader(n),obj.headerContainer.appendChild(obj.headers[n]),obj.colgroupContainer.appendChild(obj.colgroup[n]);if(obj.thead.appendChild(obj.headerContainer),1==obj.options.filters){obj.filter=document.createElement("tr");var a=document.createElement("td");for(obj.filter.appendChild(a),n=0;n<obj.options.columns.length;n++)(a=document.createElement("td")).innerHTML="&nbsp;",a.setAttribute("data-x",n),a.className="jexcel_column_filter","hidden"==obj.options.columns[n].type&&(a.style.display="none"),obj.filter.appendChild(a);obj.thead.appendChild(obj.filter)}obj.table=document.createElement("table"),obj.table.classList.add("jexcel"),obj.table.setAttribute("cellpadding","0"),obj.table.setAttribute("cellspacing","0"),obj.table.setAttribute("unselectable","yes"),obj.table.appendChild(obj.colgroupContainer),obj.table.appendChild(obj.thead),obj.table.appendChild(obj.tbody),obj.options.textOverflow||obj.table.classList.add("jexcel_overflow"),obj.corner=document.createElement("div"),obj.corner.className="jexcel_corner",obj.corner.setAttribute("unselectable","on"),obj.corner.setAttribute("onselectstart","return false"),0==obj.options.selectionCopy&&(obj.corner.style.display="none"),obj.textarea=document.createElement("textarea"),obj.textarea.className="jexcel_textarea",obj.textarea.id="jexcel_textarea",obj.textarea.tabIndex="-1",obj.contextMenu=document.createElement("div"),obj.contextMenu.className="jexcel_contextmenu",jSuites.contextmenu(obj.contextMenu,{onclick:function(){obj.contextMenu.contextmenu.close(!1)}});var c=document.createElement("a");c.setAttribute("href","https://bossanova.uk/jspreadsheet/"),obj.ads=document.createElement("div"),obj.ads.className="jexcel_about";var u=document.createElement("span");u.innerHTML="Jspreadsheet CE",c.appendChild(u),obj.ads.appendChild(c),document.createElement("div").classList.add("jexcel_table"),obj.pagination=document.createElement("div"),obj.pagination.classList.add("jexcel_pagination");var d=document.createElement("div"),j=document.createElement("div");if(obj.pagination.appendChild(d),obj.pagination.appendChild(j),obj.options.pagination||(obj.pagination.style.display="none"),1==obj.options.search&&el.appendChild(s),obj.content.appendChild(obj.table),obj.content.appendChild(obj.corner),obj.content.appendChild(obj.textarea),el.appendChild(obj.toolbar),el.appendChild(obj.content),el.appendChild(obj.pagination),el.appendChild(obj.contextMenu),el.appendChild(obj.ads),el.classList.add("jexcel_container"),obj.options.toolbar&&obj.options.toolbar.length&&obj.createToolbar(),1==obj.options.fullscreen?el.classList.add("fullscreen"):1==obj.options.tableOverflow&&(obj.options.tableHeight&&(obj.content.style["overflow-y"]="auto",obj.content.style["box-shadow"]="rgb(221 221 221) 2px 2px 5px 0.1px",obj.content.style.maxHeight=obj.options.tableHeight),obj.options.tableWidth&&(obj.content.style["overflow-x"]="auto",obj.content.style.width=obj.options.tableWidth)),1!=obj.options.tableOverflow&&obj.options.toolbar&&el.classList.add("with-toolbar"),1==obj.options.columnDrag&&obj.thead.classList.add("draggable"),1==obj.options.columnResize&&obj.thead.classList.add("resizable"),1==obj.options.rowDrag&&obj.tbody.classList.add("draggable"),1==obj.options.rowResize&&obj.tbody.classList.add("resizable"),obj.setData(),obj.options.style&&obj.setStyle(obj.options.style,null,null,1,1),obj.options.classes){var b=Object.keys(obj.options.classes);for(n=0;n<b.length;n++){var p=jexcel.getIdFromColumnName(b[n],!0);obj.records[p[1]][p[0]].classList.add(obj.options.classes[b[n]])}}},obj.refresh=function(){obj.options.url?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.url,method:obj.options.method,data:obj.options.requestVariables,dataType:"json",success:function(e){obj.options.data=e.data?e.data:e,obj.setData(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.setData()},obj.setData=function(e){if(e&&("string"==typeof e&&(e=JSON.parse(e)),obj.options.data=e),obj.options.data||(obj.options.data=[]),obj.options.data&&obj.options.data[0]&&!Array.isArray(obj.options.data[0])){e=[];for(var o=0;o<obj.options.data.length;o++){for(var t=[],n=0;n<obj.options.columns.length;n++)t[n]=obj.options.data[o][obj.options.columns[n].name];e.push(t)}obj.options.data=e}o=0,n=0;var r=obj.options.columns.length,l=obj.options.data.length,s=obj.options.minDimensions[0],i=obj.options.minDimensions[1],a=s>r?s:r,c=i>l?i:l;for(o=0;o<c;o++)for(n=0;n<a;n++)null==obj.options.data[o]&&(obj.options.data[o]=[]),null==obj.options.data[o][n]&&(obj.options.data[o][n]="");if(obj.rows=[],obj.results=null,obj.records=[],obj.history=[],obj.historyIndex=-1,obj.tbody.innerHTML="",1==obj.options.lazyLoading){var u=0,d=obj.options.data.length<100?obj.options.data.length:100;obj.options.pagination&&(obj.options.pagination=!1,console.error("Jspreadsheet: Pagination will be disable due the lazyLoading"))}else obj.options.pagination?(obj.pageNumber||(obj.pageNumber=0),obj.options.pagination,u=obj.options.pagination*obj.pageNumber,d=obj.options.pagination*obj.pageNumber+obj.options.pagination,obj.options.data.length<d&&(d=obj.options.data.length)):(u=0,d=obj.options.data.length);for(o=0;o<obj.options.data.length;o++){var j=obj.createRow(o,obj.options.data[o]);o>=u&&o<d&&obj.tbody.appendChild(j)}if(1==obj.options.lazyLoading||obj.options.pagination&&obj.updatePagination(),obj.options.mergeCells){var b=Object.keys(obj.options.mergeCells);for(n=0;n<b.length;n++){var p=obj.options.mergeCells[b[n]];obj.setMerge(b[n],p[0],p[1],1)}}obj.updateTable(),obj.dispatch("onload",el,obj)},obj.getData=function(e,o){for(var t=[],n=0,r=0,l=1==o||0==obj.options.copyCompatibility,s=obj.options.columns.length,i=obj.options.data.length,a=0;a<i;a++){n=0;for(var c=0;c<s;c++)e&&!obj.records[a][c].classList.contains("highlight")||(t[r]||(t[r]=[]),t[r][n]=l?obj.options.data[a][c]:obj.records[a][c].innerHTML,n++);n>0&&r++}return t},obj.getJsonRow=function(e){for(var o=obj.options.data[e],t=obj.options.columns.length,n={},r=0;r<t;r++)obj.options.columns[r].name||(obj.options.columns[r].name=r),n[obj.options.columns[r].name]=o[r];return n},obj.getJson=function(e){for(var o=[],t=obj.options.columns.length,n=obj.options.data.length,r=0;r<n;r++){for(var l=null,s=0;s<t;s++)e&&!obj.records[r][s].classList.contains("highlight")||(null==l&&(l={}),obj.options.columns[s].name||(obj.options.columns[s].name=s),l[obj.options.columns[s].name]=obj.options.data[r][s]);null!=l&&o.push(l)}return o},obj.prepareJson=function(e){for(var o=[],t=0;t<e.length;t++){var n=e[t].x,r=e[t].y,l=obj.options.columns[n].name?obj.options.columns[n].name:n;o[r]||(o[r]={row:r,data:{}}),o[r].data[l]=e[t].newValue}return o.filter((function(e){return null!=e}))},obj.save=function(e,o){var t=obj.dispatch("onbeforesave",el,obj,o);if(t)o=t;else if(!1===t)return!1;jSuites.ajax({url:e,method:"POST",dataType:"json",data:{data:JSON.stringify(o)},success:function(e){obj.dispatch("onsave",el,obj,o)}})},obj.getRowData=function(e){return obj.options.data[e]},obj.setRowData=function(e,o){for(var t=0;t<obj.headers.length;t++){var n=jexcel.getColumnNameFromId([t,e]);null!=o[t]&&obj.setValue(n,o[t])}},obj.getColumnData=function(e){for(var o=[],t=0;t<obj.options.data.length;t++)o.push(obj.options.data[t][e]);return o},obj.setColumnData=function(e,o){for(var t=0;t<obj.rows.length;t++){var n=jexcel.getColumnNameFromId([e,t]);null!=o[t]&&obj.setValue(n,o[t])}},obj.createRow=function(e,o){obj.records[e]||(obj.records[e]=[]),o||(o=obj.options.data[e]),obj.rows[e]=document.createElement("tr"),obj.rows[e].setAttribute("data-y",e);var t=null;obj.options.defaultRowHeight&&(obj.rows[e].style.height=obj.options.defaultRowHeight+"px"),obj.options.rows[e]&&(obj.options.rows[e].height&&(obj.rows[e].style.height=obj.options.rows[e].height),obj.options.rows[e].title&&(t=obj.options.rows[e].title)),t||(t=parseInt(e+1));var n=document.createElement("td");n.innerHTML=t,n.setAttribute("data-y",e),n.className="jexcel_row",obj.rows[e].appendChild(n);for(var r=0;r<obj.options.columns.length;r++)obj.records[e][r]=obj.createCell(r,e,o[r]),obj.rows[e].appendChild(obj.records[e][r]);return obj.rows[e]},obj.parseValue=function(e,o,t,n){"="==(""+t).substr(0,1)&&1==obj.options.parseFormulas&&(t=obj.executeFormula(t,e,o));var r=obj.options.columns[e];if(r&&!isFormula(t)){var l=null;if(l=getMask(r)){t&&t==Number(t)&&(t=Number(t));var s=jSuites.mask.render(t,l,!0);if(n&&l.mask){var i=l.mask.split(";");i[1]&&(i[1].match(new RegExp("\\[Red\\]","gi"))&&(t<0?n.classList.add("red"):n.classList.remove("red")),i[1].match(new RegExp("\\(","gi"))&&t<0&&(s="("+s+")"))}s&&(t=s)}}return t};var validDate=function(e){return"-"==(e=""+e).substr(4,1)&&"-"==e.substr(7,1)||4==(e=e.split("-"))[0].length&&e[0]==Number(e[0])&&2==e[1].length&&e[1]==Number(e[1])};obj.createCell=function(e,o,t){var n=document.createElement("td");if(n.setAttribute("data-x",e),n.setAttribute("data-y",o),"="==(""+t).substr(0,1)&&1==obj.options.secureFormulas){var r=secureFormula(t);r!=t&&(t=r)}if(obj.options.columns[e].editor)!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML?n.innerHTML=t:n.textContent=t,"function"==typeof obj.options.columns[e].editor.createCell&&(n=obj.options.columns[e].editor.createCell(n));else if("hidden"==obj.options.columns[e].type)n.style.display="none",n.textContent=t;else if("checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type){var l=document.createElement("input");l.type=obj.options.columns[e].type,l.name="c"+e,l.checked=1==t||1==t||"true"==t,l.onclick=function(){obj.setValue(n,this.checked)},1!=obj.options.columns[e].readOnly&&0!=obj.options.editable||l.setAttribute("disabled","disabled"),n.appendChild(l),obj.options.data[o][e]=l.checked}else if("calendar"==obj.options.columns[e].type){var s=null;if(!validDate(t)){var i=jSuites.calendar.extractDateFromString(t,obj.options.columns[e].options.format);i&&(s=i)}n.textContent=jSuites.calendar.getDateString(s||t,obj.options.columns[e].options.format)}else if("dropdown"==obj.options.columns[e].type||"autocomplete"==obj.options.columns[e].type)n.classList.add("jexcel_dropdown"),n.textContent=obj.getDropDownValue(e,t);else if("color"==obj.options.columns[e].type)if("square"==obj.options.columns[e].render){var a=document.createElement("div");a.className="color",a.style.backgroundColor=t,n.appendChild(a)}else n.style.color=t,n.textContent=t;else if("image"==obj.options.columns[e].type){if(t&&"data:image"==t.substr(0,10)){var c=document.createElement("img");c.src=t,n.appendChild(c)}}else if("html"==obj.options.columns[e].type)n.innerHTML=stripScript(obj.parseValue(e,o,t,n));else if(!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML)n.innerHTML=stripScript(obj.parseValue(e,o,t,n));else{var u=document.createElement("div");u.textContent=obj.parseValue(e,o,t,n),n.appendChild(u)}1==obj.options.columns[e].readOnly&&(n.className="readonly");var d=obj.options.columns[e].align?obj.options.columns[e].align:"center";return n.style.textAlign=d,0!=obj.options.columns[e].wordWrap&&(1==obj.options.wordWrap||1==obj.options.columns[e].wordWrap||n.innerHTML.length>200)&&(n.style.whiteSpace="pre-wrap"),e>0&&1==this.options.textOverflow&&(t||n.innerHTML?obj.records[o][e-1].style.overflow="hidden":e==obj.options.columns.length-1&&(n.style.overflow="hidden")),n},obj.createCellHeader=function(e){var o=obj.options.columns[e].width?obj.options.columns[e].width:obj.options.defaultColWidth,t=obj.options.columns[e].align?obj.options.columns[e].align:obj.options.defaultColAlign;obj.headers[e]=document.createElement("td"),obj.options.stripHTML?obj.headers[e].textContent=obj.options.columns[e].title?obj.options.columns[e].title:jexcel.getColumnName(e):obj.headers[e].innerHTML=obj.options.columns[e].title?obj.options.columns[e].title:jexcel.getColumnName(e),obj.headers[e].setAttribute("data-x",e),obj.headers[e].style.textAlign=t,obj.options.columns[e].title&&obj.headers[e].setAttribute("title",obj.headers[e].innerText),obj.options.columns[e].id&&obj.headers[e].setAttribute("id",obj.options.columns[e].id),obj.colgroup[e]=document.createElement("col"),obj.colgroup[e].setAttribute("width",o),"hidden"==obj.options.columns[e].type&&(obj.headers[e].style.display="none",obj.colgroup[e].style.display="none")},obj.updateNestedHeader=function(e,o,t){obj.options.nestedHeaders[o][e].title&&(obj.options.nestedHeaders[o][e].title=t,obj.options.nestedHeaders[o].element.children[e+1].textContent=t)},obj.createNestedHeader=function(e){var o=document.createElement("tr");o.classList.add("jexcel_nested");var t=document.createElement("td");o.appendChild(t),e.element=o;for(var n=0,r=0;r<e.length;r++){e[r].colspan||(e[r].colspan=1),e[r].align||(e[r].align="center"),e[r].title||(e[r].title=""),e[r].id||(e[r].id="");for(var l=e[r].colspan,s=[],i=0;i<l;i++)obj.options.columns[n]&&"hidden"==obj.options.columns[n].type&&l++,s.push(n),n++;(t=document.createElement("td")).setAttribute("data-column",s.join(",")),t.setAttribute("colspan",e[r].colspan),t.setAttribute("align",e[r].align),t.setAttribute("id",e[r].id),t.textContent=e[r].title,o.appendChild(t)}return o},obj.createToolbar=function(e){e?obj.options.toolbar=e:e=obj.options.toolbar;for(var o=0;o<e.length;o++)if("i"==e[o].type)(l=document.createElement("i")).classList.add("jexcel_toolbar_item"),l.classList.add("material-icons"),l.setAttribute("data-k",e[o].k),l.setAttribute("data-v",e[o].v),l.setAttribute("id",e[o].id),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),e[o].onclick&&(e[o].onclick,1)?l.onclick=function(o){var t=o;return function(){e[t].onclick(el,obj,this)}}(o):l.onclick=function(){var e=this.getAttribute("data-k"),o=this.getAttribute("data-v");obj.setStyle(obj.highlighted,e,o)},l.textContent=e[o].content,obj.toolbar.appendChild(l);else if("select"==e[o].type){var t=!1;(l=document.createElement("select")).classList.add("jexcel_toolbar_item"),l.setAttribute("data-k",e[o].k),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),e[o].onchange&&(e[o].onchange,1)?(l.onchange=e[o].onchange,t=!0):l.onchange=function(){var e=this.getAttribute("data-k");obj.setStyle(obj.highlighted,e,this.value)};for(var n=0;n<e[o].v.length;n++){var r=document.createElement("option");r.value=e[o].v[n],r.textContent=e[o].v[n],e[o].selectedValue&&r.value===e[o].selectedValue&&(r.selected=!0),l.appendChild(r)}t&&l.dispatchEvent(new Event("change")),obj.toolbar.appendChild(l)}else if("color"==e[o].type){var l;(l=document.createElement("i")).classList.add("jexcel_toolbar_item"),l.classList.add("material-icons"),l.setAttribute("data-k",e[o].k),l.setAttribute("data-v",""),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),obj.toolbar.appendChild(l),l.textContent=e[o].content,jSuites.color(l,{onchange:function(e,o){var t=e.getAttribute("data-k");obj.setStyle(obj.highlighted,t,o)}})}},obj.setMerge=function(e,o,t,n){var r=!1;if(!e){if(!obj.highlighted.length)return alert(obj.options.text.noCellsSelected),null;var l=parseInt(obj.highlighted[0].getAttribute("data-x")),s=parseInt(obj.highlighted[0].getAttribute("data-y")),i=parseInt(obj.highlighted[obj.highlighted.length-1].getAttribute("data-x")),a=parseInt(obj.highlighted[obj.highlighted.length-1].getAttribute("data-y"));e=jexcel.getColumnNameFromId([l,s]),o=i-l+1,t=a-s+1}var c=jexcel.getIdFromColumnName(e,!0);if(obj.options.mergeCells[e])obj.records[c[1]][c[0]].getAttribute("data-merged")&&(r=obj.options.text.cellAlreadyMerged);else if((!o||o<2)&&(!t||t<2))r=obj.options.text.invalidMergeProperties;else for(var u=c[1];u<c[1]+t;u++)for(var d=c[0];d<c[0]+o;d++)jexcel.getColumnNameFromId([d,u]),obj.records[u][d].getAttribute("data-merged")&&(r=obj.options.text.thereIsAConflictWithAnotherMergedCell);if(r)alert(r);else{o>1?obj.records[c[1]][c[0]].setAttribute("colspan",o):o=1,t>1?obj.records[c[1]][c[0]].setAttribute("rowspan",t):t=1,obj.options.mergeCells[e]=[o,t,[]],obj.records[c[1]][c[0]].setAttribute("data-merged","true"),obj.records[c[1]][c[0]].style.overflow="hidden";for(var j=[],b=c[1];b<c[1]+t;b++)for(var p=c[0];p<c[0]+o;p++)c[0]==p&&c[1]==b||(j.push(obj.options.data[b][p]),obj.updateCell(p,b,"",!0),obj.options.mergeCells[e][2].push(obj.records[b][p]),obj.records[b][p].style.display="none",obj.records[b][p]=obj.records[c[1]][c[0]]);obj.updateSelection(obj.records[c[1]][c[0]]),n||(obj.setHistory({action:"setMerge",column:e,colspan:o,rowspan:t,data:j}),obj.dispatch("onmerge",el,e,o,t))}},obj.getMerge=function(e){var o={};if(e)o=obj.options.mergeCells[e]?[obj.options.mergeCells[e][0],obj.options.mergeCells[e][1]]:null;else if(obj.options.mergeCells){obj.options.mergeCells;for(var t=Object.keys(obj.options.mergeCells),n=0;n<t.length;n++)o[t[n]]=[obj.options.mergeCells[t[n]][0],obj.options.mergeCells[t[n]][1]]}return o},obj.removeMerge=function(e,o,t){if(obj.options.mergeCells[e]){var n=jexcel.getIdFromColumnName(e,!0);obj.records[n[1]][n[0]].removeAttribute("colspan"),obj.records[n[1]][n[0]].removeAttribute("rowspan"),obj.records[n[1]][n[0]].removeAttribute("data-merged");for(var r=obj.options.mergeCells[e],l=0,s=0;s<r[1];s++)for(var i=0;i<r[0];i++)(s>0||i>0)&&(obj.records[n[1]+s][n[0]+i]=r[2][l],obj.records[n[1]+s][n[0]+i].style.display="",o&&o[l]&&obj.updateCell(n[0]+i,n[1]+s,o[l]),l++);obj.updateSelection(obj.records[n[1]][n[0]],obj.records[n[1]+s-1][n[0]+i-1]),t||delete obj.options.mergeCells[e]}},obj.destroyMerged=function(e){if(obj.options.mergeCells){obj.options.mergeCells;for(var o=Object.keys(obj.options.mergeCells),t=0;t<o.length;t++)obj.removeMerge(o[t],null,e)}},obj.isColMerged=function(e,o){var t=[];if(obj.options.mergeCells)for(var n=Object.keys(obj.options.mergeCells),r=0;r<n.length;r++){var l=jexcel.getIdFromColumnName(n[r],!0),s=obj.options.mergeCells[n[r]][0],i=l[0],a=l[0]+(s>1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i<e&&a>=e&&t.push(n[r]):i<=e&&a>e&&t.push(n[r])}return t},obj.isRowMerged=function(e,o){var t=[];if(obj.options.mergeCells)for(var n=Object.keys(obj.options.mergeCells),r=0;r<n.length;r++){var l=jexcel.getIdFromColumnName(n[r],!0),s=obj.options.mergeCells[n[r]][1],i=l[1],a=l[1]+(s>1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i<e&&a>=e&&t.push(n[r]):i<=e&&a>e&&t.push(n[r])}return t},obj.openFilter=function(e){if(obj.options.filters){e=parseInt(e),obj.resetSelection();var o=[];if("checkbox"==obj.options.columns[e].type)o.push({id:"true",name:"True"}),o.push({id:"false",name:"False"});else{for(var t=[],n=!1,r=0;r<obj.options.data.length;r++){var l=obj.options.data[r][e],s=obj.records[r][e].innerHTML;l&&s?t[l]=s:n=!0}var i=Object.keys(t);for(o=[],r=0;r<i.length;r++)o.push({id:i[r],name:t[i[r]]});n&&o.push({value:"",id:"",name:"(Blanks)"})}var a=document.createElement("div");obj.filter.children[e+1].innerHTML="",obj.filter.children[e+1].appendChild(a),obj.filter.children[e+1].style.paddingLeft="0px",obj.filter.children[e+1].style.paddingRight="0px",obj.filter.children[e+1].style.overflow="initial";var c={data:o,multiple:!0,autocomplete:!0,opened:!0,value:void 0!==obj.filters[e]?obj.filters[e]:null,width:"100%",position:1==obj.options.tableOverflow||1==obj.options.fullscreen,onclose:function(o){obj.resetFilters(),obj.filters[e]=o.dropdown.getValue(!0),obj.filter.children[e+1].innerHTML=o.dropdown.getText(),obj.filter.children[e+1].style.paddingLeft="",obj.filter.children[e+1].style.paddingRight="",obj.filter.children[e+1].style.overflow="",obj.closeFilter(e),obj.refreshSelection()}};jSuites.dropdown(a,c)}else console.log("Jspreadsheet: filters not enabled.")},obj.resetFilters=function(){if(obj.options.filters)for(var e=0;e<obj.filter.children.length;e++)obj.filter.children[e].innerHTML="&nbsp;",obj.filters[e]=null;obj.results=null,obj.updateResult()},obj.closeFilter=function(e){if(!e)for(var o=0;o<obj.filter.children.length;o++)obj.filters[o]&&(e=o);var t=function(e,o,t){for(var n=0;n<e.length;n++){var r=""+obj.options.data[t][o],l=""+obj.records[t][o].innerHTML;if(e[n]==r||e[n]==l)return!0}return!1},n=obj.filters[e];obj.results=[];for(var r=0;r<obj.options.data.length;r++)t(n,e,r)&&obj.results.push(r);obj.results.length||(obj.results=null),obj.updateResult()},obj.openEditor=function(e,o,t){var n=e.getAttribute("data-y"),r=e.getAttribute("data-x");obj.dispatch("oneditionstart",el,e,r,n),r>0&&(obj.records[n][r-1].style.overflow="hidden");var l=function(o){var t=e.getBoundingClientRect(),l=document.createElement(o);return l.style.width=t.width-6+"px",l.style.height=t.height-6+"px",l.style.minHeight=t.height-6+"px",e.classList.add("editor"),e.innerHTML="",e.appendChild(l),obj.dispatch("oncreateeditor",el,e,r,n,l),l};if(1==e.classList.contains("readonly"));else if(obj.edition=[obj.records[n][r],obj.records[n][r].innerHTML,r,n],obj.options.columns[r].editor)obj.options.columns[r].editor.openEditor(e,el,o,t);else if("hidden"==obj.options.columns[r].type);else if("checkbox"==obj.options.columns[r].type||"radio"==obj.options.columns[r].type){var s=!e.children[0].checked;obj.setValue(e,s),obj.edition=null}else if("dropdown"==obj.options.columns[r].type||"autocomplete"==obj.options.columns[r].type){if(s=obj.options.data[n][r],obj.options.columns[r].multiple&&!Array.isArray(s)&&(s=s.split(";")),"function"==typeof obj.options.columns[r].filter)var i=obj.options.columns[r].filter(el,e,r,n,obj.options.columns[r].source);else i=obj.options.columns[r].source;for(var a=[],c=0;c<i.length;c++)a.push(i[c]);var u=l("div"),d={data:a,multiple:!!obj.options.columns[r].multiple,autocomplete:!(!obj.options.columns[r].autocomplete&&"autocomplete"!=obj.options.columns[r].type),opened:!0,value:s,width:"100%",height:u.style.minHeight,position:1==obj.options.tableOverflow||1==obj.options.fullscreen,onclose:function(){obj.closeEditor(e,!0)}};obj.options.columns[r].options&&obj.options.columns[r].options.type&&(d.type=obj.options.columns[r].options.type),jSuites.dropdown(u,d)}else if("calendar"==obj.options.columns[r].type||"color"==obj.options.columns[r].type)s=obj.options.data[n][r],(u=l("input")).value=s,1!=obj.options.tableOverflow&&1!=obj.options.fullscreen||(obj.options.columns[r].options.position=!0),obj.options.columns[r].options.value=obj.options.data[n][r],obj.options.columns[r].options.opened=!0,obj.options.columns[r].options.onclose=function(o,t){obj.closeEditor(e,!0)},"color"==obj.options.columns[r].type?jSuites.color(u,obj.options.columns[r].options):jSuites.calendar(u,obj.options.columns[r].options),u.focus();else if("html"==obj.options.columns[r].type){s=obj.options.data[n][r],(u=l("div")).style.position="relative",(p=document.createElement("div")).classList.add("jexcel_richtext"),u.appendChild(p),jSuites.editor(p,{focus:!0,value:s});var j=e.getBoundingClientRect(),b=p.getBoundingClientRect();window.innerHeight<j.bottom+b.height?p.style.top=j.top-(b.height+2)+"px":p.style.top=j.top+"px"}else if("image"==obj.options.columns[r].type){var p,h=e.children[0];(u=l("div")).style.position="relative",(p=document.createElement("div")).classList.add("jclose"),h&&h.src&&p.appendChild(h),u.appendChild(p),jSuites.image(p,obj.options.imageOptions),j=e.getBoundingClientRect(),b=p.getBoundingClientRect(),window.innerHeight<j.bottom+b.height?p.style.top=j.top-(b.height+2)+"px":p.style.top=j.top+"px"}else{e.classList.add("editing");var g=e.getBoundingClientRect().height;if(obj.rows[n].style.setProperty("--table-editor-line-clamp-editing",Math.floor((g-10)/14)),obj.updateCornerPosition(),s=1==o?"":obj.options.data[n][r],0==obj.options.columns[r].wordWrap||1!=obj.options.wordWrap&&1!=obj.options.columns[r].wordWrap)u=l("input");else u=l("textarea");u.focus(),u.value=s,d=obj.options.columns[r];var f=null;if(!isFormula(s)&&(f=getMask(d))){if(!d.disabledMaskOnEdition)if(d.mask){var m=d.mask.split(";");u.setAttribute("data-mask",m[0])}else d.locale&&u.setAttribute("data-locale",d.locale);f.input=u,u.mask=f,jSuites.mask.render(s,f,!1)}u.onblur=function(){obj.closeEditor(e,!0)},u.scrollLeft=u.scrollWidth}},obj.closeEditor=function(e,o){var t=parseInt(e.getAttribute("data-x")),n=parseInt(e.getAttribute("data-y"));if(e.classList.remove("editing"),obj.rows[n].style.removeProperty("--table-editor-line-clamp-editing"),obj.updateCornerPosition(),1==o){if(obj.options.columns[t].editor)var r=obj.options.columns[t].editor.closeEditor(e,o);else if("checkbox"==obj.options.columns[t].type||"radio"==obj.options.columns[t].type||"hidden"==obj.options.columns[t].type);else if("dropdown"==obj.options.columns[t].type||"autocomplete"==obj.options.columns[t].type)r=e.children[0].dropdown.close(!0);else if("calendar"==obj.options.columns[t].type)r=e.children[0].calendar.close(!0);else if("color"==obj.options.columns[t].type)r=e.children[0].color.close(!0);else if("html"==obj.options.columns[t].type)r=e.children[0].children[0].editor.getData();else if("image"==obj.options.columns[t].type){var l=e.children[0].children[0].children[0];r=l&&"IMG"==l.tagName?l.src:""}else if("numeric"==obj.options.columns[t].type)"="!=(""+(r=e.children[0].value)).substr(0,1)&&""==r&&(r=obj.options.columns[t].allowEmpty?"":0),e.children[0].onblur=null;else{r=e.children[0].value,e.children[0].onblur=null;var s,i=obj.options.columns[t];if((s=getMask(i))&&""!==r&&!isFormula(r)&&"number"!=typeof r){var a=jSuites.mask.extract(r,s,!0);a&&""!==a.value&&(r=a.value)}}obj.options.data[n][t]==r?e.innerHTML=obj.edition[1]:obj.setValue(e,r)}else obj.options.columns[t].editor?obj.options.columns[t].editor.closeEditor(e,o):"dropdown"==obj.options.columns[t].type||"autocomplete"==obj.options.columns[t].type?e.children[0].dropdown.close(!0):"calendar"==obj.options.columns[t].type?e.children[0].calendar.close(!0):"color"==obj.options.columns[t].type?e.children[0].color.close(!0):e.children[0].onblur=null,e.innerHTML=obj.edition&&obj.edition[1]?obj.edition[1]:"";obj.dispatch("oneditionend",el,e,t,n,r,o),e.classList.remove("editor"),obj.edition=null},obj.getCell=function(e){var o=(e=jexcel.getIdFromColumnName(e,!0))[0],t=e[1];return obj.records[t][o]},obj.getColumnOptions=function(e,o){var t=obj.options.columns[e];return t||(t={type:"text"}),t},obj.getCellFromCoords=function(e,o){return obj.records[o][e]},obj.getLabel=function(e){var o=(e=jexcel.getIdFromColumnName(e,!0))[0],t=e[1];return obj.records[t][o].innerHTML},obj.getLabelFromCoords=function(e,o){return obj.records[o][e].innerHTML},obj.getValue=function(e,o){if("object"==typeof e)var t=e.getAttribute("data-x"),n=e.getAttribute("data-y");else t=(e=jexcel.getIdFromColumnName(e,!0))[0],n=e[1];var r=null;return null!=t&&null!=n&&(obj.records[n]&&obj.records[n][t]&&(o||1==obj.options.copyCompatibility)?r=obj.records[n][t].innerHTML:obj.options.data[n]&&"undefined"!=obj.options.data[n][t]&&(r=obj.options.data[n][t])),r},obj.getValueFromCoords=function(e,o,t){var n=null;return null!=e&&null!=o&&(obj.records[o]&&obj.records[o][e]&&t||1==obj.options.copyCompatibility?n=obj.records[o][e].innerHTML:obj.options.data[o]&&"undefined"!=obj.options.data[o][e]&&(n=obj.options.data[o][e])),n},obj.setValue=function(e,o,t){var n=[];if("string"==typeof e){var r=(a=jexcel.getIdFromColumnName(e,!0))[0],l=a[1];n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n)}else if(r=null,l=null,e&&e.getAttribute&&(r=e.getAttribute("data-x"),l=e.getAttribute("data-y")),null!=r&&null!=l)n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n);else{var s=Object.keys(e);if(s.length>0)for(var i=0;i<s.length;i++){var a;"string"==typeof e[i]?(r=(a=jexcel.getIdFromColumnName(e[i],!0))[0],l=a[1]):null!=e[i].x&&null!=e[i].y?(r=e[i].x,l=e[i].y,null!=e[i].newValue?o=e[i].newValue:null!=e[i].value&&(o=e[i].value)):(r=e[i].getAttribute("data-x"),l=e[i].getAttribute("data-y")),null!=r&&null!=l&&(n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n))}}obj.setHistory({action:"setValue",records:n,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,n)},obj.setValueFromCoords=function(e,o,t,n){var r=[];r.push(obj.updateCell(e,o,t,n)),obj.updateFormulaChain(e,o,r),obj.setHistory({action:"setValue",records:r,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,r)},obj.setCheckRadioValue=function(){for(var e=[],o=Object.keys(obj.highlighted),t=0;t<o.length;t++){var n=obj.highlighted[t].getAttribute("data-x"),r=obj.highlighted[t].getAttribute("data-y");"checkbox"!=obj.options.columns[n].type&&"radio"!=obj.options.columns[n].type||e.push(obj.updateCell(n,r,!obj.options.data[r][n]))}e.length&&(obj.setHistory({action:"setValue",records:e,selection:obj.selectedCell}),obj.onafterchanges(el,e))};var stripScript=function(e){var o=new Option;o.innerHTML=e;var t=null;for(e=o.getElementsByTagName("script");t=e[0];)t.parentNode.removeChild(t);return o.innerHTML};obj.updateCell=function(e,o,t,n){if(1!=obj.records[o][e].classList.contains("readonly")||n){var r;"="==(""+t).substr(0,1)&&1==obj.options.secureFormulas&&(r=secureFormula(t))!=t&&(t=r),null!=(r=obj.dispatch("onbeforechange",el,obj.records[o][e],e,o,t))&&(t=r),obj.options.columns[e].editor&&"function"==typeof obj.options.columns[e].editor.updateCell&&(t=obj.options.columns[e].editor.updateCell(obj.records[o][e],t,n)),d={x:e,y:o,col:e,row:o,newValue:t,oldValue:obj.options.data[o][e]};let j=obj.options.columns[e].editor;if(j)obj.options.data[o][e]=t,"function"==typeof j.setValue&&j.setValue(obj.records[o][e],t);else if("checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type){if("radio"==obj.options.columns[e].type)for(var l=0;l<obj.options.data.length;l++)obj.options.data[l][e]=!1;obj.records[o][e].children[0].checked=1==t||1==t||"true"==t||"TRUE"==t,obj.options.data[o][e]=obj.records[o][e].children[0].checked}else if("dropdown"==obj.options.columns[e].type||"autocomplete"==obj.options.columns[e].type)obj.options.data[o][e]=t,obj.records[o][e].textContent=obj.getDropDownValue(e,t);else if("calendar"==obj.options.columns[e].type){var s=null;if(!validDate(t)){var i=jSuites.calendar.extractDateFromString(t,obj.options.columns[e].options.format);i&&(s=i)}obj.options.data[o][e]=t,obj.records[o][e].textContent=jSuites.calendar.getDateString(s||t,obj.options.columns[e].options.format)}else if("color"==obj.options.columns[e].type)if(obj.options.data[o][e]=t,"square"==obj.options.columns[e].render){var a=document.createElement("div");a.className="color",a.style.backgroundColor=t,obj.records[o][e].textContent="",obj.records[o][e].appendChild(a)}else obj.records[o][e].style.color=t,obj.records[o][e].textContent=t;else if("image"==obj.options.columns[e].type){if(t=""+t,obj.options.data[o][e]=t,obj.records[o][e].innerHTML="",t&&"data:image"==t.substr(0,10)){var c=document.createElement("img");c.src=t,obj.records[o][e].appendChild(c)}}else{if(obj.options.data[o][e]=t,"html"==obj.options.columns[e].type)obj.records[o][e].innerHTML=stripScript(obj.parseValue(e,o,t));else if(!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML)obj.records[o][e].innerHTML=stripScript(obj.parseValue(e,o,t,obj.records[o][e]));else{var u=document.createElement("div");u.textContent=obj.parseValue(e,o,t,obj.records[o][e]),obj.records[o][e].textContent="",obj.records[o][e].appendChild(u)}0!=obj.options.columns[e].wordWrap&&(1==obj.options.wordWrap||1==obj.options.columns[e].wordWrap||obj.records[o][e].innerHTML.length>200)?obj.records[o][e].style.whiteSpace="pre-wrap":obj.records[o][e].style.whiteSpace=""}e>0&&(obj.records[o][e-1].style.overflow=t?"hidden":""),obj.dispatch("onchange",el,obj.records[o]&&obj.records[o][e]?obj.records[o][e]:null,e,o,t,d.oldValue)}else var d={x:e,y:o,col:e,row:o};return d},obj.copyData=function(e,o){var t=obj.getData(!0,!0),n=obj.selectedContainer,r=parseInt(e.getAttribute("data-x")),l=parseInt(e.getAttribute("data-y")),s=parseInt(o.getAttribute("data-x")),i=parseInt(o.getAttribute("data-y")),a=[],c=!1;if(n[0]==r){if(l<n[1])var u=l-n[1];else u=1;var d=0}else d=r<n[0]?r-n[0]:1,u=0;for(var j=0,b=0,p=l;p<=i;p++)if(!obj.rows[p]||"none"!=obj.rows[p].style.display){null==t[b]&&(b=0),j=0,n[0]!=r&&(d=r<n[0]?r-n[0]:1);for(var h=r;h<=s;h++){if(obj.records[p][h]&&!obj.records[p][h].classList.contains("readonly")&&"none"!=obj.records[p][h].style.display&&0==c){if(!obj.selection.length&&""!=obj.options.data[p][h]){c=!0;continue}(null==t[b]||null==t[b][j])&&(j=0);var g=t[b][j];if(g&&!t[1]&&1==obj.options.autoIncrement)if("text"==obj.options.columns[h].type||"number"==obj.options.columns[h].type)if("="==(""+g).substr(0,1)){var f=g.match(/([A-Z]+[0-9]+)/g);if(f){for(var m=[],C=0;C<f.length;C++){var x=jexcel.getIdFromColumnName(f[C],1);x[0]+=d,x[1]+=u,x[1]<0&&(x[1]=0);var v=jexcel.getColumnNameFromId([x[0],x[1]]);v!=f[C]&&(m[f[C]]=v)}m&&(g=obj.updateFormula(g,m))}}else g==Number(g)&&(g=Number(g)+u);else if("calendar"==obj.options.columns[h].type){var y=new Date(g);y.setDate(y.getDate()+u),g=y.getFullYear()+"-"+jexcel.doubleDigitFormat(parseInt(y.getMonth()+1))+"-"+jexcel.doubleDigitFormat(y.getDate())+" 00:00:00"}a.push(obj.updateCell(h,p,g)),obj.updateFormulaChain(h,p,a)}j++,n[0]!=r&&d++}b++,u++}obj.setHistory({action:"setValue",records:a,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,a)},obj.refreshSelection=function(){obj.selectedCell&&obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])},obj.conditionalSelectionUpdate=function(e,o,t){if(1==e){if(obj.selectedCell&&(o>=obj.selectedCell[1]&&o<=obj.selectedCell[3]||t>=obj.selectedCell[1]&&t<=obj.selectedCell[3]))return void obj.resetSelection()}else if(obj.selectedCell&&(o>=obj.selectedCell[0]&&o<=obj.selectedCell[2]||t>=obj.selectedCell[0]&&t<=obj.selectedCell[2]))return void obj.resetSelection()},obj.resetSelection=function(e){if(obj.highlighted.length){c=1;for(var o=0;o<obj.highlighted.length;o++){obj.highlighted[o].classList.remove("highlight"),obj.highlighted[o].classList.remove("highlight-left"),obj.highlighted[o].classList.remove("highlight-right"),obj.highlighted[o].classList.remove("highlight-top"),obj.highlighted[o].classList.remove("highlight-bottom"),obj.highlighted[o].classList.remove("highlight-selected");var t=parseInt(obj.highlighted[o].getAttribute("data-x")),n=parseInt(obj.highlighted[o].getAttribute("data-y"));if(obj.highlighted[o].getAttribute("data-merged"))var r=parseInt(obj.highlighted[o].getAttribute("colspan")),l=parseInt(obj.highlighted[o].getAttribute("rowspan")),s=r>0?t+(r-1):t,i=l>0?n+(l-1):n;else s=t,i=n;for(var a=t;a<=s;a++)obj.headers[a]&&obj.headers[a].classList.remove("selected");for(a=n;a<=i;a++)obj.rows[a]&&obj.rows[a].classList.remove("selected")}}else var c=0;return obj.highlighted=[],obj.selectedCell=null,obj.corner.style.top="-2000px",obj.corner.style.left="-2000px",1==e&&1==c&&obj.dispatch("onblur",el),c},obj.updateSelection=function(e,o,t){var n=e.getAttribute("data-x"),r=e.getAttribute("data-y");if(o)var l=o.getAttribute("data-x"),s=o.getAttribute("data-y");else l=n,s=r;obj.updateSelectionFromCoords(n,r,l,s,t)},obj.updateSelectionFromCoords=function(e,o,t,n,r){var l=obj.resetSelection();if(null==o&&(o=0,n=obj.rows.length-1),null==t&&(t=e),null==n&&(n=o),e>=obj.headers.length&&(e=obj.headers.length-1),o>=obj.rows.length&&(o=obj.rows.length-1),t>=obj.headers.length&&(t=obj.headers.length-1),n>=obj.rows.length&&(n=obj.rows.length-1),obj.selectedCell=[e,o,t,n],null!=e){if(obj.records[o][e]&&obj.records[o][e].classList.add("highlight-selected"),parseInt(e)<parseInt(t))var s=parseInt(e),i=parseInt(t);else s=parseInt(t),i=parseInt(e);if(parseInt(o)<parseInt(n))var a=parseInt(o),c=parseInt(n);else a=parseInt(n),c=parseInt(o);for(var u=s;u<=i;u++)for(var d=a;d<=c;d++)if(obj.records[d][u]&&obj.records[d][u].getAttribute("data-merged")){var j=parseInt(obj.records[d][u].getAttribute("data-x")),b=parseInt(obj.records[d][u].getAttribute("data-y")),p=parseInt(obj.records[d][u].getAttribute("colspan")),h=parseInt(obj.records[d][u].getAttribute("rowspan"));p>1&&(j<s&&(s=j),j+p>i&&(i=j+p-1)),h&&(b<a&&(a=b),b+h>c&&(c=b+h-1))}var g=null,f=null,m=null,C=null;for(d=a;d<=c;d++)"none"!=obj.rows[d].style.display&&(null==m&&(m=d),C=d);for(u=s;u<=i;u++){for(d=a;d<=c;d++)"none"!=obj.rows[d].style.display&&"none"!=obj.records[d][u].style.display&&(obj.records[d][u].classList.add("highlight"),obj.highlighted.push(obj.records[d][u]));"hidden"!=obj.options.columns[u].type&&(null==g&&(g=u),f=u)}for(g||(g=0),f||(f=0),u=g;u<=f;u++)"hidden"!=obj.options.columns[u].type&&(obj.records[m]&&obj.records[m][u]&&obj.records[m][u].classList.add("highlight-top"),obj.records[C]&&obj.records[C][u]&&obj.records[C][u].classList.add("highlight-bottom"),obj.headers[u].classList.add("selected"));for(d=m;d<=C;d++)obj.rows[d]&&"none"!=obj.rows[d].style.display&&(obj.records[d][g].classList.add("highlight-left"),obj.records[d][f].classList.add("highlight-right"),obj.rows[d].classList.add("selected"));obj.selectedContainer=[g,m,f,C]}0==l&&(obj.dispatch("onfocus",el),obj.removeCopyingSelection()),obj.dispatch("onselection",el,g,m,f,C,r),obj.updateCornerPosition()},obj.removeCopySelection=function(){for(var e=0;e<obj.selection.length;e++)obj.selection[e].classList.remove("selection"),obj.selection[e].classList.remove("selection-left"),obj.selection[e].classList.remove("selection-right"),obj.selection[e].classList.remove("selection-top"),obj.selection[e].classList.remove("selection-bottom");obj.selection=[]},obj.updateCopySelection=function(e,o){obj.removeCopySelection();var t=obj.selectedContainer[0],n=obj.selectedContainer[1],r=obj.selectedContainer[2],l=obj.selectedContainer[3];if(null!=e&&null!=o){if(e-r>0)var s=parseInt(r)+1,i=parseInt(e);else s=parseInt(e),i=parseInt(t)-1;if(o-l>0)var a=parseInt(l)+1,c=parseInt(o);else a=parseInt(o),c=parseInt(n)-1;i-s<=c-a?(s=parseInt(t),i=parseInt(r)):(a=parseInt(n),c=parseInt(l));for(var u=a;u<=c;u++)for(var d=s;d<=i;d++)obj.records[u][d]&&"none"!=obj.rows[u].style.display&&"none"!=obj.records[u][d].style.display&&(obj.records[u][d].classList.add("selection"),obj.records[a][d].classList.add("selection-top"),obj.records[c][d].classList.add("selection-bottom"),obj.records[u][s].classList.add("selection-left"),obj.records[u][i].classList.add("selection-right"),obj.selection.push(obj.records[u][d]))}},obj.updateCornerPosition=function(){if(obj.highlighted.length){var e=obj.highlighted[obj.highlighted.length-1],o=e.getAttribute("data-x"),t=obj.content.getBoundingClientRect(),n=t.left,r=t.top,l=e.getBoundingClientRect(),s=l.left,i=l.top,a=l.width,c=l.height,u=s-n+obj.content.scrollLeft+a-4,d=i-r+obj.content.scrollTop+c-4;if(obj.corner.style.top=d+"px",obj.corner.style.left=u+"px",obj.options.freezeColumns){var j=obj.getFreezeWidth();o>obj.options.freezeColumns-1&&s-n+a<j?obj.corner.style.display="none":1==obj.options.selectionCopy&&(obj.corner.style.display="")}else 1==obj.options.selectionCopy&&(obj.corner.style.display="")}else obj.corner.style.top="-2000px",obj.corner.style.left="-2000px"},obj.updateScroll=function(e){var o=obj.content.getBoundingClientRect(),t=o.left,n=o.top,r=o.width,l=o.height,s=obj.records[obj.selectedCell[3]][obj.selectedCell[2]].getBoundingClientRect(),i=s.left,a=s.top,c=s.width,u=s.height;if(0==e||1==e)var d=i-t+obj.content.scrollLeft,j=a-n+obj.content.scrollTop-2;else d=i-t+obj.content.scrollLeft+c,j=a-n+obj.content.scrollTop+u;j>obj.content.scrollTop+30&&j<obj.content.scrollTop+l||(j<obj.content.scrollTop+30?obj.content.scrollTop=j-u:obj.content.scrollTop=j-(l-2));var b=obj.getFreezeWidth();d>obj.content.scrollLeft+b&&d<obj.content.scrollLeft+r||(d<obj.content.scrollLeft+30?(obj.content.scrollLeft=d,obj.content.scrollLeft<50&&(obj.content.scrollLeft=0)):d<obj.content.scrollLeft+b?obj.content.scrollLeft=d-b-1:obj.content.scrollLeft=d-(r-20))},obj.getWidth=function(e){if(void 0===e)for(var o=[],t=0;t<obj.headers.length;t++)o.push(obj.options.columns[t].width);else"object"==typeof e&&(e=e.getAttribute("data-x")),o=obj.colgroup[e].getAttribute("width");return o},obj.setWidth=function(e,o,t){if(o){if(Array.isArray(e)){t||(t=[]);for(var n=0;n<e.length;n++){t[n]||(t[n]=obj.colgroup[e[n]].getAttribute("width"));var r=Array.isArray(o)&&o[n]?o[n]:o;obj.colgroup[e[n]].setAttribute("width",r),obj.options.columns[e[n]].width=r}}else t||(t=obj.colgroup[e].getAttribute("width")),obj.colgroup[e].setAttribute("width",o),obj.options.columns[e].width=o;obj.setHistory({action:"setWidth",column:e,oldValue:t,newValue:o}),obj.dispatch("onresizecolumn",el,e,o,t),obj.updateCornerPosition()}},obj.setHeight=function(e,o,t){o>0&&("object"==typeof e&&(e=e.getAttribute("data-y")),t||(t=obj.rows[e].getAttribute("height"))||(t=obj.rows[e].getBoundingClientRect().height),o=parseInt(o),obj.rows[e].style.setProperty("--table-editor-line-clamp",Math.floor((o-10)/14)),obj.options.rows[e]||(obj.options.rows[e]={}),obj.options.rows[e].height=o,obj.setHistory({action:"setHeight",row:e,oldValue:t,newValue:o}),obj.dispatch("onresizerow",el,e,o,t),obj.updateCornerPosition())},obj.getHeight=function(e){if(void 0===e)for(var o=[],t=0;t<obj.rows.length;t++){var n=obj.rows[t].style.height;n&&(o[t]=n)}else"object"==typeof e&&(e=$(e).getAttribute("data-y")),o=obj.rows[e].style.height;return o},obj.setFooter=function(e){if(e&&(obj.options.footers=e),obj.options.footers){obj.tfoot||(obj.tfoot=document.createElement("tfoot"),obj.table.appendChild(obj.tfoot));for(var o=0;o<obj.options.footers.length;o++){if(obj.tfoot.children[o])var t=obj.tfoot.children[o];else{t=document.createElement("tr");var n=document.createElement("td");t.appendChild(n),obj.tfoot.appendChild(t)}for(var r=0;r<obj.headers.length;r++){if(obj.options.footers[o][r]||(obj.options.footers[o][r]=""),obj.tfoot.children[o].children[r+1])n=obj.tfoot.children[o].children[r+1];else{n=document.createElement("td"),t.appendChild(n);var l=obj.options.columns[r].align?obj.options.columns[r].align:"center";n.style.textAlign=l}n.textContent=obj.parseValue(+obj.records.length+r,o,obj.options.footers[o][r]),n.style.display=obj.colgroup[r].style.display}}}},obj.getHeader=function(e){return obj.headers[e].textContent},obj.setHeader=function(e,o){if(obj.headers[e]){var t=obj.headers[e].textContent;o||(o=prompt(obj.options.text.columnName,t)),o&&(obj.headers[e].textContent=o,obj.headers[e].setAttribute("title",o),obj.options.columns[e].title=o),obj.setHistory({action:"setHeader",column:e,oldValue:t,newValue:o}),obj.dispatch("onchangeheader",el,e,t,o)}},obj.getHeaders=function(e){for(var o=[],t=0;t<obj.headers.length;t++)o.push(obj.getHeader(t));return e?o:o.join(obj.options.csvDelimiter)},obj.getMeta=function(e,o){return e?o?obj.options.meta[e]&&obj.options.meta[e][o]?obj.options.meta[e][o]:null:obj.options.meta[e]?obj.options.meta[e]:null:obj.options.meta},obj.setMeta=function(e,o,t){if(obj.options.meta||(obj.options.meta={}),o&&t)obj.options.meta[e]||(obj.options.meta[e]={}),obj.options.meta[e][o]=t;else for(var n=Object.keys(e),r=0;r<n.length;r++){obj.options.meta[n[r]]||(obj.options.meta[n[r]]={});for(var l=Object.keys(e[n[r]]),s=0;s<l.length;s++)obj.options.meta[n[r]][l[s]]=e[n[r]][l[s]]}obj.dispatch("onchangemeta",el,e,o,t)},obj.updateMeta=function(e){if(obj.options.meta){for(var o={},t=Object.keys(obj.options.meta),n=0;n<t.length;n++)e[t[n]]?o[e[t[n]]]=obj.options.meta[t[n]]:o[t[n]]=obj.options.meta[t[n]];obj.options.meta=o}},obj.getStyle=function(e,o){if(e)return e=jexcel.getIdFromColumnName(e,!0),o?obj.records[e[1]][e[0]].style[o]:obj.records[e[1]][e[0]].getAttribute("style");for(var t={},n=obj.options.data[0].length,r=obj.options.data.length,l=0;l<r;l++)for(var s=0;s<n;s++){var i=o?obj.records[l][s].style[o]:obj.records[l][s].getAttribute("style");i&&(t[jexcel.getColumnNameFromId([s,l])]=i)}return t},obj.resetStyle=function(e,o){for(var t=Object.keys(e),n=0;n<t.length;n++){var r=jexcel.getIdFromColumnName(t[n],!0);obj.records[r[1]]&&obj.records[r[1]][r[0]]&&obj.records[r[1]][r[0]].setAttribute("style","")}obj.setStyle(e,null,null,null,o)},obj.setStyle=function(e,o,t,n,r){var l={},s={},i=function(e,o,t){var r=jexcel.getIdFromColumnName(e,!0);if(obj.records[r[1]]&&obj.records[r[1]][r[0]]&&(0==obj.records[r[1]][r[0]].classList.contains("readonly")||n)){var i=obj.records[r[1]][r[0]].style[o];i!=t||n?obj.records[r[1]][r[0]].style[o]=t:(t="",obj.records[r[1]][r[0]].style[o]=""),s[e]||(s[e]=[]),l[e]||(l[e]=[]),s[e].push([o+":"+i]),l[e].push([o+":"+t])}};if(o&&t)if("string"==typeof e)i(e,o,t);else for(var a=[],c=0;c<e.length;c++){var u=e[c].getAttribute("data-x"),d=e[c].getAttribute("data-y"),j=jexcel.getColumnNameFromId([u,d]);a[j]||(i(j,o,t),a[j]=!0)}else{var b=Object.keys(e);for(c=0;c<b.length;c++){var p=e[b[c]];"string"==typeof p&&(p=p.split(";"));for(var h=0;h<p.length;h++)"string"==typeof p[h]&&(p[h]=p[h].split(":")),p[h][0].trim()&&i(b[c],p[h][0].trim(),p[h][1])}}for(b=Object.keys(s),c=0;c<b.length;c++)s[b[c]]=s[b[c]].join(";");for(b=Object.keys(l),c=0;c<b.length;c++)l[b[c]]=l[b[c]].join(";");r||obj.setHistory({action:"setStyle",oldValue:s,newValue:l}),obj.dispatch("onchangestyle",el,e,o,t)},obj.getComments=function(e,o){if(e)return"string"==typeof e&&(e=jexcel.getIdFromColumnName(e,!0)),o?[obj.records[e[1]][e[0]].getAttribute("title"),obj.records[e[1]][e[0]].getAttribute("author")]:obj.records[e[1]][e[0]].getAttribute("title")||"";for(var t={},n=0;n<obj.options.data.length;n++)for(var r=0;r<obj.options.columns.length;r++){var l=obj.records[n][r].getAttribute("title");l&&(t[e=jexcel.getColumnNameFromId([r,n])]=l)}return t},obj.setComments=function(e,o,t){if("string"==typeof e)var n=jexcel.getIdFromColumnName(e,!0);else n=e;var r=obj.records[n[1]][n[0]].getAttribute("title"),l=[r,t=obj.records[n[1]][n[0]].getAttribute("data-author")];obj.records[n[1]][n[0]].setAttribute("title",o||""),obj.records[n[1]][n[0]].setAttribute("data-author",t||""),o?obj.records[n[1]][n[0]].classList.add("jexcel_comments"):obj.records[n[1]][n[0]].classList.remove("jexcel_comments"),obj.setHistory({action:"setComments",column:e,newValue:[o,t],oldValue:l}),obj.dispatch("oncomments",el,o,r,n,n[0],n[1])},obj.getConfig=function(){var e=obj.options;return e.style=obj.getStyle(),e.mergeCells=obj.getMerge(),e.comments=obj.getComments(),e},obj.orderBy=function(e,o){if(e>=0){if(Object.keys(obj.options.mergeCells).length>0){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}o=null==o?obj.headers[e].classList.contains("arrow-down")?1:0:o?1:0;var t=[];if("number"==obj.options.columns[e].type||"numeric"==obj.options.columns[e].type||"percentage"==obj.options.columns[e].type||"autonumber"==obj.options.columns[e].type||"color"==obj.options.columns[e].type)for(var n=0;n<obj.options.data.length;n++)t[n]=[n,Number(obj.options.data[n][e])];else if("calendar"==obj.options.columns[e].type||"checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type)for(n=0;n<obj.options.data.length;n++)t[n]=[n,obj.options.data[n][e]];else for(n=0;n<obj.options.data.length;n++)t[n]=[n,obj.records[n][e].textContent.toLowerCase()];"function"!=typeof obj.options.sorting&&(obj.options.sorting=function(e){return function(o,t){var n=o[1],r=t[1];return e?""===n&&""!==r?1:""!==n&&""===r||n>r?-1:n<r?1:0:""===n&&""!==r?1:""!==n&&""===r?-1:n>r?1:n<r?-1:0}}),t=t.sort(obj.options.sorting(o));var r=[];for(n=0;n<t.length;n++)r[n]=t[n][0];if(window?.tp?.table?.options?.table_head){const e=0;(r=r.filter((o=>o>e))).unshift(e)}if(window?.tp?.table?.options?.table_foot){const e=r.length-1;(r=r.filter((o=>o<e))).push(e)}return obj.setHistory({action:"orderBy",rows:r,column:e,order:o}),obj.updateOrderArrow(e,o),obj.updateOrder(r),obj.dispatch("onsort",el,e,o),!0}},obj.updateOrderArrow=function(e,o){for(var t=0;t<obj.headers.length;t++)obj.headers[t].classList.remove("arrow-up"),obj.headers[t].classList.remove("arrow-down");o?obj.headers[e].classList.add("arrow-up"):obj.headers[e].classList.add("arrow-down")},obj.updateOrder=function(e){for(var o=[],t=0;t<e.length;t++)o[t]=obj.options.data[e[t]];for(obj.options.data=o,o=[],t=0;t<e.length;t++)o[t]=obj.records[e[t]];for(obj.records=o,o=[],t=0;t<e.length;t++)o[t]=obj.rows[e[t]];if(obj.rows=o,obj.updateTableReferences(),obj.results&&obj.results.length)obj.searchInput.value?obj.search(obj.searchInput.value):obj.closeFilter();else if(obj.results=null,obj.pageNumber=0,obj.options.pagination>0)obj.page(0);else if(1==obj.options.lazyLoading)obj.loadPage(0);else for(t=0;t<obj.rows.length;t++)obj.tbody.appendChild(obj.rows[t])},obj.moveRow=function(e,o,t){if(Object.keys(obj.options.mergeCells).length>0){if(e>o)var n=1;else n=0;if(obj.isRowMerged(e).length||obj.isRowMerged(o,n).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}t||(Array.prototype.indexOf.call(obj.tbody.children,obj.rows[o])>=0?e>o?obj.tbody.insertBefore(obj.rows[e],obj.rows[o]):obj.tbody.insertBefore(obj.rows[e],obj.rows[o].nextSibling):obj.tbody.removeChild(obj.rows[e])),obj.rows.splice(o,0,obj.rows.splice(e,1)[0]),obj.records.splice(o,0,obj.records.splice(e,1)[0]),obj.options.data.splice(o,0,obj.options.data.splice(e,1)[0]),obj.options.pagination>0&&obj.tbody.children.length!=obj.options.pagination&&obj.page(obj.pageNumber),obj.setHistory({action:"moveRow",oldValue:e,newValue:o}),obj.updateTableReferences(),obj.dispatch("onmoverow",el,e,o)},obj.insertRow=function(e,o,t){if(1==obj.options.allowInsertRow){var n=[];if(e>0)var r=e;else r=1,e&&(n=e);t=!!t;var l=obj.options.data.length-1;if((null==o||o>=parseInt(l)||o<0)&&(o=l),!1===obj.dispatch("onbeforeinsertrow",el,o,r,t))return!1;if(Object.keys(obj.options.mergeCells).length>0&&obj.isRowMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}for(var s=t?o:o+1,i=obj.records.splice(s),a=obj.options.data.splice(s),c=obj.rows.splice(s),u=[],d=[],j=[],b=s;b<r+s;b++){obj.options.data[b]=[];for(var p=0;p<obj.options.columns.length;p++)obj.options.data[b][p]=n[p]?n[p]:"";var h=obj.createRow(b,obj.options.data[b]);c[0]?Array.prototype.indexOf.call(obj.tbody.children,c[0])>=0&&obj.tbody.insertBefore(h,c[0]):Array.prototype.indexOf.call(obj.tbody.children,obj.rows[o])>=0&&obj.tbody.appendChild(h),u.push(obj.records[b]),d.push(obj.options.data[b]),j.push(h)}Array.prototype.push.apply(obj.records,i),Array.prototype.push.apply(obj.options.data,a),Array.prototype.push.apply(obj.rows,c),obj.options.pagination>0&&obj.page(obj.pageNumber),obj.setHistory({action:"insertRow",rowNumber:o,numOfRows:r,insertBefore:t,rowRecords:u,rowData:d,rowNode:j}),obj.updateTableReferences(),obj.dispatch("oninsertrow",el,o,r,u,t)}},obj.deleteRow=function(e,o){if(1==obj.options.allowDeleteRow)if(1==obj.options.allowDeletingAllRows||obj.options.data.length>1){if(null==e){var t=obj.getSelectedRows();t[0]?(e=parseInt(t[0].getAttribute("data-y")),o=t.length):(e=obj.options.data.length-1,o=1)}var n=obj.options.data.length-1;if((null==e||e>n||e<0)&&(e=n),o||(o=1),e+o>=obj.options.data.length&&(o=obj.options.data.length-e),!1===obj.dispatch("onbeforedeleterow",el,e,o))return!1;if(parseInt(e)>-1){var r=!1;if(Object.keys(obj.options.mergeCells).length>0)for(var l=e;l<e+o;l++)obj.isRowMerged(l,!1).length&&(r=!0);if(r){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}for(0==obj.options.allowDeletingAllRows&&n+1===o&&(o--,console.error("Jspreadsheet: It is not possible to delete the last row")),l=e;l<e+o;l++)Array.prototype.indexOf.call(obj.tbody.children,obj.rows[l])>=0&&(obj.rows[l].className="",obj.rows[l].parentNode.removeChild(obj.rows[l]));var s=obj.records.splice(e,o),i=obj.options.data.splice(e,o),a=obj.rows.splice(e,o);obj.options.pagination>0&&obj.tbody.children.length!=obj.options.pagination&&obj.page(obj.pageNumber),obj.conditionalSelectionUpdate(1,e,e+o-1),obj.setHistory({action:"deleteRow",rowNumber:e,numOfRows:o,insertBefore:1,rowRecords:s,rowData:i,rowNode:a}),obj.updateTableReferences(),obj.dispatch("ondeleterow",el,e,o,s)}}else console.error("Jspreadsheet: It is not possible to delete the last row")},obj.moveColumn=function(e,o){if(Object.keys(obj.options.mergeCells).length>0){if(e>o)var t=1;else t=0;if(obj.isColMerged(e).length||obj.isColMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}}if((e=parseInt(e))>(o=parseInt(o))){obj.headerContainer.insertBefore(obj.headers[e],obj.headers[o]),obj.colgroupContainer.insertBefore(obj.colgroup[e],obj.colgroup[o]);for(var n=0;n<obj.rows.length;n++)obj.rows[n].insertBefore(obj.records[n][e],obj.records[n][o])}else for(obj.headerContainer.insertBefore(obj.headers[e],obj.headers[o].nextSibling),obj.colgroupContainer.insertBefore(obj.colgroup[e],obj.colgroup[o].nextSibling),n=0;n<obj.rows.length;n++)obj.rows[n].insertBefore(obj.records[n][e],obj.records[n][o].nextSibling);for(obj.options.columns.splice(o,0,obj.options.columns.splice(e,1)[0]),obj.headers.splice(o,0,obj.headers.splice(e,1)[0]),obj.colgroup.splice(o,0,obj.colgroup.splice(e,1)[0]),n=0;n<obj.rows.length;n++)obj.options.data[n].splice(o,0,obj.options.data[n].splice(e,1)[0]),obj.records[n].splice(o,0,obj.records[n].splice(e,1)[0]);if(obj.options.footers)for(n=0;n<obj.options.footers.length;n++)obj.options.footers[n].splice(o,0,obj.options.footers[n].splice(e,1)[0]);obj.setHistory({action:"moveColumn",oldValue:e,newValue:o}),obj.updateTableReferences(),obj.dispatch("onmovecolumn",el,e,o)},obj.insertColumn=function(e,o,t,n){if(1==obj.options.allowInsertColumn){var r=[];if(e>0)var l=e;else l=1,e&&(r=e);t=!!t;var s=obj.options.columns.length-1;if((null==o||o>=parseInt(s)||o<0)&&(o=s),!1===obj.dispatch("onbeforeinsertcolumn",el,o,l,t))return!1;if(Object.keys(obj.options.mergeCells).length>0&&obj.isColMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}n||(n=[]);for(var i=0;i<l;i++)n[i]||(n[i]={type:"text",source:[],options:[],width:obj.options.defaultColWidth,align:obj.options.defaultColAlign});var a=t?o:o+1;obj.options.columns=jexcel.injectArray(obj.options.columns,a,n);for(var c=obj.headers.splice(a),u=obj.colgroup.splice(a),d=[],j=[],b=[],p=[],h=[],g=a;g<l+a;g++)obj.createCellHeader(g),obj.headerContainer.insertBefore(obj.headers[g],obj.headerContainer.children[g+1]),obj.colgroupContainer.insertBefore(obj.colgroup[g],obj.colgroupContainer.children[g+1]),d.push(obj.headers[g]),j.push(obj.colgroup[g]);if(obj.options.footers)for(var f=0;f<obj.options.footers.length;f++){for(h[f]=[],i=0;i<l;i++)h[f].push("");obj.options.footers[f].splice(a,0,h[f])}for(var m=0;m<obj.options.data.length;m++){var C=obj.options.data[m].splice(a),x=obj.records[m].splice(a);for(p[m]=[],b[m]=[],g=a;g<l+a;g++){var v=r[m]?r[m]:"";obj.options.data[m][g]=v;var y=obj.createCell(g,m,obj.options.data[m][g]);obj.records[m][g]=y,obj.rows[m]&&obj.rows[m].insertBefore(y,obj.rows[m].children[g+1]),p[m].push(v),b[m].push(y)}Array.prototype.push.apply(obj.options.data[m],C),Array.prototype.push.apply(obj.records[m],x)}if(Array.prototype.push.apply(obj.headers,c),Array.prototype.push.apply(obj.colgroup,u),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(f=0;f<obj.options.nestedHeaders.length;f++){var w=parseInt(obj.options.nestedHeaders[f][obj.options.nestedHeaders[f].length-1].colspan)+l;obj.options.nestedHeaders[f][obj.options.nestedHeaders[f].length-1].colspan=w,obj.thead.children[f].children[obj.thead.children[f].children.length-1].setAttribute("colspan",w);var A=obj.thead.children[f].children[obj.thead.children[f].children.length-1].getAttribute("data-column");for(A=A.split(","),g=a;g<l+a;g++)A.push(g);obj.thead.children[f].children[obj.thead.children[f].children.length-1].setAttribute("data-column",A)}else w=parseInt(obj.options.nestedHeaders[0].colspan)+l,obj.options.nestedHeaders[0].colspan=w,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",w);obj.setHistory({action:"insertColumn",columnNumber:o,numOfColumns:l,insertBefore:t,columns:n,headers:d,colgroup:j,records:b,footers:h,data:p}),obj.updateTableReferences(),obj.dispatch("oninsertcolumn",el,o,l,b,t)}},obj.deleteColumn=function(e,o){if(1==obj.options.allowDeleteColumn)if(obj.headers.length>1){if(null==e){var t=obj.getSelectedColumns(!0);t.length?(e=parseInt(t[0]),o=parseInt(t.length)):(e=obj.headers.length-1,o=1)}var n=obj.options.data[0].length-1;if((null==e||e>n||e<0)&&(e=n),o||(o=1),o>obj.options.data[0].length-e&&(o=obj.options.data[0].length-e),!1===obj.dispatch("onbeforedeletecolumn",el,e,o))return!1;if(parseInt(e)>-1){var r=!1;if(Object.keys(obj.options.mergeCells).length>0)for(var l=e;l<e+o;l++)obj.isColMerged(l,!1).length&&(r=!0);if(r){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}var s=obj.options.columns.splice(e,o);for(l=e;l<e+o;l++)obj.colgroup[l].className="",obj.headers[l].className="",obj.colgroup[l].parentNode.removeChild(obj.colgroup[l]),obj.headers[l].parentNode.removeChild(obj.headers[l]);for(var i=obj.headers.splice(e,o),a=obj.colgroup.splice(e,o),c=[],u=[],d=[],j=0;j<obj.options.data.length;j++)for(l=e;l<e+o;l++)obj.records[j][l].className="",obj.records[j][l].parentNode.removeChild(obj.records[j][l]);for(j=0;j<obj.options.data.length;j++)u[j]=obj.options.data[j].splice(e,o),c[j]=obj.records[j].splice(e,o);if(obj.options.footers)for(j=0;j<obj.options.footers.length;j++)d[j]=obj.options.footers[j].splice(e,o);if(obj.conditionalSelectionUpdate(0,e,e+o-1),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var b=0;b<obj.options.nestedHeaders.length;b++){var p=parseInt(obj.options.nestedHeaders[b][obj.options.nestedHeaders[b].length-1].colspan)-o;obj.options.nestedHeaders[b][obj.options.nestedHeaders[b].length-1].colspan=p,obj.thead.children[b].children[obj.thead.children[b].children.length-1].setAttribute("colspan",p)}else p=parseInt(obj.options.nestedHeaders[0].colspan)-o,obj.options.nestedHeaders[0].colspan=p,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",p);obj.setHistory({action:"deleteColumn",columnNumber:e,numOfColumns:o,insertBefore:1,columns:s,headers:i,colgroup:a,records:c,footers:d,data:u}),obj.updateTableReferences(),obj.dispatch("ondeletecolumn",el,e,o,c)}}else console.error("Jspreadsheet: It is not possible to delete the last column")},obj.getSelectedRows=function(e){for(var o=[],t=0;t<obj.rows.length;t++)obj.rows[t].classList.contains("selected")&&(e?o.push(t):o.push(obj.rows[t]));return o},obj.getSelectedColumns=function(){for(var e=[],o=0;o<obj.headers.length;o++)obj.headers[o].classList.contains("selected")&&e.push(o);return e},obj.getHighlighted=function(){return obj.highlighted},obj.updateTableReferences=function(){for(var e=0;e<obj.headers.length;e++)(l=obj.headers[e].getAttribute("data-x"))!=e&&(obj.headers[e].setAttribute("data-x",e),obj.headers[e].getAttribute("title")||(obj.headers[e].innerHTML=jexcel.getColumnName(e)));for(var o=0;o<obj.rows.length;o++)obj.rows[o]&&(s=obj.rows[o].getAttribute("data-y"))!=o&&(obj.rows[o].setAttribute("data-y",o),obj.rows[o].children[0].setAttribute("data-y",o),obj.rows[o].children[0].innerHTML=o+1);var t=[],n=[],r=function(e,o,n,r){if(e!=n&&obj.records[r][n].setAttribute("data-x",n),o!=r&&obj.records[r][n].setAttribute("data-y",r),e!=n||o!=r){var l=jexcel.getColumnNameFromId([e,o]),s=jexcel.getColumnNameFromId([n,r]);t[l]=s}};for(o=0;o<obj.records.length;o++)for(e=0;e<obj.records[0].length;e++)if(obj.records[o][e]){var l=obj.records[o][e].getAttribute("data-x"),s=obj.records[o][e].getAttribute("data-y");if(obj.records[o][e].getAttribute("data-merged")){var i=jexcel.getColumnNameFromId([l,s]),a=jexcel.getColumnNameFromId([e,o]);if(null==n[i])if(i==a)n[i]=!1;else{var c=parseInt(e-l),u=parseInt(o-s);n[i]=[a,c,u]}}else r(l,s,e,o)}var d=Object.keys(n);if(d.length)for(e=0;e<d.length;e++)if(n[d[e]]){var j=jexcel.getIdFromColumnName(d[e],!0);for(r(l=j[0],s=j[1],l+n[d[e]][1],s+n[d[e]][2]),i=d[e],a=n[d[e]][0],o=0;o<obj.options.mergeCells[i][2].length;o++)l=parseInt(obj.options.mergeCells[i][2][o].getAttribute("data-x")),s=parseInt(obj.options.mergeCells[i][2][o].getAttribute("data-y")),obj.options.mergeCells[i][2][o].setAttribute("data-x",l+n[d[e]][1]),obj.options.mergeCells[i][2][o].setAttribute("data-y",s+n[d[e]][2]);obj.options.mergeCells[a]=obj.options.mergeCells[i],delete obj.options.mergeCells[i]}obj.updateFormulas(t),obj.updateMeta(t),obj.refreshSelection(),obj.updateTable()},obj.updateTable=function(){if(obj.options.minSpareRows>0){for(var e=0,o=obj.rows.length-1;o>=0;o--){for(var t=!1,n=0;n<obj.headers.length;n++)obj.options.data[o][n]&&(t=!0);if(t)break;e++}obj.options.minSpareRows-e>0&&obj.insertRow(obj.options.minSpareRows-e)}if(obj.options.minSpareCols>0){var r=0;for(n=obj.headers.length-1;n>=0;n--){for(t=!1,o=0;o<obj.rows.length;o++)obj.options.data[o][n]&&(t=!0);if(t)break;r++}obj.options.minSpareCols-r>0&&obj.insertColumn(obj.options.minSpareCols-r)}if("function"==typeof obj.options.updateTable){for(obj.options.detachForUpdates&&el.removeChild(obj.content),o=0;o<obj.rows.length;o++)for(n=0;n<obj.headers.length;n++)obj.options.updateTable(el,obj.records[o][n],n,o,obj.options.data[o][n],obj.records[o][n].textContent,jexcel.getColumnNameFromId([n,o]));obj.options.detachForUpdates&&el.insertBefore(obj.content,obj.pagination)}obj.options.footers&&obj.setFooter(),setTimeout((function(){obj.updateCornerPosition()}),0)},obj.isReadOnly=function(e){if(e=obj.getCell(e))return!!e.classList.contains("readonly")},obj.setReadOnly=function(e,o){(e=obj.getCell(e))&&(o?e.classList.add("readonly"):e.classList.remove("readonly"))},obj.showRow=function(e){obj.rows[e].style.display=""},obj.hideRow=function(e){obj.rows[e].style.display="none"},obj.showColumn=function(e){obj.headers[e].style.display="",obj.colgroup[e].style.display="",obj.filter&&obj.filter.children.length>e+1&&(obj.filter.children[e+1].style.display="");for(var o=0;o<obj.options.data.length;o++)obj.records[o][e].style.display="";obj.options.footers&&obj.setFooter(),obj.resetSelection()},obj.hideColumn=function(e){obj.headers[e].style.display="none",obj.colgroup[e].style.display="none",obj.filter&&obj.filter.children.length>e+1&&(obj.filter.children[e+1].style.display="none");for(var o=0;o<obj.options.data.length;o++)obj.records[o][e].style.display="none";obj.options.footers&&obj.setFooter(),obj.resetSelection()},obj.showIndex=function(){obj.table.classList.remove("jexcel_hidden_index")},obj.hideIndex=function(){obj.table.classList.add("jexcel_hidden_index")};var chainLoopProtection=[];obj.updateFormulaChain=function(e,o,t){var n=jexcel.getColumnNameFromId([e,o]);if(obj.formula[n]&&obj.formula[n].length>0)if(chainLoopProtection[n])obj.records[o][e].innerHTML="#ERROR",obj.formula[n]="";else{chainLoopProtection[n]=!0;for(var r=0;r<obj.formula[n].length;r++){var l=jexcel.getIdFromColumnName(obj.formula[n][r],!0),s=""+obj.options.data[l[1]][l[0]];"="==s.substr(0,1)?t.push(obj.updateCell(l[0],l[1],s,!0)):Object.keys(obj.formula)[r]=null,obj.updateFormulaChain(l[0],l[1],t)}}chainLoopProtection=[]},obj.updateFormulas=function(e){for(var o=0;o<obj.options.data.length;o++)for(var t=0;t<obj.options.data[0].length;t++)if("="==(i=""+obj.options.data[o][t]).substr(0,1)){var n=obj.updateFormula(i,e);n!=i&&obj.updateCell(t,o,n)}var r=[],l=Object.keys(obj.formula);for(o=0;o<l.length;o++){var s=l[o],i=obj.formula[s];for(e[s]&&(s=e[s]),r[s]=[],t=0;t<i.length;t++){var a=i[t];e[a]&&(a=e[a]),r[s].push(a)}}obj.formula=r},obj.updateFormula=function(e,o){for(var t=/[A-Z]/,n=/[0-9]/,r="",l=null,s=null,i="",a=0;a<e.length;a++)t.exec(e[a])?(l=1,s=0,i+=e[a]):n.exec(e[a])?(s=l?1:0,i+=e[a]):(l&&s&&(i=o[i]?o[i]:i),r+=i,r+=e[a],l=0,s=0,i="");return i&&(l&&s&&(i=o[i]?o[i]:i),r+=i),r};var secureFormula=function(e){for(var o="",t=0,n=0;n<e.length;n++)'"'==e[n]&&(t=0==t?1:0),o+=1==t?e[n]:e[n].toUpperCase();return o};obj.executeFormula=function(expression,x,y){var formulaResults=[],formulaLoopProtection=[],execute=function(expression,x,y){var parentId=jexcel.getColumnNameFromId([x,y]);if(formulaLoopProtection[parentId])return console.error("Reference loop detected"),"#ERROR";formulaLoopProtection[parentId]=!0;var tokensUpdate=function(e){for(var o=0;o<e.length;o++){var t=[],n=e[o].split(":"),r=jexcel.getIdFromColumnName(n[0],!0),l=jexcel.getIdFromColumnName(n[1],!0);if(r[0]<=l[0])var s=r[0],i=l[0];else s=l[0],i=r[0];if(r[1]<=l[1])var a=r[1],c=l[1];else a=l[1],c=r[1];for(var u=a;u<=c;u++)for(var d=s;d<=i;d++)t.push(jexcel.getColumnNameFromId([d,u]));expression=expression.replace(e[o],t.join(","))}};expression=expression.replace(/\$?([A-Z]+)\$?([0-9]+)/g,"$1$2");var tokens=expression.match(/([A-Z]+[0-9]+)\:([A-Z]+[0-9]+)/g);tokens&&tokens.length&&tokensUpdate(tokens);var tokens=expression.match(/([A-Z]+[0-9]+)/g);if(tokens&&tokens.indexOf(parentId)>-1)return console.error("Self Reference detected"),"#ERROR";var formulaExpressions={};if(tokens)for(var i=0;i<tokens.length;i++)if(obj.formula[tokens[i]]||(obj.formula[tokens[i]]=[]),obj.formula[tokens[i]].indexOf(parentId)<0&&obj.formula[tokens[i]].push(parentId),eval("typeof("+tokens[i]+') == "undefined"')){var position=jexcel.getIdFromColumnName(tokens[i],1);if(void 0!==obj.options.data[position[1]]&&void 0!==obj.options.data[position[1]][position[0]])var value=obj.options.data[position[1]][position[0]];else var value="";if("="==(""+value).substr(0,1)&&(void 0!==formulaResults[tokens[i]]?value=formulaResults[tokens[i]]:(value=execute(value,position[0],position[1]),formulaResults[tokens[i]]=value)),""==(""+value).trim())formulaExpressions[tokens[i]]=null;else if(value==Number(value)&&1==obj.options.autoCasting)formulaExpressions[tokens[i]]=Number(value);else{var number=obj.parseNumber(value,position[0]);1==obj.options.autoCasting&&number?formulaExpressions[tokens[i]]=number:formulaExpressions[tokens[i]]='"'+value+'"'}}try{var res=jexcel.formula(expression.substr(1),formulaExpressions,x,y,obj)}catch(e){var res="#ERROR";console.log(e)}return res};return execute(expression,x,y)},obj.parseNumber=function(e,o){var t=o&&obj.options.columns[o].decimal?obj.options.columns[o].decimal:".",n=""+e;if((n=n.split(t))[0]=n[0].match(/[+-]?[0-9]/g),n[0]&&(n[0]=n[0].join("")),n[1]&&(n[1]=n[1].match(/[0-9]*/g).join("")),n[0]&&Number.isInteger(Number(n[0])))if(n[1])e=Number(n[0]+"."+n[1]);else e=Number(n[0]+".00");else e=null;return e},obj.row=function(e){},obj.col=function(e){},obj.up=function(e,o){if(e?obj.selectedCell[3]>0&&obj.up.visible(1,o?0:1):(obj.selectedCell[1]>0&&obj.up.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),1==obj.options.lazyLoading)if(0==obj.selectedCell[1]||0==obj.selectedCell[3])obj.loadPage(0),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]);else if(obj.loadValidation())obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]);else{var t=parseInt(obj.tbody.firstChild.getAttribute("data-y"));obj.selectedCell[1]-t<30&&(obj.loadUp(),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]))}else if(obj.options.pagination>0){var n=obj.whichPage(obj.selectedCell[3]);n!=obj.pageNumber&&obj.page(n)}obj.updateScroll(1)},obj.up.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=0;r<n;r++)if("none"!=obj.records[r][t].style.display&&"none"!=obj.rows[r].style.display){n=r;break}}else n=obj.up.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.up.get=function(e,o){e=parseInt(e);for(var t=(o=parseInt(o))-1;t>=0;t--)if("none"!=obj.records[t][e].style.display&&"none"!=obj.rows[t].style.display){if(obj.records[t][e].getAttribute("data-merged")&&obj.records[t][e]==obj.records[o][e])continue;o=t;break}return o},obj.down=function(e,o){if(e?obj.selectedCell[3]<obj.records.length-1&&obj.down.visible(1,o?0:1):(obj.selectedCell[1]<obj.records.length-1&&obj.down.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),1==obj.options.lazyLoading)obj.selectedCell[1]==obj.records.length-1||obj.selectedCell[3]==obj.records.length-1?(obj.loadPage(-1),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])):obj.loadValidation()?obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]):parseInt(obj.tbody.lastChild.getAttribute("data-y"))-obj.selectedCell[3]<30&&(obj.loadDown(),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]));else if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}obj.updateScroll(3)},obj.down.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=obj.rows.length-1;r>n;r--)if("none"!=obj.records[r][t].style.display&&"none"!=obj.rows[r].style.display){n=r;break}}else n=obj.down.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.down.get=function(e,o){e=parseInt(e);for(var t=(o=parseInt(o))+1;t<obj.rows.length;t++)if("none"!=obj.records[t][e].style.display&&"none"!=obj.rows[t].style.display){if(obj.records[t][e].getAttribute("data-merged")&&obj.records[t][e]==obj.records[o][e])continue;o=t;break}return o},obj.right=function(e,o){e?obj.selectedCell[2]<obj.headers.length-1&&obj.right.visible(1,o?0:1):(obj.selectedCell[0]<obj.headers.length-1&&obj.right.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(2)},obj.right.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=obj.headers.length-1;r>t;r--)if("none"!=obj.records[n][r].style.display){t=r;break}}else t=obj.right.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.right.get=function(e,o){e=parseInt(e),o=parseInt(o);for(var t=e+1;t<obj.headers.length;t++)if("none"!=obj.records[o][t].style.display){if(obj.records[o][t].getAttribute("data-merged")&&obj.records[o][t]==obj.records[o][e])continue;e=t;break}return e},obj.left=function(e,o){e?obj.selectedCell[2]>0&&obj.left.visible(1,o?0:1):(obj.selectedCell[0]>0&&obj.left.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(0)},obj.left.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=0;r<t;r++)if("none"!=obj.records[n][r].style.display){t=r;break}}else t=obj.left.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.left.get=function(e,o){e=parseInt(e),o=parseInt(o);for(var t=e-1;t>=0;t--)if("none"!=obj.records[o][t].style.display){if(obj.records[o][t].getAttribute("data-merged")&&obj.records[o][t]==obj.records[o][e])continue;e=t;break}return e},obj.first=function(e,o){if(e?o?obj.selectedCell[3]=0:obj.left.visible(1,0):(o?obj.selectedCell[1]=0:obj.left.visible(0,0),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),1!=obj.options.lazyLoading||0!=obj.selectedCell[1]&&0!=obj.selectedCell[3]){if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}}else obj.loadPage(0);obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(1)},obj.last=function(e,o){if(e?o?obj.selectedCell[3]=obj.records.length-1:obj.right.visible(1,0):(o?obj.selectedCell[1]=obj.records.length-1:obj.right.visible(0,0),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),1!=obj.options.lazyLoading||obj.selectedCell[1]!=obj.records.length-1&&obj.selectedCell[3]!=obj.records.length-1){if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}}else obj.loadPage(-1);obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(3)},obj.selectAll=function(){obj.selectedCell||(obj.selectedCell=[]),obj.selectedCell[0]=0,obj.selectedCell[1]=0,obj.selectedCell[2]=obj.headers.length-1,obj.selectedCell[3]=obj.records.length-1,obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])},obj.loadPage=function(e){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)o=obj.rows;else var o=obj.results;var t=100;null!=e&&-1!=e||(e=Math.ceil(o.length/t)-1);var n=e*t,r=e*t+t;r>o.length&&(r=o.length),(n=r-100)<0&&(n=0);for(var l=n;l<r;l++)1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[l]):obj.tbody.appendChild(obj.rows[o[l]]),obj.tbody.children.length>t&&obj.tbody.removeChild(obj.tbody.firstChild)},obj.loadUp=function(){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows;else var e=obj.results;var o=0;if(e.length>100){var t=parseInt(obj.tbody.firstChild.getAttribute("data-y"));if(1!=obj.options.search&&1!=obj.options.filters||!obj.results||(t=e.indexOf(t)),t>0)for(var n=0;n<30;n++)(t-=1)>-1&&(1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.insertBefore(obj.rows[t],obj.tbody.firstChild):obj.tbody.insertBefore(obj.rows[e[t]],obj.tbody.firstChild),obj.tbody.children.length>100&&(obj.tbody.removeChild(obj.tbody.lastChild),o=1))}return o},obj.loadDown=function(){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows;else var e=obj.results;var o=0;if(e.length>100){var t=parseInt(obj.tbody.lastChild.getAttribute("data-y"));if(1!=obj.options.search&&1!=obj.options.filters||!obj.results||(t=e.indexOf(t)),t<obj.rows.length-1)for(var n=0;n<=30;n++)t<e.length&&(1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[t]):obj.tbody.appendChild(obj.rows[e[t]]),obj.tbody.children.length>100&&(obj.tbody.removeChild(obj.tbody.firstChild),o=1)),t+=1}return o},obj.loadValidation=function(){if(obj.selectedCell){var e=parseInt(obj.tbody.firstChild.getAttribute("data-y"))/100,o=parseInt(obj.selectedCell[3]/100),t=parseInt(obj.rows.length/100);if(e!=o&&o<=t&&!Array.prototype.indexOf.call(obj.tbody.children,obj.rows[obj.selectedCell[3]]))return obj.loadPage(o),!0}return!1},obj.resetSearch=function(){obj.searchInput.value="",obj.search(""),obj.results=null},obj.search=function(e){if(obj.options.filters&&obj.resetFilters(),obj.resetSelection(),obj.pageNumber=0,obj.results=[],e){var o=function(e){-1==obj.results.indexOf(e)&&obj.results.push(e)},t=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");t=new RegExp(t,"i"),obj.options.data.forEach((function(e,n){if(function(e,o,t){for(var n=0;n<e.length;n++)if((""+e[n]).toLowerCase().search(o)>=0||(""+obj.records[t][n].innerHTML).toLowerCase().search(o)>=0)return!0;return!1}(e,t,n)){var r=obj.isRowMerged(n);if(r.length)for(var l=0;l<r.length;l++)for(var s=jexcel.getIdFromColumnName(r[l],!0),i=0;i<obj.options.mergeCells[r[l]][1];i++)o(s[1]+i);else o(n)}}))}else obj.results=null;return obj.updateResult()},obj.updateResult=function(){var e,o=0;for(e=1==obj.options.lazyLoading?100:obj.options.pagination>0?obj.options.pagination:obj.results?obj.results.length:obj.rows.length;obj.tbody.firstChild;)obj.tbody.removeChild(obj.tbody.firstChild);for(var t=0;t<obj.rows.length;t++)!obj.results||obj.results.indexOf(t)>-1?(o<e&&(obj.tbody.appendChild(obj.rows[t]),o++),obj.rows[t].style.display=""):obj.rows[t].style.display="none";return obj.options.pagination>0&&obj.updatePagination(),obj.updateCornerPosition(),e},obj.whichPage=function(e){return 1!=obj.options.search&&1!=obj.options.filters||!obj.results||(e=obj.results.indexOf(e)),Math.ceil((parseInt(e)+1)/parseInt(obj.options.pagination))-1},obj.page=function(e){var o=obj.pageNumber;if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)t=obj.rows;else var t=obj.results;var n=parseInt(obj.options.pagination);null!=e&&-1!=e||(e=Math.ceil(t.length/n)-1),obj.pageNumber=e;var r=e*n,l=e*n+n;for(l>t.length&&(l=t.length),r<0&&(r=0);obj.tbody.firstChild;)obj.tbody.removeChild(obj.tbody.firstChild);for(var s=r;s<l;s++)1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[s]):obj.tbody.appendChild(obj.rows[t[s]]);obj.options.pagination>0&&obj.updatePagination(),obj.updateCornerPosition(),obj.dispatch("onchangepage",el,e,o)},obj.updatePagination=function(){if(obj.pagination.children[0].innerHTML="",obj.pagination.children[1].innerHTML="",obj.options.pagination){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows.length;else var e=obj.results.length;if(e){var o=Math.ceil(e/obj.options.pagination);if(obj.pageNumber<6)var t=1,n=o<10?o:10;else o-obj.pageNumber<5?(n=o,(t=o-9)<1&&(t=1)):(t=obj.pageNumber-4,n=obj.pageNumber+5);t>1&&((l=document.createElement("div")).className="jexcel_page",l.innerHTML="<",l.title=1,obj.pagination.children[1].appendChild(l));for(var r=t;r<=n;r++){var l;(l=document.createElement("div")).className="jexcel_page",l.innerHTML=r,obj.pagination.children[1].appendChild(l),obj.pageNumber==r-1&&l.classList.add("jexcel_page_selected")}n<o&&((l=document.createElement("div")).className="jexcel_page",l.innerHTML=">",l.title=o,obj.pagination.children[1].appendChild(l)),obj.pagination.children[0].innerHTML=function(e){var o=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,(function(e,t){return void 0!==o[t]?o[t]:e}))}(obj.options.text.showingPage,obj.pageNumber+1,o)}else obj.pagination.children[0].innerHTML=obj.options.text.noRecordsFound}},obj.download=function(e){if(0==obj.options.allowExport)console.error("Export not allowed");else{var o="";o+=obj.copy(!1,obj.options.csvDelimiter,!0,e,!0);var t=new Blob(["\ufeff"+o],{type:"text/csv;charset=utf-8;"});if(window.navigator&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(t,obj.options.csvFileName+".csv");else{var n=document.createElement("a"),r=URL.createObjectURL(t);n.href=r,n.setAttribute("download",obj.options.csvFileName+".csv"),document.body.appendChild(n),n.click(),n.parentNode.removeChild(n)}}},obj.setHistory=function(e){if(1!=obj.ignoreHistory){var o=++obj.historyIndex;obj.history=obj.history=obj.history.slice(0,o+1),obj.history[o]=e}},obj.copy=function(e,o,t,n,r){o||(o="\t");for(var l=new RegExp(o,"ig"),s=[],i=[],a=[],c=[],u=[],d=obj.options.data[0].length,j=obj.options.data.length,b="",p=!1,h="",g="",f=0,m=0,C=0,x=0,v=!0,y=0;y<j;y++)for(var w=0;w<d;w++)e&&!obj.records[y][w].classList.contains("highlight")||(C<=w&&(C=w),x<=y&&(x=y));if(d===C+1&&j===x+1&&(v=!1),r&&1==obj.options.includeHeadersOnDownload||!r&&1==obj.options.includeHeadersOnCopy&&!v||n){if(obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)for(b=obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0]?obj.options.nestedHeaders:[obj.options.nestedHeaders],y=0;y<b.length;y++){var A=[];for(w=0;w<b[y].length;w++){var F=parseInt(b[y][w].colspan);A.push(b[y][w].title);for(var E=0;E<F-1;E++)A.push("")}g+=A.join(o)+"\r\n"}p=!0}for(obj.style=[],y=0;y<j;y++){for(i=[],a=[],w=0;w<d;w++)if(!e||obj.records[y][w].classList.contains("highlight")){1==p&&s.push(obj.headers[w].textContent);var L=obj.options.data[y][w];if(L.match&&(L.match(l)||L.includes(o)||L.includes("\n"))&&(L.includes('"')&&(L=L.replace(new RegExp('"',"g"),'""')),L='"'+L+'"'),i.push(L),"checkbox"==obj.options.columns[w].type||"radio"==obj.options.columns[w].type)var D=L;else(D=1==obj.options.stripHTMLOnCopy?obj.records[y][w].textContent:obj.records[y][w].innerHTML).match&&(D.match(l)||D.match(/,/g)||D.match(/\n/)||D.match(/\"/))&&(D='"'+(D=D.replace(new RegExp('"',"g"),'""'))+'"');a.push(D),b=(b=obj.records[y][w].getAttribute("style")).replace("display: none;",""),obj.style.push(b||"")}i.length&&(p&&(f=i.length,c.push(s.join(o))),c.push(i.join(o))),a.length&&(m++,p&&(u.push(s.join(o)),p=!1),u.push(a.join(o)))}d==f&&j==m&&(h=g);var S=h+c.join("\r\n"),I=h+u.join("\r\n");if(t||(1==obj.options.copyCompatibility?obj.textarea.value=I:obj.textarea.value=S,obj.textarea.select(),document.execCommand("copy")),1==obj.options.copyCompatibility?obj.data=I:obj.data=S,obj.hashString=obj.hash(obj.data),!t){if(obj.removeCopyingSelection(),obj.highlighted)for(w=0;w<obj.highlighted.length;w++)obj.highlighted[w].classList.add("copying"),obj.highlighted[w].classList.contains("highlight-left")&&obj.highlighted[w].classList.add("copying-left"),obj.highlighted[w].classList.contains("highlight-right")&&obj.highlighted[w].classList.add("copying-right"),obj.highlighted[w].classList.contains("highlight-top")&&obj.highlighted[w].classList.add("copying-top"),obj.highlighted[w].classList.contains("highlight-bottom")&&obj.highlighted[w].classList.add("copying-bottom");obj.dispatch("oncopy",el,1==obj.options.copyCompatibility?u:c,obj.hashString)}return obj.data},obj.paste=function(e,o,t){var n=obj.dispatch("onbeforepaste",el,t,e,o);if(!1===n)return!1;n&&(t=n);var r=obj.hash(t),l=r==obj.hashString?obj.style:null;if(1==obj.options.copyCompatibility&&r==obj.hashString&&(t=obj.data),t=obj.parseCSV(t,"\t"),null!=e&&null!=o&&t){for(var s=0,i=0,a=[],c={},u={},d=0,j=parseInt(e),b=parseInt(o),p=null;p=t[i];){for(s=0,j=parseInt(e);null!=p[s];){var h=obj.updateCell(j,b,p[s]);if(a.push(h),obj.updateFormulaChain(j,b,a),l&&l[d]){var g=jexcel.getColumnNameFromId([j,b]);c[g]=l[d],u[g]=obj.getStyle(g),obj.records[b][j].setAttribute("style",l[d]),d++}if(null!=p[++s]){if(j>=obj.headers.length-1){if(1!=obj.options.allowInsertColumn)break;obj.insertColumn()}j=obj.right.get(j,b)}}if(t[++i]){if(b>=obj.rows.length-1){if(1!=obj.options.allowInsertRow)break;obj.insertRow()}b=obj.down.get(e,b)}}obj.updateSelectionFromCoords(e,o,j,b),obj.setHistory({action:"setValue",records:a,selection:obj.selectedCell,newStyle:c,oldStyle:u}),obj.updateTable(),obj.dispatch("onpaste",el,t),obj.onafterchanges(el,a)}obj.removeCopyingSelection()},obj.removeCopyingSelection=function(){for(var e=document.querySelectorAll(".jexcel .copying"),o=0;o<e.length;o++)e[o].classList.remove("copying"),e[o].classList.remove("copying-left"),e[o].classList.remove("copying-right"),e[o].classList.remove("copying-top"),e[o].classList.remove("copying-bottom")},obj.historyProcessRow=function(e,o){var t=o.insertBefore?+o.rowNumber:o.rowNumber+1;if(1==obj.options.search&&obj.results&&obj.results.length!=obj.rows.length&&obj.resetSearch(),1==e){for(var n=o.numOfRows,r=t;r<n+t;r++)obj.rows[r].parentNode.removeChild(obj.rows[r]);obj.records.splice(t,n),obj.options.data.splice(t,n),obj.rows.splice(t,n),obj.conditionalSelectionUpdate(1,t,n+t-1)}else{obj.records=jexcel.injectArray(obj.records,t,o.rowRecords),obj.options.data=jexcel.injectArray(obj.options.data,t,o.rowData),obj.rows=jexcel.injectArray(obj.rows,t,o.rowNode);var l=0;for(r=t;r<o.numOfRows+t;r++)obj.tbody.insertBefore(o.rowNode[l],obj.tbody.children[r]),l++}obj.options.pagination>0&&obj.page(obj.pageNumber),obj.updateTableReferences()},obj.historyProcessColumn=function(e,o){var t=o.insertBefore?o.columnNumber:o.columnNumber+1;if(1==e){var n=o.numOfColumns;obj.options.columns.splice(t,n);for(var r=t;r<n+t;r++)obj.headers[r].parentNode.removeChild(obj.headers[r]),obj.colgroup[r].parentNode.removeChild(obj.colgroup[r]);obj.headers.splice(t,n),obj.colgroup.splice(t,n);for(var l=0;l<o.data.length;l++){for(r=t;r<n+t;r++)obj.records[l][r].parentNode.removeChild(obj.records[l][r]);obj.records[l].splice(t,n),obj.options.data[l].splice(t,n)}if(obj.options.footers)for(l=0;l<obj.options.footers.length;l++)obj.options.footers[l].splice(t,n)}else{obj.options.columns=jexcel.injectArray(obj.options.columns,t,o.columns),obj.headers=jexcel.injectArray(obj.headers,t,o.headers),obj.colgroup=jexcel.injectArray(obj.colgroup,t,o.colgroup);var s=0;for(r=t;r<o.numOfColumns+t;r++)obj.headerContainer.insertBefore(o.headers[s],obj.headerContainer.children[r+1]),obj.colgroupContainer.insertBefore(o.colgroup[s],obj.colgroupContainer.children[r+1]),s++;for(l=0;l<o.data.length;l++)for(obj.options.data[l]=jexcel.injectArray(obj.options.data[l],t,o.data[l]),obj.records[l]=jexcel.injectArray(obj.records[l],t,o.records[l]),s=0,r=t;r<o.numOfColumns+t;r++)obj.rows[l].insertBefore(o.records[l][s],obj.rows[l].children[r+1]),s++;if(obj.options.footers)for(l=0;l<obj.options.footers.length;l++)obj.options.footers[l]=jexcel.injectArray(obj.options.footers[l],t,o.footers[l])}if(obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(l=0;l<obj.options.nestedHeaders.length;l++){if(1==e)var i=parseInt(obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan)-o.numOfColumns;else i=parseInt(obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan)+o.numOfColumns;obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan=i,obj.thead.children[l].children[obj.thead.children[l].children.length-1].setAttribute("colspan",i)}else i=1==e?parseInt(obj.options.nestedHeaders[0].colspan)-o.numOfColumns:parseInt(obj.options.nestedHeaders[0].colspan)+o.numOfColumns,obj.options.nestedHeaders[0].colspan=i,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",i);obj.updateTableReferences()},obj.undo=function(){var e=!!obj.ignoreEvents,o=!!obj.ignoreHistory;obj.ignoreEvents=!0,obj.ignoreHistory=!0;var t=[];if(obj.historyIndex>=0){var n=obj.history[obj.historyIndex--];if("insertRow"==n.action)obj.historyProcessRow(1,n);else if("deleteRow"==n.action)obj.historyProcessRow(0,n);else if("insertColumn"==n.action)obj.historyProcessColumn(1,n);else if("deleteColumn"==n.action)obj.historyProcessColumn(0,n);else if("moveRow"==n.action)obj.moveRow(n.newValue,n.oldValue);else if("moveColumn"==n.action)obj.moveColumn(n.newValue,n.oldValue);else if("setMerge"==n.action)obj.removeMerge(n.column,n.data);else if("setStyle"==n.action)obj.setStyle(n.oldValue,null,null,1);else if("setWidth"==n.action)obj.setWidth(n.column,n.oldValue);else if("setHeight"==n.action)obj.setHeight(n.row,n.oldValue);else if("setHeader"==n.action)obj.setHeader(n.column,n.oldValue);else if("setComments"==n.action)obj.setComments(n.column,n.oldValue[0],n.oldValue[1]);else if("orderBy"==n.action){for(var r=[],l=0;l<n.rows.length;l++)r[n.rows[l]]=l;obj.updateOrderArrow(n.column,n.order?0:1),obj.updateOrder(r)}else if("setValue"==n.action){for(var s=0;s<n.records.length;s++)t.push({x:n.records[s].x,y:n.records[s].y,newValue:n.records[s].oldValue}),n.oldStyle&&obj.resetStyle(n.oldStyle);obj.setValue(t),n.selection&&obj.updateSelectionFromCoords(n.selection[0],n.selection[1],n.selection[2],n.selection[3])}}obj.ignoreEvents=e,obj.ignoreHistory=o,obj.dispatch("onundo",el,n)},obj.redo=function(){var e=!!obj.ignoreEvents,o=!!obj.ignoreHistory;if(obj.ignoreEvents=!0,obj.ignoreHistory=!0,obj.historyIndex<obj.history.length-1){var t=obj.history[++obj.historyIndex];if("insertRow"==t.action)obj.historyProcessRow(0,t);else if("deleteRow"==t.action)obj.historyProcessRow(1,t);else if("insertColumn"==t.action)obj.historyProcessColumn(0,t);else if("deleteColumn"==t.action)obj.historyProcessColumn(1,t);else if("moveRow"==t.action)obj.moveRow(t.oldValue,t.newValue);else if("moveColumn"==t.action)obj.moveColumn(t.oldValue,t.newValue);else if("setMerge"==t.action)obj.setMerge(t.column,t.colspan,t.rowspan,1);else if("setStyle"==t.action)obj.setStyle(t.newValue,null,null,1);else if("setWidth"==t.action)obj.setWidth(t.column,t.newValue);else if("setHeight"==t.action)obj.setHeight(t.row,t.newValue);else if("setHeader"==t.action)obj.setHeader(t.column,t.newValue);else if("setComments"==t.action)obj.setComments(t.column,t.newValue[0],t.newValue[1]);else if("orderBy"==t.action)obj.updateOrderArrow(t.column,t.order),obj.updateOrder(t.rows);else if("setValue"==t.action){obj.setValue(t.records);for(var n=0;n<t.records.length;n++)t.oldStyle&&obj.resetStyle(t.newStyle);t.selection&&obj.updateSelectionFromCoords(t.selection[0],t.selection[1],t.selection[2],t.selection[3])}}obj.ignoreEvents=e,obj.ignoreHistory=o,obj.dispatch("onredo",el,t)},obj.getDropDownValue=function(e,o){var t=[];if(obj.options.columns[e]&&obj.options.columns[e].source){for(var n=[],r=obj.options.columns[e].source,l=0;l<r.length;l++)"object"==typeof r[l]?n[r[l].id]=r[l].name:n[r[l]]=r[l];var s=Array.isArray(o)?o:(""+o).split(";");for(l=0;l<s.length;l++)"object"==typeof s[l]?t.push(n[s[l].id]):n[s[l]]&&t.push(n[s[l]])}else console.error("Invalid column");return t.length>0?t.join("; "):""},obj.parseCSV=function(e,o){e=e.replace(/\r?\n$|\r$|\n$/g,""),e+="\n",o=o||",";const t=new RegExp("^"+" \t\v\0".replace(o,"")+"*");let n=[],r=[],l=0,s="",i=!1,a=!1;const c=e.length;for(let u=0;u<c;u++){let d=e[u],j=u+1<c?e[u+1]:"";if('"'===d)if(i)if('"'===j)s+=d,++u;else if(j!==o&&"\r"!==j&&"\n"!==j){let n=u+1;for(;void 0!==e[n]&&""===e[n].replace(t,"");n++);e[n]===o?(i=!1,u=n):(s+=d,i=!1)}else i=!1;else""===s.replace(t,"")?(i=!0,a=!0):s+=d;else d!==o&&"\n"!==d&&"\r"!==d||i?s+=d:(r[l]=a?s:s.trim(),s="",a=!1,++l,"\n"!==d&&"\r"!==d||(n.push(r),r=[],l=0,"\r"===d&&"\n"===j&&++u))}return n},obj.hash=function(e){var o,t=0;if(0===e.length)return t;for(o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return t},obj.onafterchanges=function(e,o){obj.dispatch("onafterchanges",e,o)},obj.destroy=function(){jexcel.destroy(el)},obj.init=function(){jexcel.current=obj,"function"==typeof jexcel.build&&(obj.options.root?jexcel.build(obj.options.root):(jexcel.build(document),jexcel.build=null)),el.setAttribute("tabindex",1),el.addEventListener("focus",(function(e){jexcel.current&&!obj.selectedCell&&(obj.updateSelectionFromCoords(0,0,0,0),obj.left())})),obj.options.csv?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.csv,method:obj.options.method,data:obj.options.requestVariables,dataType:"text",success:function(e){var o=obj.parseCSV(e,obj.options.csvDelimiter);if(1==obj.options.csvHeaders&&o.length>0)for(var t=o.shift(),n=0;n<t.length;n++)obj.options.columns[n]||(obj.options.columns[n]={type:"text",align:obj.options.defaultColAlign,width:obj.options.defaultColWidth}),void 0===obj.options.columns[n].title&&(obj.options.columns[n].title=t[n]);obj.options.data=o,obj.prepareTable(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.options.url?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.url,method:obj.options.method,data:obj.options.requestVariables,dataType:"json",success:function(e){obj.options.data=e.data?e.data:e,obj.prepareTable(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.prepareTable()},options&&null!=options.contextMenu?obj.options.contextMenu=options.contextMenu:obj.options.contextMenu=function(e,o,t,n){var r=[];if(null==t)1==obj.options.allowInsertColumn&&r.push({title:obj.options.text.insertANewColumnBefore,onclick:function(){obj.insertColumn(1,parseInt(o),1)}}),1==obj.options.allowInsertColumn&&r.push({title:obj.options.text.insertANewColumnAfter,onclick:function(){obj.insertColumn(1,parseInt(o),0)}}),1==obj.options.allowDeleteColumn&&r.push({title:obj.options.text.deleteSelectedColumns,onclick:function(){obj.deleteColumn(obj.getSelectedColumns().length?void 0:parseInt(o))}}),1==obj.options.allowRenameColumn&&r.push({title:obj.options.text.renameThisColumn,onclick:function(){obj.setHeader(o)}}),1==obj.options.columnSorting&&(r.push({type:"line"}),r.push({title:obj.options.text.orderAscending,onclick:function(){obj.orderBy(o,0)}}),r.push({title:obj.options.text.orderDescending,onclick:function(){obj.orderBy(o,1)}}));else if(1==obj.options.allowInsertRow&&(r.push({title:obj.options.text.insertANewRowBefore,onclick:function(){obj.insertRow(1,parseInt(t),1)}}),r.push({title:obj.options.text.insertANewRowAfter,onclick:function(){obj.insertRow(1,parseInt(t))}})),1==obj.options.allowDeleteRow&&r.push({title:obj.options.text.deleteSelectedRows,onclick:function(){obj.deleteRow(obj.getSelectedRows().length?void 0:parseInt(t))}}),o&&1==obj.options.allowComments){r.push({type:"line"});var l=obj.records[t][o].getAttribute("title")||"";r.push({title:l?obj.options.text.editComments:obj.options.text.addComments,onclick:function(){var e=prompt(obj.options.text.comments,l);e&&obj.setComments([o,t],e)}}),l&&r.push({title:obj.options.text.clearComments,onclick:function(){obj.setComments([o,t],"")}})}return r.push({type:"line"}),r.push({title:obj.options.text.copy,shortcut:"Ctrl + C",onclick:function(){obj.copy(!0)}}),navigator&&navigator.clipboard&&r.push({title:obj.options.text.paste,shortcut:"Ctrl + V",onclick:function(){obj.selectedCell&&navigator.clipboard.readText().then((function(e){e&&jexcel.current.paste(obj.selectedCell[0],obj.selectedCell[1],e)}))}}),obj.options.allowExport&&r.push({title:obj.options.text.saveAs,shortcut:"Ctrl + S",onclick:function(){obj.download()}}),obj.options.about&&r.push({title:obj.options.text.about,onclick:function(){!0===obj.options.about?alert(Version().print()):alert(obj.options.about)}}),r},obj.scrollControls=function(e){obj.wheelControls(),obj.options.freezeColumns>0&&obj.content.scrollLeft!=scrollLeft&&obj.updateFreezePosition(),1!=obj.options.lazyLoading&&1!=obj.options.tableOverflow||obj.edition&&"jdropdown"!=e.target.className.substr(0,9)&&obj.closeEditor(obj.edition[0],!0)},obj.wheelControls=function(e){1==obj.options.lazyLoading&&null==jexcel.timeControlLoading&&(jexcel.timeControlLoading=setTimeout((function(){obj.content.scrollTop+obj.content.clientHeight>=obj.content.scrollHeight-10?obj.loadDown()&&(obj.content.scrollTop+obj.content.clientHeight>obj.content.scrollHeight-10&&(obj.content.scrollTop=obj.content.scrollTop-obj.content.clientHeight),obj.updateCornerPosition()):obj.content.scrollTop<=obj.content.clientHeight&&obj.loadUp()&&(obj.content.scrollTop<10&&(obj.content.scrollTop=obj.content.scrollTop+obj.content.clientHeight),obj.updateCornerPosition()),jexcel.timeControlLoading=null}),100))},obj.getFreezeWidth=function(){var e=0;if(obj.options.freezeColumns>0)for(var o=0;o<obj.options.freezeColumns;o++)e+=parseInt(obj.options.columns[o].width);return e};var scrollLeft=0;return obj.updateFreezePosition=function(){var e=0;if((scrollLeft=obj.content.scrollLeft)>50)for(var o=0;o<obj.options.freezeColumns;o++){o>0&&"hidden"!==obj.options.columns[o-1].type&&(e+=parseInt(obj.options.columns[o-1].width)),obj.headers[o].classList.add("jexcel_freezed"),obj.headers[o].style.left=e+"px";for(var t=0;t<obj.rows.length;t++)if(obj.rows[t]&&obj.records[t][o]){var n=scrollLeft+(o>0?obj.records[t][o-1].style.width:0)-51+"px";obj.records[t][o].classList.add("jexcel_freezed"),obj.records[t][o].style.left=n}}else for(o=0;o<obj.options.freezeColumns;o++)for(obj.headers[o].classList.remove("jexcel_freezed"),obj.headers[o].style.left="",t=0;t<obj.rows.length;t++)obj.records[t][o]&&(obj.records[t][o].classList.remove("jexcel_freezed"),obj.records[t][o].style.left="");obj.updateCornerPosition()},el.addEventListener("DOMMouseScroll",obj.wheelControls),el.addEventListener("mousewheel",obj.wheelControls),el.jexcel=obj,el.jspreadsheet=obj,obj.init(),obj};jexcel.setDictionary=function(e){jSuites.setDictionary(e)},jexcel.setExtensions=function(e){for(var o=Object.keys(e),t=0;t<o.length;t++)"function"==typeof e[o[t]]&&(jexcel[o[t]]=e[o[t]],jexcel.license&&"function"==typeof e[o[t]].license&&e[o[t]].license(jexcel.license))},"undefined"!=typeof formula&&(jexcel.formula=formula),jexcel.version=Version,jexcel.current=null,jexcel.timeControl=null,jexcel.timeControlLoading=null;const destroyEvents=function(e){e.removeEventListener("mouseup",jexcel.mouseUpControls),e.removeEventListener("mousedown",jexcel.mouseDownControls),e.removeEventListener("mousemove",jexcel.mouseMoveControls),e.removeEventListener("mouseover",jexcel.mouseOverControls),e.removeEventListener("dblclick",jexcel.doubleClickControls),e.removeEventListener("paste",jexcel.pasteControls),e.removeEventListener("contextmenu",jexcel.contextMenuControls),e.removeEventListener("touchstart",jexcel.touchStartControls),e.removeEventListener("touchend",jexcel.touchEndControls),e.removeEventListener("touchcancel",jexcel.touchEndControls),document.removeEventListener("keydown",jexcel.keyDownControls)};var component;return jexcel.destroy=function(e,o){if(e.jexcel){var t=e.jexcel.options.root?e.jexcel.options.root:document;e.removeEventListener("DOMMouseScroll",e.jexcel.scrollControls),e.removeEventListener("mousewheel",e.jexcel.scrollControls),e.jexcel=null,e.innerHTML="",o&&(destroyEvents(t),jexcel=null)}},jexcel.build=function(e){destroyEvents(e),e.addEventListener("mouseup",jexcel.mouseUpControls),e.addEventListener("mousedown",jexcel.mouseDownControls),e.addEventListener("mousemove",jexcel.mouseMoveControls),e.addEventListener("mouseover",jexcel.mouseOverControls),e.addEventListener("dblclick",jexcel.doubleClickControls),e.addEventListener("paste",jexcel.pasteControls),e.addEventListener("contextmenu",jexcel.contextMenuControls),e.addEventListener("touchstart",jexcel.touchStartControls),e.addEventListener("touchend",jexcel.touchEndControls),e.addEventListener("touchcancel",jexcel.touchEndControls),e.addEventListener("touchmove",jexcel.touchEndControls),document.addEventListener("keydown",jexcel.keyDownControls)},jexcel.keyDownControls=function(e){if(jexcel.current){if(jexcel.current.edition)if(27==e.which)jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!1),e.preventDefault();else if(13==e.which){if("calendar"==jexcel.current.options.columns[jexcel.current.edition[2]].type)jexcel.current.closeEditor(jexcel.current.edition[0],!0);else if("dropdown"==jexcel.current.options.columns[jexcel.current.edition[2]].type||"autocomplete"==jexcel.current.options.columns[jexcel.current.edition[2]].type);else if((1==jexcel.current.options.wordWrap||1==jexcel.current.options.columns[jexcel.current.edition[2]].wordWrap||jexcel.current.options.data[jexcel.current.edition[3]][jexcel.current.edition[2]].length>200)&&e.altKey){var o=jexcel.current.edition[0].children[0],t=jexcel.current.edition[0].children[0].value,n=o.selectionStart;t=t.slice(0,n)+"\n"+t.slice(n),o.value=t,o.focus(),o.selectionStart=n+1,o.selectionEnd=n+1}}else 9==e.which&&(["calendar","html"].includes(jexcel.current.options.columns[jexcel.current.edition[2]].type)?jexcel.current.closeEditor(jexcel.current.edition[0],!0):jexcel.current.edition[0].children[0].blur());if(!jexcel.current.edition&&jexcel.current.selectedCell)if(37==e.which)jexcel.current.left(e.shiftKey,e.ctrlKey),e.preventDefault();else if(39==e.which)jexcel.current.right(e.shiftKey,e.ctrlKey),e.preventDefault();else if(38==e.which)jexcel.current.up(e.shiftKey,e.ctrlKey),e.preventDefault();else if(40==e.which)jexcel.current.down(e.shiftKey,e.ctrlKey),e.preventDefault();else if(36==e.which)jexcel.current.first(e.shiftKey,e.ctrlKey),e.preventDefault();else if(35==e.which)jexcel.current.last(e.shiftKey,e.ctrlKey),e.preventDefault();else if(46==e.which)1==jexcel.current.options.editable&&(jexcel.current.selectedRow?1==jexcel.current.options.allowDeleteRow&&confirm(jexcel.current.options.text.areYouSureToDeleteTheSelectedRows)&&jexcel.current.deleteRow():jexcel.current.selectedHeader?1==jexcel.current.options.allowDeleteColumn&&confirm(jexcel.current.options.text.areYouSureToDeleteTheSelectedColumns)&&jexcel.current.deleteColumn():jexcel.current.setValue(jexcel.current.highlighted,""));else if(13==e.which)e.shiftKey?jexcel.current.up():(1==jexcel.current.options.allowInsertRow&&1==jexcel.current.options.allowManualInsertRow&&jexcel.current.selectedCell[1]==jexcel.current.options.data.length-1&&jexcel.current.insertRow(),jexcel.current.down()),e.preventDefault();else if(9==e.which)e.shiftKey?0==jexcel.current.selectedCell[0]?(jexcel.current.up(),jexcel.current.last()):jexcel.current.left():(1==jexcel.current.options.allowInsertColumn&&1==jexcel.current.options.allowManualInsertColumn&&jexcel.current.selectedCell[0]==jexcel.current.options.data[0].length-1&&jexcel.current.insertColumn(),jexcel.current.selectedCell[0]==jexcel.current.options.data[0].length-1?(jexcel.current.down(),jexcel.current.first()):jexcel.current.right()),e.preventDefault();else if(!e.ctrlKey&&!e.metaKey||e.shiftKey){if(jexcel.current.selectedCell&&1==jexcel.current.options.editable){var r=jexcel.current.selectedCell[1],l=jexcel.current.selectedCell[0];"readonly"!=jexcel.current.options.columns[l].type&&(32==e.keyCode?(e.preventDefault(),"checkbox"==jexcel.current.options.columns[l].type||"radio"==jexcel.current.options.columns[l].type?jexcel.current.setCheckRadioValue():jexcel.current.openEditor(jexcel.current.records[r][l],!0)):113==e.keyCode?jexcel.current.openEditor(jexcel.current.records[r][l],!1):(8==e.keyCode||e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=111||e.keyCode>=187&&e.keyCode<=190||(String.fromCharCode(e.keyCode)==e.key||String.fromCharCode(e.keyCode).toLowerCase()==e.key.toLowerCase())&&jexcel.validLetter(String.fromCharCode(e.keyCode)))&&(jexcel.current.openEditor(jexcel.current.records[r][l],!0),"calendar"==jexcel.current.options.columns[l].type&&e.preventDefault()))}}else 65==e.which?(jexcel.current.selectAll(),e.preventDefault()):83==e.which?(jexcel.current.download(),e.preventDefault()):89==e.which?(jexcel.current.redo(),e.preventDefault()):90==e.which?(jexcel.current.undo(),e.preventDefault()):67==e.which?(jexcel.current.copy(!0),e.preventDefault()):88==e.which?(1==jexcel.current.options.editable?jexcel.cutControls():jexcel.copyControls(),e.preventDefault()):86==e.which&&jexcel.pasteControls();else e.target.classList.contains("jexcel_search")&&(jexcel.timeControl&&clearTimeout(jexcel.timeControl),jexcel.timeControl=setTimeout((function(){jexcel.current.search(e.target.value)}),200))}},jexcel.isMouseAction=!1,jexcel.mouseDownControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;var t=jexcel.getElement(e.target);if(t[0]?jexcel.current!=t[0].jexcel&&(jexcel.current&&(jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!0),jexcel.current.resetSelection()),jexcel.current=t[0].jexcel):jexcel.current&&(jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!0),jexcel.current.resetSelection(!0),jexcel.current=null),jexcel.current&&1==o){if(e.target.classList.contains("jexcel_selectall"))jexcel.current&&jexcel.current.selectAll();else if(e.target.classList.contains("jexcel_corner"))1==jexcel.current.options.editable&&(jexcel.current.selectedCorner=!0);else{if(1==t[1]){if(b=e.target.getAttribute("data-x")){var n=e.target.getBoundingClientRect();if(1==jexcel.current.options.columnResize&&n.width-e.offsetX<12){jexcel.current.resizing={mousePosition:e.pageX,column:b,width:n.width},jexcel.current.headers[b].classList.add("resizing");for(var r=0;r<jexcel.current.records.length;r++)jexcel.current.records[r][b]&&jexcel.current.records[r][b].classList.add("resizing")}else if(1==jexcel.current.options.columnDrag&&n.height-e.offsetY<12)if(jexcel.current.isColMerged(b).length)console.error("Jspreadsheet: This column is part of a merged cell.");else for(jexcel.current.resetSelection(),jexcel.current.dragging={element:e.target,column:b,destination:b},jexcel.current.headers[b].classList.add("dragging"),r=0;r<jexcel.current.records.length;r++)jexcel.current.records[r][b]&&jexcel.current.records[r][b].classList.add("dragging");else{if(jexcel.current.selectedHeader&&(e.shiftKey||e.ctrlKey))var l=jexcel.current.selectedHeader,s=b;else jexcel.current.selectedHeader==b&&1==jexcel.current.options.allowRenameColumn&&(jexcel.timeControl=setTimeout((function(){jexcel.current.setHeader(b)}),800)),jexcel.current.selectedHeader=b,l=b,s=b;jexcel.current.updateSelectionFromCoords(l,0,s,jexcel.current.options.data.length-1)}}else if(e.target.parentNode.classList.contains("jexcel_nested")){if(e.target.getAttribute("data-column"))var i=e.target.getAttribute("data-column").split(","),a=parseInt(i[0]),c=parseInt(i[i.length-1]);else a=0,c=jexcel.current.options.columns.length-1;jexcel.current.updateSelectionFromCoords(a,0,c,jexcel.current.options.data.length-1)}}else jexcel.current.selectedHeader=!1;if(2==t[1]){var u=e.target.getAttribute("data-y");if(e.target.classList.contains("jexcel_row"))n=e.target.getBoundingClientRect(),1==jexcel.current.options.rowResize&&n.height-e.offsetY<12?(jexcel.current.resizing={element:e.target.parentNode,mousePosition:e.pageY,row:u,height:n.height},e.target.parentNode.classList.add("resizing")):1==jexcel.current.options.rowDrag&&n.width-e.offsetX<18?jexcel.current.isRowMerged(u).length?console.error("Jspreadsheet: This row is part of a merged cell"):1==jexcel.current.options.search&&jexcel.current.results?console.error("Jspreadsheet: Please clear your search before perform this action"):(jexcel.current.resetSelection(),jexcel.current.dragging={element:e.target.parentNode,row:u,destination:u},e.target.parentNode.classList.add("dragging")):(jexcel.current.selectedRow&&(e.shiftKey||e.ctrlKey)?(l=jexcel.current.selectedRow,s=u):(jexcel.current.selectedRow=u,l=u,s=u),jexcel.current.updateSelectionFromCoords(0,l,jexcel.current.options.data[0].length-1,s));else if(e.target.classList.contains("jclose")&&e.target.clientWidth-e.offsetX<50&&e.offsetY<50)jexcel.current.closeEditor(jexcel.current.edition[0],!0);else{var d=function(e){var o=e.getAttribute("data-x"),t=e.getAttribute("data-y");return o&&t?[o,t]:e.parentNode?d(e.parentNode):void 0},j=d(e.target);if(j){var b=j[0];u=j[1],jexcel.current.edition&&(jexcel.current.edition[2]==b&&jexcel.current.edition[3]==u||jexcel.current.closeEditor(jexcel.current.edition[0],!0)),jexcel.current.edition||(e.shiftKey?jexcel.current.updateSelectionFromCoords(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],b,u):jexcel.current.updateSelectionFromCoords(b,u)),jexcel.current.selectedHeader=null,jexcel.current.selectedRow=null}}}else jexcel.current.selectedRow=!1;e.target.classList.contains("jexcel_page")&&("<"==e.target.textContent?jexcel.current.page(0):">"==e.target.textContent?jexcel.current.page(e.target.getAttribute("title")-1):jexcel.current.page(e.target.textContent-1))}jexcel.current.edition?jexcel.isMouseAction=!1:jexcel.isMouseAction=!0}else jexcel.isMouseAction=!1},jexcel.mouseUpControls=function(e){if(jexcel.current)if(jexcel.current.resizing){if(jexcel.current.resizing.column){var o=jexcel.current.colgroup[jexcel.current.resizing.column].getAttribute("width"),t=jexcel.current.getSelectedColumns();if(t.length>1){for(var n=[],r=0;r<t.length;r++)n.push(parseInt(jexcel.current.colgroup[t[r]].getAttribute("width")));n[t.indexOf(parseInt(jexcel.current.resizing.column))]=jexcel.current.resizing.width,jexcel.current.setWidth(t,o,n)}else jexcel.current.setWidth(jexcel.current.resizing.column,o,jexcel.current.resizing.width);jexcel.current.headers[jexcel.current.resizing.column].classList.remove("resizing");for(var l=0;l<jexcel.current.records.length;l++)jexcel.current.records[l][jexcel.current.resizing.column]&&jexcel.current.records[l][jexcel.current.resizing.column].classList.remove("resizing")}else{jexcel.current.rows[jexcel.current.resizing.row].children[0].classList.remove("resizing");var s=jexcel.current.rows[jexcel.current.resizing.row].getAttribute("height");jexcel.current.setHeight(jexcel.current.resizing.row,s,jexcel.current.resizing.height),jexcel.current.resizing.element.classList.remove("resizing")}jexcel.current.resizing=null}else if(jexcel.current.dragging){if(jexcel.current.dragging){if(jexcel.current.dragging.column){var i=e.target.getAttribute("data-x");for(jexcel.current.headers[jexcel.current.dragging.column].classList.remove("dragging"),l=0;l<jexcel.current.rows.length;l++)jexcel.current.records[l][jexcel.current.dragging.column]&&jexcel.current.records[l][jexcel.current.dragging.column].classList.remove("dragging");for(r=0;r<jexcel.current.headers.length;r++)jexcel.current.headers[r].classList.remove("dragging-left"),jexcel.current.headers[r].classList.remove("dragging-right");i&&jexcel.current.dragging.column!=jexcel.current.dragging.destination&&jexcel.current.moveColumn(jexcel.current.dragging.column,jexcel.current.dragging.destination)}else{if(jexcel.current.dragging.element.nextSibling){var a=parseInt(jexcel.current.dragging.element.nextSibling.getAttribute("data-y"));jexcel.current.dragging.row<a&&(a-=1)}else a=parseInt(jexcel.current.dragging.element.previousSibling.getAttribute("data-y"));jexcel.current.dragging.row!=jexcel.current.dragging.destination&&jexcel.current.moveRow(jexcel.current.dragging.row,a,!0),jexcel.current.dragging.element.classList.remove("dragging")}jexcel.current.dragging=null}}else jexcel.current.selectedCorner&&(jexcel.current.selectedCorner=!1,jexcel.current.selection.length>0&&(jexcel.current.copyData(jexcel.current.selection[0],jexcel.current.selection[jexcel.current.selection.length-1]),jexcel.current.removeCopySelection()));jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null),jexcel.isMouseAction=!1},jexcel.mouseMoveControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;if(o||(jexcel.isMouseAction=!1),jexcel.current)if(1==jexcel.isMouseAction){if(jexcel.current.resizing)if(jexcel.current.resizing.column){var t=e.pageX-jexcel.current.resizing.mousePosition;if(jexcel.current.resizing.width+t>0){var n=jexcel.current.resizing.width+t;jexcel.current.colgroup[jexcel.current.resizing.column].setAttribute("width",n),jexcel.current.updateCornerPosition()}}else{var r=e.pageY-jexcel.current.resizing.mousePosition;if(jexcel.current.resizing.height+r>0){var l=jexcel.current.resizing.height+r;jexcel.current.rows[jexcel.current.resizing.row].setAttribute("height",l),jexcel.current.rows[jexcel.current.resizing.row].style.setProperty("--table-editor-line-clamp",Math.floor((l-10)/14)),jexcel.current.updateCornerPosition()}}else if(jexcel.current.dragging)if(jexcel.current.dragging.column){var s=e.target.getAttribute("data-x");if(s)if(jexcel.current.isColMerged(s).length)console.error("Jspreadsheet: This column is part of a merged cell.");else{for(var i=0;i<jexcel.current.headers.length;i++)jexcel.current.headers[i].classList.remove("dragging-left"),jexcel.current.headers[i].classList.remove("dragging-right");jexcel.current.dragging.column==s?jexcel.current.dragging.destination=parseInt(s):e.target.clientWidth/2>e.offsetX?(jexcel.current.dragging.column<s?jexcel.current.dragging.destination=parseInt(s)-1:jexcel.current.dragging.destination=parseInt(s),jexcel.current.headers[s].classList.add("dragging-left")):(jexcel.current.dragging.column<s?jexcel.current.dragging.destination=parseInt(s):jexcel.current.dragging.destination=parseInt(s)+1,jexcel.current.headers[s].classList.add("dragging-right"))}}else{var a=e.target.getAttribute("data-y");if(a)if(jexcel.current.isRowMerged(a).length)console.error("Jspreadsheet: This row is part of a merged cell.");else{var c=e.target.clientHeight/2>e.offsetY?e.target.parentNode.nextSibling:e.target.parentNode;jexcel.current.dragging.element!=c&&(e.target.parentNode.parentNode.insertBefore(jexcel.current.dragging.element,c),jexcel.current.dragging.destination=Array.prototype.indexOf.call(jexcel.current.dragging.element.parentNode.children,jexcel.current.dragging.element))}}}else{var u=e.target.getAttribute("data-x"),d=e.target.getAttribute("data-y"),j=e.target.getBoundingClientRect();jexcel.current.cursor&&(jexcel.current.cursor.style.cursor="",jexcel.current.cursor=null),e.target.parentNode.parentNode&&e.target.parentNode.parentNode.className&&(e.target.parentNode.parentNode.classList.contains("resizable")&&(e.target&&u&&!d&&j.width-(e.clientX-j.left)<12?(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="col-resize"):e.target&&!u&&d&&j.height-(e.clientY-j.top)<12&&(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="row-resize")),e.target.parentNode.parentNode.classList.contains("draggable")&&(e.target&&!u&&d&&j.width-(e.clientX-j.left)<18||e.target&&u&&!d&&j.height-(e.clientY-j.top)<12&&e.clientX-j.left<j.width-24)&&(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="move"))}},jexcel.mouseOverControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;if(o||(jexcel.isMouseAction=!1),jexcel.current&&1==jexcel.isMouseAction){var t=jexcel.getElement(e.target);if(t[0]){if(jexcel.current!=t[0].jexcel&&jexcel.current)return!1;var n=e.target.getAttribute("data-x"),r=e.target.getAttribute("data-y");if(jexcel.current.resizing||jexcel.current.dragging);else{if(1==t[1]&&jexcel.current.selectedHeader){n=e.target.getAttribute("data-x");var l=jexcel.current.selectedHeader,s=n;jexcel.current.updateSelectionFromCoords(l,0,s,jexcel.current.options.data.length-1)}2==t[1]&&(e.target.classList.contains("jexcel_row")?jexcel.current.selectedRow&&(l=jexcel.current.selectedRow,s=r,jexcel.current.updateSelectionFromCoords(0,l,jexcel.current.options.data[0].length-1,s)):jexcel.current.edition||n&&r&&(jexcel.current.selectedCorner?jexcel.current.updateCopySelection(n,r):jexcel.current.selectedCell&&jexcel.current.updateSelectionFromCoords(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],n,r)))}}}jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null)},jexcel.doubleClickControls=function(e){if(jexcel.current)if(e.target.classList.contains("jexcel_corner")){if(jexcel.current.highlighted.length>0){var o=jexcel.current.highlighted[0].getAttribute("data-x"),t=parseInt(jexcel.current.highlighted[jexcel.current.highlighted.length-1].getAttribute("data-y"))+1,n=jexcel.current.highlighted[jexcel.current.highlighted.length-1].getAttribute("data-x"),r=jexcel.current.records.length-1;jexcel.current.copyData(jexcel.current.records[t][o],jexcel.current.records[r][n])}}else if(e.target.classList.contains("jexcel_column_filter")){var l=e.target.getAttribute("data-x");jexcel.current.openFilter(l)}else{var s=jexcel.getElement(e.target);if(1==s[1]&&1==jexcel.current.options.columnSorting&&(l=e.target.getAttribute("data-x"))&&jexcel.current.orderBy(l),2==s[1]&&1==jexcel.current.options.editable&&!jexcel.current.edition){var i=function(e){if(e.parentNode){var o=e.getAttribute("data-x"),t=e.getAttribute("data-y");return o&&t?e:i(e.parentNode)}},a=i(e.target);a&&a.classList.contains("highlight")&&jexcel.current.openEditor(a)}}},jexcel.copyControls=function(e){jexcel.current&&jexcel.copyControls.enabled&&(jexcel.current.edition||jexcel.current.copy(!0))},jexcel.cutControls=function(e){jexcel.current&&(jexcel.current.edition||(jexcel.current.copy(!0),1==jexcel.current.options.editable&&jexcel.current.setValue(jexcel.current.highlighted,"")))},jexcel.pasteControls=function(e){jexcel.current&&jexcel.current.selectedCell&&(jexcel.current.edition||1==jexcel.current.options.editable&&(e&&e.clipboardData?(jexcel.current.paste(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],e.clipboardData.getData("text")),e.preventDefault()):window.clipboardData&&jexcel.current.paste(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],window.clipboardData.getData("text"))))},jexcel.contextMenuControls=function(e){if("buttons"in(e=e||window.event)?e.buttons:e.which||e.button,jexcel.current&&jexcel.current.options.contextMenu&&(jexcel.current.contextMenu.contextmenu.close(),jexcel.current)){var o="DIV"===e.target.tagName||"TEXTAREA"===e.target.tagName?e.target.parentNode:e.target,t=o.getAttribute("data-x"),n=o.getAttribute("data-y");if(t||n){const o=jexcel.current.selectedCell,l={l:Math.min(parseInt(o[0]),parseInt(o[2])),r:Math.max(parseInt(o[0]),parseInt(o[2])),t:Math.min(parseInt(o[1]),parseInt(o[3])),b:Math.max(parseInt(o[1]),parseInt(o[3]))};(t<l.l||t>l.r||n<l.t||n>l.b)&&jexcel.current.updateSelectionFromCoords(t,n,t,n);var r=jexcel.current.options.contextMenu(jexcel.current,t,n,e);jexcel.current.contextMenu.contextmenu.open(e,r),e.preventDefault()}}},jexcel.touchStartControls=function(e){var o=jexcel.getElement(e.target);if(o[0]?jexcel.current!=o[0].jexcel&&(jexcel.current&&jexcel.current.resetSelection(),jexcel.current=o[0].jexcel):jexcel.current&&(jexcel.current.resetSelection(),jexcel.current=null),jexcel.current&&!jexcel.current.edition){var t=e.target.getAttribute("data-x"),n=e.target.getAttribute("data-y");t&&n&&(jexcel.current.updateSelectionFromCoords(t,n),jexcel.timeControl=setTimeout((function(){"color"==jexcel.current.options.columns[t].type?jexcel.tmpElement=null:jexcel.tmpElement=e.target,jexcel.current.openEditor(e.target,!1,e)}),500))}},jexcel.touchEndControls=function(e){jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null,jexcel.tmpElement&&"INPUT"==jexcel.tmpElement.children[0].tagName&&jexcel.tmpElement.children[0].focus(),jexcel.tmpElement=null)},jexcel.tabs=function(e,o){var t=[];if(e.classList.contains("jexcel_tabs"))r=e.children[0],l=e.children[1];else{e.innerHTML="",e.classList.add("jexcel_tabs"),e.jexcel=[];var n=document.createElement("div"),r=e.appendChild(n),l=(n=document.createElement("div"),e.appendChild(n))}for(var s=[],i=[],a=0;a<o.length;a++){s[a]=document.createElement("div"),s[a].classList.add("jexcel_tab");var c=jexcel(s[a],o[a]);l.appendChild(s[a]),t[a]=e.jexcel.push(c),i[a]=document.createElement("div"),i[a].classList.add("jexcel_tab_link"),i[a].setAttribute("data-spreadsheet",e.jexcel.length-1),i[a].innerHTML=o[a].sheetName,i[a].onclick=function(){for(var e=0;e<r.children.length;e++)r.children[e].classList.remove("selected"),l.children[e].style.display="none";var o=this.getAttribute("data-spreadsheet");l.children[o].style.display="block",r.children[o].classList.add("selected")},r.appendChild(i[a])}for(var u=0;u<r.children.length;u++)r.children[u].classList.remove("selected"),l.children[u].style.display="none";return r.children[r.children.length-1].classList.add("selected"),l.children[r.children.length-1].style.display="block",t},jexcel.createTabs=jexcel.tabs,jexcel.fromSpreadsheet=function(e,o){var t,n=function(e){var o=[];return e.SheetNames.forEach((function(t){var n={rows:[],columns:[],data:[],style:{}};if(n.sheetName=t,(j=e.Sheets[t]["!cols"])&&j.length)for(var r=0;r<j.length;r++)n.columns[r]={},j[r]&&j[r].wpx&&(n.columns[r].width=j[r].wpx+"px");if((j=e.Sheets[t]["!rows"])&&j.length)for(r=0;r<j.length;r++)j[r]&&j[r].hpx&&(n.rows[r]={},n.rows[r].height=j[r].hpx+"px");if((j=e.Sheets[t]["!merges"])&&j.length>0)for(n.mergeCells=[],r=0;r<j.length;r++){var l=j[r].s.c,s=j[r].s.r,i=j[r].e.c,a=j[r].e.r,c=jexcel.getColumnNameFromId([l,s]);n.mergeCells[c]=[i-l+1,a-s+1]}var u=0,d=0,j=Object.keys(e.Sheets[t]);for(r=0;r<j.length;r++)if("!"!=j[r].substr(0,1)){var b=e.Sheets[t][j[r]],p=jexcel.getIdFromColumnName(j[r],!0);n.data[p[1]]||(n.data[p[1]]=[]),n.data[p[1]][p[0]]=b.f?"="+b.f:b.w,u<p[0]&&(u=p[0]),d<p[1]&&(d=p[1]),b.style&&Object.keys(b.style).length>0&&(n.style[j[r]]=b.style),b.s&&b.s.fgColor&&(n.style[j[r]]&&(n.style[j[r]]+=";"),n.style[j[r]]+="background-color:#"+b.s.fgColor.rgb)}for(var h=n.columns,g=0;g<=d;g++)for(r=0;r<=u;r++)n.data[g]||(n.data[g]=[]),n.data[g][r]||h<r&&(n.data[g][r]="");o.push(n)})),o};(t=new XMLHttpRequest).open("GET",e,!0),"undefined"!=typeof Uint8Array?(t.responseType="arraybuffer",t.onload=function(e){var r=t.response,l=new Uint8Array(r),s=XLSX.read(l,{type:"array",cellFormula:!0,cellStyles:!0});o(n(s))}):(t.setRequestHeader("Accept-Charset","x-user-defined"),t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var e=convertResponseBodyToText(t.responseBody),r=XLSX.read(e,{type:"binary",cellFormula:!0,cellStyles:!0});o(n(r))}}),t.send()},jexcel.validLetter=function(e){return e.match(/([\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC-\u0400-\u04FF']+)/g)?1:0},jexcel.injectArray=function(e,o,t){return e.slice(0,o).concat(t).concat(e.slice(o))},jexcel.getColumnName=function(e){var o="";return e>701?(o+=String.fromCharCode(64+parseInt(e/676)),o+=String.fromCharCode(64+parseInt(e%676/26))):e>25&&(o+=String.fromCharCode(64+parseInt(e/26))),o+String.fromCharCode(65+e%26)},jexcel.getIdFromColumnName=function(e,o){var t=/^[a-zA-Z]+/.exec(e);if(t){for(var n=0,r=0;r<t[0].length;r++)n+=parseInt(t[0].charCodeAt(r)-64)*Math.pow(26,t[0].length-1-r);--n<0&&(n=0);var l=parseInt(/[0-9]+$/.exec(e));l>0&&l--,e=1==o?[n,l]:n+"-"+l}return e},jexcel.getColumnNameFromId=function(e){return Array.isArray(e)||(e=e.split("-")),jexcel.getColumnName(parseInt(e[0]))+(parseInt(e[1])+1)},jexcel.getElement=function(e){var o=0,t=0;return function e(n){n.className&&n.classList.contains("jexcel_container")&&(t=n),"THEAD"==n.tagName?o=1:"TBODY"==n.tagName&&(o=2),n.parentNode&&(t||e(n.parentNode))}(e),[t,o]},jexcel.doubleDigitFormat=function(e){return 1==(e=""+e).length&&(e="0"+e),e},jexcel.createFromTable=function(e,o){if("TABLE"==e.tagName){o||(o={}),o.columns=[],o.data=[];var t=e.querySelectorAll("colgroup > col");if(t.length)for(var n=0;n<t.length;n++){if(!(r=t[n].style.width))var r=t[n].getAttribute("width");r&&(o.columns[n]||(o.columns[n]={}),o.columns[n].width=r)}var l=function(e){var t=e.getBoundingClientRect(),r=t.width>50?t.width:50;o.columns[n]||(o.columns[n]={}),e.getAttribute("data-celltype")?o.columns[n].type=e.getAttribute("data-celltype"):o.columns[n].type="text",o.columns[n].width=r+"px",o.columns[n].title=e.innerHTML,o.columns[n].align=e.style.textAlign||"center",(t=e.getAttribute("name"))&&(o.columns[n].name=t),(t=e.getAttribute("id"))&&(o.columns[n].id=t),(t=e.getAttribute("data-mask"))&&(o.columns[n].mask=t)},s=[],i=e.querySelectorAll(":scope > thead > tr");if(i.length){for(var a=0;a<i.length-1;a++){var c=[];for(n=0;n<i[a].children.length;n++){var u={title:i[a].children[n].textContent,colspan:i[a].children[n].getAttribute("colspan")||1};c.push(u)}s.push(c)}for(i=i[i.length-1].children,n=0;n<i.length;n++)l(i[n])}var d=0,j={},b={},p={},h={},g=e.querySelectorAll(":scope > tr, :scope > tbody > tr");for(a=0;a<g.length;a++)if(o.data[d]=[],1!=o.parseTableFirstRowAsHeader||i.length||0!=a){for(n=0;n<g[a].children.length;n++){if(f=g[a].children[n].getAttribute("data-formula"))"="!=f.substr(0,1)&&(f="="+f);else var f=g[a].children[n].innerHTML;o.data[d].push(f);var m=jexcel.getColumnNameFromId([n,a]),C=g[a].children[n].getAttribute("class");C&&(h[m]=C);var x=parseInt(g[a].children[n].getAttribute("colspan"))||0,v=parseInt(g[a].children[n].getAttribute("rowspan"))||0;(x||v)&&(j[m]=[x||1,v||1]),g[a].children[n].style&&"none"==g[a].children[n].style.display&&(g[a].children[n].style.display="");var y=g[a].children[n].getAttribute("style");y&&(p[m]=y),g[a].children[n].classList.contains("styleBold")&&(p[m]?p[m]+="; font-weight:bold;":p[m]="font-weight:bold;")}g[a].style&&g[a].style.height&&(b[a]={height:g[a].style.height}),d++}else for(n=0;n<g[a].children.length;n++)l(g[a].children[n]);if(Object.keys(s).length>0&&(o.nestedHeaders=s),Object.keys(p).length>0&&(o.style=p),Object.keys(j).length>0&&(o.mergeCells=j),Object.keys(b).length>0&&(o.rows=b),Object.keys(h).length>0&&(o.classes=h),(g=e.querySelectorAll("tfoot tr")).length){var w=[];for(a=0;a<g.length;a++){var A=[];for(n=0;n<g[a].children.length;n++)A.push(g[a].children[n].textContent);w.push(A)}Object.keys(w).length>0&&(o.footers=w)}if(1==o.parseTableAutoCellType){var F=[];for(n=0;n<o.columns.length;n++){var E=!0,L=!0;for(F[n]=[],a=0;a<o.data.length;a++)f=o.data[a][n],F[n][f]||(F[n][f]=0),F[n][f]++,f.length>25&&(E=!1),10==f.length&&"-"==f.substr(4,1)&&"-"==f.substr(7,1)||(L=!1);var D=Object.keys(F[n]).length;L?o.columns[n].type="calendar":1==E&&D>1&&D<=parseInt(.1*o.data.length)&&(o.columns[n].type="dropdown",o.columns[n].source=Object.keys(F[n]))}}return o}console.log("Element is not a table")},jexcel.helpers=(component={getCaretIndex:function(e){if(this.config.root)var o=this.config.root;else o=window;var t=0,n=o.getSelection();if(n&&0!==n.rangeCount){var r=n.getRangeAt(0),l=r.cloneRange();l.selectNodeContents(e),l.setEnd(r.endContainer,r.endOffset),t=l.toString().length}return t},invert:function(e){for(var o=[],t=Object.keys(e),n=0;n<t.length;n++)o[e[t[n]]]=t[n];return o},getColumnName:function(e){var o="";return e>701?(o+=String.fromCharCode(64+parseInt(e/676)),o+=String.fromCharCode(64+parseInt(e%676/26))):e>25&&(o+=String.fromCharCode(64+parseInt(e/26))),o+String.fromCharCode(65+e%26)},getColumnNameFromCoords:function(e,o){return component.getColumnName(parseInt(e))+(parseInt(o)+1)},getCoordsFromColumnName:function(e){var o=/^[a-zA-Z]+/.exec(e);if(o){for(var t=0,n=0;n<o[0].length;n++)t+=parseInt(o[0].charCodeAt(n)-64)*Math.pow(26,o[0].length-1-n);--t<0&&(t=0);var r=parseInt(/[0-9]+$/.exec(e))||null;return r>0&&r--,[t,r]}},createFromTable:function(){},injectArray:function(e,o,t){return e.slice(0,o).concat(t).concat(e.slice(o))},parseCSV:function(e,o){o=o||",";for(var t=0,n=0,r=[[]],l=0,s=null,i=!1,a=!1,c=0;c<e.length;c++)if(r[n]||(r[n]=[]),r[n][t]||(r[n][t]=""),"\r"!=e[c])if("\n"!=e[c]&&e[c]!=o||0!=i&&1!=a&&s){if('"'==e[c]&&(i=!i),null===s){if(1==(s=i))continue}else if(!0===s&&!a&&'"'==e[c]){'"'==e[c+1]?(i=!0,r[n][t]+=e[c],c++):a=!0;continue}r[n][t]+=e[c]}else{if(s=null,i=!1,a=!1,'"'==r[n][t][0]){var u=r[n][t].trim();'"'==u[u.length-1]&&(r[n][t]=u.substr(1,u.length-2))}"\n"==e[c]?(t=0,n++):++t>l&&(l=t)}for(var d=0;d<r.length;d++)for(c=0;c<=l;c++)void 0===r[d][c]&&(r[d][c]="");return r}},component),"undefined"!=typeof jQuery&&function(e){e.fn.jspreadsheet=e.fn.jexcel=function(o){var t=e(this).get(0);return t.jexcel?Array.isArray(t.jexcel)?t.jexcel[o][arguments[1]].apply(this,Array.prototype.slice.call(arguments,2)):t.jexcel[o].apply(this,Array.prototype.slice.call(arguments,1)):jexcel(e(this).get(0),arguments[0])}}(jQuery),jexcel},global.jspreadsheet=global.jexcel=factory()})();