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