import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import loadEmbedScript from"/js/modules/loadEmbedScript.min.js";import Cookie from"/js/cookies/main.min.js";const cookieManager=new Cookie,fileInput=document.getElementById("file-input"),introElement=document.getElementById("intro"),loadingAnimation=document.getElementById("loading-animation"),loadingText=document.getElementById("loading-text"),resultsElement=document.getElementById("results"),userInfo=document.getElementById("user-info"),userAvatar=document.getElementById("user-avatar"),userDescription=document.getElementById("user-description"),userDataBreakdown=document.getElementById("user-data-breakdown"),chartElement=document.getElementById("chart"),handleUpload=()=>{fileInput&&fileInput.addEventListener("change",async e=>{loadingAnimation.classList.remove("d-none"),loadingText.classList.remove("d-none"),fileInput.disabled=!0;var r=new FormData;r.set("archive",fileInput.files[0]);r=await(await fetch("/extract-data",{method:"POST",body:r})).json();if(console.log(r),r&&r.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");r=r.data;let e="",t="",o=(r.actor?(e+=`

${r.actor.name||r.actor.preferredUsername}

${r.actor.summary.replaceAll('class="invisible"',"")} `,r.actor.attachment&&(e+=` `),userDescription.innerHTML=`
${e}
`,userAvatar.innerHTML=` `):(userInfo.remove(),userDescription.remove()),[]),a,n=0;r?.outbox?.orderedItems?o=r.outbox.orderedItems:r?.outbox&&(o=r.outbox),(n=o.length)&&(a=o[0]);var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};r.actor&&(l=moment(r.actor.published),l=moment().diff(l,"days"),t+=`

You created your account on ${new Date(r.actor.published).toLocaleDateString(void 0,i)}, which is ${l.toLocaleString()} day(s) ago. Since then, you posted ${n.toLocaleString()} times, or about ${Math.round(n/l).toLocaleString()} time(s) a day on average.

`);let s;"mastodon"===r.format?(a&&(i=a?.object?.id||a?.id,l=new URL(i),s=l.protocol+"//"+l.hostname,t=t+`

Here's your first post!

`+` `),t+=`

And this is what your posting history looks like.

`):t+=`

Here's what your posting history looks like.

`,userDataBreakdown.innerHTML=t,"mastodon"===r.format&&loadEmbedScript(s);var l={labels:o.map(e=>moment(e.published||e.createdAt)),datasets:[{label:"Your posts in time",data:o.map((e,t)=>({x:moment(e.published||e.createdAt),y:new Date(e.published||e.createdAt).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:l,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}}}})}else loadingAnimation.classList.add("d-none"),loadingText.classList.add("d-none"),fileInput.disabled=!1})};export default handleUpload; //# sourceMappingURL=handleUpload.min.js.map