/*!
* HTML5 export buttons for Buttons and DataTables.
* 2016 SpryMedia Ltd - datatables.net/license
*
* FileSaver.js (1.3.3) - MIT license
* Copyright © 2016 Eli Grey - http://eligrey.com
*/
import $ from"jquery";import DataTable from"datatables.net";import Buttons from"datatables.net-buttons";var useJszip,usePdfmake;function _jsZip(){return useJszip||window.JSZip}function _pdfMake(){return usePdfmake||window.pdfMake}DataTable.Buttons.pdfMake=function(e){if(!e)return _pdfMake();usePdfmake=e},DataTable.Buttons.jszip=function(e){if(!e)return _jsZip();useJszip=e};var _saveAs=function(d){"use strict";var p,i,s,f,m,c,t,y,u,l,e;if(!(void 0===d||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent)))return e=d.document,p=function(){return d.URL||d.webkitURL||d},i=e.createElementNS("http://www.w3.org/1999/xhtml","a"),s="download"in i,f=/constructor/i.test(d.HTMLElement)||d.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent),c=function(e){(d.setImmediate||d.setTimeout)(function(){throw e},0)},t=4e4,y=function(e){setTimeout(function(){"string"==typeof e?p().revokeObjectURL(e):e.remove()},t)},u=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},e=(l=function(e,o,t){t||(e=u(e));var l,r,n=this,t="application/octet-stream"===e.type,a=function(){for(var e=n,t="writestart progress write writeend".split(" "),o=void 0,l=(t=[].concat(t)).length;l--;){var r=e["on"+t[l]];if("function"==typeof r)try{r.call(e,o||e)}catch(e){c(e)}}};n.readyState=n.INIT,s?(l=p().createObjectURL(e),setTimeout(function(){var e,t;i.href=l,i.download=o,e=i,t=new MouseEvent("click"),e.dispatchEvent(t),a(),y(l),n.readyState=n.DONE})):(m||t&&f)&&d.FileReader?((r=new FileReader).onloadend=function(){var e=m?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");d.open(e,"_blank")||(d.location.href=e),n.readyState=n.DONE,a()},r.readAsDataURL(e),n.readyState=n.INIT):(l=l||p().createObjectURL(e),!t&&d.open(l,"_blank")||(d.location.href=l),n.readyState=n.DONE,a(),y(l))}).prototype,"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,o){return t=t||e.name||"download",o||(e=u(e)),navigator.msSaveOrOpenBlob(e,t)}:(e.abort=function(){},e.readyState=e.INIT=0,e.WRITING=1,e.DONE=2,e.error=e.onwritestart=e.onprogress=e.onwrite=e.onabort=e.onerror=e.onwriteend=null,function(e,t,o){return new l(e,t||e.name||"download",o)})}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content),_sheetname=(DataTable.fileSave=_saveAs,function(e){var t="Sheet1";return t=e.sheetName?e.sheetName.replace(/[\[\]\*\/\\\?\:]/g,""):t}),_newLine=function(e){return e.newline||(navigator.userAgent.match(/Windows/)?"\r\n":"\n")},_exportData=function(e,t){function o(e){for(var t="",o=0,l=e.length;o'+i:i).replace(/_dt_b_namespace_token_/g,":")).replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""):i).replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");s.file(e,i)}})}function _createNode(e,t,o){var l=e.createElement(t);return o&&(o.attr&&$(l).attr(o.attr),o.children&&$.each(o.children,function(e,t){l.appendChild(t)}),null!==o.text)&&void 0!==o.text&&l.appendChild(e.createTextNode(o.text)),l}function _excelColWidth(e,t){var o=e.header[t].length;e.footer&&e.footer[t].length>o&&(o=e.footer[t].length);for(var l=0,r=e.body.length;l',"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'',"xl/workbook.xml":'',"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''},_excelSpecials=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(e){return e/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(e){return e/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(e){return-1*e.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(e){return-1*e.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63},{match:/^\-?[\d,]+\.\d{2}$/,style:64},{match:/^[\d]{4}\-[01][\d]\-[0123][\d]$/,style:67,fmt:function(e){return Math.round(25569+Date.parse(e)/864e5)}}];DataTable.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(e){return e.i18n("buttons.copy","Copy")},action:function(e,t,o,l){this.processing(!0);var r=this,n=_exportData(t,l),a=t.buttons.exportInfo(l),d=_newLine(l),p=n.str,i=$("").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0}),d=(a.title&&(p=a.title+d+d+p),a.messageTop&&(p=a.messageTop+d+d+p),a.messageBottom&&(p=p+d+d+a.messageBottom),l.customize&&(p=l.customize(p,l,t)),$("").val(p).appendTo(i));if(document.queryCommandSupported("copy")){i.appendTo(t.table().container()),d[0].focus(),d[0].select();try{var s=document.execCommand("copy");if(i.remove(),s)return t.buttons.info(t.i18n("buttons.copyTitle","Copy to clipboard"),t.i18n("buttons.copySuccess",{1:"Copied one row to clipboard",_:"Copied %d rows to clipboard"},n.rows),2e3),void this.processing(!1)}catch(e){}}function f(){m.off("click.buttons-copy"),$(document).off(".buttons-copy"),t.buttons.info(!1)}var a=$(""+t.i18n("buttons.copyKeys","Press ctrl or ⌘ + C to copy the table data
to your system clipboard.
To cancel, click this message or press escape.")+"").append(i),m=(t.buttons.info(t.i18n("buttons.copyTitle","Copy to clipboard"),a,0),d[0].focus(),d[0].select(),$(a).closest(".dt-button-info"));m.on("click.buttons-copy",f),$(document).on("keydown.buttons-copy",function(e){27===e.keyCode&&(f(),r.processing(!1))}).on("copy.buttons-copy cut.buttons-copy",function(){f(),r.processing(!1)})},exportOptions:{},fieldSeparator:"\t",fieldBoundary:"",header:!0,footer:!1,title:"*",messageTop:"*",messageBottom:"*"},DataTable.ext.buttons.csvHtml5={bom:!1,className:"buttons-csv buttons-html5",available:function(){return void 0!==window.FileReader&&window.Blob},text:function(e){return e.i18n("buttons.csv","CSV")},action:function(e,t,o,l){this.processing(!0);var r=_exportData(t,l).str,n=t.buttons.exportInfo(l),a=l.charset;l.customize&&(r=l.customize(r,l,t)),a=!1!==a?(a=a||document.characterSet||document.charset)&&";charset="+a:"",l.bom&&(r=String.fromCharCode(65279)+r),_saveAs(new Blob([r],{type:"text/csv"+a}),n.filename,!0),this.processing(!1)},filename:"*",extension:".csv",exportOptions:{},fieldSeparator:",",fieldBoundary:'"',escapeChar:'"',charset:null,header:!0,footer:!1},DataTable.ext.buttons.excelHtml5={className:"buttons-excel buttons-html5",available:function(){return void 0!==window.FileReader&&void 0!==_jsZip()&&!_isDuffSafari()&&_serialiser},text:function(e){return e.i18n("buttons.excel","Excel")},action:function(e,t,o,s){this.processing(!0);function l(e){return e=excelStrings[e],$.parseXML(e)}function r(e){m=_createNode(y,"row",{attr:{r:f=c+1}});for(var t=0,o=e.length;t