"use strict";window.onload=async()=>{const i=JSON.parse(localStorage.getItem("account")).token,l=(a,s={})=>new Promise((t,c)=>{i&&(s.i=i),fetch(a.indexOf("://")>-1?a:`/api/${a}`,{method:"POST",body:JSON.stringify(s),credentials:"omit",cache:"no-cache"}).then(async n=>{const o=n.status===204?null:await n.json();n.status===200?t(o):n.status===204?t():c(o.error)}).catch(c)});document.getElementById("submit").addEventListener("click",()=>{l("notes/create",{text:document.getElementById("text").value}).then(()=>{location.reload()})}),l("notes/timeline").then(a=>{const s=document.getElementById("tl");for(const e of a){const t=document.createElement("div"),c=document.createElement("header"),n=document.createElement("p"),o=document.createElement("img");n.textContent=`${e.user.name} @${e.user.username}`,o.src=e.user.avatarUrl,o.style="height: 40px";const d=document.createElement("div");if(d.textContent=`${e.text}`,t.appendChild(c),c.appendChild(o),c.appendChild(n),e.text&&t.appendChild(d),e.files)for(const r of e.files){const m=document.createElement("img");m.src=r.properties.thumbnailUrl,t.appendChild(m)}s.appendChild(t)}})};
