text: var lsKeys={token:"token",viewType:{uploads:"viewTypeUploads",uploadsAll:"viewTypeUploadsAll"},selected:{uploads:"selectedUploads",uploadsAll:"selectedUploadsAll",albums:"selectedAlbums",albumsAll:"selectedAlbumsAll",users:"selectedUsers"},originalNames:{uploads:"originalNames",uploadsAll:"originalNamesAll"}},page={section:null,dom:null,token:localStorage[lsKeys.token],username:null,permissions:null,menusContainer:null,menus:[],currentView:null,views:{uploads:{type:localStorage[lsKeys.viewType.uploads],originalNames:"1"===localStorage[lsKeys.originalNames.uploads],album:null,pageNum:null},uploadsAll:{type:localStorage[lsKeys.viewType.uploadsAll],originalNames:"1"===localStorage[lsKeys.originalNames.uploadsAll],filters:null,pageNum:null,all:!0},albums:{filters:null,pageNum:null},albumsAll:{filters:null,pageNum:null,all:!0},users:{filters:null,pageNum:null}},selected:{uploads:[],uploadsAll:[],albums:[],albumsAll:[],users:[]},checkboxes:[],lastSelected:[],selectAlbumContainer:null,cache:{},clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv",".m4v",".m2ts"],isSomethingLoading:!1,fadingIn:null,albumTitleMaxLength:70,albumDescMaxLength:4e3,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),page.section.classList.remove("is-hidden")},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML="<code>"+e.toString()+"</code>",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,t,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Update detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(t){if(!1===t.data.success)return swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,t.data.version&&page.checkClientVersion(t.data.version),page.token=e,page.username=t.data.username,page.permissions=t.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.section=document.querySelector("#dashboard"),page.dom=page.section.querySelector("#page"),page.dom.addEventListener("click",page.domClick,!0),page.dom.addEventListener("submit",(function(e){if(e.target&&e.target.classList.contains("prevent-default"))return e.preventDefault()}),!0),page.menusContainer=document.querySelector("#menu");for(var e=[{selector:"#itemUploads",onclick:page.getUploads},{selector:"#itemDeleteUploadsByNames",onclick:page.deleteUploadsByNames},{selector:"#itemManageYourAlbums",onclick:page.getAlbums},{selector:"#itemManageToken",onclick:page.changeToken},{selector:"#itemChangePassword",onclick:page.changePassword},{selector:"#itemLogout",onclick:page.logout},{selector:"#itemManageUploads",onclick:page.getUploads,params:{all:!0},group:"moderator"},{selector:"#itemManageAlbums",onclick:page.getAlbums,params:{all:!0},group:"moderator"},{selector:"#itemStatistics",onclick:page.getStatistics,group:"admin"},{selector:"#itemManageUsers",onclick:page.getUsers,group:"admin"}],a=function(a){if(!e[a].group||page.permissions[e[a].group]){var t=document.querySelector(e[a].selector);t.addEventListener("click",(function(t){if(page.isSomethingLoading)return page.warnSomethingLoading();e[a].onclick.call(null,Object.assign(e[a].params||{},{trigger:t.currentTarget}))})),t.classList.remove("is-hidden"),page.menus.push(t)}},t=0;t<e.length;t++)a(t);page.permissions.moderator&&(document.querySelector("#itemLabelAdmin").classList.remove("is-hidden"),document.querySelector("#itemListAdmin").classList.remove("is-hidden")),document.querySelector("#itemLogout").innerHTML="Logout ( "+page.username+" )",page.unhide(),page.getAlbumsSidebar(),"function"==typeof page.prepareShareX&&page.prepareShareX()},logout:function(e){page.updateTrigger(e.trigger,"active"),localStorage.removeItem(lsKeys.token),window.location="auth"},warnSomethingLoading:function(){swal("Please wait!","Something else is still loading…","warning",{buttons:!1,timer:3e3})},updateTrigger:function(e,a){if(e)if("loading"===a?(page.isSomethingLoading=!0,page.section.classList.add("is-loading")):(page.section.classList.remove("is-loading"),page.isSomethingLoading=!1),"loading"===a)e.classList.add("is-loading");else if("active"===a){if("LI"===e.parentNode.tagName&&!e.className.includes("pagination-link")){for(var t=0;t<page.menus.length;t++)page.menus[t].classList.remove("is-active");e.classList.add("is-active")}e.classList.remove("is-loading")}else e.classList.remove("is-loading"),e.classList.remove("is-active")},getItemID:function(e){var a=e.parentNode;return e.parentNode.classList.contains("controls")&&(a=a.parentNode),parseInt(a.dataset.id)},domClick:function(e){var a=e.target;if(a&&(["I"].includes(a.tagName)&&["SPAN"].includes(a.parentNode.tagName)&&(a=a.parentNode),["SPAN"].includes(a.tagName)&&["A","BUTTON"].includes(a.parentNode.tagName)&&(a=a.parentNode),a.dataset&&a.dataset.action&&!a.hasAttribute("disabled"))){e.stopPropagation();var t=page.getItemID(a),n=a.dataset.action;switch(n){case"view-list":return page.setUploadsView("list",a);case"view-thumbs":return page.setUploadsView("thumbs",a);case"toggle-original-names":return page.toggleOriginalNames(a);case"add-to-album":return page.addToAlbum(t);case"delete-upload":return page.deleteUpload(t);case"add-selected-uploads-to-album":return page.addSelectedUploadsToAlbum();case"bulk-delete-uploads":return page.bulkDeleteUploads();case"display-preview":return page.displayPreview(t);case"upload-filters-help":return page.uploadFiltersHelp(a);case"filter-uploads":return page.filterUploads(a);case"submit-album":return page.submitAlbum(a);case"edit-album":return page.editAlbum(t);case"disable-album":return page.disableAlbum(t);case"view-album-uploads":return page.viewAlbumUploads(t,a);case"create-user":return page.createUser();case"edit-user":return page.editUser(t);case"disable-user":return page.disableUser(t);case"delete-user":return page.deleteUser(t);case"view-user-uploads":return page.viewUserUploads(t,a);case"get-new-token":return page.getNewToken(a);case"clear-selection":return page.clearSelection();case"select":return page.select(a,e);case"select-all":return page.selectAll(a);case"page-ellipsis":return page.focusJumpToPage(a);case"page-prev":case"page-next":case"page-goto":case"jump-to-page":return page.switchPage(n,a)}}},fadeAndScroll:function(e){page.fadingIn&&(clearTimeout(page.fadingIn),page.dom.classList.remove("fade-in")),e||(page.dom.classList.add("fade-in"),page.fadingIn=setTimeout((function(){page.dom.classList.remove("fade-in")}),500)),page.dom.scrollIntoView({behavior:e?"auto":"smooth",block:"start",inline:"nearest"})},getByView:function(e,a){switch(e){case"uploads":case"uploadsAll":return{type:"uploads",func:page.getUploads}[a];case"albums":case"albumsAll":return{type:"albums",func:page.getAlbums}[a];case"users":return{type:"users",func:page.getUsers}[a];default:return null}},switchPage:function(e,a){if(page.isSomethingLoading)return page.warnSomethingLoading();var t=Object.assign(page.views[page.currentView],{trigger:a}),n=page.getByView(page.currentView,"func");switch(e){case"page-prev":return t.pageNum=page.views[page.currentView].pageNum-1,t.pageNum<0?swal("An error occurred!","This is already the first page.","error"):n(t);case"page-next":return t.pageNum=page.views[page.currentView].pageNum+1,n(t);case"page-goto":return t.pageNum=parseInt(a.dataset.goto),n(t);case"jump-to-page":var s=document.querySelector("#"+(a.dataset.jumpid||"jumpToPage"));if(!s.checkValidity())return;var i=parseInt(s.value);return t.pageNum=isNaN(i)?0:i-1,t.pageNum<0&&(t.pageNum=0),n(t)}},focusJumpToPage:function(e){var a=document.querySelector("#"+(e.dataset.jumpid||"jumpToPage"));a&&(a.focus(),a.select())},getUploads:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),("number"!=typeof e.pageNum||e.pageNum<0)&&(e.pageNum=0);var a=void 0!==e.album?"api/album/"+e.album+"/"+e.pageNum:"api/uploads/"+e.pageNum,t={};e.all&&(t.all="1"),e.filters&&(t.filters=e.filters,/(^|\s)(date|expiry):[\d"]/.test(e.filters)&&(t.minoffset=(new Date).getTimezoneOffset())),axios.get(a,{headers:t}).then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.files;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getUploads(e)):swal("An error occurred!","There are no more uploads to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"uploadsAll":"uploads",page.cache={};var s=a.data.albums,i=a.data.users,l=a.data.basedomain;e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));for(var o=page.paginate(a.data.count,25,e.pageNum),r='\n      <div class="columns">\n        '+('\n      <div class="column">\n        <form class="prevent-default">\n          <div class="field has-addons">\n            <div class="control is-expanded">\n              <input id="filters" class="input is-small" type="text" placeholder="Filter uploads" value="'+page.escape(e.filters||"")+'">\n            </div>\n            <div class="control">\n              <button type="button" class="button is-small is-primary is-outlined" title="Help?" data-action="upload-filters-help"'+(e.all?' data-all="true"':"")+'>\n                <span class="icon">\n                  <i class="icon-help-circled"></i>\n                </span>\n              </button>\n            </div>\n            <div class="control">\n              <button type="submit" class="button is-small is-info is-outlined" title="Filter uploads" data-action="filter-uploads">\n                <span class="icon">\n                  <i class="icon-filter"></i>\n                </span>\n              </button>\n            </div>\n          </div>\n        </form>\n      </div>\n    ')+'\n        <div class="column is-one-quarter">\n          <form class="prevent-default">\n            <div class="field has-addons">\n              <div class="control is-expanded">\n                <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+t+'" value="'+(e.pageNum+1)+'"'+(1===t?" disabled":"")+'>\n              </div>\n              <div class="control">\n                <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n                  <span class="icon">\n                    <i class="icon-paper-plane"></i>\n                  </span>\n                </button>\n              </div>\n            </div>\n          </form>\n        </div>\n      </div>\n    ',c='\n      <div class="columns">\n        <div class="column exclusive-operations has-text-left">\n          <a class="button is-small is-primary is-outlined" title="Toggle original names" data-action="toggle-original-names">\n            <span class="icon">\n              <i class="icon-exchange"></i>\n            </span>\n            <span>Toggle original names</span>\n          </a>\n        </div>\n        <div class="column has-text-centered">\n          <a class="button is-small is-danger is-outlined" title="List view" data-action="view-list">\n            <span class="icon">\n              <i class="icon-th-list"></i>\n            </span>\n          </a>\n          <a class="button is-small is-danger is-outlined" title="Thumbs view" data-action="view-thumbs">\n            <span class="icon">\n              <i class="icon-th-large"></i>\n            </span>\n          </a>\n        </div>\n        <div class="column bulk-operations has-text-right">\n          <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n            <span class="icon">\n              <i class="icon-cancel"></i>\n            </span>\n          </a>\n          '+(e.all?"":'<a class="button is-small is-warning is-outlined" title="Bulk add to album" data-action="add-selected-uploads-to-album">\n            <span class="icon">\n              <i class="icon-plus"></i>\n            </span>\n          </a>')+'\n          <a class="button is-small is-danger is-outlined" title="Bulk delete" data-action="bulk-delete-uploads">\n            <span class="icon">\n              <i class="icon-trash"></i>\n            </span>\n            <span>Bulk delete</span>\n          </a>\n        </div>\n      </div>\n    ',d=r.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),u=o.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),p=!1,g=page.views[page.currentView].originalNames,m=n.some((function(e){return void 0!==e.expirydate})),b=0;b<n.length;b++){n[b].file=l+"/"+n[b].name,n[b].thumb&&(n[b].thumb=l+"/"+n[b].thumb),n[b].type="other";var h=/.[\w]+(\?|$)/.exec(n[b].file),v=h&&h[0]?h[0].toLowerCase():null;page.imageExts.includes(v)?n[b].type="picture":page.videoExts.includes(v)&&(n[b].type="video"),page.cache[n[b].id]={name:n[b].name,original:n[b].original,thumb:n[b].thumb,file:n[b].file,type:n[b].type},n[b].prettyBytes=page.getPrettyBytes(parseInt(n[b].size)),n[b].prettyDate=page.getPrettyDate(new Date(1e3*n[b].timestamp)),m&&(n[b].prettyExpiryDate=n[b].expirydate?page.getPrettyDate(new Date(1e3*n[b].expirydate)):null),n[b].selected=page.selected[page.currentView].includes(n[b].id),n[b].selected||(p=!0),e.all?n[b].appendix=n[b].userid&&i[n[b].userid]||"":void 0===e.album&&(n[b].appendix=n[b].albumid&&s[n[b].albumid]||"")}if("thumbs"===page.views[page.currentView].type){page.dom.innerHTML="\n        "+o+"\n        "+r+"\n        "+c+'\n        <div id="table" class="columns is-multiline is-mobile is-centered">\n        </div>\n        '+c+"\n        "+d+"\n        "+u+"\n      ";for(var f=document.querySelector("#table"),w=0;w<n.length;w++){var y=n[w],k=document.createElement("div");k.className="image-container column",k.dataset.id=y.id,void 0!==y.thumb?k.innerHTML='<a class="image" href="'+y.file+'" target="_blank"><img alt="'+y.name+'" data-src="'+y.thumb+'"/></a>':k.innerHTML='<a class="image" href="'+y.file+'" target="_blank"><h1 class="title">'+(y.extname||"N/A")+"</h1></a>",k.innerHTML+='\n          <input type="checkbox" class="checkbox" title="Select" data-index="'+w+'" data-action="select"'+(y.selected?" checked":"")+'>\n          <div class="controls">\n            '+(y.thumb?'<a class="button is-small is-primary" title="Display preview" data-action="display-preview">\n              <span class="icon">\n                <i class="'+("other"!==y.type?"icon-"+y.type:"icon-doc-inv")+'"></i>\n              </span>\n            </a>':"")+'\n            <a class="button is-small is-info clipboard-js" title="Copy link to clipboard" data-clipboard-text="'+y.file+'">\n              <span class="icon">\n                <i class="icon-clipboard"></i>\n              </span>\n            </a>\n            <a class="button is-small is-warning" title="Add to album" data-action="add-to-album">\n              <span class="icon">\n                <i class="icon-plus"></i>\n              </span>\n            </a>\n            <a class="button is-small is-danger" title="Delete" data-action="delete-upload">\n              <span class="icon">\n                <i class="icon-trash"></i>\n              </span>\n            </a>\n          </div>\n          <div class="details">\n            <p class="name" title="'+y.file+'">'+y.name+"</p>\n            "+(g?'<p class="originalname" title="'+y.original+'">'+y.original+"</p>":"")+'\n            <p class="prettybytes">'+(y.appendix?"<span>"+y.appendix+"</span> – ":"")+y.prettyBytes+"</p>\n            "+(m&&y.prettyExpiryDate?'<p class="prettyexpirydate">EXP: '+y.prettyExpiryDate+"</p>":"")+"\n          </div>\n        ",f.appendChild(k),page.checkboxes=f.querySelectorAll('.checkbox[data-action="select"]')}}else{var x=e.all&&e.filters&&e.filters.includes("albumid:");page.dom.innerHTML="\n        "+o+"\n        "+r+"\n        "+c+'\n        <div class="table-container has-text-left">\n          <table class="table is-narrow is-fullwidth is-hoverable">\n            <thead>\n              <tr>\n                <th class="controls"><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n                <th title="Key: name">File name</th>\n                '+(g?'<th title="Key: original">Original name</th>':"")+"\n                "+(void 0===e.album?'<th title="Key: '+(e.all?'userid">User':'albumid">Album')+"</th>":"")+"\n                "+(x?'<th title="Key: albumid">Album</th>':"")+'\n                <th title="Key: size">Size</th>\n                '+(e.all?'<th title="Key: ip">IP</th>':"")+'\n                <th title="Key: timestamp">Upload date</th>\n                '+(m?'<th title="Key: expirydate">Expiry date</th>':"")+'\n                <th></th>\n              </tr>\n            </thead>\n            <tbody id="table">\n            </tbody>\n          </table>\n        </div>\n        '+c+"\n        "+d+"\n        "+u+"\n      ";for(var T=document.querySelector("#table"),S=0;S<n.length;S++){var A=n[S],N=document.createElement("tr");N.dataset.id=A.id,N.innerHTML='\n          <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+S+'" data-action="select"'+(A.selected?" checked":"")+'></td>\n          <th class="name"><a href="'+A.file+'" target="_blank" title="'+A.file+'">'+A.name+"</a></th>\n          "+(g?'<th class="originalname" title="'+A.original+'">'+A.original+"</th>":"")+"\n          "+(void 0===e.album?'<th class="appendix">'+A.appendix+"</th>":"")+"\n          "+(x?'<th class="album">'+(A.albumid&&s[A.albumid]||"")+"</th>":"")+'\n          <td class="prettybytes">'+A.prettyBytes+"</td>\n          "+(e.all?'<td class="ip">'+(A.ip||"")+"</td>":"")+'\n          <td class="prettydate">'+A.prettyDate+"</td>\n          "+(m?'<td class="prettyexpirydate">'+(A.prettyExpiryDate||"-")+"</td>":"")+'\n          <td class="controls has-text-right">\n            <a class="button is-small is-primary is-outlined" title="'+(A.thumb?"Display preview":"File can't be previewed")+'" data-action="display-preview"'+(A.thumb?"":" disabled")+'>\n              <span class="icon">\n                <i class="'+("other"!==A.type?"icon-"+A.type:"icon-doc-inv")+'"></i>\n              </span>\n            </a>\n            <a class="button is-small is-info is-outlined clipboard-js" title="Copy link to clipboard" data-clipboard-text="'+A.file+'">\n              <span class="icon">\n                <i class="icon-clipboard"></i>\n              </span>\n            </a>\n            '+(e.all?"":'<a class="button is-small is-warning is-outlined" title="Add to album" data-action="add-to-album">\n              <span class="icon">\n                <i class="icon-plus"></i>\n              </span>\n            </a>')+'\n            <a class="button is-small is-danger is-outlined" title="Delete" data-action="delete-upload">\n              <span class="icon">\n                <i class="icon-trash"></i>\n              </span>\n            </a>\n          </td>\n        ',T.appendChild(N),page.checkboxes=T.querySelectorAll('.checkbox[data-action="select"]')}}var L=document.querySelector("#selectAll");L&&!p&&n.length&&(L.checked=!0,L.title="Unselect all"),"thumbs"===page.views[page.currentView].type?(page.fadeAndScroll(!0),page.lazyLoad.update()):page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),"uploads"===page.currentView&&(page.views.uploads.album=e.album),page.views[page.currentView].filters=e.filters,page.views[page.currentView].pageNum=n.length?e.pageNum:0})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){if(page.isSomethingLoading)return page.warnSomethingLoading();"list"===e?(delete localStorage[lsKeys.viewType[page.currentView]],page.views[page.currentView].type=void 0):(localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e),page.getUploads(Object.assign(page.views[page.currentView],{trigger:a}))},toggleOriginalNames:function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.views[page.currentView].originalNames?(delete localStorage[lsKeys.originalNames[page.currentView]],page.views[page.currentView].originalNames=!1):(localStorage[lsKeys.originalNames[page.currentView]]="1",page.views[page.currentView].originalNames=!0),page.getUploads(Object.assign(page.views[page.currentView],{trigger:e}))},displayPreview:function(e){var a=page.cache[e];if(a.thumb){var t=document.createElement("div");if(t.innerHTML='\n    <div class="content has-text-centered">\n      <p>\n        <div class="has-text-weight-bold">'+a.name+"</div>\n        <div>"+a.original+'</div>\n      </p>\n      <p class="swal-display-thumb-container">\n        <img id="swalThumb" src="'+a.thumb+'">\n      </p>\n    </div>\n  ',a.file){var n=/.[\w]+(\?|$)/.exec(a.file),s=n&&n[0]?n[0].toLowerCase():null,i=page.imageExts.includes(s),l=!i&&page.videoExts.includes(s);(i||l)&&(t.innerHTML+='\n        <div class="field has-text-centered">\n          <div class="controls">\n            <a id="swalOriginal" type="button" class="button is-info" data-original="'+a.file+'">\n              <span class="icon">\n                <i class="icon-arrows-cw"></i>\n              </span>\n              <span>Load original</span>\n            </a>\n          </div>\n        </div>\n      ',t.querySelector("#swalOriginal").addEventListener("click",(function(e){var n=e.currentTarget;if(!n.classList.contains("is-danger")){n.classList.add("is-loading");var s=t.querySelector("#swalThumb");if(i)s.src=a.file,s.onload=function(){n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},s.onerror=function(e){e.currentTarget.classList.add("is-hidden"),n.className="button is-danger is-fullwidth",n.innerHTML='\n              <span class="icon">\n                <i class="icon-block"></i>\n              </span>\n              <span>Unable to load original</span>\n            '};else if(l){s.classList.add("is-hidden");var o=document.createElement("video");o.id="swalVideo",o.controls=!0,o.autoplay=!0,o.src=a.file,s.insertAdjacentElement("afterend",o),n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")}}})))}return swal({content:t,buttons:!1}).then((function(){var e=t.querySelector("#swalVideo");e&&e.remove(),document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;a<page.checkboxes.length;a++){var t=page.getItemID(page.checkboxes[a]);isNaN(t)||page.checkboxes[a].checked!==e.checked&&(page.checkboxes[a].checked=e.checked,page.checkboxes[a].checked?page.selected[page.currentView].push(t):page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(t),1))}page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],e.title=e.checked?"Unselect all":"Select all"},selectInBetween:function(e,a){var t=parseInt(e.dataset.index),n=parseInt(a.dataset.index);if(!(Math.abs(t-n)<2))for(var s=0;s<page.checkboxes.length;s++)if(t>n&&s>n&&s<t||t<n&&s>t&&s<n){var i=page.checkboxes[s].checked=a.checked,l=page.getItemID(page.checkboxes[s]);!page.selected[page.currentView].includes(l)&&i?page.selected[page.currentView].push(l):page.selected[page.currentView].includes(l)&&!i&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(l),1)}},select:function(e,a){var t=page.getItemID(e);isNaN(t)||(a.shiftKey&&page.lastSelected?(page.selectInBetween(e,page.lastSelected),e.checked=page.lastSelected.checked):page.lastSelected=e,!page.selected[page.currentView].includes(t)&&e.checked?page.selected[page.currentView].push(t):page.selected[page.currentView].includes(t)&&!e.checked&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(t),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]])},clearSelection:function(){var e=page.selected[page.currentView],a=page.getByView(page.currentView,"type"),t=e.length;if(!t)return swal("An error occurred!","You have not selected any "+a+".","error");var n=1===t?a.substring(0,a.length-1):a;return swal({title:"Are you sure?",text:"You are going to unselect "+t+" "+n+".",buttons:!0}).then((function(e){if(e){for(var a=page.checkboxes,s=0;s<a.length;s++)a[s].checked&&(a[s].checked=!1);page.selected[page.currentView]=[],delete localStorage[lsKeys.selected[page.currentView]];var i=document.querySelector("#selectAll");return i&&(i.checked=!1),swal("Cleared selection!","Unselected "+t+" "+n+".","success")}}))},uploadFiltersHelp:function(e){var a=Boolean(e.dataset.all),t=document.createElement("div");t.style="text-align: left",t.innerHTML=((a?"There are 2 filter keys, namely <b>user</b> (username) and <b>ip</b>.\n    These keys can be specified more than once.\n    For usernames with whitespaces, wrap them with double quotes (<code>\"</code>).\n    Special cases such as uploads by non-registered users or have no IPs respectively, use <code>user:-</code> or <code>ip:-</code>.\n\n    To exclude certain users/ips while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n    Negation sign can also be used to exclude the special cases mentioned above (i.e. <code>-user:-</code> or <code>-ip:-</code>).\n\n    If you know the ID of a user's album, you can list its uploads with <b>albumid</b> key.\n    Negation sign works for this key as well.":"There is only 1 filter key, namely <b>albumid</b>.\n    This key can be specified more than once.\n    Special case such as uploads with no albums, use <code>albumid:-</code>.\n\n    To exclude certain albums while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n    Negation sign can also be used to exclude the special case mentioned above (i.e. <code>-albumid:-</code>).")+'\n\n    There are 2 range keys: <b>date</b> (upload date) and <b>expiry</b> (expiry date).\n    Their format is: <code>"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS"</code> ("from" date and "to" date respectively).\n    You may specify only one of the dates.\n    If "to" date is missing, \'now\' will be used. If "from" date is missing, \'beginning of time\' will be used.\n    If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n    If only time is specified, today\'s date will be used.\n    If you do not need to specify both date and time, you may omit the double quotes.\n    In conclusion, the following examples are all valid: <code>date:"2020/01/01 01:23-2018/01/01 06"</code>, <code>expiry:-2020/05</code>, <code>date:12:34:56</code>.\n    These keys can only be specified once each.\n\n    <b>Timezone?</b> Feel free to query the dates with your own timezone.\n    API requests to the filter endpoint will attach your browser\'s timezone offset, so the server will automatically calculate timezone differences.\n\n    Matches can also be sorted with <b>sort</b> keys.\n    Their formats are: <code>sort:columnName[:d[escending]]</code>, where <code>:d[escending]</code> is an optional tag to set the direction to descending.\n    This key must be used with internal column names used in the database (<code>id</code>, <code>'+(a?"userid":"albumid")+"</code>, and so on),\n    but there are 2 shortcuts available: <b>date</b> for <code>timestamp</code> column and <b>expiry</b> for <code>expirydate</code> column.\n    This key can also be specified more than once, where their order will decide the sorting steps.\n\n    Finally, there are type-<b>is</b> keys to refine by types.\n    You can use <code>is:image</code> and <code>is:video</code> to list images and videos respectively.\n    This will only use image/video extensions whose thumbnails can be generated by the safe.\n    Negation sign works for this key as well.\n    Mixing inclusion and exclusion is not allowed (i.e. <code>is:image -is:video</code>, since the second key is redundant).\n\n    Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n    Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n    <b>Internal steps:</b>\n    "+(a?"- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n    - Refine matches":"- Filter uploads")+" using date key, if any.\n    - Refine matches using expiry key, if any.\n    - Refine matches using type-is keys, if any.\n    - Refine matches using ANY non-keyed keywords, if any.\n    - Filter matches using ALL exclusion non-keyed keywords, if any.\n    - Sort matches using sorting keys, if any.\n\n    <b>Examples:</b>\n    "+(a?'- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n    <code>user:demo user:"John Doe" user:-</code>\n    - ALL uploads, but NOT the ones from user named "demo" AND "John Doe":\n    <code>-user:demo -user:"John Doe"</code>\n    - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n    <code>ip:127.0.0.1 *.rar *.zip</code>\n    ':"")+'- Uploads without albums:\n    <code>albumid:-</code>\n    - ALL uploads, but NOT the ones from album with ID 69:\n    <code>-albumid:69</code>\n    - Uploads uploaded since "1 June 2019 00:00:00":\n    <code>date:2019/06</code>\n    - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59":\n    <code>date:"2020/04/07 12-2020/04/07 23:59:59"</code>\n    - Uploads uploaded before "5 February 2020 00:00:00":\n    <code>date:-2020/02/05</code>\n    - Uploads which file names match "*.gz" but NOT "*.tar.gz":\n    <code>*.gz -*.tar.gz</code>\n    - Sort matches by "size" column in ascending and descending order respectively:\n    <code>'+(a?'user:"John Doe"':"*.txt")+" sort:size</code>\n    <code>*.mp4 "+(a?"user:- ":"")+"sort:size:d</code>\n    "+(page.permissions.moderator?"":"<b>Notice:</b> Regular users may face some limitations in the amount of keys that can be used at a time.")+"\n    <b>Friendly reminder:</b> This window can be scrolled up!\n  ").trim().replace(/^\s*/g,"").replace(/\n/g,"<br>"),swal({content:t}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim().replace(/\t/g," ").replace(/(^|\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\s+/g,"$2");page.getUploads(Object.assign(page.views[page.currentView],{filters:a,pageNum:0,trigger:e}))},viewUserUploads:function(e,a){var t=page.cache[e];if(t){a.classList.add("is-loading");var n=t.username.includes(" ")?'"'+t.username+'"':t.username;page.getUploads({all:!0,filters:"user:"+n,trigger:document.querySelector("#itemManageUploads")})}},viewAlbumUploads:function(e,a){if(page.cache[e]){a.classList.add("is-loading");var t="albumsAll"===page.currentView&&page.permissions.moderator;page.getUploads({all:t,filters:"albumid:"+e,trigger:t?document.querySelector("#itemManageUploads"):document.querySelector("#itemUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="<br><b>Hint:</b> You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n    <form class="prevent-default">\n      <div class="field">\n        <label class="label">Upload names:</label>\n        <div class="control">\n          <textarea id="bulkDeleteNames" class="textarea"></textarea>\n        </div>\n        <p class="help">Separate each entry with a new line.'+a+'</p>\n      </div>\n      <div class="field">\n        <div class="control">\n          <button type="submit" id="submitBulkDelete" class="button is-danger is-outlined is-fullwidth">\n            <span class="icon">\n              <i class="icon-trash"></i>\n            </span>\n            <span>Bulk delete</span>\n          </button>\n        </div>\n      </div>\n    </form>\n  ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#submitBulkDelete").addEventListener("click",(function(){if(page.isSomethingLoading)return page.warnSomethingLoading();var e=document.querySelector("#bulkDeleteNames"),a={},t=e.value.split(/\r?\n/).map((function(e){var a=e.trim();return/^[^\s]+$/.test(a)?a:""})).filter((function(e){return!(!e||Object.prototype.hasOwnProperty.call(a,e))&&(a[e]=!0)}));if(e.value=t.join("\n"),!t.length)return swal("An error occurred!","You have not entered any upload names.","error");page.postBulkDeleteUploads({all:!0,field:"name",values:t,cb:function(a){e.value=a.join("\n")}})}))},postBulkDeleteUploads:function(e){void 0===e&&(e={});var a=e.values.length,t=e.values.length+" upload"+(1===a?"":"s"),n="<p>You won't be able to recover "+t.replace(/^(\d*)(.*)/,"<b>$1</b>$2")+"!</p>";e.all&&(n+="\n<p><b>Warning:</b> You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!</p>");var s=document.createElement("div");s.innerHTML=n,swal({title:"Are you sure?",content:s,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke "+(1===e.values.length?"it":"them")+"!",closeModal:!1}}}).then((function(n){n&&axios.post("api/upload/bulkdelete",{field:e.field,values:e.values}).then((function(n){if(n){if(!1===n.data.success)return"No token provided"===n.data.description?page.verifyToken(page.token):swal("An error occurred!",n.data.description,"error");var s=Array.isArray(n.data.failed)?n.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+t+".","error"):s.length&&s.length<e.values.length?swal("Warning!","From "+t+", unable to delete "+s.length+" of them.","warning"):swal("Deleted!",t+" "+(1===a?"has":"have")+" been deleted.","success",{buttons:!1,timer:1500}),"function"==typeof e.cb&&e.cb(s)}})).catch(page.onAxiosError)}))},addSelectedUploadsToAlbum:function(){if("uploads"===page.currentView){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.addUploadsToAlbum(page.selected[page.currentView],(function(e){e&&(e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]),page.getUploads(page.views[page.currentView]))}))}},addToAlbum:function(e){page.addUploadsToAlbum([e],(function(e){e&&page.getUploads(page.views[page.currentView])}))},addUploadsToAlbum:function(e,a){var t=e.length,n=document.createElement("div");n.innerHTML='\n    <div class="field has-text-centered">\n      <p>You are about to add <b>'+t+"</b> upload"+(1===t?"":"s")+' to an album.</p>\n      <p><b>If an upload is already in an album, it will be moved.</b></p>\n    </div>\n    <div class="field">\n      <div class="control">\n        <div class="select is-fullwidth">\n          <select id="swalAlbum" disabled>\n            <option value="-1">Remove from album</option>\n            <option value="" selected disabled>Fetching albums list…</option>\n          </select>\n        </div>\n      </div>\n    </div>\n  ',swal({icon:"warning",content:n,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(t){if(t){var n=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(n))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:n}).then((function(t){if(t)if(!1!==t.data.success){var s=e.length;t.data.failed&&t.data.failed.length&&(s-=t.data.failed.length);var i="upload"+(1===e.length?"":"s");if(!s)return swal("An error occurred!","Could not add the "+i+" to the album.","error");swal("Woohoo!","Successfully "+(n<0?"removed":"added")+" "+s+" "+i+" "+(n<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(t.data.failed)}else"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error")})).catch(page.onAxiosError)}})),axios.get("api/albums").then((function(e){if(!1!==e.data.success){var a=document.querySelector("#swalAlbum");a&&(a.innerHTML+=e.data.albums.map((function(e){return'<option value="'+e.id+'">'+e.name+"</option>"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a={};e.all&&(a.all="1");var t="api/albums/"+e.pageNum;axios.get(t,{headers:a}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.albums;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getAlbums(e)):swal("An error occurred!","There are no more albums to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"albumsAll":"albums",page.cache={};var s=a.data.users,i=a.data.homeDomain;e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var l=page.paginate(a.data.count,25,e.pageNum),o='\n      <div class="columns">\n        '+('\n      <div class="column">\n        <form class="prevent-default">\n          <div class="field has-addons">\n            <div class="control is-expanded">\n              <input id="filters" class="input is-small" type="text" placeholder="Filter albums (WIP)" value="'+page.escape(e.filters||"")+'" disabled>\n            </div>\n            <div class="control">\n              <button type="button" class="button is-small is-primary is-outlined" title="Help? (WIP)" data-action="album-filters-help" disabled>\n                <span class="icon">\n                  <i class="icon-help-circled"></i>\n                </span>\n              </button>\n            </div>\n            <div class="control">\n              <button type="submit" class="button is-small is-info is-outlined" title="Filter albums (WIP)" data-action="filter-albums" disabled>\n                <span class="icon">\n                  <i class="icon-filter"></i>\n                </span>\n              </button>\n            </div>\n          </div>\n        </form>\n      </div>\n    ')+'\n        <div class="column is-one-quarter">\n          <form class="prevent-default">\n            <div class="field has-addons">\n              <div class="control is-expanded">\n                <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+t+'" value="'+(e.pageNum+1)+'"'+(1===t?" disabled":"")+'>\n              </div>\n              <div class="control">\n                <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n                  <span class="icon">\n                    <i class="icon-paper-plane"></i>\n                  </span>\n                </button>\n              </div>\n            </div>\n          </form>\n        </div>\n      </div>\n    ',r='\n      <div class="columns">\n        <div class="column is-hidden-mobile"></div>\n        <div class="column bulk-operations has-text-right">\n          <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n            <span class="icon">\n              <i class="icon-cancel"></i>\n            </span>\n          </a>\n          <a class="button is-small is-dangerish is-outlined" title="Bulk disable (WIP)" data-action="bulk-disable-albums" disabled>\n            <span class="icon">\n              <i class="icon-trash"></i>\n            </span>\n            '+(e.all?"":"<span>Bulk disable</span>")+"\n          </a>\n          "+(e.all?'<a class="button is-small is-danger is-outlined" title="Bulk delete (WIP)" data-action="bulk-delete-albums" disabled>\n                <span class="icon">\n                  <i class="icon-trash"></i>\n                </span>\n                <span>Bulk delete</span>\n              </a>':"")+"\n        </div>\n      </div>\n    ",c=o.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),d=l.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),u=!1,p='\n      <h2 class="subtitle">Create new album</h2>\n      <form class="prevent-default">\n        <div class="field">\n          <div class="control">\n            <input id="albumName" class="input" type="text" placeholder="Name" maxlength="'+page.albumTitleMaxLength+'">\n          </div>\n          <p class="help">Max length is '+page.albumTitleMaxLength+' characters.</p>\n        </div>\n        <div class="field">\n          <div class="control">\n            <textarea id="albumDescription" class="textarea" placeholder="Description" rows="1" maxlength="'+page.albumDescMaxLength+'"></textarea>\n          </div>\n          <p class="help">Max length is '+page.albumDescMaxLength+' characters.</p>\n        </div>\n        <div class="field">\n          <div class="control">\n            <button type="submit" id="submitAlbum" class="button is-info is-outlined is-fullwidth" data-action="submit-album">\n              <span class="icon">\n                <i class="icon-paper-plane"></i>\n              </span>\n              <span>Create</span>\n            </button>\n          </div>\n        </div>\n      </form>\n      <hr>\n    ';page.dom.innerHTML="\n      "+(e.all?"":p)+"\n      "+l+"\n      "+o+"\n      "+r+'\n      <div class="table-container has-text-left">\n        <table class="table is-narrow is-fullwidth is-hoverable">\n          <thead>\n            <tr>\n              <th><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n              <th>ID</th>\n              <th>Name</th>\n              '+(e.all?"<th>User</th>":"")+'\n              <th>Uploads</th>\n              <th>Created at</th>\n              <th>Public link</th>\n              <th></th>\n            </tr>\n          </thead>\n          <tbody id="table">\n          </tbody>\n        </table>\n      </div>\n      '+r+"\n      "+c+"\n      "+d+"\n    ";for(var g=document.querySelector("#table"),m=0;m<n.length;m++){var b=n[m],h=i+"/a/"+b.identifier,v=page.selected[page.currentView].includes(b.id);v||(u=!0),b.prettyDate=page.getPrettyDate(new Date(1e3*b.timestamp));var f=0!==b.enabled;page.cache[b.id]={name:b.name,download:b.download,public:b.public,description:b.description,enabled:f};var w=document.createElement("tr");w.dataset.id=b.id,w.innerHTML='\n        <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+m+'" data-action="select"'+(v?" checked":"")+"></td>\n        <th>"+b.id+"</th>\n        <th"+(f?"":' class="has-text-grey"')+">"+b.name+"</td>\n        "+(e.all?"<th>"+(b.userid&&s[b.userid]||"")+"</th>":"")+"\n        <th>"+b.uploads+"</th>\n        <td>"+b.prettyDate+"</td>\n        <td><a "+(f&&b.public?"":'class="is-linethrough" ')+'href="'+h+'" target="_blank">'+h+'</a></td>\n        <td class="has-text-right" data-id="'+b.id+'">\n          <a class="button is-small is-primary is-outlined" title="Edit album" data-action="edit-album">\n            <span class="icon is-small">\n              <i class="icon-pencil"></i>\n            </span>\n          </a>\n          <a class="button is-small is-info is-outlined" title="'+(b.uploads?"View uploads":"Album doesn't have uploads")+'" data-action="view-album-uploads" '+(b.uploads?"":"disabled")+'>\n            <span class="icon">\n              <i class="icon-docs"></i>\n            </span>\n          </a>\n          <a class="button is-small is-info is-outlined clipboard-js" title="Copy link to clipboard" '+(b.public?'data-clipboard-text="'+h+'"':"disabled")+'>\n            <span class="icon is-small">\n              <i class="icon-clipboard"></i>\n            </span>\n          </a>\n          <a class="button is-small is-warning is-outlined" title="Download album" '+(f&&b.download?'href="api/album/zip/'+b.identifier+"?v="+b.editedAt+'"':"disabled")+'>\n            <span class="icon is-small">\n              <i class="icon-download"></i>\n            </span>\n          </a>\n          <a class="button is-small is-dangerish is-outlined" title="Disable album" data-action="disable-album"'+(f?"":" disabled")+'>\n            <span class="icon is-small">\n              <i class="icon-trash"></i>\n            </span>\n          </a>\n        </td>\n      ',g.appendChild(w),page.checkboxes=g.querySelectorAll('.checkbox[data-action="select"]')}var y=document.querySelector("#selectAll");y&&!u&&(y.checked=!0,y.title="Unselect all"),page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),"albumsAll"===page.currentView&&(page.views[page.currentView].filters=e.filters),page.views[page.currentView].pageNum=n.length?e.pageNum:0}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache[e];if(a){var t=document.createElement("div");t.innerHTML='\n    <div class="field">\n      <div class="controls">\n        <input id="swalName" class="input" type="text" placeholder="Name" maxlength="'+page.albumTitleMaxLength+'" value="'+(a.name||"").substring(0,page.albumTitleMaxLength)+'">\n      </div>\n      <p class="help">Max length is '+page.albumTitleMaxLength+' characters.</p>\n    </div>\n    <div class="field">\n      <div class="control">\n        <textarea id="swalDescription" class="textarea" placeholder="Description" rows="2" maxlength="'+page.albumDescMaxLength+'">'+(a.description||"").substring(0,page.albumDescMaxLength)+'</textarea>\n      </div>\n      <p class="help">Max length is '+page.albumDescMaxLength+" characters.</p>\n    </div>\n    "+("albumsAll"===page.currentView&&page.permissions.moderator?'<div class="field">\n          <div class="control">\n            <label class="checkbox">\n              <input id="swalEnabled" type="checkbox" '+(a.enabled?"checked":"")+">\n              Enabled\n            </label>\n          </div>\n        </div>":"")+'\n    <div class="field">\n      <div class="control">\n        <label class="checkbox">\n          <input id="swalDownload" type="checkbox" '+(a.download?"checked":"")+'>\n          Enable download\n        </label>\n      </div>\n    </div>\n    <div class="field">\n      <div class="control">\n        <label class="checkbox">\n          <input id="swalPublic" type="checkbox" '+(a.public?"checked":"")+'>\n          Enable public link\n        </label>\n      </div>\n    </div>\n    <div class="field">\n      <div class="control">\n        <label class="checkbox">\n          <input id="swalRequestLink" type="checkbox">\n          Request new public link\n        </label>\n      </div>\n    </div>\n  ',swal({title:"Edit album",icon:"info",content:t,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){if(t){var n={id:e,name:document.querySelector("#swalName").value.trim(),description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked,requestLink:document.querySelector("#swalRequestLink").checked};"albumsAll"===page.currentView&&page.permissions.moderator&&(n.enabled=document.querySelector("#swalEnabled").checked),axios.post("api/albums/edit",n).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");e.data.identifier?swal("Success!","The album's new identifier is: "+e.data.identifier+".","success"):e.data.name!==a.name?swal("Success!","The album was renamed to: "+e.data.name+".","success"):swal("Success!","The album was edited.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))}})).catch(page.onAxiosError)}}))}},disableAlbum:function(e){swal({title:"Are you sure?",text:"This won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable it!",closeModal:!1},purge:{text:"Umm, delete the uploads, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/disable",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Disabled!","Your album has been disabled.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},submitAlbum:function(e){page.updateTrigger(e,"loading"),axios.post("api/albums",{name:document.querySelector("#albumName").value.trim(),description:document.querySelector("#albumDescription").value.trim()}).then((function(a){if(a){if(page.updateTrigger(e),!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Woohoo!","Album was created successfully.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums({pageNum:-1})}})).catch((function(a){page.updateTrigger(e),page.onAxiosError(a)}))},getAlbumsSidebar:function(){axios.get("api/albums",{headers:{sidebar:"1"}}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=e.data.albums,t=e.data.count,n=document.querySelector("#albumsContainer"),s=n.querySelectorAll("li > a");if(s.length){for(var i=0;i<s.length;i++)page.menus.splice(page.menus.indexOf(s[i]),1);n.innerHTML=""}if(void 0!==a){for(var l=0;l<a.length;l++){var o=a[l],r=document.createElement("li"),c=document.createElement("a");c.id=o.id,c.className="is-relative",c.innerHTML=o.name,c.addEventListener("click",(function(e){page.getUploads({album:parseInt(e.currentTarget.id),trigger:e.currentTarget})})),page.menus.push(c),r.appendChild(c),n.appendChild(r)}if(t>a.length){var d=document.createElement("li"),u=document.createElement("a");u.className="is-relative",u.innerHTML="...",u.title="You have "+t+" albums, but the sidebar can only list your first "+a.length+" albums.",u.addEventListener("click",(function(e){page.getAlbums({trigger:document.querySelector("#itemManageYourAlbums")})})),d.appendChild(u),n.appendChild(d)}}}})).catch(page.onAxiosError)},changeToken:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n    <div class="field">\n      <label class="label">Your current token:</label>\n      <div class="field">\n        <div class="control">\n          <input id="token" readonly class="input" type="text" placeholder="Your token" value="'+page.token+'">\n        </div>\n      </div>\n    </div>\n    <div class="field">\n      <div class="control">\n        <a id="getNewToken" class="button is-info is-outlined is-fullwidth">\n          <span class="icon">\n            <i class="icon-arrows-cw"></i>\n          </span>\n          <span>Request new token</span>\n        </a>\n      </div>\n    </div>\n  ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#getNewToken").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();var a=e.currentTarget;page.updateTrigger(a,"loading"),axios.post("api/tokens/change").then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your token was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){axios.defaults.headers.common.token=e.data.token,localStorage[lsKeys.token]=e.data.token,page.token=e.data.token,page.changeToken()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))}))},changePassword:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n    <form class="prevent-default">\n      <div class="field">\n        <label class="label">New password:</label>\n        <div class="control">\n          <input id="password" class="input" type="password" minlength="6" maxlength="64">\n        </div>\n      </div>\n      <div class="field">\n        <label class="label">Re-type new password:</label>\n        <div class="control">\n          <input id="passwordConfirm" class="input" type="password" minlength="6" maxlength="64">\n        </div>\n      </div>\n      <div class="field">\n        <div class="control">\n          <button type="submit" id="sendChangePassword" class="button is-info is-outlined is-fullwidth">\n            <span class="icon">\n              <i class="icon-paper-plane"></i>\n            </span>\n            <span>Set new password</span>\n          </button>\n        </div>\n      </div>\n    </form>\n  ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#sendChangePassword").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.dom.querySelector("form").checkValidity()&&(document.querySelector("#password").value===document.querySelector("#passwordConfirm").value?page.sendNewPassword(document.querySelector("#password").value,e.currentTarget):swal({title:"Password mismatch!",text:"Your passwords do not match, please try again.",icon:"error"}))}))},sendNewPassword:function(e,a){page.updateTrigger(a,"loading"),axios.post("api/password/change",{password:e}).then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your password was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){page.changePassword()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))},getUsers:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a="api/users/"+e.pageNum;axios.get(a).then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.users;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getUsers(e)):swal("An error occurred!","There are no more users to populate page "+(e.pageNum+1)+".","error");page.currentView="users",page.cache={},e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var s=page.paginate(a.data.count,25,e.pageNum),i='\n      <div class="columns">\n        '+('\n      <div class="column">\n        <form class="prevent-default">\n          <div class="field has-addons">\n            <div class="control is-expanded">\n              <input id="filters" class="input is-small" type="text" placeholder="Filter users (WIP)" value="'+page.escape(e.filters||"")+'" disabled>\n            </div>\n            <div class="control">\n              <button type="button" class="button is-small is-primary is-outlined" title="Help? (WIP)" data-action="user-filters-help" disabled>\n                <span class="icon">\n                  <i class="icon-help-circled"></i>\n                </span>\n              </button>\n            </div>\n            <div class="control">\n              <button type="submit" class="button is-small is-info is-outlined" title="Filter users (WIP)" data-action="filter-users" disabled>\n                <span class="icon">\n                  <i class="icon-filter"></i>\n                </span>\n              </button>\n            </div>\n          </div>\n        </form>\n      </div>\n    ')+'\n        <div class="column is-one-quarter">\n          <form class="prevent-default">\n            <div class="field has-addons">\n              <div class="control is-expanded">\n                <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+t+'" value="'+(e.pageNum+1)+'"'+(1===t?" disabled":"")+'>\n              </div>\n              <div class="control">\n                <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n                  <span class="icon">\n                    <i class="icon-paper-plane"></i>\n                  </span>\n                </button>\n              </div>\n            </div>\n          </form>\n        </div>\n      </div>\n    ',l='\n      <div class="columns">\n        <div class="column exclusive-operations has-text-left">\n          <a class="button is-small is-primary is-outlined" title="Create new user" data-action="create-user">\n            <span class="icon">\n              <i class="icon-plus"></i>\n            </span>\n            <span>Create new user</span>\n          </a>\n        </div>\n        <div class="column bulk-operations has-text-right">\n          <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n            <span class="icon">\n              <i class="icon-cancel"></i>\n            </span>\n          </a>\n          <a class="button is-small is-dangerish is-outlined" title="Bulk disable (WIP)" data-action="bulk-disable-users" disabled>\n            <span class="icon">\n              <i class="icon-hammer"></i>\n            </span>\n          </a>\n          <a class="button is-small is-danger is-outlined" title="Bulk delete (WIP)" data-action="bulk-delete-users" disabled>\n            <span class="icon">\n              <i class="icon-trash"></i>\n            </span>\n            <span>Bulk delete</span>\n          </a>\n        </div>\n      </div>\n    ',o=i.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),r=s.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),c=!1;page.dom.innerHTML="\n      "+s+"\n      "+i+"\n      "+l+'\n      <div class="table-container has-text-left">\n        <table class="table is-narrow is-fullwidth is-hoverable">\n          <thead>\n            <tr>\n              <th><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n              <th title="Key: username">Username</th>\n              <th>Uploads</th>\n              <th>Usage</th>\n              <th title="Key: permission">Group</th>\n              <th title="Key: registration">Registration date</th>\n              <th title="Key: timestamp">Last token update</th>\n              <th></th>\n            </tr>\n          </thead>\n          <tbody id="table">\n          </tbody>\n        </table>\n      </div>\n      '+l+"\n      "+o+"\n      "+r+"\n    ";for(var d=document.querySelector("#table"),u=0;u<n.length;u++){var p=n[u],g=page.selected[page.currentView].includes(p.id);g||(c=!0);for(var m=null,b=Object.keys(p.groups),h=0;h<b.length&&p.groups[b[h]];h++)m=b[h];var v=!1!==p.enabled&&0!==p.enabled;page.cache[p.id]={username:p.username,groups:p.groups,enabled:v,displayGroup:m};var f=p.registration?page.getPrettyDate(new Date(1e3*p.registration)):"-",w=p.timestamp?page.getPrettyDate(new Date(1e3*p.timestamp)):"-",y=document.createElement("tr");y.dataset.id=p.id,y.innerHTML='\n        <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+u+'" data-action="select"'+(g?" checked":"")+"></td>\n        <th"+(v?"":' class="has-text-grey"')+">"+p.username+"</td>\n        <th>"+p.uploads+"</th>\n        <td>"+page.getPrettyBytes(p.usage)+"</td>\n        <td>"+m+"</td>\n        <td>"+f+"</td>\n        <td>"+w+'</td>\n        <td class="controls has-text-right">\n          <a class="button is-small is-primary is-outlined" title="Edit user" data-action="edit-user">\n            <span class="icon">\n              <i class="icon-pencil"></i>\n            </span>\n          </a>\n          <a class="button is-small is-info is-outlined" title="'+(p.uploads?"View uploads":"User doesn't have uploads")+'" data-action="view-user-uploads" '+(p.uploads?"":"disabled")+'>\n            <span class="icon">\n              <i class="icon-docs"></i>\n            </span>\n          </a>\n          <a class="button is-small is-dangerish is-outlined" title="'+(v?"Disable user":"User is disabled")+'" data-action="disable-user" '+(v?"":"disabled")+'>\n            <span class="icon">\n              <i class="icon-hammer"></i>\n            </span>\n          </a>\n          <a class="button is-small is-danger is-outlined" title="Delete user" data-action="delete-user">\n            <span class="icon">\n              <i class="icon-trash"></i>\n            </span>\n          </a>\n        </td>\n      ',d.appendChild(y),page.checkboxes=d.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!c&&(k.checked=!0,k.title="Unselect all"),page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),page.views[page.currentView].pageNum=n.length?e.pageNum:0})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},createUser:function(){var e=Object.keys(page.permissions).map((function(e,a,t){return'<option value="'+e+'"'+(!(t[a+1]&&page.permissions[t[a+1]])?" disabled":"")+">"+e+"</option>"})).join("\n"),a=document.createElement("div");a.innerHTML='\n    <div class="field">\n      <label class="label">Username</label>\n      <div class="controls">\n        <input id="swalUsername" class="input" type="text">\n      </div>\n    </div>\n    <div class="field">\n      <label class="label">Password (optional)</label>\n      <div class="controls">\n        <input id="swalPassword" class="input" type="text">\n      </div>\n    </div>\n    <div class="field">\n      <label class="label">User group</label>\n      <div class="control">\n        <div class="select is-fullwidth">\n          <select id="swalGroup">\n            '+e+"\n          </select>\n        </div>\n      </div>\n    </div>\n  ",swal({title:"Create new user",icon:"info",content:a,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){e&&axios.post("api/users/create",{username:document.querySelector("#swalUsername").value,password:document.querySelector("#swalPassword").value,group:document.querySelector("#swalGroup").value}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=document.createElement("div");a.innerHTML="\n        <p>Username: <b>"+e.data.username+"</b></p>\n        <p>Password: <code>"+e.data.password+"</code></p>\n        <p>User group: <b>"+e.data.group+"</b></p>\n      ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache[e];if(a){var t=Object.keys(page.permissions).map((function(e,t,n){return'<option value="'+e+'"'+(e===a.displayGroup?" selected":"")+(!(n[t+1]&&page.permissions[n[t+1]])?" disabled":"")+">"+e+"</option>"})).join("\n"),n=document.createElement("div");n.innerHTML='\n    <div class="field">\n      <p>User ID: '+e+'</p>\n    </div>\n    <div class="field">\n      <label class="label">Username</label>\n      <div class="controls">\n        <input id="swalUsername" class="input" type="text" value="'+(a.username||"")+'">\n      </div>\n    </div>\n    <div class="field">\n      <label class="label">User group</label>\n      <div class="control">\n        <div class="select is-fullwidth">\n          <select id="swalGroup">\n            '+t+'\n          </select>\n        </div>\n      </div>\n    </div>\n    <div class="field">\n      <div class="control">\n        <label class="checkbox">\n          <input id="swalEnabled" type="checkbox" '+(a.enabled?"checked":"")+'>\n          Enabled\n        </label>\n      </div>\n    </div>\n    <div class="field">\n      <div class="control">\n        <label class="checkbox">\n          <input id="swalResetPassword" type="checkbox">\n          Reset password\n        </label>\n      </div>\n    </div>\n  ',swal({title:"Edit user",icon:"info",content:n,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){t&&axios.post("api/users/edit",{id:e,username:document.querySelector("#swalUsername").value,group:document.querySelector("#swalGroup").value,enabled:document.querySelector("#swalEnabled").checked,resetPassword:document.querySelector("#swalResetPassword").checked}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var t=!0,n=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(n.innerHTML+="<p>"+a.username+" was renamed into: <b>"+e.data.update.username+"</b>.</p>",t=!1,s=e.data.update.username),e.data.update.password&&(n.innerHTML+="\n          <p>"+s+"'s new password is:</p>\n          <p><code>"+e.data.update.password+"</code></p>\n        ",t=!1),e.data.update.enabled!==a.enabled&&(n.innerHTML+="<p>"+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!</p>"),n.innerHTML||(n.innerHTML="<p>"+s+" was edited!</p>"),swal({title:"Success!",icon:"success",content:n,buttons:!t,timer:t?1500:null}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},disableUser:function(e){var a=page.cache[e];if(a&&a.enabled){var t=document.createElement("div");t.innerHTML="\n    <p>You will be disabling a user named <b>"+page.cache[e].username+"</b>.</p>\n    <p>Their files will remain.</p>\n  ",swal({title:"Are you sure?",icon:"warning",content:t,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable them!",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/disable",{id:e}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Success!",page.cache[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache[e]){var a=document.createElement("div");a.innerHTML="\n    <p>You will be deleting a user named <b>"+page.cache[e].username+"</b>.<p>\n    <p>Their files will remain, unless you choose otherwise.</p>\n  ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Yes, and the uploads too!",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/delete",{id:e,purge:"purge"===a}).then((function(a){if(a){if(!1===a.data.success){var t=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):t.length?swal("An error occurred!","Unable to delete "+t.length+" of the user's upload"+(1===t.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign(page.views.users,{autoPage:!0}))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,t){t+=1;var n=Math.ceil(e/a),s="",i=function(e,a){for(var n=e;n<=a;++n)s+='<li><a class="button pagination-link '+(n===t?" is-current":"")+'" aria-label="Goto page '+n+'" data-action="page-goto" data-goto="'+(n-1)+'">'+n+"</a></li>"},l=function(){s+='\n        <li><a class="button pagination-link" aria-label="Goto page 1" data-action="page-goto" data-goto="0">1</a></li>\n        <li data-action="page-ellipsis"><span class="pagination-ellipsis">&hellip;</span></li>\n      '},o=function(){s+='\n        <li data-action="page-ellipsis"><span class="pagination-ellipsis">&hellip;</span></li>\n        <li><a class="button pagination-link" aria-label="Goto page '+n+'" data-action="page-goto" data-goto="'+(n-1)+'">'+n+"</a></li>\n      "};return 7>=n?i(1,n):t<6?(i(1,6),o()):t>n-6+1?(l(),i(n-6+1,n)):(l(),i(t-3+1,t+3-1),o()),'\n    <nav class="pagination is-centered is-small">\n      <a class="button pagination-previous" data-action="page-prev"'+(1===t?" disabled":"")+'>Previous</a>\n      <a class="button pagination-next" data-action="page-next"'+(t>=n?" disabled":"")+'>Next page</a>\n      <ul class="pagination-list">'+s+"</ul>\n    </nav>\n  "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var t="",n=Object.keys(a.data.stats),s=0;s<n.length;s++){var i="";if(a.data.stats[n[s]])try{for(var l=a.data.stats[n[s]]._types||{},o=Object.keys(a.data.stats[n[s]]),r=0;r<o.length;r++)if(!/^_/.test(o[r])){var c=a.data.stats[n[s]][o[r]],d=c;(l.number||[]).includes(o[r])&&(d=c.toLocaleString()),(l.byte||[]).includes(o[r])&&(d=page.getPrettyBytes(c)),(l.byteUsage||[]).includes(o[r])&&(d=page.getPrettyBytes(c.used)+" / "+page.getPrettyBytes(c.total)+" ("+Math.floor(c.used/c.total*100)+"%)"),(l.uptime||[]).includes(o[r])&&(d=page.getPrettyUptime(c)),i+='\n              <tr>\n                <th class="capitalize">'+o[r].replace(/([A-Z])/g," $1").replace(/(^|\s)(cpu|db|zip)/gi,(function(e){return e.toUpperCase()}))+"</th>\n                <td>"+d+"</td>\n              </tr>\n            "}}catch(e){i="\n              <tr>\n                <td>Error parsing response. Try again?</td>\n                <td></td>\n              </tr>\n            ",page.onError(e)}else i+="\n          <tr>\n            <td>Generating, please try again later…</td>\n            <td></td>\n          </tr>\n        ";t+='\n        <div class="table-container has-text-left">\n          <table id="statistics" class="table is-narrow is-fullwidth is-hoverable">\n            <thead>\n              <tr>\n                <th class="capitalize">'+n[s]+"</th>\n                <td></td>\n              </tr>\n            </thead>\n            <tbody>\n              "+i+"\n            </tbody>\n          </table>\n        </div>\n      "}Array.isArray(a.data.hrtime)&&(t+='\n        <article class="message is-size-7">\n          <div class="message-body has-text-left">\n            Time taken: '+a.data.hrtime[0]+"s "+Math.ceil(a.data.hrtime[1]/1e6)+"ms.\n          </div>\n        </article>\n      "),page.dom.innerHTML=t,page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.addEventListener("DOMContentLoaded",(function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var t=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),s=1;s<arguments.length;s++){var i=t[s];if(null!=i)for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(n[l]=i[l])}return n},writable:!0,configurable:!0}),"ontouchstart"in document.documentElement||document.documentElement.classList.add("no-touch");for(var e=["uploads","uploadsAll","albums","albumsAll","users"],a=0;a<e.length;a++){var t=localStorage[lsKeys.selected[e[a]]];t&&(page.selected[e[a]]=JSON.parse(t))}page.preparePage(),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.lazyLoad=new LazyLoad}));
  //# sourceMappingURL=dashboard.js.map
  