(()=>{let l=(r,s,c,u,m)=>{let w="",h="",v="",y="",b="",g="",B="",t=!1;if(m){var n=document.querySelectorAll(`a[rel="${m}"]`);for(let e=0;e  "+wuboxL10n.next+""):(w=n[e].title,h=n[e].href,v="  "+wuboxL10n.prev+""):(t=!0,B=wuboxL10n.image+" "+(e+1)+" "+wuboxL10n.of+" "+n.length)}let p=new Image;p.onload=()=>{p.onload=null,t=document.documentElement,e=window.innerWidth||self.innerWidth||t&&t.clientWidth||document.body.clientWidth,t=window.innerHeight||self.innerHeight||t&&t.clientHeight||document.body.clientHeight;var e={width:e,height:t},t=e.width-150,e=e.height-150;let n=p.width,d=p.height,i=(n>t?(d*=t/n,n=t,d>e&&(n*=e/d,d=e)):d>e&&(n*=e/d,d=e,n>t)&&(d*=t/n,n=t),f(r,n,d),r.insertAdjacentHTML("beforeend",` ${wuboxL10n.close} ${u}
${u}
${B+v+g}
`),null!=(e=document.getElementById("WUB_closeWindowButton"))&&e.addEventListener("click",W),()=>{r.innerHTML="",l(),_(w,h,m)}),o=()=>{r.innerHTML="",l(),_(y,b,m)},a=(null!=(t=document.getElementById("WUB_prev"))&&t.addEventListener("click",i),null!=(e=document.getElementById("WUB_next"))&&e.addEventListener("click",o),e=>{"Escape"===e.key?W():"ArrowRight"===e.key&&g?o():"ArrowLeft"===e.key&&v&&i()}),l=()=>{window.removeEventListener("keydown",a),document.body.removeEventListener("wubox:unload",l)};window.addEventListener("keydown",a),document.body.addEventListener("wubox:unload",l),null!=(t=document.getElementById("WUB_ImageOff"))&&t.addEventListener("click",W),s()},p.src=c},r=(e,t,n,d,i,o)=>{var a,d=d.split("WUB_");null!=(a=document.getElementById("WUB_load"))&&a.remove(),o.modal?(t.removeEventListener("click",W),e.insertAdjacentHTML("beforeend",` `),null!=(a=document.getElementById("WUB_iframeContent"))&&a.addEventListener("load",m)):(e.insertAdjacentHTML("beforeend",`
${i}
`),null!=(t=document.getElementById("WUB_iframeContent"))&&t.addEventListener("load",m)),f(e,o.width,o.height),n()},s=(e,t,n,d)=>("visible"!==e.style.visibility?d.modal?(t.removeEventListener("click",W),e.insertAdjacentHTML("beforeend",`
`)):e.insertAdjacentHTML("beforeend",`
${n}
`):((t=document.getElementById("WUB_ajaxContent")).style.width=d.width+"px",t.style.height=d.height+"px",t.scrollTop=0,t.innerHTML=n),document.getElementById("WUB_ajaxContent")),c=(t,e,n,d,i,o)=>{let a=s(t,e,i,o);e=d+(d.includes("?")?"&":"?")+"random="+(new Date).getTime();fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(e=>e.text()).then(e=>{a.innerHTML=e,f(t,o.width,o.height),n()})},u=(e,t,n,d,i)=>{let o=s(e,t,d,i),a=document.getElementById(i.inlineId),l=(o.insertAdjacentElement("beforeend",null==a?void 0:a.children[0]),()=>{null!=a&&a.insertAdjacentElement("afterbegin",o.children[0]),document.body.removeEventListener("wubox:unload",l)});document.body.addEventListener("wubox:unload",l),f(e,i.width,i.height),n()},t=d=>async e=>{e.preventDefault();var t=d.querySelector("textarea[data-editor]"),n=t?d.querySelector('input[name="'+t.id+'"]'):null,n=(t&&n&&(n.value=t.value),wu_block_ui(d)),t=(window["wu_"+d.getAttribute("id")+"_errors"]&&(window["wu_"+d.getAttribute("id")+"_errors"].errors=[]),e.submitter.value),e=new FormData(d),t=(e.append("submit",t),await fetch(d.getAttribute("action"),{method:"POST",body:e,headers:{"X-Requested-With":"XMLHttpRequest"}}).then(e=>e.text()).then(e=>e?JSON.parse(e):null));null===t||null===t.data?(n.unblock(),W()):(t.success||(n.unblock(),e=d.getAttribute("id"),window["wu_"+e+"_errors"]&&(window["wu_"+e+"_errors"].errors=t.data),null!=(e=document.querySelector('[data-wu-app="'+e+'_errors"]'))&&e.setAttribute("tabindex","-1"),null!=e&&e.focus()),"object"==typeof t.data.tables&&(n.unblock(),W(),Object.keys(t.data.tables).forEach(e=>{window[e].update()})),"string"==typeof t.data.redirect_url&&(window.location.href=t.data.redirect_url),"object"==typeof t.data.send&&window[t.data.send.scope][t.data.send.function_name](t.data.send.data,W))};function f(e,t,n){e.style.marginLeft="-"+t/2+"px",e.style.marginTop="-"+n/2+"px"}function n(d,i,o){let a=parseFloat(getComputedStyle(d).opacity),l=null;requestAnimationFrame(function e(t){var t=t-(l=l||t),n=Math.max(a-t/i,0);d.style.opacity=n.toString(),t{i.style.visibility="visible",document.body.dispatchEvent(new Event("wubox:load")),o.remove(),w()};document.body.insertAdjacentElement("beforeend",o);!!t.split("?")[0].toLowerCase().match(/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/)?l(i,a,t,e,n):(n=t.replace(/^[^\?]+\??/,""),n=new URLSearchParams(n),n={width:parseInt(n.get("width")||"")||630,height:parseInt(n.get("height")||"")||440,modal:!!n.get("modal")||!1,inlineId:n.get("inlineId")||""},t.includes("WUB_iframe")?r(i,d,a,t,e,n):t.includes("WUB_inline")?u(i,d,a,e,n):c(i,d,a,t,e,n),null!=(d=document.getElementById("WUB_closeWindowButton"))&&d.addEventListener("click",W));a=document.getElementById("WUB_closeWindowButton"),t=null==a?void 0:a.querySelector(".wutb-close-icon");t&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&a.focus()}let d=e=>{document.body.addEventListener("wubox:iframe:loaded",()=>{var e;null!=(e=document.getElementById("WUB_window"))&&e.classList.remove("wubox-loading")}),document.body.addEventListener("wubox:load",()=>{var e=document.querySelector("#WUB_ajaxContent .wu_form");e&&((e=e).addEventListener("submit",t(e)),wu_initialize_editors())})},i=e=>{e.preventDefault();e=e.currentTarget;_(e.title||e.name||"",e.href||e.alt,e.rel||!1),e.blur()},o=(e,t=!1,n=!1)=>{document.querySelectorAll(e).forEach(e=>{e.removeEventListener("click",i),e.addEventListener("click",i)}),t&&d(),n&&(t={childList:!0,subtree:!0},new MutationObserver(()=>{o(e,!1,!1)}).observe(document.body,t))},W=()=>{var e;null!=(e=document.getElementById("WUB_ImageOff"))&&e.removeEventListener("click",W),null!=(e=document.getElementById("WUB_closeWindowButton"))&&e.removeEventListener("click",W),document.body.classList.remove("modal-open"),null!=(e=document.getElementById("WUB_load"))&&e.remove(),n(document.getElementById("WUB_window"),200),n(document.getElementById("WUB_overlay"),150,()=>{document.body.dispatchEvent(new Event("wubox:unload")),document.querySelectorAll("#WUB_window, #WUB_overlay, #WUB_HideSelect").forEach(e=>e.remove()),document.body.dispatchEvent(new Event("wubox:removed"))})},w=()=>{var e,t,n,d=document.querySelector("#WUB_ajaxContent .wu_form");d&&(wu_initialize_editors(),e=document.getElementById("WUB_ajaxContent"),t=document.getElementById("WUB_window"),e.style.height="100vh",n=window.innerHeight-120,n=d.offsetHeight>=n?n:d.offsetHeight+1,t.style.transition="margin 200ms",e.style.height=n+"px",t.style.marginTop="-"+n/2+"px")};window.wubox={init:o,show:_,remove:W,refresh:w,width:e=>{var t=document.getElementById("WUB_ajaxContent"),n=document.getElementById("WUB_window");t&&(t.style.transition="width 150ms",n.style.transition="margin 150ms",t.style.width=e+"px",n.style.marginLeft="-"+e/2+"px",n.style.width=e+"px",setTimeout(()=>{w()},150))}},window.addEventListener("DOMContentLoaded",()=>{window.wubox.init(".wubox",!0,!0)})})();