var lsKeys={token:"token",chunkSize:"chunkSize",parallelUploads:"parallelUploads",uploadsHistoryOrder:"uploadsHistoryOrder",previewImages:"previewImages",fileLength:"fileLength",uploadAge:"uploadAge",stripTags:"stripTags"},page={token:localStorage[lsKeys.token],apiChecked:!1,private:null,enableUserAccounts:null,maxSize:null,chunkSizeConfig:null,temporaryUploadAges:null,fileIdentifierLength:null,stripTagsConfig:null,album:null,parallelUploads:null,previewImages:null,fileLength:null,uploadAge:null,stripTags:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,chunkSize:null,tabs:[],activeTab:null,albumSelect:null,albumSelectOnChange:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,urlsQueue:[],activeUrlsQueue:0,imageExts:[".gif",".jpeg",".jpg",".png",".svg",".tif",".tiff",".webp",".bmp"],videoExts:[".avi",".m2ts",".m4v",".mkv",".mov",".mp4",".webm",".wmv"],albumTitleMaxLength:70,albumDescMaxLength:4e3,onInitError:function(e){document.querySelector("#albumDiv").classList.add("is-hidden"),document.querySelector("#tabs").classList.add("is-hidden"),document.querySelectorAll(".tab-content").forEach((function(e){return e.classList.add("is-hidden")}));var a=document.querySelector("#loginToUpload");a.innerText="An error occurred. Try to reload?",a.classList.remove("is-loading"),a.classList.remove("is-hidden"),a.addEventListener("click",(function(){window.location.reload()})),e&&(e.response?page.onAxiosError(e):page.onError(e))},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML="\n

"+e.toString()+"

\n

Please check your console for more information.

\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e,a){a||console.error(e);var t={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;if(a)return e.response.data&&e.response.data.description?e.response:{data:{success:!1,description:e.response?e.response.status+" "+t:e.toString()}};var n=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request.\nPlease check the console for more information.";return swal(e.response.status+" "+t,n,"error")},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()}))},checkIfPublic:function(){return axios.get("api/check",{onDownloadProgress:function(){"undefined"==typeof render||render.done||render.do(),"undefined"==typeof newsfeed||newsfeed.done||newsfeed.do(),page.apiChecked||(page.apiChecked=!0)}}).then((function(e){return e.data.version&&page.checkClientVersion(e.data.version),page.private=e.data.private,page.enableUserAccounts=e.data.enableUserAccounts,page.maxSize=parseInt(e.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSizeConfig={max:e.data.chunkSize&&parseInt(e.data.chunkSize.max)||95,default:e.data.chunkSize&&parseInt(e.data.chunkSize.default)},page.temporaryUploadAges=e.data.temporaryUploadAges,page.fileIdentifierLength=e.data.fileIdentifierLength,page.stripTagsConfig=e.data.stripTags,page.preparePage()})).catch(page.onInitError)},preparePage:function(){if(page.token)return page.verifyToken(page.token);if(!page.private)return page.prepareUpload();var e=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled.\nLog in or register to upload.":e.innerText="Running in private mode.\nLog in to upload."},verifyToken:function(e){return axios.post("api/tokens/verify",{token:e}).then((function(a){return localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload()})).catch((function(e){return swal({title:"An error occurred!",text:e.response.data?e.response.data.description:e.toString(),icon:"error"}).then((function(){e.response.data&&10001===e.response.data.code?(localStorage.removeItem(lsKeys.token),window.location.reload()):page.onInitError()}))}))},prepareUpload:function(){if(page.token){var e=document.querySelector('#linksColumn a[href="auth"]');e&&e.setAttribute("href","dashboard"),document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelectOnChange=function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()},page.albumSelect.addEventListener("change",page.albumSelectOnChange),page.fetchAlbums()}else page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads");page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var a=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes));var t=document.querySelector("#uploadUrls");t&&t.addEventListener("click",(function(e){page.addUrlsToQueue()}));for(var n=document.querySelector("#tabs"),r=n.querySelectorAll("li"),i=function(e){var a=r[e].dataset.id,t=document.querySelector("#"+a);t&&(r[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:r[e],content:t}))},l=0;l2){for(var f=0,h=0,v=!1,b=m-1;b--;)if(v)l._uplSpeedCalc.data.splice(b,1);else if((f=c-l._uplSpeedCalc.data[b].timestamp)>1e3){var y=f-1e3,S=f-(c-l._uplSpeedCalc.data[b+1].timestamp);h+=(S-y)/S*l._uplSpeedCalc.data[b+1].bytes,v=!0}else h+=l._uplSpeedCalc.data[b+1].bytes;v||(h*=1e3/f),t=page.getPrettyBytes(h)}}e.previewElement.querySelector(".descriptive-progress").innerHTML=o+" "+r+"%"+(t?" at "+t+"/s":"")})),this.on("success",(function(e,a){a&&(e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===a.success&&(e.previewElement.querySelector(".error").innerHTML=a.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),Array.isArray(a.files)&&a.files[0]&&page.updateTemplate(e,a.files[0]))})),this.on("error",(function(e,a,t){var n=a;"object"==typeof a&&a.description?n=a.description:t?n=page.onAxiosError({response:{status:t.status,statusText:t.statusText}},!0).data.description:a instanceof Error&&(n=a.toString()),(/^File is too big/.test(n)||/File too large/.test(n))&&(n="File too large ("+page.getPrettyBytes(e.size)+")."),e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),e.previewElement.querySelector(".error").innerHTML=n,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")}))},chunksUploaded:function(e,a){return e.previewElement.querySelector(".descriptive-progress").innerHTML="Rebuilding "+e.upload.totalChunkCount+" chunks…",axios.post("api/upload/finishchunks",{files:[{uuid:e.upload.uuid,original:e.name,type:e.type,albumid:page.album,filelength:page.fileLength,age:page.uploadAge}]},{headers:{token:page.token,striptags:page.stripTags}}).catch((function(e){return page.onAxiosError(e,!0)})).then((function(t){return e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===t.data.success&&(e.previewElement.querySelector(".error").innerHTML=t.data.description,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")),t.data.files&&t.data.files[0]&&page.updateTemplate(e,t.data.files[0]),a()}))}})},addUrlsToQueue:function(){var e=document.querySelector("#urls").value.split(/\r?\n/).filter((function(e){return e.trim().length}));if(!e.length)return swal("An error occurred!","You have not entered any URLs.","error");var a=document.querySelector("#tab-urls");a.querySelector(".uploads").classList.remove("is-hidden");for(var t=0;t .clipboard-js");n.href=n.innerHTML=r.dataset.clipboardText=a.url,t.classList.remove("is-hidden"),r.parentElement.classList.remove("is-hidden");var i=/.[\w]+$/.exec(a.url),l=i&&i[0]?i[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var o=e.previewElement.querySelector("img");o.setAttribute("alt",a.name||""),o.dataset.src=a.url,o.classList.remove("is-hidden"),o.onerror=function(a){a.currentTarget.classList.add("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-picture")},page.lazyLoad.update(e.previewElement.querySelectorAll("img"))}else page.updateTemplateIcon(e.previewElement,"icon-picture");else page.videoExts.includes(l)?page.updateTemplateIcon(e.previewElement,"icon-video"):page.updateTemplateIcon(e.previewElement,"icon-doc-inv");if(a.expirydate){var s=e.previewElement.querySelector(".expiry-date");s.dataset.timestamp=a.expirydate,s.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),s.classList.remove("is-hidden")}}},page.createAlbum=function(){var e=document.createElement("div");e.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 ',swal({title:"Create new album",icon:"info",content:e,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){if(e){var a=document.querySelector("#swalName").value.trim();axios.post("api/albums",{name:a,description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked},{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");var t=document.createElement("option");page.albumSelect.appendChild(t),t.value=e.data.id,t.innerHTML=a,t.selected=!0,page.albumSelectOnChange(),swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},page.prepareUploadConfig=function(){var e={chunkSize:page.chunkSizeConfig.default,parallelUploads:2},a=Array.isArray(page.temporaryUploadAges)&&page.temporaryUploadAges.length,t=page.fileIdentifierLength&&"number"==typeof page.fileIdentifierLength.min&&"number"==typeof page.fileIdentifierLength.max,n={siBytes:{label:"File size display",select:[{value:"default",text:"1000 B = 1 kB = 1 Kilobyte"},{value:"0",text:"1024 B = 1 KiB = 1 Kibibyte"}],help:"This will be used in our homepage, dashboard, and album public pages.",valueHandler:function(){}},ampmTime:{label:"Show AM/PM on date",select:[{value:"default",text:"No"},{value:"1",text:"Yes"}],help:"This will be used in our homepage and dashboard.",valueHandler:function(){}},fileLength:{display:t,label:"File identifier length",number:t?{min:page.fileIdentifierLength.min,max:page.fileIdentifierLength.max,default:page.fileIdentifierLength.default,round:!0}:void 0,help:!0,disabled:t&&page.fileIdentifierLength.force},uploadAge:{display:a,label:"Upload age",select:[],help:"Whether to automatically delete your uploads after a certain amount of time."},stripTags:{display:page.stripTagsConfig,label:"Strip tags",select:page.stripTagsConfig?[{value:page.stripTagsConfig.default?"default":"1",text:"Yes"},{value:page.stripTagsConfig.default?"0":"default",text:"No"}]:null,help:"Whether to strip tags (e.g. EXIF) from your uploads.
\n This only applies to regular image"+(page.stripTagsConfig&&page.stripTagsConfig.video?" and video":"")+" uploads (i.e. not URL uploads).",disabled:page.stripTagsConfig&&page.stripTagsConfig.force},chunkSize:{display:Boolean(page.chunkSizeConfig.default),label:"Upload chunk size (MB)",number:{min:1,max:page.chunkSizeConfig.max,default:e.chunkSize,suffix:" MB",round:!0},help:!0},parallelUploads:{label:"Parallel uploads",number:{min:1,max:10,default:e.parallelUploads,round:!0},help:!0},uploadsHistoryOrder:{label:"Uploads history order",select:[{value:"default",text:"Older files on top"},{value:"0",text:"Newer files on top"}],help:'"Newer files on top" will use a CSS technique, which unfortunately come with some undesirable side effects.
\n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.',valueHandler:function(e){if("0"===e)for(var a=document.querySelectorAll(".tab-content > .uploads"),t=0;t=page.fileIdentifierLength.min&&o<=page.fileIdentifierLength.max&&(n.fileLength.value=o)}var s=document.querySelector("#tab-config"),p=document.createElement("form");p.addEventListener("submit",(function(e){return e.preventDefault()}));for(var u=Object.keys(n),d=0;d=g.number.min&&(f=h)}else{var v=localStorage[lsKeys[c]];f=Array.isArray(g.select)?g.select.find((function(e){return e.value===v}))?v:void 0:v}"function"==typeof g.valueHandler?g.valueHandler(f):void 0!==f?page[c]=f:void 0!==e[c]&&(page[c]=e[c])}var b=void 0;if(Array.isArray(g.select)){(b=document.createElement("div")).className="select is-fullwidth";for(var y=[],S=0;S\n "+w.text+("default"===w.value?" (default)":"")+"\n \n ")}b.innerHTML='\n \n "}else g.number&&((b=document.createElement("input")).id=b.name=c,b.className="input is-fullwidth",b.type="number",void 0!==g.number.min&&(b.min=g.number.min),void 0!==g.number.max&&(b.max=g.number.max),"number"==typeof f?b.value=f:void 0!==g.number.default&&(b.value=g.number.default));var x=void 0;if(g.disabled)Array.isArray(g.select)?b.querySelector("select").disabled=g.disabled:b.disabled=g.disabled,x="This option is currently not configurable.";else if("string"==typeof g.help)x=g.help;else if(!0===g.help&&void 0!==g.number){var L=[];void 0!==g.number.default&&L.push("Default is "+g.number.default+(g.number.suffix||"")+"."),void 0!==g.number.min&&L.push("Min is "+g.number.min+(g.number.suffix||"")+"."),void 0!==g.number.max&&L.push("Max is "+g.number.max+(g.number.suffix||"")+"."),x=L.join(" ")}m.innerHTML='\n \n
\n '+(x?'

'+x+"

":"")+"\n ",m.querySelector("div.control").appendChild(b),p.appendChild(m)}}var T=document.createElement("div");T.className="field",T.innerHTML='\n

\n \n

\n

\n This configuration will only be used in this browser.
\n After reloading the page, some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below.\n

\n ',p.appendChild(T),p.querySelector("#saveConfig").addEventListener("click",(function(){if(p.checkValidity()){for(var e=Object.keys(n).filter((function(e){return!1!==n[e].display&&!0!==n[e].disabled})),a=0;a=24){var t=e/24;return t+" day"+(1===t?"":"s")}return e+" hour"+(1===e?"":"s")},window.addEventListener("paste",(function(e){for(var a=(e.clipboardData||e.originalEvent.clipboardData).items,t=Object.keys(a),n=0;n