import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import getDomain from"/js/modules/getDomain.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 s=new FormData;s.set("archive",fileInput.files[0]);s=await(await fetch("/extract-data",{method:"POST",body:s})).json();if(s&&s.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");s=s.data;let e="",t="",a=(s.actor?(e+=`
${s.actor.name||s.actor.preferredUsername}
${s.actor.summary.replaceAll('class="invisible"',"")} `,s.actor.attachment&&(e+=`You created your account on ${new Date(s.actor.published).toLocaleDateString(void 0,c)}, which is ${u.toLocaleString()} day(s) ago. Since then, you posted ${r.toLocaleString()} times, or about ${Math.round(r/u).toLocaleString()} time(s) a day on average.
`);let n;if(o){let e;if(!["firefish","calckey","misskey"].includes(s.format)){c=o?.uri||o?.object?.id||o?.id;try{e=new URL(c)}catch(e){console.log("error parsing data file",e)}e&&e.protocol&&e.hostname&&(n=e.protocol+"//"+e.hostname),t+=`Here's your first post!
`,"mastodon"===s.format&&(t+=` `),i&&i.length&&(t+=`Here are more of your milestones:
And this is what your posting history looks like.
`}}userDataBreakdown.innerHTML=t,"mastodon"===s.format&&loadEmbedScript(n);var u={labels:a.map(e=>moment(e.published||e.createdAt||e.created)),datasets:[{label:"Your posts in time",data:a.map((e,t)=>({x:moment(e.published||e.createdAt||e.created),y:new Date(e.published||e.createdAt||e.created).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:u,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}},plugins:{tooltip:{callbacks:{label:e=>e.label}}}}})}else loadingAnimation.classList.add("d-none"),loadingText.classList.add("d-none"),fileInput.disabled=!1})};export default handleUpload; //# sourceMappingURL=handleUpload.min.js.map