var lsKeys={token:"token",viewType:{uploads:"viewTypeUploads",uploadsAll:"viewTypeUploadsAll"},selected:{uploads:"selectedUploads",uploadsAll:"selectedUploadsAll",users:"selectedUsers"}},page={dom:null,token:localStorage[lsKeys.token],username:null,permissions:null,menusContainer:null,menus:[],currentView:null,views:{uploads:{type:localStorage[lsKeys.viewType.uploads],album:null,pageNum:null},uploadsAll:{type:localStorage[lsKeys.viewType.uploadsAll],filters:null,pageNum:null,all:!0},users:{filters:null,pageNum:null}},selected:{uploads:[],uploadsAll:[],users:[]},checkboxes:{uploads:[],uploadsAll:[],users:[]},lastSelected:{upload:null,uploadsAll:null,user:null},selectAlbumContainer:null,cache:{uploads:{},albums:{},users:{}},clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv"],isTriggerLoading:null,fadingIn:null,albumTitleMaxLength:70,albumDescMaxLength:4e3,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),document.querySelector("#dashboard").classList.remove("is-hidden")},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML=""+e.toString()+"",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,n=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,n,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(n){if(!1===n.data.success)return swal({title:"An error occurred!",text:n.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,page.token=e,page.username=n.data.username,page.permissions=n.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.dom=document.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:"#itemManageAlbums",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:"#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 n=document.querySelector(e[a].selector);n.addEventListener("click",(function(n){page.menusContainer.classList.contains("is-loading")||e[a].onclick.call(null,Object.assign({trigger:n.currentTarget},e[a].params||{}))})),n.classList.remove("is-hidden"),page.menus.push(n)}},n=0;n';e.all&&(o='\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ');for(var c='\n
\n '+o+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n ',d='\n
\n
\n \n \n
\n ',u=!1,p=t.some((function(e){return void 0!==e.expirydate})),g=0;g\n \n '+r+"\n ";for(var h=document.querySelector("#table"),v=0;v'+f.name+'':w.innerHTML='

'+(f.extname||"N/A")+"

",w.innerHTML+='\n \n
\n '+(f.thumb?'\n \n \n \n \n ':"")+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n

'+f.name+"

\n

"+(f.appendix?""+f.appendix+" – ":"")+f.prettyBytes+"

\n "+(p&&f.prettyExpiryDate?'\n

EXP: '+f.prettyExpiryDate+"

":"")+"\n
\n ",h.appendChild(w),page.checkboxes[page.currentView]=h.querySelectorAll('.checkbox[data-action="select"]')}}else{page.dom.innerHTML="\n "+r+"\n "+c+"\n "+d+'\n
\n \n \n \n \n \n '+(void 0===e.album?"":"")+"\n \n "+(e.all?"":"")+"\n \n "+(p?"":"")+'\n \n \n \n \n \n
File name"+(e.all?"User":"Album")+"SizeIPDateExpiry date
\n
\n '+r+"\n ";for(var y=document.querySelector("#table"),k=0;k\n '+x.name+"\n "+(void 0===e.album?""+x.appendix+"":"")+"\n "+x.prettyBytes+"\n "+(e.all?""+(x.ip||"")+"":"")+"\n "+x.prettyDate+"\n "+(p?""+(x.prettyExpiryDate||"-")+"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?"":'\n \n \n \n \n ')+'\n \n \n \n \n \n \n ',y.appendChild(T),page.checkboxes[page.currentView]=y.querySelectorAll('.checkbox[data-action="select"]')}}var A=document.querySelector("#selectAll");A&&!u&&t.length&&(A.checked=!0,A.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),"uploadsAll"===page.currentView&&(page.views.uploadsAll.filters=e.filters),page.views[page.currentView].pageNum=t.length?e.pageNum:0})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e,page.getUploads(Object.assign({trigger:a},page.views[page.currentView]))},displayPreview:function(e){var a=page.cache.uploads[e];if(a.thumb){var n=document.createElement("div");if(n.innerHTML='\n
\n \n
\n \n
\n
\n ',a.original){var t=/.[\w]+(\?|$)/.exec(a.original),s=t&&t[0]?t[0].toLowerCase():null,i=page.imageExts.includes(s),l=!i&&page.videoExts.includes(s);(i||l)&&(n.innerHTML+='\n \n ',n.querySelector("#swalOriginal").addEventListener("click",(function(e){var t=e.currentTarget;if(!t.classList.contains("is-danger")){t.classList.add("is-loading");var s=n.querySelector("#swalThumb");if(i)s.src=a.original,s.onload=function(){t.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"),t.className="button is-danger is-fullwidth",t.innerHTML='\n \n \n \n Unable to load original\n '};else if(l){s.classList.add("is-hidden");var r=document.createElement("video");r.id="swalVideo",r.controls=!0,r.autoplay=!0,r.src=a.original,s.insertAdjacentElement("afterend",r),t.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")}}})))}return swal({content:n,buttons:!1}).then((function(){var e=n.querySelector("#swalVideo");e&&e.remove(),document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;at&&s>t&&sn&&s2020/01/01 01:23, 2018/01/01 06, 2019/11, 12:34:56.\n These keys can only be specified once each.\n\n Matches can also be sorted with orderby:columnName[:d[escending]] keys.\n This key require internal column names used in the database (id, userid, and so on), but there are 2 shortcuts, namely date for timestamp column and expiry for expirydate column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Any leftover keywords which do not use keys will be matched against the matches\' file names.\n Excluding certain keywords is also supported by adding negation sign (-) before the keywords.\n\n Internals:\n First, it will filter uploads matching ANY of the supplied filter keys AND/OR special filter keys, if any.\n Second, it will refine the matches using the supplied date AND/OR expiry range keys, if any.\n Third, it will refine the matches using the leftover non-keyed keywords, if any.\n Finally, it will sort the matches using the supplied orderby keys, if any.\n\n Examples:\n Uploads from user named "demo":\n user:demo\n Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n user:demo user:"John Doe" user:-\n ALL uploads, including from non-registered users, but NOT the ones from user named "demo":\n -user:demo user:-\n Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n ip:127.0.0.1 *.rar *.zip\n Uploads uploaded since "1 June 2019 00:00:00":\n date:2019/06\n Uploads uploaded between "7 April 2020 00:00:00" and "7 April 2020 23:59:59":\n date:2020/04/07-2020/04/07 23:59:59\n Uploads which file names match "*.gz" but NOT "*.tar.gz":\n *.gz -*.tar.gz\n Sort matches by "size" column in ascending and descending order respectively:\n user:"John Doe" orderby:size\n *.mp4 user:- orderby:size:d\n\n Friendly reminder: This window can be scrolled up!\n '.trim().replace(/^ {6}/gm,"").replace(/\n/g,"
"),swal({content:a}).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("#filters").value.trim();page.getUploads({all:!0,filters:a},e)},viewUserUploads:function(e,a){var n=page.cache.users[e];if(n){a.classList.add("is-loading");var t=n.username.includes(" ")?'"'+n.username+'"':n.username;page.getUploads({all:!0,filters:"user:"+t,trigger:document.querySelector("#itemManageUploads")})}},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({autoPage:!0},page.views[page.currentView]))}})},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({autoPage:!0},page.views[page.currentView]))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="
Hint: You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n
\n
\n \n
\n \n
\n

Separate each entry with a new line.'+a+'

\n
\n
\n
\n \n
\n
\n
\n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#submitBulkDelete").addEventListener("click",(function(){var e=document.querySelector("#bulkDeleteNames"),a={},n=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=n.join("\n"),!n.length)return swal("An error occurred!","You have not entered any upload names.","error");page.postBulkDeleteUploads({all:!0,field:"name",values:n,cb:function(a){e.value=a.join("\n")}})}))},postBulkDeleteUploads:function(e){void 0===e&&(e={});var a=e.values.length,n=e.values.length+" upload"+(1===a?"":"s"),t="

You won't be able to recover "+n.replace(/^(\d*)(.*)/,"$1$2")+"!

";e.all&&(t+="\n

Warning: You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!

");var s=document.createElement("div");s.innerHTML=t,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(t){t&&axios.post("api/upload/bulkdelete",{field:e.fields,values:e.values}).then((function(t){if(t){if(!1===t.data.success)return"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error");var s=Array.isArray(t.data.failed)?t.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+n+".","error"):s.length&&s.length\n

You are about to add '+n+" upload"+(1===n?"":"s")+' to an album.

\n

If an upload is already in an album, it will be moved.

\n \n
\n
\n
\n \n
\n
\n
\n ',swal({icon:"warning",content:t,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(n){if(n){var t=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(t))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:t}).then((function(n){if(n)if(!1!==n.data.success){var s=e.length;n.data.failed&&n.data.failed.length&&(s-=n.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 "+(t<0?"removed":"added")+" "+s+" "+i+" "+(t<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(n.data.failed)}else"No token provided"===n.data.description?page.verifyToken(page.token):swal("An error occurred!",n.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'"})).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){void 0===e&&(e={}),page.updateTrigger(e.trigger,"loading"),axios.get("api/albums").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"));page.cache.albums={},page.dom.innerHTML='\n

Create new album

\n
\n
\n
\n \n
\n

Max length is '+page.albumTitleMaxLength+' characters.

\n
\n
\n
\n \n
\n

Max length is '+page.albumDescMaxLength+' characters.

\n
\n
\n
\n \n
\n
\n
\n
\n

List of albums

\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
IDNameFilesCreated atPublic link
\n
\n ';for(var n=a.data.homeDomain,t=document.querySelector("#table"),s=0;s"+i.id+"\n "+i.name+"\n "+i.files+"\n "+i.prettyDate+"\n '+l+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',t.appendChild(r)}page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache.albums[e];if(a){var n=document.createElement("div");n.innerHTML='\n
\n
\n \n
\n

Max length is '+page.albumTitleMaxLength+' characters.

\n
\n
\n
\n \n
\n

Max length is '+page.albumDescMaxLength+' characters.

\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n ',swal({title:"Edit album",icon:"info",content:n,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(n){n&&axios.post("api/albums/edit",{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}).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!","Your album's new identifier is: "+e.data.identifier+".","success"):e.data.name!==a.name?swal("Success!","Your album was renamed to: "+e.data.name+".","success"):swal("Success!","Your album was edited!","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums()}})).catch(page.onAxiosError)}))}},deleteAlbum:function(e){swal({title:"Are you sure?",text:"This won't delete your uploads, only the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Umm, delete the uploads too please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/delete",{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("Deleted!","Your album has been deleted.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums()})).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()}})).catch((function(a){page.updateTrigger(e),page.onAxiosError(a)}))},getAlbumsSidebar:function(){axios.get("api/albums/sidebar").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.querySelector("#albumsContainer"),n=a.querySelectorAll("li > a");if(n.length){for(var t=0;t\n \n
\n
\n \n
\n
\n \n \n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#getNewToken").addEventListener("click",(function(e){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
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n
\n
\n
\n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#sendChangePassword").addEventListener("click",(function(e){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.updateTrigger(e.trigger,"loading"),void 0===e.pageNum&&(e.pageNum=0),!page.permissions.admin)return swal("An error occurred!","You can not do this!","error");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 n=Math.ceil(a.data.count/25);if(e.pageNum&&0===a.data.users.length)return e.autoPage?(e.pageNum=n-1,page.getUsers(e)):(page.updateTrigger(e.trigger),swal("An error occurred!","There are no more users to populate page "+(e.pageNum+1)+".","error"));page.currentView="users",page.cache.users={};var t=page.paginate(a.data.count,25,e.pageNum),s='\n
\n '+('\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ')+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n ',i=!1;page.dom.innerHTML="\n "+t+"\n "+s+'\n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
UsernameUploadsUsageGroup
\n
\n '+t+"\n ";for(var l=document.querySelector("#table"),r=0;r\n "+o.username+"\n "+o.uploads+"\n "+page.getPrettyBytes(o.usage)+"\n "+d+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',l.appendChild(m),page.checkboxes.users=l.querySelectorAll('.checkbox[data-action="select"]')}var b=document.querySelector("#selectAll");b&&!i&&(b.checked=!0,b.title="Unselect all"),page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),page.views.users.pageNum=a.data.users.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,n){return'"})).join("\n"),a=document.createElement("div");a.innerHTML='\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\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

Username: "+e.data.username+"

\n

Password: "+e.data.password+"

\n

User group: "+e.data.group+"

\n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache.users[e];if(a){var n=Object.keys(page.permissions).map((function(e,n,t){return'"})).join("\n"),t=document.createElement("div");t.innerHTML='\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n ',swal({title:"Edit user",icon:"info",content:t,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(n){n&&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 n=!0,t=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(t.innerHTML+="

"+a.username+" was renamed into: "+e.data.update.username+".

",n=!1,s=e.data.update.username),e.data.update.password&&(t.innerHTML+="\n

"+s+"'s new password is:

\n

"+e.data.update.password+"

\n ",n=!1),e.data.update.enabled!==a.enabled&&(t.innerHTML+="

"+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!

"),t.innerHTML||(t.innerHTML="

"+s+" was edited!

"),swal({title:"Success!",icon:"success",content:t,buttons:!n,timer:n?1500:null}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},disableUser:function(e){var a=page.cache.users[e];if(a&&a.enabled){var n=document.createElement("div");n.innerHTML="\n

You will be disabling a user named "+page.cache.users[e].username+".

\n

Their files will remain.

\n ",swal({title:"Are you sure?",icon:"warning",content:n,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.users[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache.users[e]){var a=document.createElement("div");a.innerHTML="\n

You will be deleting a user named "+page.cache.users[e].username+".

\n

Their files will remain, unless you choose otherwise.

\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 n=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):n.length?swal("An error occurred!","Unable to delete "+n.length+" of the user's upload"+(1===n.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache.users[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign({autoPage:!0},page.views.users))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,n){n+=1;var t=Math.ceil(e/a),s="",i=function(e,a){for(var t=e;t<=a;++t)s+='
  • '+t+"
  • "},l=function(){s+='\n
  • 1
  • \n
  • \n '},r=function(){s+='\n
  • \n
  • '+t+"
  • \n "};return 7>=t?i(1,t):n<6?(i(1,6),r()):n>t-6+1?(l(),i(t-6+1,t)):(l(),i(n-3+1,n+3-1),r()),'\n \n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You can not do this!","error");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 n="",t=Object.keys(a.data.stats),s=0;s\n "+d+"\n \n "}}catch(e){i="\n \n Error parsing response. Try again?\n \n \n ",page.onError(e)}else i+="\n \n Generating, please try again later…\n \n \n ";n+='\n
    \n \n \n \n \n \n \n \n \n "+i+"\n \n
    '+t[s].toUpperCase()+"
    \n
    \n "}page.dom.innerHTML=n,page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.onload=function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var n=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),s=1;s