class e{static flatten(e){if(!e||!e.length)return;const t=Object.keys(e[0]);e.map((e=>{t.map((t=>{let i=null===e[t]||void 0===e[t]?"":e[t].toString();if("string"==typeof i&&i.startsWith("[object Object]")&&(i=JSON.stringify(e[t])),i.search(/("|,|\n)/g)>=0)if("["===i[0]){let n=JSON.parse(i);"groups"===t?e[t+".name"]=n.map((e=>e.name)).join(";"):n.map((i=>{e[t+"."+i]=i})),delete e[t]}else if("{"===i[0]){let n=JSON.parse(i);Object.keys(n).map((i=>{n[i]=["cpu","mem","cuda_shares","cuda_device"].includes(i)&&"string"==typeof n[i]?"":n[i],e[t+"."+i]=n[i]})),delete e[t]}else i.includes("GMT")?e[t]=i.split(",").join(""):i.includes(",")&&(i=i.split(","))}))}))}static exportToCsv(t,i){if(!i||!i.length)return;e.flatten(i);const n=Object.keys(i[0]),s=n.join(",")+"\n"+i.map((e=>n.map((t=>{let i="";return e[t]&&"object"==typeof e[t]?(i=JSON.stringify(e[t]),i=i.replace(/"/g,'""'),i.search(/("|,|\n)/g)>=0&&(i=`"${i}"`)):i=null===e[t]||void 0===e[t]?"":e[t].toString(),i})).join(","))).join("\n"),o=new Blob([s],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(o,t);else{const e=document.createElement("a");if(void 0!==e.download){const i=URL.createObjectURL(o);e.setAttribute("href",i),e.setAttribute("download",t+".csv"),e.style.visibility="hidden",document.body.appendChild(e),e.click(),document.body.removeChild(e)}}}}export{e as J};
