function UnicModal(e){e?(void 0!==e.background?this.bg=e.background:this.bg="rgba(0,0,0,0.6)",void 0!==e.btnClose?this.btnClose=e.btnClose:this.btnClose=!0,void 0!==e.overflow?this.overflow=e.overflow:this.overflow=!1,void 0!==e.cross?this.cross=e.cross:this.cross=!0,void 0!==e.fade?this.fade=e.fade:this.fade=!0,void 0!==e["fade-speed"]?this.fade=e["fade-speed"]:this.fade=5e3,void 0!==e.drag?this.drag=e.drag:this.drag=!1,void 0!==e.preload?this.preload=e.preload:this.preload=!0):(this.bg="rgba(0,0,0,0.6)",this.btnClose=!0,this.overflow=!1,this.cross=!0,this.fade=!0,this.fadeSpeed=5e3,this.drag=!1,this.preload=!0),this.translate=[0,0],this.startX=0,this.startY=0,this.initDrag=!1,this.modalContent=[],this.modalID=0,this.init()}UnicModal.prototype.updateClassName=function(e,t,o){let a=!1,l=e.className.split(" "),i="";if(1!=o){for(let e=0;e<=l.length-1;e++)e>0&&(i+=" "),l[e]==t&&(a=!0),i+=l[e];0==a&&(i+=" "+t)}else for(let e=0;e<=l.length-1;e++)e>0&&(i+=" "),l[e]!=t&&(i+=l[e]);e.className=i},UnicModal.prototype.loadUnicModalScripts=function(){$this=this,1==this.btnClose&&(document.getElementsByTagName("body")[0].onkeyup=function(e){27==e.keyCode&&$this.closeUnicModal()});let e=document.querySelectorAll(".unic-modal-overlay[data-modal-id='"+this.modalID+"']")[0];if(e.onclick=function(e){let t=e.target;"unic-modal-overlay-body"==t.className||t.closest(".unic-modal-overlay-body")||$this.closeUnicModal()},e.getElementsByClassName("modal-close")[0].onclick=function(){$this.closeUnicModal()},1==this.drag){let t=e.getElementsByClassName("unic-modal-overlay-body")[0];e.getElementsByClassName("modal-close")[0];t.setAttribute("data-curr-x",0),t.setAttribute("data-curr-y",0),t.onmousedown=function(e){1==e.which&&($this.initDrag=!0,$this.updateClassName(t,"move"),$this.startX=e.clientX,$this.startY=e.clientY)},t.onmouseup=function(e){1==e.which&&($this.initDrag=!1,$this.updateClassName(t,"move",!0),t.setAttribute("data-curr-x",$this.translate[0]),t.setAttribute("data-curr-y",$this.translate[1]))},t.onmouseleave=function(){$this.initDrag=!1,$this.updateClassName(t,"move",!0),t.setAttribute("data-curr-x",$this.translate[0]),t.setAttribute("data-curr-y",$this.translate[1])},t.onmousemove=function(e){if(1==$this.initDrag){document.getElementsByTagName("body")[0].style.cursor="move";let o=Number(t.getAttribute("data-curr-x"))+e.clientX-$this.startX,a=Number(t.getAttribute("data-curr-y"))+e.clientY-$this.startY;t.style.transform="translateX("+o+"px) translateY("+a+"px)",$this.translate=[o,a]}}}},UnicModal.prototype.preloaderUnicModal=function(e){if(1==this.preload){let t=document.querySelectorAll(".unic-modal-overlay[data-modal-id='"+this.modalID+"']")[0];if(t){let o=t.getElementsByClassName("unic-modal-preloader")[0];1==e?this.updateClassName(o,"active"):this.updateClassName(o,"active",!0)}}},UnicModal.prototype.openUnicModal=function(e){this.modalID++;let t=document.querySelectorAll(e)[0];if(t){let o=document.getElementsByTagName("body")[0],a=document.getElementsByTagName("html")[0];0==this.overflow&&(this.updateClassName(a,"modal-lock"),this.updateClassName(o,"modal-lock")),this.modalContent[this.modalID]=e;let l='<div class="unic-modal-overlay-body">';1==this.cross&&(l+='<div class="modal-close"><div></div><div></div></div>'),1==this.preload&&(l+='<div class="unic-modal-preloader"></div>'),l+="</div>";let i=document.createElement("div");i.className="unic-modal-overlay",i.setAttribute("data-modal-id",this.modalID),i.style.backgroundColor=this.bg,1==this.fade&&(i.style.opacity=0,i.style.transition=this.fadeSpeed/1e3+"s"),i.innerHTML=l,i.getElementsByClassName("unic-modal-overlay-body")[0].appendChild(t),this.updateClassName(t,"unic-modal-item-active"),this.updateClassName(i.getElementsByClassName("unic-modal-item")[0],"unic-modal-item",!0),document.getElementsByTagName("body")[0].appendChild(i),1==this.fade&&(i.style.opacity=1),this.loadUnicModalScripts()}},UnicModal.prototype.generateUnicModal=function(e){this.modalID++;let t=document.getElementsByTagName("body")[0],o=document.getElementsByTagName("html")[0];if(0==this.overflow){let e=self.pageYOffset||document.documentElement&&document.documentElement.scrollTop||document.body&&document.body.scrollTop;this.updateClassName(o,"modal-lock"),this.updateClassName(t,"modal-lock"),t.style.top=-1*e+"px",t.setAttribute("zweb-scroll",e)}this.modalContent[this.modalID]=!1;let a='<div class="unic-modal-overlay-body">';1==this.cross&&(a+='<div class="modal-close"><div></div><div></div></div>'),1==this.preload&&(a+='<div class="unic-modal-preloader"></div>'),a+=void 0!==e?e+"</div>":"</div>";let l=document.createElement("div");l.className="unic-modal-overlay",l.setAttribute("data-modal-id",this.modalID),l.style.backgroundColor=this.bg,1==this.fade&&(l.style.opacity=0,l.style.transition=this.fadeSpeed/1e3+"s"),l.innerHTML=a,window.jQuery?$("body").append(l):document.getElementsByTagName("body")[0].appendChild(l),1==this.fade&&(l.style.opacity=1),this.loadUnicModalScripts()},UnicModal.prototype.closeUnicModal=function(){let e=document.getElementsByTagName("body")[0],t=document.getElementsByTagName("html")[0],o=document.getElementsByClassName("unic-modal-overlay"),a=o[o.length-1];if(a){if(0!=this.modalContent[this.modalID]){let t=a.getElementsByClassName("unic-modal-item-active")[0];e.appendChild(t),this.updateClassName(t,"unic-modal-item-active",!0),this.updateClassName(t,"unic-modal-item")}if(e.removeChild(a),0==this.overflow&&1==this.modalID){this.updateClassName(t,"modal-lock",!0),this.updateClassName(e,"modal-lock",!0);let o=e.getAttribute("zweb-scroll");o&&(e.setAttribute("style",""),window.scrollTo(0,o))}this.modalID--}this.initDrag=!1},UnicModal.prototype.init=function(){let e=this,t=document.querySelectorAll("[data-unic-modal]");if(t)for(i=0;i<=t.length-1;i++){let o=t[i].getAttribute("href"),a=document.querySelectorAll(o)[0];a&&e.updateClassName(a,"unic-modal-item"),t[i].onclick=function(t){t.preventDefault(),e.openUnicModal(o)}}};var UNIC_MODAL=new UnicModal;!function(){if(!window.zWebModal){window.ZWEBMODAL=new class{constructor(e={}){this.MODALS={},this.MODALID=1,this.ACTIVEMODALID=!1,this.SCROLL=!0,this.PARAMS={background:void 0!==e.background?e.background:"rgba(0,0,0,0.6)",closeByESC:void 0===e.closeByESC||e.closeByESC,pageOverflow:void 0===e.pageOverflow||e.pageOverflow,cross:void 0===e.cross||e.cross,modalOverlay:void 0===e.modalOverlay||e.modalOverlay};let t=this;window.addEventListener("DOMContentLoaded",function(){t.setGeneralScripts()})}setGeneralScripts(){let e=this;document.body.addEventListener("keyup",function(t){if(27==t.keyCode&&0!=e.ACTIVEMODALID){let t=e.MODALS[e.ACTIVEMODALID];void 0!==t.PARAMS.closeByESC&&1!=t.PARAMS.closeByESC||e.closeModal(e.ACTIVEMODALID)}}),document.body.addEventListener("wheel",function(t){0!=e.SCROLL||t.target.closest(".zWebModalOverlayBody")||t.target.classList.contains(".zWebModalOverlayBody")||(t.preventDefault?t.preventDefault():t.returnValue=!1)},{passive:!1}),document.body.addEventListener("click",function(e){if(e.target.hasAttribute("zweb-modal")&&e.target.hasAttribute("href")){e.preventDefault();let t=document.querySelector(e.target.getAttribute("href"));null!=t&&(ZWEBMODAL.closeModal(),ZWEBMODAL.openModal(t,{fromElement:!0}))}})}setModalScripts(e){let t=this;void 0!==e.modal.overlay&&(void 0!==e.modal.PARAMS.closeByOverlay&&1!=e.modal.PARAMS.closeByOverlay||e.modal.overlay.addEventListener("mousedown",function(o){o.target.classList.contains("zWebModalOverlay")&&t.closeModal(e.id)})),void 0!==e.modal.cross&&e.modal.cross.addEventListener("click",function(){t.closeModal(e.id)})}loadFromFile(e){void 0!==e.disableAction&&1==e.disableAction||(document.querySelector("html").style.pointerEvents="none",document.querySelector("html").style.cursor="wait"),window.jQuery&&$.ajax({type:void 0!==e.type?e.type:"POST",url:e.file,data:e.params,success:function(t){void 0!==e.closeModals&&0==e.closeModals||ZWEBMODAL.closeModal(),ZWEBMODAL.openModal(t,void 0!==e.modalParams?e.modalParams:{}),void 0!==e.disableAction&&1==e.disableAction||(document.querySelector("html").style.pointerEvents="all",document.querySelector("html").style.cursor="auto"),void 0!==e.callback&&(0,e.callback)()}})}addCallback(e={}){if(void 0!==this.MODALS[e.id]){let t=this.MODALS[e.id];void 0!==e.beforeClose&&(t.PARAMS.beforeClose=e.beforeClose),void 0!==e.afterClose&&(t.PARAMS.afterClose=e.afterClose)}else console.log(`Modal id "${e.id}" not found`)}openModal(e,t={}){let o=void 0!==t.id?t.id:`zwmodal${this.MODALID}`,a=this;if(void 0!==this.MODALS[o]&&(void 0===t.forceOpen||1!=t.forceOpen))return void console.log(`Modal id "${o}" has already been open`);window.innerWidth<1e3&&(document.body.style.overflow="hidden"),1==this.PARAMS.pageOverflow&&(this.SCROLL=!1),this.MODALS[o]={};let l=this.MODALS[o];if("object"!=typeof t&&(t={}),void 0===t.fromElement&&(t.fromElement=!1),void 0!==t.appendTo){let e=document.querySelector(t.appendTo);t.appendTo=null!=e?e:document.body}else t.appendTo=document.body;if(l.PARAMS=t,l.parent=!1,l.overlay=document.createElement("div"),l.overlay.className=(l.PARAMS.modalOverlay,"zWebModalOverlay"),l.overlay.setAttribute("zweb-modal-id",o),l.body=document.createElement("div"),l.body.className="zWebModalOverlayBody",void 0!==t.customPosition){let e=void 0!==t.customPosition.x?t.customPosition.x:"0",o=void 0!==t.customPosition.y?t.customPosition.y:"0";l.body.classList.add("custom"),l.body.style.transform="translateX("+e+") translateY("+o+")"}if(0==t.fromElement?l.body.innerHTML=e:(l.parent=e.parentNode,l.content=e,l.body.appendChild(e),e.style.display="block"),void 0!==t.showCross&&1!=t.showCross||(l.cross=document.createElement("div"),l.cross.className="zWebModalCross",l.cross.innerHTML="<div></div><div></div>",l.body.appendChild(l.cross)),l.overlay.appendChild(l.body),void 0!==t.beforeOpen&&(0,t.beforeOpen)(l),void 0!==t.openDelay)setTimeout(function(){if(window.jQuery?$(l.PARAMS.appendTo).append(l.overlay):l.PARAMS.appendTo.appendChild(l.overlay),a.setModalScripts({id:o,modal:l}),a.ACTIVEMODALID=o,a.MODALID++,void 0!==t.afterOpen){let e=t.afterOpen;setTimeout(function(){e(l)},100)}},parseInt(t.openDelay));else if(window.jQuery?$(l.PARAMS.appendTo).append(l.overlay):l.PARAMS.appendTo.appendChild(l.overlay),a.setModalScripts({id:o,modal:l}),a.ACTIVEMODALID=o,a.MODALID++,void 0!==t.afterOpen){let e=t.afterOpen;setTimeout(function(){e(l)},100)}}updateModal(e={}){if(void 0===this.MODALS[e.id])return console.log(`Modal id "${e.id}" not found`),void(void 0!==e.error&&e.error());{let t=this.MODALS[e.id];void 0!==e.content&&(t.body.innerHTML="",window.jQuery?$(t.body).html(e.content):t.body.innerHTML=e["content;"],void 0!==t.cross&&t.body.appendChild(t.cross)),void 0!==e.success&&e.success(t)}}getLastID(){let e=!1;return Object.keys(this.MODALS).length>0?Object.keys(this.MODALS).forEach(function(t){e=t}):e=!1,e}closeModal(e=!1,t=!1,o={}){let a=this;0==e&&(e=Object.keys(this.MODALS)),Object.keys(this.MODALS).forEach(function(t){if(-1!=e.indexOf(t)){let l=a.MODALS[e],i=(l.PARAMS.closeDelay,parseInt(l.PARAMS.closeDelay));void 0!==l.PARAMS.beforeClose&&(0,l.PARAMS.beforeClose)(l),setTimeout(function(){1==l.PARAMS.fromElement&&(l.content.style.display="none",l.parent.appendChild(l.content)),void 0===l.overlay||void 0!==o.saveOverlay&&1==o.saveOverlay||l.overlay.remove(),delete a.MODALS[t],a.ACTIVEMODALID=a.getLastID(),a.MODALID--,void 0!==l.PARAMS.afterClose&&(0,l.PARAMS.afterClose)()},i)}}),window.innerWidth<1e3&&(document.body.style.overflow="unset"),this.SCROLL=!0,0!=t&&t()}}}}();