import{getElement as e,store as t}from"@wordpress/interactivity";const __=wp.i18n.__;t("billy",{actions:{exportTable:()=>{const{ref:t}=e(),l=t.value??"xlsx";let r=__("Billy Table","billy");globalDataBilly.postTitle&&(r=globalDataBilly.postTitle);const n=document.querySelector('[id^="billy-"] table');let a=document.createElement("tr");if(a.appendChild(document.createElement("td")),n.insertBefore(a,n.firstChild),globalDataBilly.postDate){let e=document.createElement("tr");const t=document.createElement("td");t.innerText=String(globalDataBilly.postDate),e.appendChild(t),n.insertBefore(e,n.firstChild)}const o=document.querySelector(".addressee");if(document.body.contains(o)){let e=document.createElement("tr");const t=document.createElement("td");t.innerHTML=document.querySelector(".addressee").innerHTML.replace(/(<br\s*[\/]?>|<\/p>)/gi,", ").replace(/<\/?[^>]+(>|$)/g,"").replace(/,\s*$/,""),e.appendChild(t),n.insertBefore(e,n.firstChild)}Array.from(n.querySelectorAll("td")).forEach(e=>{e.innerHTML=e.innerHTML.replace(/(<br\s*[\/]?>|<\/p>)/gi,", ").replace(/<\/?[^>]+(>|$)/g,"").replace(/,\s*$/,"")});let i=XLSX.utils.table_to_book(n,{sheet:r.replace(/\W/g,"")});XLSX.writeFile(i,`${r}.${l}`)}}});