varlsKeys={token:"token",chunkSize:"chunkSize",parallelUploads:"parallelUploads",uploadsHistoryOrder:"uploadsHistoryOrder",fileLength:"fileLength",uploadAge:"uploadAge"},page={token:localStorage[lsKeys.token],private:null,enableUserAccounts:null,maxSize:null,chunkSize:null,temporaryUploadAges:null,fileIdentifierLength:null,album:null,parallelUploads:null,uploadsHistoryOrder:null,fileLength:null,uploadAge:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,tabs:[],activeTab:null,albumSelect:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,imageExtensions:[".webp",".jpg",".jpeg",".bmp",".gif",".png",".svg"],checkIfPublic:function(e){returnaxios.get("api/check").then((function(a){returnpage.private=a.data.private,page.enableUserAccounts=a.data.enableUserAccounts,page.maxSize=parseInt(a.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSize=parseInt(a.data.chunkSize),page.temporaryUploadAges=a.data.temporaryUploadAges,page.fileIdentifierLength=a.data.fileIdentifierLength,page.preparePage(e)})).catch(e)},preparePage:function(e){if(!page.private)returnpage.prepareUpload(e);if(page.token)returnpage.verifyToken(page.token,e,!0);vara=document.querySelector("#loginToUpload");a.href="auth",a.classList.remove("is-loading"),page.enableUserAccounts?a.innerText="Anonymous upload is disabled. Log in to upload.":a.innerText="Running in private mode. Log in to upload."},verifyToken:function(e,a,t){returnaxios.post("api/tokens/verify",{token:e}).then((function(r){return!1===r.data.success?swal({title:"An error occurred!",text:r.data.description,icon:"error"}).then((function(){t&&(localStorage.removeItem("token"),location.reload())})):(localStorage.token=e,page.token=e,page.prepareUpload(a))})).catch(a)},prepareUpload:function(e){page.token&&(document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelect.addEventListener("change",(function(){page.album=parseInt(page.albumSelect.value),"function"==typeofpage.prepareShareX&&page.prepareShareX()})),page.fetchAlbums(e)),page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),!page.token&&page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads"),page.prepareDropzone(),"function"==typeofpage.prepareShareX&&page.prepareShareX();vara=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes),document.querySelector("#uploadUrls").addEventListener("click",(function(e){page.uploadUrls(e.currentTarget)})));for(vart=document.querySelector("#tabs"),r=t.querySelectorAll("li"),n=function(e){vara=r[e].dataset.id,t=document.querySelector("#"+a);t&&(r[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:r[e],content:t}))},l=0;l<r.length;l++)n(l);page.tabs.length&&(page.setActiveTab(0),t.classList.remove("is-hidden"))},setActiveTab:function(e){for(vara=0;a<page.tabs.length;a++)a===e?(page.tabs[a].tab.classList.add("is-active"),page.tabs[a].content.classList.remove("is-hidden"),page.activeTab=e):(page.tabs[a].tab.classList.remove("is-active"),page.tabs[a].content.classList.add("is-hidden"))},fetchAlbums:function(e){returnaxios.get("api/albums",{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)returnswal("An error occurred!",e.data.description,"error");if(Array.isArray(e.data.albums)&&e.data.albums.length)for(vara=0;a<e.data.albums.length;a++){vart=e.data.albums[a],r=document.createElement("option");r.value=t.id,r.innerHTML=t.name,page.albumSelect.appendChild(r)}})).catch(e)},prepareDropzone:function(){vare=document.querySelector("#tpl");page.previewTemplate=e.innerHTML,e.parentNode.removeChild(e);vara=document.querySelector("#tab-files"),t=document.createElement("div");t.className="control is-expanded",t.innerHTML='\