import{l as w,d as f,t as m,c as p}from"./logger-DsWSbSNC.chunk.mjs";const{limit:a,downloads:c}=w("files_downloadlimit","download_limit",{limit:-1,downloads:0});f.debug("Download limit",{limit:a,downloads:c});let t=a-c,r=0;function s(e,o){o===0?e.innerText=m("files_downloadlimit","You have reached the maximum amount of downloads allowed"):e.innerText=p("files_downloadlimit","1 remaining download allowed","{count} remaining downloads allowed",o,{count:o})}window.addEventListener("DOMContentLoaded",()=>{if(a<1)return;const e=document.getElementById("header-primary-action");if(!e)return;const o=document.createElement("span");o.setAttribute("style","color: var(--color-background-plain-text, var(--color-primary-text)); padding: 0 10px;"),s(o,t),e.prepend(o);const i=document.querySelector("#files-public-content");if(!i)return;i.oncontextmenu=n=>(n.preventDefault(),n.stopPropagation(),!1);const l=Array.from(document.querySelectorAll('a[href*="/download/"]'));new Set(l).forEach(n=>{n.addEventListener("click",d=>{if(r>0&&!confirm(m("files_downloadlimit","This share has a limited number of downloads. Are you sure you want to trigger a new download?"))){d.preventDefault(),d.stopPropagation();return}t--,r++,s(o,t),t===0&&[...l].forEach(u=>u.remove())})})});
//# sourceMappingURL=files_downloadlimit-public.mjs.map
