/* Tabulator v4.6.3 (c) Oliver Folkerd */ var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},Download=function(o){this.table=o,this.fields={},this.columnsByIndex=[],this.columnsByField={},this.config={},this.active=!1};Download.prototype.download=function(o,t,n,e,i){function s(n,e){i?!0===i?a.triggerDownload(n,e,o,t,!0):i(n):a.triggerDownload(n,e,o,t)}var a=this,r=!1;this.processConfig(),this.active=e,"function"==typeof o?r=o:a.downloaders[o]?r=a.downloaders[o]:console.warn("Download Error - No such download type found: ",o),this.processColumns(),r&&r.call(this,a.processDefinitions(),a.processData(e||"active"),n||{},s,this.config)},Download.prototype.processConfig=function(){var o={columnGroups:!0,rowGroups:!0,columnCalcs:!0,dataTree:!0};if(this.table.options.downloadConfig)for(var t in this.table.options.downloadConfig)o[t]=this.table.options.downloadConfig[t];this.config.rowGroups=o.rowGroups&&this.table.options.groupBy&&this.table.modExists("groupRows"),o.columnGroups&&this.table.columnManager.columns.length!=this.table.columnManager.columnsByIndex.length&&(this.config.columnGroups=!0),o.columnCalcs&&this.table.modExists("columnCalcs")&&(this.config.columnCalcs=!0),o.dataTree&&this.table.options.dataTree&&this.table.modExists("dataTree")&&(this.config.dataTree=!0)},Download.prototype.processColumns=function(){var o=this;o.columnsByIndex=[],o.columnsByField={},o.table.columnManager.columnsByIndex.forEach(function(t){t.field&&!1!==t.definition.download&&(t.visible||!t.visible&&t.definition.download)&&(o.columnsByIndex.push(t),o.columnsByField[t.field]=t)})},Download.prototype.processDefinitions=function(){var o=this,t=[];return this.config.columnGroups?o.table.columnManager.columns.forEach(function(n){var e=o.processColumnGroup(n);e&&t.push(e)}):o.columnsByIndex.forEach(function(n){!1!==n.download&&t.push(o.processDefinition(n))}),t},Download.prototype.processColumnGroup=function(o){var t=this,n=o.columns,e=0,i=this.processDefinition(o),s={type:"group",title:i.title,depth:1};if(n.length){if(s.subGroups=[],s.width=0,n.forEach(function(o){var n=t.processColumnGroup(o);n.depth>e&&(e=n.depth),n&&(s.width+=n.width,s.subGroups.push(n))}),s.depth+=e,!s.width)return!1}else{if(!o.field||!1===o.definition.download||!(o.visible||!o.visible&&o.definition.download))return!1;s.width=1,s.definition=i}return s},Download.prototype.processDefinition=function(o){var t={};for(var n in o.definition)t[n]=o.definition[n];return void 0!==o.definition.downloadTitle&&(t.title=o.definition.downloadTitle),t},Download.prototype.processData=function(o){var t=this,n=this,e=[],i=[],s=!1,a={};return this.config.rowGroups?("visible"==o?(s=n.table.rowManager.getRows(o),s.forEach(function(o){if("row"==o.type){var t=o.getGroup();-1===i.indexOf(t)&&i.push(t)}})):i=this.table.modules.groupRows.getGroups(),i.forEach(function(o){e.push(t.processGroupData(o,s))})):(this.config.dataTree&&(o=o="display"),e=n.table.rowManager.getData(o,"download")),this.config.columnCalcs&&(a=this.table.getCalcResults(),e={calcs:a,data:e}),"function"==typeof n.table.options.downloadDataFormatter&&(e=n.table.options.downloadDataFormatter(e)),e},Download.prototype.processGroupData=function(o,t){var n=this,e=o.getSubGroups(),i={type:"group",key:o.key};return e.length?(i.subGroups=[],e.forEach(function(o){i.subGroups.push(n.processGroupData(o,t))})):t?(i.rows=[],o.rows.forEach(function(o){t.indexOf(o)>-1&&i.rows.push(o.getData("download"))})):i.rows=o.getData(!0,"download"),i},Download.prototype.triggerDownload=function(o,t,n,e,i){var s=document.createElement("a"),a=new Blob([o],{type:t}),e=e||"Tabulator."+("function"==typeof n?"txt":n);(a=this.table.options.downloadReady.call(this.table,o,a))&&(i?window.open(window.URL.createObjectURL(a)):navigator.msSaveOrOpenBlob?navigator.msSaveOrOpenBlob(a,e):(s.setAttribute("href",window.URL.createObjectURL(a)),s.setAttribute("download",e),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)),this.table.options.downloadComplete&&this.table.options.downloadComplete())},Download.prototype.getFieldValue=function(o,t){var n=this.columnsByField[o];return!!n&&n.getFieldValue(t)},Download.prototype.commsReceived=function(o,t,n){switch(t){case"intercept":this.download(n.type,"",n.options,n.active,n.intercept)}},Download.prototype.downloaders={csv:function(o,t,n,e,i){function s(o,t){o.subGroups?o.subGroups.forEach(function(o){s(o,t+1)}):(f.push('"'+String(o.title).split('"').join('""')+'"'),p.push(o.definition.field))}function a(o){o.forEach(function(o){var t=[];p.forEach(function(n){var e=c.getFieldValue(n,o);switch(void 0===e?"undefined":_typeof(e)){case"object":e=JSON.stringify(e);break;case"undefined":case"null":e="";break;default:e=e}t.push('"'+String(e).split('"').join('""')+'"')}),u.push(t.join(d))})}function r(o){o.subGroups?o.subGroups.forEach(function(o){r(o)}):a(o.rows)}var u,l,c=this,f=[],p=[],d=n&&n.delimiter?n.delimiter:",";i.columnGroups?(console.warn("Download Warning - CSV downloader cannot process column groups"),o.forEach(function(o){s(o,0)})):function(){o.forEach(function(o){f.push('"'+String(o.title).split('"').join('""')+'"'),p.push(o.field)})}(),u=[f.join(d)],i.columnCalcs&&(console.warn("Download Warning - CSV downloader cannot process column calculations"),t=t.data),i.rowGroups?(console.warn("Download Warning - CSV downloader cannot process row groups"),t.forEach(function(o){r(o)})):a(t),l=u.join("\n"),n.bom&&(l="\ufeff"+l),e(l,"text/csv")},json:function(o,t,n,e,i){var s;i.columnCalcs&&(console.warn("Download Warning - CSV downloader cannot process column calculations"),t=t.data),s=JSON.stringify(t,null,"\t"),e(s,"application/json")},pdf:function(o,t,n,e,i){function s(o,t){var n=o.width,e=1,i={content:o.title||""};if(o.subGroups?(o.subGroups.forEach(function(o){s(o,t+1)}),e=1):(p.push(o.definition.field),e=m-t),i.rowSpan=e,d[t].push(i),n--,e>1)for(var a=t+1;am&&(m=o.depth)});for(var S=0;S1&&p[t].push({type:"hoz",start:w[t].length,end:w[t].length+o.width-1}),w[t].push(o.title),o.subGroups?o.subGroups.forEach(function(o){n(o,t+1)}):(m.push(o.definition.field),e(m.length),p[t].push({type:"vert",start:m.length-1}))}function e(){var o=0;w.forEach(function(t){var n=t.length;n>o&&(o=n)}),w.forEach(function(t){var n=t.length;if(n