<!-- Dropshare client-side decryption -->
<script id="dropshare-encryption-decrypt" type="text/javascript">
!function(){"use strict";function e(e,t){var n,r,i,a,o,l,u=(l=t,n=(new TextEncoder).encode(l),r=n.length,i=r<16?16:r<24?24:32,a=new Uint8Array(i),o=Math.min(r,i),a.set(n.subarray(0,o)),a),c=new Uint8Array(16);return crypto.subtle.importKey("raw",u,{name:"AES-CBC"},!1,["decrypt"]).then((function(t){return crypto.subtle.decrypt({name:"AES-CBC",iv:c},t,e)}))}function t(e){try{var t=new URL(e,window.location.href).pathname.split("/").pop()||"";return(t=t.split("?")[0])?decodeURIComponent(t):""}catch(e){return""}}function n(e){return!e||e.length<5||".enc"!==e.slice(-4).toLowerCase()?e:e.slice(0,-4)}function r(e){return/\.[A-Za-z0-9]{1,15}$/.test(e)}function i(e,i){if(e||(e="download"),r(e))return e;var a=function(e){if(!r(e))return"";var t=e.lastIndexOf(".");return t>=0?e.slice(t):""}(n(t(i)));return a?e+a:e}function a(e,r,a){var o=e.getAttribute("download");return null!=o&&(o=String(o).trim()),!o&&e.download&&(o=String(e.download).trim()),o||(o=function(){var e=document.body;if(!e||!e.dataset)return"";var t=e.dataset.fileName||e.getAttribute("data-file-name");return t?String(t).trim():""}()),o||(o=function(e){if(!e||"string"!=typeof e)return null;var t=/filename\*=(?:UTF-8''|utf-8'')([^;\n]+)/i.exec(e);if(t)try{return decodeURIComponent(t[1].trim().replace(/^["']|["']$/g,""))}catch(e){}var n=/filename="([^"]*)"/i.exec(e);if(n&&n[1])return n[1];var r=/filename=([^;\s]+)/i.exec(e);return r&&r[1]?r[1].replace(/^["']|["']$/g,""):null}(a)||"")&&(o=String(o).trim()),o||(o=t(r||e.href)),n(o=i(o,r||e.href))}function o(e){var t="",n=e.lastIndexOf(".");n>=0&&n<e.length-1&&(t=e.slice(n+1).toLowerCase());return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",pdf:"application/pdf",txt:"text/plain",html:"text/html",htm:"text/html",css:"text/css",js:"text/javascript",json:"application/json",xml:"application/xml",zip:"application/zip",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",aiff:"audio/aiff",aif:"audio/aiff",md:"text/markdown",markdown:"text/markdown",svg:"image/svg+xml"}[t]||"application/octet-stream"}var l=document.getElementById("download-button");if(l&&window.crypto&&window.crypto.subtle){var u=!1;l.addEventListener("click",(function(t){t.preventDefault();var n=function(){var e=window.location.hash;if(!e||e.length<2)return null;var t=new URLSearchParams(e.slice(1)).get("dec");return null===t||""===t?null:t}();if(!n){var r=window.prompt("No key was found in the page URL. Enter the decryption key to download the decrypted file:","");if(null===r)return;if(!(n=String(r).trim()))return void window.alert("A decryption key is required to download this file.")}if(!u){u=!0;var i=l.innerHTML,c=l.getAttribute("aria-busy");l.setAttribute("aria-busy","true"),l.style.pointerEvents="none",l.innerHTML='<span style="display:inline-flex;align-items:center;justify-content:center;gap:0.55em;flex-wrap:wrap;text-align:center"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><g stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="0.85s" repeatCount="indefinite"/><circle cx="12" cy="12" r="9" stroke-dasharray="42 56" opacity="0.9"/></g></svg><span>Decrypting file, please wait…</span></span>';var f=l.href;fetch(f).then((function(e){if(!e.ok)throw new Error("HTTP "+e.status);var t=e.headers.get("Content-Disposition"),n=a(l,f,t);return e.arrayBuffer().then((function(e){return{cipherBuf:e,filename:n}}))})).then((function(t){return e(t.cipherBuf,n).then((function(e){return{plainBuf:e,filename:t.filename}}))})).then((function(e){!function(e,t){var n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.rel="noopener",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout((function(){URL.revokeObjectURL(n)}),0)}(new Blob([e.plainBuf],{type:o(e.filename)}),e.filename)})).catch((function(){window.alert("Decryption failed. The key may be wrong or the file is not valid encrypted data.")})).finally((function(){l.innerHTML=i,l.style.pointerEvents="",null===c?l.removeAttribute("aria-busy"):l.setAttribute("aria-busy",c),u=!1}))}}))}}();
</script>
