import{c as g,na as h}from"./chunk-GJDGQISV.js";var b=class d{csvPrefixFormat="";convertToCSV(e,s){let i;if(typeof e=="string")i=e;else{var t=typeof e=="object"?e:JSON.parse(e);i=this.transformToCSVStringFormat(t)}this.exportCSV(i,s)}isNumeric(e){return/^-?\d+$/.test(e)}parseCSV(e){return new g(i=>{let t=new FileReader;t.onload=()=>{let a=t.result.split(/\r\n|\n/),r=a[0].split(","),m=[];for(let p=0;p<a.length;p++){let u=a[p].split(",");if(u.length==r.length){let l=[];for(let n=0;n<r.length;n++)if(this.isNumeric(u[n])){let f=u[n];l.push(parseFloat(f))}else l.push(u[n]);m.push(l)}else{var c=a[p].split(new RegExp(',(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)'));let l=[];for(let n=0;n<c.length;n++)if(this.isNumeric(c[n])){let f=c[n];l.push(parseFloat(f))}else l.push(c[n]);m.push(l)}}i.next(m)},t.readAsBinaryString(e)})}transformToCSVStringFormat(e){if(!e||!e.length)return;let s=",",i=Object.keys(e[0]);return e.map(o=>i.map(a=>{let r=o[a]===null||o[a]===void 0?"":o[a];return r=r instanceof Date?r.toLocaleString():r.toString().replace(/"/g,'""'),r.search(/("|,|\n)/g)>=0&&(r=`"${r}"`),r}).join(s)).join(`
`)}exportCSV(e,s){var i=new Blob([e],{type:"text/csv;charset=utf8;"}),t=document.createElement("a");t.setAttribute("href",window.URL.createObjectURL(i)),t.setAttribute("download",s),document.body.appendChild(t),t.click(),document.body.removeChild(t)}static \u0275fac=function(s){return new(s||d)};static \u0275prov=h({token:d,factory:d.\u0275fac,providedIn:"root"})};export{b as a};
